@vpdev2/metakyc-sdk 1.0.106 → 1.0.108
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/config.d.ts +6 -1
- package/dist/client/config.d.ts.map +1 -1
- package/dist/identity/provider-manager.d.ts.map +1 -1
- package/dist/identity/providers/sumsub.d.ts +8 -1
- package/dist/identity/providers/sumsub.d.ts.map +1 -1
- package/dist/index.cjs +32 -80
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +965 -1002
- package/dist/index.js.map +1 -1
- package/dist/types/identity.d.ts +5 -0
- package/dist/types/identity.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,72 +1,24 @@
|
|
|
1
|
-
"use strict";var Wr=Object.defineProperty;var Ur=(t,r,s)=>r in t?Wr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var pe=(t,r,s)=>Ur(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Kr=require("axios"),i=require("react"),e=require("react/jsx-runtime"),ut=require("react-dom"),Ke=require("react-hook-form"),He=require("zod");function qr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,a.get?a:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const jt=qr(i);var oe=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(oe||{}),it=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(it||{}),Fe=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(Fe||{}),Et=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(Et||{}),At=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(At||{}),qe=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(qe||{}),Ve=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(Ve||{}),Ft=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Ft||{}),Tt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Tt||{}),Ae=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(Ae||{}),Pt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Pt||{}),ot=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(ot||{}),Lt=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(Lt||{}),Dt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Dt||{}),Mt=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Mt||{}),De=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(De||{}),Ot=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(Ot||{}),zt=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(zt||{}),je=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(je||{}),Bt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Bt||{});const $e={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ye={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"select",countriesType:$e.PhoneNumber},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select",countriesType:$e.Address},nationality:{label:"Nationality",type:"select",countriesType:$e.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:$e.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:$e.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:$e.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Je={companyName:{label:"Company Name",type:"text"},email:{label:"Email",type:"email"},phone:{label:"Phone",type:"tel"},registrationNumber:{label:"Registration Number",type:"text"},countryResidence:{label:"Country of Residence",type:"select",countriesType:$e.Address},legalAddress:{label:"Legal Address",type:"text"},incorporatedOn:{label:"Incorporation Date",type:"date"},controlScheme:{label:"Control Scheme",type:"text"},taxId:{label:"Tax ID",type:"text"},registrationLocation:{label:"Registration Location",type:"text"},website:{label:"Website",type:"text"},postalAddress:{label:"Postal Address",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},city:{label:"City",type:"text"},state:{label:"State / Province",type:"text"},postalCode:{label:"Postal Code",type:"text"},addressCountry:{label:"Address Country",type:"select",countriesType:$e.Address},lei:{label:"LEI",type:"text"}},_t=["companyName","email","phone","registrationNumber"],$t=["firstName","lastName","email","phonenumber","dateOfBirth"],xt=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var we=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(we||{});const Ht={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Wt{constructor(r){this.config=r}build(r,s){const a=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class Le extends Error{constructor(s,a,n,o,c){super(s);pe(this,"response");this.code=a,this.details=n,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,Le.prototype)}}class tt{static handleApiError(r){return new Le(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new Le(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new Le(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new Le((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new Le("No response from server",0,"The request was made but no response was received. Please check your network connection."):new Le(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof Le}}class Ut{constructor(r){pe(this,"axiosInstance");pe(this,"endpointBuilder");pe(this,"config");this.config={...Ht,...r},this.endpointBuilder=new Wt(this.config.endpoints),this.axiosInstance=Kr.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,a){try{const n=this.buildEndpoint(r,s),o=await this.axiosInstance.get(n,{params:a});return this.handleResponse(o)}catch(n){throw tt.handleAxiosError(n)}}async post(r,s,a){try{const n=this.buildEndpoint(r,s),o=await this.axiosInstance.post(n,a);return this.handleResponse(o)}catch(n){throw tt.handleAxiosError(n)}}async put(r,s,a){try{const n=this.buildEndpoint(r,s),o=await this.axiosInstance.put(n,a);return this.handleResponse(o)}catch(n){throw tt.handleAxiosError(n)}}async delete(r,s,a){try{const n=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(o)}catch(n){throw tt.handleAxiosError(n)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw tt.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class Kt{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class qt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class Vt{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class Yt{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class Qt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class Gt{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class Jt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}async refreshSumsubToken(r){console.log("[IdentityService] Refreshing Sumsub token for applicant:",r);const s=await this.httpClient.post("Applicant","RefreshSumsubToken",{applicantId:r});return console.log("[IdentityService] Sumsub token refresh result:",s),s.result.accessToken}}class Zt{constructor(r){this.httpClient=r}async getCountries(r,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class Xt{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const Re={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},er={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},tr={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},rr={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},sr={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},ar={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},nr={[we.Default]:Re,[we.Corporate]:er,[we.Fintech]:tr,[we.Healthcare]:rr,[we.Modern]:sr,[we.Minimal]:ar};function rt(t){return nr[t]||Re}class ir{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return rt(we.Default);let a=s.result.preset?rt(s.result.preset):rt(we.Default);if(s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(r=a.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const n=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(a.applicantFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const n=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(n)&&n.length>0&&(a.reviewPageFields=n)}catch{}if(s.result.reviewPageDisabled&&(a.reviewPageDisabled=!0),s.result.fieldLabelMode==="placeholder"&&(a.fieldLabelMode="placeholder"),s.result.companyFormVisibleFields&&s.result.companyFormVisibleFields.length>0&&(a.companyFormVisibleFields=s.result.companyFormVisibleFields),s.result.companyFormRequiredFields&&s.result.companyFormRequiredFields.length>0&&(a.companyFormRequiredFields=s.result.companyFormRequiredFields),s.result.companyFormPages)try{const n=typeof s.result.companyFormPages=="string"?JSON.parse(s.result.companyFormPages):s.result.companyFormPages;Array.isArray(n)&&n.length>0&&(a.companyFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(u=>({...u,colSpan:c?u.colSpan===1?2:4:Math.min(4,Math.max(1,u.colSpan??4))}))}}))}catch{}if(s.result.companyReviewPageFields)try{const n=typeof s.result.companyReviewPageFields=="string"?JSON.parse(s.result.companyReviewPageFields):s.result.companyReviewPageFields;Array.isArray(n)&&n.length>0&&(a.companyReviewPageFields=n)}catch{}return a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),rt(we.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:we.Default,name:"Default"},{id:we.Corporate,name:"Corporate"},{id:we.Fintech,name:"Fintech"},{id:we.Healthcare,name:"Healthcare"},{id:we.Modern,name:"Modern"},{id:we.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const a=rt(r);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class or{constructor(){pe(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const a=this.listeners.get(r);a&&a.delete(s)}emit(r,s){const a=this.listeners.get(r);a&&a.forEach(n=>{try{n(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class lr{constructor(){pe(this,"events",new or);pe(this,"_applicantId",null);pe(this,"_progress",null);pe(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||Fe.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===Fe.Finished}get isOnHold(){return this.status===Fe.OnHold}get isInProgress(){return this.status===Fe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===Fe.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class cr{constructor(){pe(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${oe[r]}`);return a.loadData(s)}async submitStepData(r,s){const a=this.getHandler(r);if(!a)throw new Error(`No handler registered for step action: ${oe[r]}`);return a.submitData(s)}}class dr{constructor(r,s,a,n,o,c,u,y){pe(this,"state");pe(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=y,this.state=new lr,this.stepRouter=new cr,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(oe.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(oe.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(oe.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(oe.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(oe.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(oe.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(oe.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function ft(t,r){return new Promise((s,a)=>{if(r&&document.getElementById(r)){s();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function Vr(t){return!!document.getElementById(t)}function Yr(t){const r=document.getElementById(t);r&&r.remove()}const Qr="https://static.sumsub.com/idensic/static/sns-websdk-builder.js";function Gr(){return`
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
border-radius: 10px;
|
|
23
|
-
border: 1px solid var(--metakyc-border, #e5e7eb);
|
|
24
|
-
}
|
|
25
|
-
input {
|
|
26
|
-
color: var(--metakyc-text-primary, #111827);
|
|
27
|
-
font-weight: 500;
|
|
28
|
-
outline: none;
|
|
29
|
-
}
|
|
30
|
-
button.submit, button.back {
|
|
31
|
-
border-radius: 8px;
|
|
32
|
-
height: 44px;
|
|
33
|
-
padding: 0 24px;
|
|
34
|
-
font-size: 14px;
|
|
35
|
-
font-weight: 600;
|
|
36
|
-
background-image: none !important;
|
|
37
|
-
transform: none !important;
|
|
38
|
-
box-shadow: none !important;
|
|
39
|
-
transition: all 0.15s ease;
|
|
40
|
-
}
|
|
41
|
-
button.submit {
|
|
42
|
-
min-width: 120px;
|
|
43
|
-
background: none;
|
|
44
|
-
background-color: var(--metakyc-primary, #2563eb);
|
|
45
|
-
color: #ffffff;
|
|
46
|
-
}
|
|
47
|
-
button.submit:hover {
|
|
48
|
-
background-color: var(--metakyc-primary-hover, #1d4ed8);
|
|
49
|
-
}
|
|
50
|
-
button.back {
|
|
51
|
-
background: none;
|
|
52
|
-
background-color: var(--metakyc-background, #ffffff);
|
|
53
|
-
border: 1px solid var(--metakyc-border, #d1d5db);
|
|
54
|
-
color: var(--metakyc-text-primary, #111827);
|
|
55
|
-
}
|
|
56
|
-
button.back:hover {
|
|
57
|
-
background-color: var(--metakyc-surface, #f3f4f6);
|
|
58
|
-
}
|
|
59
|
-
.round-icon {
|
|
60
|
-
background-color: var(--metakyc-primary, #2563eb) !important;
|
|
61
|
-
background-image: none !important;
|
|
62
|
-
}
|
|
63
|
-
.upload-item, .document-status {
|
|
64
|
-
border-color: var(--metakyc-border, #e5e7eb) !important;
|
|
65
|
-
}
|
|
66
|
-
.step-desc {
|
|
67
|
-
color: var(--metakyc-text-secondary, #6b7280);
|
|
68
|
-
}
|
|
69
|
-
`.replace(/\n\s+/g," ").trim()}class ur{constructor(r){pe(this,"sdk",null);pe(this,"config");pe(this,"completeCallback",null);pe(this,"errorCallback",null);this.config=r}async loadSDK(){if(!window.snsWebSdk&&(await ft(Qr,"sumsub-websdk"),!window.snsWebSdk))throw new Error("Sumsub Web SDK failed to load from CDN")}async initialize(r){await this.loadSDK();const s={};this.config.customCss&&(s.customCss=this.config.customCss),s.customCssStr=Gr();const a=window.snsWebSdk.init(this.config.accessToken,()=>this.config.onTokenRefresh()).withConf({lang:this.config.lang||"en",...this.config.applicantEmail?{email:this.config.applicantEmail}:{},...this.config.applicantPhone?{phone:this.config.applicantPhone}:{},...this.config.theme?{theme:this.config.theme}:{},uiConf:s}).withOptions({addViewportTag:!1,adaptIframeHeight:this.config.adaptIframeHeight!==!1}).on("idCheck.onStepCompleted",n=>{console.log("[Sumsub] Step completed:",n)}).on("idCheck.applicantStatus",n=>{var o,c;console.log("[Sumsub] Applicant status:",n),((n==null?void 0:n.reviewStatus)==="completed"||((o=n==null?void 0:n.reviewResult)==null?void 0:o.reviewAnswer)==="GREEN")&&((c=this.completeCallback)==null||c.call(this,n))}).on("idCheck.onError",n=>{var o;console.error("[Sumsub] Error:",n),(o=this.errorCallback)==null||o.call(this,n)}).onMessage((n,o)=>{var c;console.log("[Sumsub] Message:",n,o),n==="idCheck.onApplicantSubmitted"&&((c=this.completeCallback)==null||c.call(this,o))});this.sdk=a.build(),this.sdk.launch(`#${r}`)}destroy(){if(this.sdk){try{this.sdk.destroy()}catch{}this.sdk=null}}onComplete(r){this.completeCallback=r}onError(r){this.errorCallback=r}}class pr{constructor(r){pe(this,"sdk",null);pe(this,"config");this.config=r}async loadSDK(){await ft("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class mr{constructor(r){pe(this,"sardineContext",null);pe(this,"config");pe(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(n,o):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:u=>{console.log(`[SardinAI] Device ID: ${u.deviceId}`)},onConfigUpdate:(u,y,p)=>{switch(u){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",y);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",u)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:o}=this.config;a.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${o||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class _e{static createProvider(r,s){switch(r){case Ae.Sumsub:return new ur(s);case Ae.Onfido:return new pr(s);case Ae.SardinAI:return new mr(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,a){var n,o;switch(r){case Ae.Sumsub:const c=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sumsub)||{};return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:c.lang||s.lang||"en",theme:c.theme,customCss:c.customCss,adaptIframeHeight:c.adaptIframeHeight};case Ae.Onfido:return{token:s.token||s.sdkToken};case Ae.SardinAI:const u=((o=a==null?void 0:a.identityProviders)==null?void 0:o.sardinai)||{};return{clientId:u.clientId||s.clientId,sessionKey:u.sessionKey||s.sessionKey,environment:u.environment||s.environment||"production",flow:u.flow||s.flow,region:u.region,enableBiometrics:u.enableBiometrics,enablePortScanning:u.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}function Jr(){return`
|
|
1
|
+
"use strict";var Ur=Object.defineProperty;var Kr=(t,r,s)=>r in t?Ur(t,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[r]=s;var pe=(t,r,s)=>Kr(t,typeof r!="symbol"?r+"":r,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const qr=require("axios"),i=require("react"),e=require("react/jsx-runtime"),pt=require("react-dom"),qe=require("react-hook-form"),We=require("zod");function Vr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const s in t)if(s!=="default"){const n=Object.getOwnPropertyDescriptor(t,s);Object.defineProperty(r,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return r.default=t,Object.freeze(r)}const wt=Vr(i);var oe=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(oe||{}),ot=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(ot||{}),Fe=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(Fe||{}),At=(t=>(t[t.None=0]="None",t[t.RepresentativeKYC=1]="RepresentativeKYC",t[t.ManualRiskCriteria=2]="ManualRiskCriteria",t[t.UploadDocumentReview=3]="UploadDocumentReview",t[t.AdminReview=4]="AdminReview",t))(At||{}),Ft=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Ft||{}),Ve=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(Ve||{}),Ye=(t=>(t[t.Approved=0]="Approved",t[t.Reject=1]="Reject",t[t.UnderReview=2]="UnderReview",t[t.Closed=3]="Closed",t[t.AdminReview=4]="AdminReview",t[t.New=5]="New",t[t.InProgress=6]="InProgress",t))(Ye||{}),Tt=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Tt||{}),Pt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Pt||{}),Ae=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(Ae||{}),Lt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Lt||{}),lt=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(lt||{}),Dt=(t=>(t[t.Image=0]="Image",t[t.Video=1]="Video",t[t.PDF=2]="PDF",t[t.OfficePDF=3]="OfficePDF",t[t.Custom=4]="Custom",t))(Dt||{}),Mt=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Mt||{}),Ot=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Ot||{}),De=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(De||{}),zt=(t=>(t[t.Text=0]="Text",t[t.Radio=1]="Radio",t[t.Checkbox=2]="Checkbox",t[t.Dropdown=3]="Dropdown",t[t.Country=4]="Country",t))(zt||{}),$t=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))($t||{}),je=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(je||{}),Bt=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Bt||{});const He={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Qe={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"select",countriesType:He.PhoneNumber},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select",countriesType:He.Address},nationality:{label:"Nationality",type:"select",countriesType:He.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:He.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:He.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:He.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Ze={companyName:{label:"Company Name",type:"text"},email:{label:"Email",type:"email"},phone:{label:"Phone",type:"tel"},registrationNumber:{label:"Registration Number",type:"text"},countryResidence:{label:"Country of Residence",type:"select",countriesType:He.Address},legalAddress:{label:"Legal Address",type:"text"},incorporatedOn:{label:"Incorporation Date",type:"date"},controlScheme:{label:"Control Scheme",type:"text"},taxId:{label:"Tax ID",type:"text"},registrationLocation:{label:"Registration Location",type:"text"},website:{label:"Website",type:"text"},postalAddress:{label:"Postal Address",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},city:{label:"City",type:"text"},state:{label:"State / Province",type:"text"},postalCode:{label:"Postal Code",type:"text"},addressCountry:{label:"Address Country",type:"select",countriesType:He.Address},lei:{label:"LEI",type:"text"}},_t=["companyName","email","phone","registrationNumber"],Ht=["firstName","lastName","email","phonenumber","dateOfBirth"],ht=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var we=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(we||{});const Wt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Ut{constructor(r){this.config=r}build(r,s){const n=`${r}.${s}`;if(this.config.customPaths&&this.config.customPaths[n])return this.config.customPaths[n];switch(this.config.pattern){case"host-controller":return`/api/${r}/${s}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${n}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class Le extends Error{constructor(s,n,a,o,c){super(s);pe(this,"response");this.code=n,this.details=a,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,Le.prototype)}}class rt{static handleApiError(r){return new Le(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const s=r.response.data;return s&&s.error?new Le(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,r.response):s&&s.result&&s.result.message?new Le(s.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new Le((s==null?void 0:s.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new Le("No response from server",0,"The request was made but no response was received. Please check your network connection."):new Le(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof Le}}class Kt{constructor(r){pe(this,"axiosInstance");pe(this,"endpointBuilder");pe(this,"config");this.config={...Wt,...r},this.endpointBuilder=new Ut(this.config.endpoints),this.axiosInstance=qr.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var a;const n=s.config;return((a=s.response)==null?void 0:a.status)>=500&&!n._retry&&(n._retry=!0,n._retryCount=(n._retryCount||0)+1,n._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,1e3*n._retryCount)),this.axiosInstance(n)):Promise.reject(s)})}buildEndpoint(r,s){return this.endpointBuilder.build(r,s)}async get(r,s,n){try{const a=this.buildEndpoint(r,s),o=await this.axiosInstance.get(a,{params:n});return this.handleResponse(o)}catch(a){throw rt.handleAxiosError(a)}}async post(r,s,n){try{const a=this.buildEndpoint(r,s),o=await this.axiosInstance.post(a,n);return this.handleResponse(o)}catch(a){throw rt.handleAxiosError(a)}}async put(r,s,n){try{const a=this.buildEndpoint(r,s),o=await this.axiosInstance.put(a,n);return this.handleResponse(o)}catch(a){throw rt.handleAxiosError(a)}}async delete(r,s,n){try{const a=this.buildEndpoint(r,s),o=await this.axiosInstance.delete(a,{params:n});return this.handleResponse(o)}catch(a){throw rt.handleAxiosError(a)}}handleResponse(r){const s=r.data;if(!s.success&&s.error)throw rt.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class qt{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:s})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class Vt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class Yt{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class Qt{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class Gt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class Jt{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class Zt{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const s=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(r){const s={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}async refreshSumsubToken(r){console.log("[IdentityService] Refreshing Sumsub token for applicant:",r);const s=await this.httpClient.post("Applicant","RefreshSumsubToken",{applicantId:r});return console.log("[IdentityService] Sumsub token refresh result:",s),s.result.accessToken}}class Xt{constructor(r){this.httpClient=r}async getCountries(r,s,n){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:s||"en",type:n})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class er{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const Re={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},tr={name:"Corporate",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#0052CC",primaryHover:"#0747A6",primaryLight:"#DEEBFF",primaryDark:"#0747A6",secondary:"#6B778C",secondaryHover:"#5E6C84",success:"#00875A",warning:"#FF991F",danger:"#DE350B",info:"#0065FF",background:"#ffffff",surface:"#F4F5F7",border:"#DFE1E6",textPrimary:"#172B4D",textSecondary:"#5E6C84",textMuted:"#97A0AF"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.5rem",inputHeight:"2.5rem"}},rr={name:"Fintech",logo:{url:"",height:"36px",visible:!0},colors:{primary:"#00B386",primaryHover:"#009973",primaryLight:"#D1FAE5",primaryDark:"#047857",secondary:"#7C3AED",secondaryHover:"#6D28D9",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#F9FAFB",border:"#E5E7EB",textPrimary:"#111827",textSecondary:"#6B7280",textMuted:"#9CA3AF"},typography:{fontFamily:"Montserrat, system-ui, sans-serif"},spacing:{borderRadius:"0.75rem",cardPadding:"2rem",inputHeight:"3rem"}},sr={name:"Healthcare",logo:{url:"",height:"44px",visible:!0},colors:{primary:"#06B6D4",primaryHover:"#0891B2",primaryLight:"#CFFAFE",primaryDark:"#0E7490",secondary:"#8B5CF6",secondaryHover:"#7C3AED",success:"#059669",warning:"#D97706",danger:"#DC2626",info:"#0284C7",background:"#ffffff",surface:"#F0F9FF",border:"#E0F2FE",textPrimary:"#0F172A",textSecondary:"#475569",textMuted:"#94A3B8"},typography:{fontFamily:"Lato, system-ui, sans-serif"},spacing:{borderRadius:"0.5rem",cardPadding:"1.75rem",inputHeight:"2.75rem"},darkMode:{colors:{background:"#0F172A",surface:"#1E293B",border:"#334155",textPrimary:"#F1F5F9",textSecondary:"#CBD5E1"}}},nr={name:"Modern",logo:{url:"",height:"38px",visible:!0},colors:{primary:"#8B5CF6",primaryHover:"#7C3AED",primaryLight:"#EDE9FE",primaryDark:"#6D28D9",secondary:"#EC4899",secondaryHover:"#DB2777",success:"#10B981",warning:"#F59E0B",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E5E5E5",textPrimary:"#171717",textSecondary:"#737373",textMuted:"#A3A3A3"},typography:{fontFamily:"Poppins, system-ui, sans-serif"},spacing:{borderRadius:"1rem",cardPadding:"2rem",inputHeight:"3rem"}},ar={name:"Minimal",logo:{url:"",height:"32px",visible:!0},colors:{primary:"#000000",primaryHover:"#18181B",primaryLight:"#F4F4F5",primaryDark:"#000000",secondary:"#71717A",secondaryHover:"#52525B",success:"#22C55E",warning:"#EAB308",danger:"#EF4444",info:"#3B82F6",background:"#ffffff",surface:"#FAFAFA",border:"#E4E4E7",textPrimary:"#09090B",textSecondary:"#71717A",textMuted:"#A1A1AA"},typography:{fontFamily:"system-ui, -apple-system, sans-serif"},spacing:{borderRadius:"0.25rem",cardPadding:"1.25rem",inputHeight:"2.25rem"}},ir={[we.Default]:Re,[we.Corporate]:tr,[we.Fintech]:rr,[we.Healthcare]:sr,[we.Modern]:nr,[we.Minimal]:ar};function st(t){return ir[t]||Re}class or{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return st(we.Default);let n=s.result.preset?st(s.result.preset):st(we.Default);if(s.result.title&&(n.title=s.result.title),s.result.logo&&(n.logo={...n.logo,...s.result.logo}),s.result.colors&&(n.colors={...n.colors,...s.result.colors}),s.result.typography&&(n.typography={...n.typography,...s.result.typography}),s.result.spacing&&(n.spacing={...n.spacing,...s.result.spacing}),s.result.customCSS&&(n.customCSS=s.result.customCSS),s.result.darkMode&&(n.darkMode={colors:{...(r=n.darkMode)==null?void 0:r.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(n.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(n.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(n.allowedLanguages=s.result.allowedLanguages),s.result.applicantFormPages)try{const a=typeof s.result.applicantFormPages=="string"?JSON.parse(s.result.applicantFormPages):s.result.applicantFormPages;Array.isArray(a)&&a.length>0&&(n.applicantFormPages=a.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(s.result.reviewPageFields)try{const a=typeof s.result.reviewPageFields=="string"?JSON.parse(s.result.reviewPageFields):s.result.reviewPageFields;Array.isArray(a)&&a.length>0&&(n.reviewPageFields=a)}catch{}if(s.result.reviewPageDisabled&&(n.reviewPageDisabled=!0),s.result.fieldLabelMode==="placeholder"&&(n.fieldLabelMode="placeholder"),s.result.companyFormVisibleFields&&s.result.companyFormVisibleFields.length>0&&(n.companyFormVisibleFields=s.result.companyFormVisibleFields),s.result.companyFormRequiredFields&&s.result.companyFormRequiredFields.length>0&&(n.companyFormRequiredFields=s.result.companyFormRequiredFields),s.result.companyFormPages)try{const a=typeof s.result.companyFormPages=="string"?JSON.parse(s.result.companyFormPages):s.result.companyFormPages;Array.isArray(a)&&a.length>0&&(n.companyFormPages=a.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(s.result.companyReviewPageFields)try{const a=typeof s.result.companyReviewPageFields=="string"?JSON.parse(s.result.companyReviewPageFields):s.result.companyReviewPageFields;Array.isArray(a)&&a.length>0&&(n.companyReviewPageFields=a)}catch{}return n}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),st(we.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:we.Default,name:"Default"},{id:we.Corporate,name:"Corporate"},{id:we.Fintech,name:"Fintech"},{id:we.Healthcare,name:"Healthcare"},{id:we.Modern,name:"Modern"},{id:we.Minimal,name:"Minimal"}]}getPreviewTheme(r,s){const n=st(r);return s?{...n,...s,logo:{...n.logo,...s.logo},colors:{...n.colors,...s.colors},typography:s.typography?{...n.typography,...s.typography}:n.typography,spacing:s.spacing?{...n.spacing,...s.spacing}:n.spacing}:n}}class lr{constructor(){pe(this,"listeners",new Map)}on(r,s){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(s),()=>{this.off(r,s)}}off(r,s){const n=this.listeners.get(r);n&&n.delete(s)}emit(r,s){const n=this.listeners.get(r);n&&n.forEach(a=>{try{a(s)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class cr{constructor(){pe(this,"events",new lr);pe(this,"_applicantId",null);pe(this,"_progress",null);pe(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||Fe.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===Fe.Finished}get isOnHold(){return this.status===Fe.OnHold}get isInProgress(){return this.status===Fe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var n,a;const s=(n=this._progress)==null?void 0:n.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(s==null?void 0:s.order)!==((a=r.currentStep)==null?void 0:a.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===Fe.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class dr{constructor(){pe(this,"handlers",new Map)}registerHandler(r,s){this.handlers.set(r,s)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,s){const n=this.getHandler(r);if(!n)throw new Error(`No handler registered for step action: ${oe[r]}`);return n.loadData(s)}async submitStepData(r,s){const n=this.getHandler(r);if(!n)throw new Error(`No handler registered for step action: ${oe[r]}`);return n.submitData(s)}}class ur{constructor(r,s,n,a,o,c,d,y){pe(this,"state");pe(this,"stepRouter");this.applicantService=r,this.questionnaireService=s,this.uploadDocumentService=n,this.appropriatenessTestService=a,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=y,this.state=new cr,this.stepRouter=new dr,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(oe.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(oe.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(oe.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(oe.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(oe.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(oe.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(oe.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const s=await this.applicantService.getProgress(r);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function gt(t,r){return new Promise((s,n)=>{if(r&&document.getElementById(r)){s();return}const a=document.createElement("script");a.src=t,r&&(a.id=r),a.async=!0,a.onload=()=>s(),a.onerror=()=>n(new Error(`Failed to load script: ${t}`)),document.head.appendChild(a)})}function Yr(t){return!!document.getElementById(t)}function Qr(t){const r=document.getElementById(t);r&&r.remove()}const Gr="https://static.sumsub.com/idensic/static/sns-websdk-builder.js";function Be(t,r){try{return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||r}catch{return r}}function Jr(){const t=Be("--metakyc-primary","#2563eb"),r=Be("--metakyc-primary-hover","#1d4ed8"),s=Be("--metakyc-background","#ffffff"),n=Be("--metakyc-surface","#f9fafb"),a=Be("--metakyc-text-primary","#111827"),o=Be("--metakyc-text-secondary","#6b7280"),c=Be("--metakyc-text-muted","#9ca3af"),d=Be("--metakyc-border","#e5e7eb");return`
|
|
2
|
+
body, html { font-family: ${Be("--metakyc-font-family","-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif")} !important; background-color: ${s} !important; }
|
|
3
|
+
p, span, label, div { color: ${a}; }
|
|
4
|
+
h1, h2, h3, h4 { color: ${a}; }
|
|
5
|
+
.step-desc { color: ${o}; }
|
|
6
|
+
section.content { background-color: ${n}; color: ${a}; padding: 32px 32px 16px; box-shadow: none; border-radius: 10px; border: 1px solid ${d}; }
|
|
7
|
+
input { color: ${a}; font-weight: 500; outline: none; background-color: ${s}; border: 1px solid ${d}; border-radius: 6px; }
|
|
8
|
+
input:focus { border-color: ${t}; box-shadow: 0 0 0 2px ${t}33; }
|
|
9
|
+
button.submit, button.back { border-radius: 8px; height: 44px; padding: 0 24px; font-size: 14px; font-weight: 600; background-image: none !important; transform: none !important; box-shadow: none !important; transition: all 0.15s ease; cursor: pointer; }
|
|
10
|
+
button.submit { min-width: 120px; background: none; background-color: ${t}; color: #ffffff; border: none; }
|
|
11
|
+
button.submit:hover { background-color: ${r}; }
|
|
12
|
+
button.back { background: none; background-color: ${s}; border: 1px solid ${d}; color: ${a}; }
|
|
13
|
+
button.back:hover { background-color: ${n}; }
|
|
14
|
+
.round-icon { background-color: ${t} !important; background-image: none !important; }
|
|
15
|
+
.upload-item, .document-status { border-color: ${d} !important; }
|
|
16
|
+
select { background-color: ${s}; color: ${a}; border: 1px solid ${d}; border-radius: 6px; }
|
|
17
|
+
.description { color: ${o}; }
|
|
18
|
+
.subtitle { color: ${c}; }
|
|
19
|
+
a { color: ${t}; }
|
|
20
|
+
a:hover { color: ${r}; }
|
|
21
|
+
`.trim()}class pr{constructor(r){pe(this,"sdk",null);pe(this,"config");pe(this,"completeCallback",null);pe(this,"errorCallback",null);this.config=r}async loadSDK(){if(!window.snsWebSdk&&(await gt(Gr,"sumsub-websdk"),!window.snsWebSdk))throw new Error("Sumsub Web SDK failed to load from CDN")}async initialize(r){await this.loadSDK();const s={lang:this.config.lang||"en"};if(this.config.applicantEmail&&(s.email=this.config.applicantEmail),this.config.applicantPhone&&(s.phone=this.config.applicantPhone),this.config.theme&&(s.theme=this.config.theme),this.config.customizationName&&(s.customizationName=this.config.customizationName),!this.config.customizationName){const a={};this.config.customCss&&(a.customCss=this.config.customCss),this.config.customCssStr&&(a.customCssStr=this.config.customCssStr),a.customCssStr||(a.customCssStr=Jr()),s.uiConf=a}const n=window.snsWebSdk.init(this.config.accessToken,()=>this.config.onTokenRefresh()).withConf(s).withOptions({addViewportTag:!1,adaptIframeHeight:this.config.adaptIframeHeight!==!1}).on("idCheck.onStepCompleted",a=>{console.log("[Sumsub] Step completed:",a)}).on("idCheck.applicantStatus",a=>{var o,c;console.log("[Sumsub] Applicant status:",a),((a==null?void 0:a.reviewStatus)==="completed"||((o=a==null?void 0:a.reviewResult)==null?void 0:o.reviewAnswer)==="GREEN")&&((c=this.completeCallback)==null||c.call(this,a))}).on("idCheck.onError",a=>{var o;console.error("[Sumsub] Error:",a),(o=this.errorCallback)==null||o.call(this,a)}).onMessage((a,o)=>{var c;console.log("[Sumsub] Message:",a,o),a==="idCheck.onApplicantSubmitted"&&((c=this.completeCallback)==null||c.call(this,o))});this.sdk=n.build(),this.sdk.launch(`#${r}`)}destroy(){if(this.sdk){try{this.sdk.destroy()}catch{}this.sdk=null}}onComplete(r){this.completeCallback=r}onError(r){this.errorCallback=r}}class mr{constructor(r){pe(this,"sdk",null);pe(this,"config");this.config=r}async loadSDK(){await gt("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class yr{constructor(r){pe(this,"sardineContext",null);pe(this,"config");pe(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const s=Math.random()*16|0;return(r==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:r,region:s}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,s)=>{if(window._Sardine){r();return}const n=this.getSardineHost(),a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=`https://${n}/assets/loader.min.js`,a.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},a.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(a,o):document.head.appendChild(a)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:s,environment:n,flow:a,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:a||window.location.pathname,environment:n||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:d=>{console.log(`[SardinAI] Device ID: ${d.deviceId}`)},onConfigUpdate:(d,y,p)=>{switch(d){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",y);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",d)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const s=document.createElement("noscript"),n=document.createElement("img"),{clientId:a,flow:o}=this.config;n.src=`https://${r}/v1/a.png?clientId=${a}&sessionKey=${this.sessionKey}&flow=${o||"kyc"}&ns=1`,n.style.display="none",s.appendChild(n),document.body.appendChild(s)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(s,n,a)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",a);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",n);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class _e{static createProvider(r,s){switch(r){case Ae.Sumsub:return new pr(s);case Ae.Onfido:return new mr(s);case Ae.SardinAI:return new yr(s);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,s,n){var a,o;switch(r){case Ae.Sumsub:const c=((a=n==null?void 0:n.identityProviders)==null?void 0:a.sumsub)||{};return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:c.lang||s.lang||"en",theme:c.theme,customizationName:c.customizationName,customCss:c.customCss,adaptIframeHeight:c.adaptIframeHeight};case Ae.Onfido:return{token:s.token||s.sdkToken};case Ae.SardinAI:const d=((o=n==null?void 0:n.identityProviders)==null?void 0:o.sardinai)||{};return{clientId:d.clientId||s.clientId,sessionKey:d.sessionKey||s.sessionKey,environment:d.environment||s.environment||"production",flow:d.flow||s.flow,region:d.region,enableBiometrics:d.enableBiometrics,enablePortScanning:d.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}function Zr(){return`
|
|
70
22
|
/* ── metakyc-input-colors (ThemeManager failsafe — same rules as globals.css) ── */
|
|
71
23
|
.metakyc-sdk input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
|
|
72
24
|
.metakyc-sdk select,
|
|
@@ -97,55 +49,55 @@
|
|
|
97
49
|
position: relative !important;
|
|
98
50
|
z-index: 2 !important;
|
|
99
51
|
}
|
|
100
|
-
`}class yr{constructor(r){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"inputStyleElement",null);pe(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var a;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([n,o])=>{o&&this.container.style.setProperty(`--metakyc-${n}`,o)}),this.injectInputColors(),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectInputColors(){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=Jr(),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=Re.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const gt=i.createContext(null),Zr=({config:t,children:r})=>{const[s,a]=i.useState(null),n=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Ut(t),p=new Kt(y),b=new qt(y),F=new Vt(y),v=new Yt(y),E=new Qt(y),A=new Gt(y),k=new Jt(y),S=new Zt(y),M=new Xt(y),Y=new ir(y),L=new yr;return{httpClient:y,applicantService:p,questionnaireService:b,uploadDocumentService:F,appropriatenessTestService:v,overviewService:E,riskScoringService:A,identityService:k,baseInformationService:S,investorCategorizationService:M,themeService:Y,themeManager:L}},[t]),u=i.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new dr(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return i.useEffect(()=>((async()=>{if(n.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),a(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),a(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),a(c.themeManager.getCurrentTheme()),o.current=!0}finally{n.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(gt.Provider,{value:u,children:r})};function Ne(){const t=i.useContext(gt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function xr(t){return new Promise((r,s)=>{const a=new FileReader;a.readAsDataURL(t),a.onload=()=>{const o=a.result.split(",")[1];r(o)},a.onerror=n=>s(n)})}function Xr(t,r){return t.size<=r}function es(t,r){return r.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return t.type.startsWith(n)}return t.type===a})}function dt(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,a)*100)/100+" "+s[a]}function ts(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const at={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function hr(t){try{localStorage.setItem(at.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function fr(){try{const t=localStorage.getItem(at.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function gr(){try{localStorage.removeItem(at.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function br(t){try{localStorage.setItem(at.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function rs(){try{const t=localStorage.getItem(at.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function vr(){try{localStorage.removeItem(at.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function ss(){gr(),vr()}function kr(t){const{createOrchestrator:r}=Ne(),[s,a]=i.useState(null),[n,o]=i.useState(!1),[c,u]=i.useState(null),y=i.useRef(null),p=t||fr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;s&&p&&(hr(p),br({applicantId:p,currentStepOrder:(L=s.currentStep)==null?void 0:L.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const b=i.useRef(!1),F=i.useRef(!1),v=i.useCallback(async()=>{if(!(!p||!y.current)){if(b.current){console.log("[Workflow] Load already in progress, skipping...");return}b.current=!0,o(!0),u(null);try{const L=await y.current.initialize(p);a(L),F.current=!0}catch(L){u(L)}finally{o(!1),b.current=!1}}},[p]);i.useEffect(()=>{p&&!F.current&&v()},[p,v]);const E=i.useCallback(async()=>{if(y.current){if(b.current){console.log("[Workflow] Refresh already in progress, skipping...");return}b.current=!0,o(!0),u(null);try{const L=await y.current.refreshProgress();a(L)}catch(L){u(L)}finally{o(!1),b.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),u(null);try{const L=await y.current.moveToNextStep();a(L)}catch(L){u(L)}finally{o(!1)}}},[]),k=i.useCallback(async()=>{if(y.current){o(!0),u(null);try{const L=await y.current.moveToPreviousStep();a(L)}catch(L){u(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),u(null);try{await y.current.submitCurrentStep(L);const _=await y.current.refreshProgress();a(_)}catch(_){throw u(_),_}finally{o(!1)}}},[]),M=jt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((L,_)=>L.order-_.order):[],[s==null?void 0:s.stepInfoList]),Y=jt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:M,status:(s==null?void 0:s.status)||Fe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:Y,isLoading:n,error:c,isComplete:(s==null?void 0:s.status)===Fe.Finished,isOnHold:(s==null?void 0:s.status)===Fe.OnHold,refreshProgress:E,moveToNext:A,moveBack:k,submitCurrentStep:S,orchestrator:y.current}}function jr(t){const{questionnaireService:r,applicantService:s}=Ne(),[a,n]=i.useState(null),[o,c]=i.useState({}),[u,y]=i.useState(!1),[p,b]=i.useState(!1),[F,v]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),k=i.useCallback(async()=>{var M,Y;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),v(null);try{const[L,_]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(n(L),(M=_==null?void 0:_.questionnaireResults)!=null&&M.length&&L){const U=new Map;for(const g of _.questionnaireResults)g.question&&((Y=g.answers)!=null&&Y.length)&&U.set(g.question.trim().toLowerCase(),g.answers);const X={},R=L.questionGroups.flatMap(g=>g.questions??[]);for(const g of R){const O=g.text.trim().toLowerCase();U.has(O)&&(X[g.id]=U.get(O))}c(X)}A.current=t}catch(L){v(L)}finally{y(!1),E.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&A.current!==t&&k()},[t]);const S=i.useCallback(async M=>{b(!0),v(null);try{return await r.fillQuestionnaire(M)}catch(Y){throw v(Y),Y}finally{b(!1)}},[r]);return{questionnaire:a,initialAnswers:o,isLoading:u,isSubmitting:p,error:F,load:k,submit:S}}function wr(t){const{uploadDocumentService:r}=Ne(),[s,a]=i.useState(null),[n,o]=i.useState(!1),[c,u]=i.useState(!1),[y,p]=i.useState(0),[b,F]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[UploadDocument] Load already in progress, skipping...");return}v.current=!0,o(!0),F(null);try{const S=await r.getUploadDocument(t);a(S),E.current=t}catch(S){F(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{u(!0),p(0),F(null);try{await r.fillUploadDocument(S),p(100)}catch(M){throw F(M),M}finally{u(!1)}},[r]);return{uploadDocument:s,isLoading:n,isSubmitting:c,uploadProgress:y,error:b,load:A,submit:k}}function as(t){const{appropriatenessTestService:r}=Ne(),[s,a]=i.useState(null),[n,o]=i.useState(!1),[c,u]=i.useState(!1),[y,p]=i.useState(null),[b,F]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);a(S),E.current=t}catch(S){p(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{u(!0),p(null);try{const M=await r.fillAppropriatenessTest(S);return F(M),M}catch(M){throw p(M),M}finally{u(!1)}},[r]);return{test:s,result:b,isLoading:n,isSubmitting:c,error:y,load:A,submit:k}}function Sr(t){const{overviewService:r}=Ne(),[s,a]=i.useState(null),[n,o]=i.useState(!1),[c,u]=i.useState(!1),[y,p]=i.useState(null),b=i.useRef(!1),F=i.useRef(null),v=i.useCallback(async()=>{if(t){if(b.current){console.log("[Overview] Load already in progress, skipping...");return}b.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);a(A),F.current=t}catch(A){p(A)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&F.current!==t&&v()},[t]);const E=i.useCallback(async()=>{if(t){u(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{u(!1)}}},[t,r]);return{overview:s,isLoading:n,isSubmitting:c,error:y,load:v,passOverview:E}}function Cr(t){const{identityService:r}=Ne(),[s,a]=i.useState(null),[n,o]=i.useState(!1),[c,u]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(v,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),u(null);try{const A={applicantId:t,restart:!1,redirectUrl:v||"",ttl:E||604800};console.log("Identity request input:",A);const k=await r.identityRequest(A);return console.log("Identity request result:",k),a(k),k}catch(A){throw u(A),A}finally{o(!1),y.current=!1}}},[t,r]),b=i.useCallback(async(v,E)=>{if(t){o(!0),u(null);try{const A={applicantId:t,restart:!1,redirectUrl:v,ttl:E},k=await r.identityCompanyRequest(A);return a(k),k}catch(A){throw u(A),A}finally{o(!1)}}},[t,r]),F=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),u(null);try{const v={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",v);const E=await r.identityRequest(v);return console.log("Restart identity result:",E),a(E),E}catch(v){throw u(v),v}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:c,requestIdentity:p,requestCompanyIdentity:b,restartIdentity:F}}function Nr(t){const{riskScoringService:r,applicantService:s}=Ne(),[a,n]=i.useState(null),[o,c]=i.useState({}),[u,y]=i.useState(!1),[p,b]=i.useState(!1),[F,v]=i.useState(null),[E,A]=i.useState(null),k=i.useRef(!1),S=i.useRef(null),M=i.useCallback(async()=>{var L;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,y(!0),v(null);try{const[_,U]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(n(_),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const X=U.riskScoringResults[0],R={};for(const g of X.riskCriteriaResults??[])if(g.riskCriteriaId!=null&&g.answer!=null&&g.answer!==""){const O=[...new Set(g.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];O.length>0&&(R[g.riskCriteriaId]=O)}c(R)}S.current=t}catch(_){v(_)}finally{y(!1),k.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&S.current!==t&&M()},[t]);const Y=i.useCallback(async L=>{b(!0),v(null);try{const _=await r.submitRiskScoring(L);return A(_),_}catch(_){throw v(_),_}finally{b(!1)}},[r]);return{criteria:a,initialAnswers:o,result:E,isLoading:u,isSubmitting:p,error:F,load:M,submit:Y}}function bt(){const{applicantService:t,config:r}=Ne(),[s,a]=i.useState(!1),[n,o]=i.useState(null),c=i.useRef(!1),u=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,a(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(k){throw o(k),k}finally{a(!1),c.current=!1}},[t,r]),b=i.useCallback(async E=>{a(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{a(!1)}},[t]),F=i.useCallback(async E=>{if(u.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");u.current=!0,a(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{a(!1),u.current=!1}},[t]),v=i.useCallback(async E=>{a(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{a(!1)}},[t]);return{isLoading:s,error:n,createApplicant:p,createCompanyApplicant:b,getApplicantData:F,stopProgress:v}}const ns={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:s="md",isLoading:a=!1,disabled:n,className:o,style:c,...u})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return e.jsxs("button",{className:Se(y,p[s],o),style:{...ns[r],...c},disabled:n||a,...u,children:[a&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ye=i.forwardRef(({label:t,error:r,helperText:s,leftIcon:a,rightIcon:n,className:o,style:c,...u},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[a&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),e.jsx("input",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",a?"pl-10":"",n?"pr-10":"",o),style:{backgroundColor:u.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:u.readOnly?"default":void 0,...c},...u}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ye.displayName="Input";const ee=({children:t,className:r,...s})=>e.jsx("div",{className:Se("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ge=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),te=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4",r),...s,children:t}),be=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),is={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},vt=({children:t,variant:r="default",className:s,style:a,...n})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",s),style:{...is[r],...a},...n,children:t}),Ee=({size:t="md",className:r,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:Se("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:Se("animate-spin text-primary-500",a[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},pt=i.forwardRef(({label:t,error:r,helperText:s,options:a,placeholder:n,className:o,style:c,...u},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...u,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),a.map((p,b)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${b}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));pt.displayName="Select";const wt=280,Rr=({label:t,value:r,onChange:s,options:a,placeholder:n="Select...",disabled:o=!1,readOnly:c=!1,required:u=!1})=>{const y=o||c,[p,b]=i.useState(!1),[F,v]=i.useState(""),[E,A]=i.useState(null),[k,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),M=i.useRef(null),Y=i.useRef(null),L=i.useRef(null),_=i.useCallback(()=>{if(!Y.current)return null;const I=Y.current.getBoundingClientRect(),z=window.innerHeight-I.bottom<wt&&I.top>wt;return{top:z?I.top:I.bottom+4,left:I.left,width:I.width,openUp:z}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.documentElement),W=($,me)=>I.getPropertyValue($).trim()||me,z=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:z,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",z)})},[]),X=i.useCallback(()=>{if(y)return;U();const I=_();I&&A(I),b(!0)},[y,_,U]),R=i.useCallback(()=>{b(!1),v("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var $,me;const z=W.target;!(($=M.current)!=null&&$.contains(z))&&!((me=L.current)!=null&&me.contains(z))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=_();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,_]);const g=a.filter(I=>I.label.toLowerCase().includes(F.toLowerCase())),O=I=>{y||s(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||s(r.filter(z=>z!==I))},Q=I=>{var W;return((W=a.find(z=>z.value===I))==null?void 0:W.label)||I},{bg:B,borderColor:G,textPrimary:ae,textSecondary:V,primaryColor:he,primaryLight:le,hoverBg:de}=k,fe=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:B,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:F,onChange:I=>v(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:B,color:ae,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.documentElement),z=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=B,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=z,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${z}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=B,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:g.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:V},children:"No results"}):g.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>O(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?le:"transparent",color:W?he:ae,userSelect:"none"},onMouseEnter:z=>{W||(z.currentTarget.style.backgroundColor=de)},onMouseLeave:z=>{W||(z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:W,readOnly:!0,style:{accentColor:he,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:M,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,u&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Y,onClick:()=>p?R():X(),className:Se("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},I))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p?"▲":"▼"})]}),typeof document<"u"&&fe?ut.createPortal(fe,document.body):null]})},St=260,Me=({label:t,error:r,helperText:s,options:a,placeholder:n="Select...",value:o,onChange:c,disabled:u=!1,readOnly:y=!1,required:p=!1,className:b})=>{var me;const F=u||y,[v,E]=i.useState(!1),[A,k]=i.useState(""),[S,M]=i.useState(null),[Y,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),_=i.useCallback(()=>{const N=getComputedStyle(document.documentElement),re=(ne,ve)=>N.getPropertyValue(ne).trim()||ve,ue=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:ue,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",ue)})},[]),U=i.useRef(null),X=i.useRef(null),R=i.useRef(null),g=i.useRef(null),O=i.useCallback(()=>{if(!X.current)return null;const N=X.current.getBoundingClientRect(),ue=window.innerHeight-N.bottom<St&&N.top>St;return{top:ue?N.top:N.bottom+4,left:N.left,width:N.width,openUp:ue}},[]),q=i.useCallback(()=>{if(F)return;_();const N=O();N&&M(N),E(!0)},[F,O,_]),Q=i.useCallback(()=>{E(!1),k("")},[]),B=()=>v?Q():q();i.useEffect(()=>{if(!v)return;const N=re=>{var ne,ve;const ue=re.target;!((ne=U.current)!=null&&ne.contains(ue))&&!((ve=R.current)!=null&&ve.contains(ue))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[v,Q]),i.useEffect(()=>{if(!v)return;const N=()=>{const re=O();re&&M(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[v,O]),i.useEffect(()=>{v&&g.current&&setTimeout(()=>{var N;return(N=g.current)==null?void 0:N.focus()},0)},[v]);const G=a.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),ae=(me=a.find(N=>N.value===o))==null?void 0:me.label,V=(N,re)=>{F||re||(c(N),Q())},{bg:he,border:le,text:de,textSecondary:fe,primary:I,primaryLight:W,hoverBg:z}=Y,$=v&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${le}`,backgroundColor:he,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${le}`},children:e.jsx("input",{ref:g,type:"text",value:A,onChange:N=>k(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${le}`,backgroundColor:he,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.documentElement),ue=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ue,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${ue}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=le,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:G.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:fe},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>V(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:ue=>{!re&&!N.disabled&&(ue.currentTarget.style.backgroundColor=z)},onMouseLeave:ue=>{re||(ue.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",b),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:X,role:"button",tabIndex:F?-1:0,onClick:B,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),B()),N.key==="Escape"&&Q()},className:Se("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",F?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:ae?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:ae||n}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&$?ut.createPortal($,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]})};Me.displayName="SearchableSelect";function os(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Ir=({label:t,subtitle:r,error:s,accept:a,multiple:n=!1,maxSize:o,required:c,onChange:u,value:y=[],className:p})=>{const[b,F]=i.useState(!1),[v,E]=i.useState(null),A=i.useRef(null),k=i.useCallback(R=>{if(!R)return;E(null);const g=Array.from(R);if(o&&g.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${dt(o)}`);return}u==null||u(n?[...y,...g]:[g[0]])},[o,n,u,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!0)},[]),M=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1)},[]),Y=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1),k(R.dataTransfer.files)},[k]),L=()=>{var R;(R=A.current)==null||R.click()},_=R=>{E(null);const g=y.filter((O,q)=>q!==R);u==null||u(g)},U=s||v,X=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:M,onDrop:Y,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:X?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:a,multiple:n,onChange:R=>{k(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(a||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[a&&e.jsx("span",{children:a}),a&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",dt(o)]})]})]})]})]}),X&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,g)=>{const O=os(R),q=O==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):O==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:dt(R.size)})]}),e.jsx("button",{type:"button",onClick:B=>{B.stopPropagation(),_(g)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:B=>{B.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",B.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:B=>{B.currentTarget.style.backgroundColor="transparent",B.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${g}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Er=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...a},n)=>e.jsxs("div",{className:"w-full",children:[a.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[a.label,a.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:n,type:"tel",className:Se("flex-1",s),...a,label:""})]}),a.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Er.displayName="PhoneInput";/**
|
|
52
|
+
`}class xr{constructor(r){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"inputStyleElement",null);pe(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var n;const s={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(s).forEach(([a,o])=>{o&&this.container.style.setProperty(`--metakyc-${a}`,o)}),this.injectInputColors(),(n=this.currentTheme.darkMode)!=null&&n.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([s,n])=>{if(n){const a=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,n)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,n.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([s,n])=>{const a=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)})}injectInputColors(){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=Zr(),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var s;return{name:r.name||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(s=Re.darkMode)==null?void 0:s.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const bt=i.createContext(null),Xr=({config:t,children:r})=>{const[s,n]=i.useState(null),a=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Kt(t),p=new qt(y),b=new Vt(y),F=new Yt(y),v=new Qt(y),E=new Gt(y),A=new Jt(y),k=new Zt(y),S=new Xt(y),M=new er(y),Y=new or(y),L=new xr;return{httpClient:y,applicantService:p,questionnaireService:b,uploadDocumentService:F,appropriatenessTestService:v,overviewService:E,riskScoringService:A,identityService:k,baseInformationService:S,investorCategorizationService:M,themeService:Y,themeManager:L}},[t]),d=i.useMemo(()=>({config:t,...c,currentTheme:s,createOrchestrator:()=>new ur(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,s]);return i.useEffect(()=>((async()=>{if(a.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}a.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),n(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),n(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),n(c.themeManager.getCurrentTheme()),o.current=!0}finally{a.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsx(bt.Provider,{value:d,children:r})};function Ne(){const t=i.useContext(bt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function hr(t){return new Promise((r,s)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const o=n.result.split(",")[1];r(o)},n.onerror=a=>s(a)})}function es(t,r){return t.size<=r}function ts(t,r){return r.split(",").map(n=>n.trim()).some(n=>{if(n.endsWith("/*")){const a=n.slice(0,-2);return t.type.startsWith(a)}return t.type===n})}function ut(t){if(t===0)return"0 Bytes";const r=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,n)*100)/100+" "+s[n]}function rs(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const at={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function fr(t){try{localStorage.setItem(at.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function gr(){try{const t=localStorage.getItem(at.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function br(){try{localStorage.removeItem(at.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function vr(t){try{localStorage.setItem(at.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function ss(){try{const t=localStorage.getItem(at.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function kr(){try{localStorage.removeItem(at.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function ns(){br(),kr()}function jr(t){const{createOrchestrator:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(null),p=t||gr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;s&&p&&(fr(p),vr({applicantId:p,currentStepOrder:(L=s.currentStep)==null?void 0:L.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,p]);const b=i.useRef(!1),F=i.useRef(!1),v=i.useCallback(async()=>{if(!(!p||!y.current)){if(b.current){console.log("[Workflow] Load already in progress, skipping...");return}b.current=!0,o(!0),d(null);try{const L=await y.current.initialize(p);n(L),F.current=!0}catch(L){d(L)}finally{o(!1),b.current=!1}}},[p]);i.useEffect(()=>{p&&!F.current&&v()},[p,v]);const E=i.useCallback(async()=>{if(y.current){if(b.current){console.log("[Workflow] Refresh already in progress, skipping...");return}b.current=!0,o(!0),d(null);try{const L=await y.current.refreshProgress();n(L)}catch(L){d(L)}finally{o(!1),b.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToNextStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),k=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToPreviousStep();n(L)}catch(L){d(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),d(null);try{await y.current.submitCurrentStep(L);const B=await y.current.refreshProgress();n(B)}catch(B){throw d(B),B}finally{o(!1)}}},[]),M=wt.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((L,B)=>L.order-B.order):[],[s==null?void 0:s.stepInfoList]),Y=wt.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:p,currentStep:(s==null?void 0:s.currentStep)||null,steps:M,status:(s==null?void 0:s.status)||Fe.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:Y,isLoading:a,error:c,isComplete:(s==null?void 0:s.status)===Fe.Finished,isOnHold:(s==null?void 0:s.status)===Fe.OnHold,refreshProgress:E,moveToNext:A,moveBack:k,submitCurrentStep:S,orchestrator:y.current}}function wr(t){const{questionnaireService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,b]=i.useState(!1),[F,v]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),k=i.useCallback(async()=>{var M,Y;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),v(null);try{const[L,B]=await Promise.all([r.getQuestionnaire(t),s.getApplicantData(t).catch(()=>null)]);if(a(L),(M=B==null?void 0:B.questionnaireResults)!=null&&M.length&&L){const U=new Map;for(const g of B.questionnaireResults)g.question&&((Y=g.answers)!=null&&Y.length)&&U.set(g.question.trim().toLowerCase(),g.answers);const X={},R=L.questionGroups.flatMap(g=>g.questions??[]);for(const g of R){const O=g.text.trim().toLowerCase();U.has(O)&&(X[g.id]=U.get(O))}c(X)}A.current=t}catch(L){v(L)}finally{y(!1),E.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&A.current!==t&&k()},[t]);const S=i.useCallback(async M=>{b(!0),v(null);try{return await r.fillQuestionnaire(M)}catch(Y){throw v(Y),Y}finally{b(!1)}},[r]);return{questionnaire:n,initialAnswers:o,isLoading:d,isSubmitting:p,error:F,load:k,submit:S}}function Sr(t){const{uploadDocumentService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(0),[b,F]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[UploadDocument] Load already in progress, skipping...");return}v.current=!0,o(!0),F(null);try{const S=await r.getUploadDocument(t);n(S),E.current=t}catch(S){F(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(0),F(null);try{await r.fillUploadDocument(S),p(100)}catch(M){throw F(M),M}finally{d(!1)}},[r]);return{uploadDocument:s,isLoading:a,isSubmitting:c,uploadProgress:y,error:b,load:A,submit:k}}function as(t){const{appropriatenessTestService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),[b,F]=i.useState(null),v=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(v.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}v.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);n(S),E.current=t}catch(S){p(S)}finally{o(!1),v.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const k=i.useCallback(async S=>{d(!0),p(null);try{const M=await r.fillAppropriatenessTest(S);return F(M),M}catch(M){throw p(M),M}finally{d(!1)}},[r]);return{test:s,result:b,isLoading:a,isSubmitting:c,error:y,load:A,submit:k}}function Cr(t){const{overviewService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),b=i.useRef(!1),F=i.useRef(null),v=i.useCallback(async()=>{if(t){if(b.current){console.log("[Overview] Load already in progress, skipping...");return}b.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);n(A),F.current=t}catch(A){p(A)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&F.current!==t&&v()},[t]);const E=i.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{d(!1)}}},[t,r]);return{overview:s,isLoading:a,isSubmitting:c,error:y,load:v,passOverview:E}}function Nr(t){const{identityService:r}=Ne(),[s,n]=i.useState(null),[a,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(v,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v||"",ttl:E||604800};console.log("Identity request input:",A);const k=await r.identityRequest(A);return console.log("Identity request result:",k),n(k),k}catch(A){throw d(A),A}finally{o(!1),y.current=!1}}},[t,r]),b=i.useCallback(async(v,E)=>{if(t){o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:v,ttl:E},k=await r.identityCompanyRequest(A);return n(k),k}catch(A){throw d(A),A}finally{o(!1)}}},[t,r]),F=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const v={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",v);const E=await r.identityRequest(v);return console.log("Restart identity result:",E),n(E),E}catch(v){throw d(v),v}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:a,error:c,requestIdentity:p,requestCompanyIdentity:b,restartIdentity:F}}function Rr(t){const{riskScoringService:r,applicantService:s}=Ne(),[n,a]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,b]=i.useState(!1),[F,v]=i.useState(null),[E,A]=i.useState(null),k=i.useRef(!1),S=i.useRef(null),M=i.useCallback(async()=>{var L;if(t){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,y(!0),v(null);try{const[B,U]=await Promise.all([r.getRiskCriterias(t),s.getApplicantData(t).catch(()=>null)]);if(a(B),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const X=U.riskScoringResults[0],R={};for(const g of X.riskCriteriaResults??[])if(g.riskCriteriaId!=null&&g.answer!=null&&g.answer!==""){const O=[...new Set(g.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];O.length>0&&(R[g.riskCriteriaId]=O)}c(R)}S.current=t}catch(B){v(B)}finally{y(!1),k.current=!1}}},[t,r,s]);i.useEffect(()=>{t&&S.current!==t&&M()},[t]);const Y=i.useCallback(async L=>{b(!0),v(null);try{const B=await r.submitRiskScoring(L);return A(B),B}catch(B){throw v(B),B}finally{b(!1)}},[r]);return{criteria:n,initialAnswers:o,result:E,isLoading:d,isSubmitting:p,error:F,load:M,submit:Y}}function vt(){const{applicantService:t,config:r}=Ne(),[s,n]=i.useState(!1),[a,o]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,n(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(k){throw o(k),k}finally{n(!1),c.current=!1}},[t,r]),b=i.useCallback(async E=>{n(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]),F=i.useCallback(async E=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,n(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{n(!1),d.current=!1}},[t]),v=i.useCallback(async E=>{n(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{n(!1)}},[t]);return{isLoading:s,error:a,createApplicant:p,createCompanyApplicant:b,getApplicantData:F,stopProgress:v}}const is={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:s="md",isLoading:n=!1,disabled:a,className:o,style:c,...d})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"};return e.jsxs("button",{className:Se(y,p[s],o),style:{...is[r],...c},disabled:a||n,...d,children:[n&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ye=i.forwardRef(({label:t,error:r,helperText:s,leftIcon:n,rightIcon:a,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[n&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:n}),e.jsx("input",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",n?"pl-10":"",a?"pr-10":"",o),style:{backgroundColor:d.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:d.readOnly?"default":void 0,...c},...d}),a&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:a})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));ye.displayName="Input";const ee=({children:t,className:r,...s})=>e.jsx("div",{className:Se("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),ge=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-b",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),te=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4",r),...s,children:t}),be=({children:t,className:r,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-t",r),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),os={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},kt=({children:t,variant:r="default",className:s,style:n,...a})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",s),style:{...os[r],...n},...a,children:t}),Ee=({size:t="md",className:r,...s})=>{const n={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:Se("flex items-center justify-center",r),...s,children:e.jsxs("svg",{className:Se("animate-spin text-primary-500",n[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},mt=i.forwardRef(({label:t,error:r,helperText:s,options:n,placeholder:a,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...d,children:[a&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:a},"__placeholder__"),n.map((p,b)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${b}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]}));mt.displayName="Select";const St=280,Ir=({label:t,value:r,onChange:s,options:n,placeholder:a="Select...",disabled:o=!1,readOnly:c=!1,required:d=!1})=>{const y=o||c,[p,b]=i.useState(!1),[F,v]=i.useState(""),[E,A]=i.useState(null),[k,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),M=i.useRef(null),Y=i.useRef(null),L=i.useRef(null),B=i.useCallback(()=>{if(!Y.current)return null;const I=Y.current.getBoundingClientRect(),z=window.innerHeight-I.bottom<St&&I.top>St;return{top:z?I.top:I.bottom+4,left:I.left,width:I.width,openUp:z}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.documentElement),W=(_,me)=>I.getPropertyValue(_).trim()||me,z=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:z,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",z)})},[]),X=i.useCallback(()=>{if(y)return;U();const I=B();I&&A(I),b(!0)},[y,B,U]),R=i.useCallback(()=>{b(!1),v("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var _,me;const z=W.target;!((_=M.current)!=null&&_.contains(z))&&!((me=L.current)!=null&&me.contains(z))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=B();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,B]);const g=n.filter(I=>I.label.toLowerCase().includes(F.toLowerCase())),O=I=>{y||s(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||s(r.filter(z=>z!==I))},Q=I=>{var W;return((W=n.find(z=>z.value===I))==null?void 0:W.label)||I},{bg:$,borderColor:G,textPrimary:ne,textSecondary:V,primaryColor:he,primaryLight:le,hoverBg:de}=k,fe=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:F,onChange:I=>v(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:$,color:ne,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.documentElement),z=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ne,I.currentTarget.style.borderColor=z,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${z}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ne,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:g.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:V},children:"No results"}):g.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>O(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?le:"transparent",color:W?he:ne,userSelect:"none"},onMouseEnter:z=>{W||(z.currentTarget.style.backgroundColor=de)},onMouseLeave:z=>{W||(z.currentTarget.style.backgroundColor="transparent")},children:[e.jsx("input",{type:"checkbox",checked:W,readOnly:!0,style:{accentColor:he,pointerEvents:"none",flexShrink:0}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:M,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Y,onClick:()=>p?R():X(),className:Se("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:a}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},I))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p?"▲":"▼"})]}),typeof document<"u"&&fe?pt.createPortal(fe,document.body):null]})},Ct=260,Me=({label:t,error:r,helperText:s,options:n,placeholder:a="Select...",value:o,onChange:c,disabled:d=!1,readOnly:y=!1,required:p=!1,className:b})=>{var me;const F=d||y,[v,E]=i.useState(!1),[A,k]=i.useState(""),[S,M]=i.useState(null),[Y,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),B=i.useCallback(()=>{const N=getComputedStyle(document.documentElement),re=(ae,ve)=>N.getPropertyValue(ae).trim()||ve,ue=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:ue,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",ue)})},[]),U=i.useRef(null),X=i.useRef(null),R=i.useRef(null),g=i.useRef(null),O=i.useCallback(()=>{if(!X.current)return null;const N=X.current.getBoundingClientRect(),ue=window.innerHeight-N.bottom<Ct&&N.top>Ct;return{top:ue?N.top:N.bottom+4,left:N.left,width:N.width,openUp:ue}},[]),q=i.useCallback(()=>{if(F)return;B();const N=O();N&&M(N),E(!0)},[F,O,B]),Q=i.useCallback(()=>{E(!1),k("")},[]),$=()=>v?Q():q();i.useEffect(()=>{if(!v)return;const N=re=>{var ae,ve;const ue=re.target;!((ae=U.current)!=null&&ae.contains(ue))&&!((ve=R.current)!=null&&ve.contains(ue))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[v,Q]),i.useEffect(()=>{if(!v)return;const N=()=>{const re=O();re&&M(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[v,O]),i.useEffect(()=>{v&&g.current&&setTimeout(()=>{var N;return(N=g.current)==null?void 0:N.focus()},0)},[v]);const G=n.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),ne=(me=n.find(N=>N.value===o))==null?void 0:me.label,V=(N,re)=>{F||re||(c(N),Q())},{bg:he,border:le,text:de,textSecondary:fe,primary:I,primaryLight:W,hoverBg:z}=Y,_=v&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${le}`,backgroundColor:he,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${le}`},children:e.jsx("input",{ref:g,type:"text",value:A,onChange:N=>k(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${le}`,backgroundColor:he,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.documentElement),ue=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ue,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${ue}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=he,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=le,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:G.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:fe},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>V(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:ue=>{!re&&!N.disabled&&(ue.currentTarget.style.backgroundColor=z)},onMouseLeave:ue=>{re||(ue.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",b),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:X,role:"button",tabIndex:F?-1:0,onClick:$,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),$()),N.key==="Escape"&&Q()},className:Se("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",F?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:ne?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":v?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"42px",outline:v?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:ne||a}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v?"▲":"▼"})]}),typeof document<"u"&&_?pt.createPortal(_,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&s&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s})]})};Me.displayName="SearchableSelect";function ls(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Er=({label:t,subtitle:r,error:s,accept:n,multiple:a=!1,maxSize:o,required:c,onChange:d,value:y=[],className:p})=>{const[b,F]=i.useState(!1),[v,E]=i.useState(null),A=i.useRef(null),k=i.useCallback(R=>{if(!R)return;E(null);const g=Array.from(R);if(o&&g.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${ut(o)}`);return}d==null||d(a?[...y,...g]:[g[0]])},[o,a,d,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!0)},[]),M=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1)},[]),Y=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1),k(R.dataTransfer.files)},[k]),L=()=>{var R;(R=A.current)==null||R.click()},B=R=>{E(null);const g=y.filter((O,q)=>q!==R);d==null||d(g)},U=s||v,X=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:M,onDrop:Y,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:X?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:n,multiple:a,onChange:R=>{k(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:b?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(n||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[n&&e.jsx("span",{children:n}),n&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",ut(o)]})]})]})]})]}),X&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,g)=>{const O=ls(R),q=O==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):O==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:ut(R.size)})]}),e.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),B(g)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:$=>{$.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",$.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${g}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Ar=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:s,...n},a)=>e.jsxs("div",{className:"w-full",children:[n.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[n.label,n.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:a,type:"tel",className:Se("flex-1",s),...n,label:""})]}),n.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:n.error})]}));Ar.displayName="PhoneInput";/**
|
|
101
53
|
* @license lucide-react v0.574.0 - ISC
|
|
102
54
|
*
|
|
103
55
|
* This source code is licensed under the ISC license.
|
|
104
56
|
* See the LICENSE file in the root directory of this source tree.
|
|
105
|
-
*/const
|
|
57
|
+
*/const Fr=(...t)=>t.filter((r,s,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===s).join(" ").trim();/**
|
|
106
58
|
* @license lucide-react v0.574.0 - ISC
|
|
107
59
|
*
|
|
108
60
|
* This source code is licensed under the ISC license.
|
|
109
61
|
* See the LICENSE file in the root directory of this source tree.
|
|
110
|
-
*/const
|
|
62
|
+
*/const cs=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
111
63
|
* @license lucide-react v0.574.0 - ISC
|
|
112
64
|
*
|
|
113
65
|
* This source code is licensed under the ISC license.
|
|
114
66
|
* See the LICENSE file in the root directory of this source tree.
|
|
115
|
-
*/const
|
|
67
|
+
*/const ds=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,s,n)=>n?n.toUpperCase():s.toLowerCase());/**
|
|
116
68
|
* @license lucide-react v0.574.0 - ISC
|
|
117
69
|
*
|
|
118
70
|
* This source code is licensed under the ISC license.
|
|
119
71
|
* See the LICENSE file in the root directory of this source tree.
|
|
120
|
-
*/const
|
|
72
|
+
*/const Nt=t=>{const r=ds(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
|
|
121
73
|
* @license lucide-react v0.574.0 - ISC
|
|
122
74
|
*
|
|
123
75
|
* This source code is licensed under the ISC license.
|
|
124
76
|
* See the LICENSE file in the root directory of this source tree.
|
|
125
|
-
*/var
|
|
77
|
+
*/var us={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
126
78
|
* @license lucide-react v0.574.0 - ISC
|
|
127
79
|
*
|
|
128
80
|
* This source code is licensed under the ISC license.
|
|
129
81
|
* See the LICENSE file in the root directory of this source tree.
|
|
130
|
-
*/const
|
|
82
|
+
*/const ps=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
|
|
131
83
|
* @license lucide-react v0.574.0 - ISC
|
|
132
84
|
*
|
|
133
85
|
* This source code is licensed under the ISC license.
|
|
134
86
|
* See the LICENSE file in the root directory of this source tree.
|
|
135
|
-
*/const
|
|
87
|
+
*/const ms=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:s=2,absoluteStrokeWidth:n,className:a="",children:o,iconNode:c,...d},y)=>i.createElement("svg",{ref:y,...us,width:r,height:r,stroke:t,strokeWidth:n?Number(s)*24/Number(r):s,className:Fr("lucide",a),...!o&&!ps(d)&&{"aria-hidden":"true"},...d},[...c.map(([p,b])=>i.createElement(p,b)),...Array.isArray(o)?o:[o]]));/**
|
|
136
88
|
* @license lucide-react v0.574.0 - ISC
|
|
137
89
|
*
|
|
138
90
|
* This source code is licensed under the ISC license.
|
|
139
91
|
* See the LICENSE file in the root directory of this source tree.
|
|
140
|
-
*/const
|
|
92
|
+
*/const Tr=(t,r)=>{const s=i.forwardRef(({className:n,...a},o)=>i.createElement(ms,{ref:o,iconNode:r,className:Fr(`lucide-${cs(Nt(t))}`,`lucide-${t}`,n),...a}));return s.displayName=Nt(t),s};/**
|
|
141
93
|
* @license lucide-react v0.574.0 - ISC
|
|
142
94
|
*
|
|
143
95
|
* This source code is licensed under the ISC license.
|
|
144
96
|
* See the LICENSE file in the root directory of this source tree.
|
|
145
|
-
*/const
|
|
97
|
+
*/const ys=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Pr=Tr("chevron-left",ys);/**
|
|
146
98
|
* @license lucide-react v0.574.0 - ISC
|
|
147
99
|
*
|
|
148
100
|
* This source code is licensed under the ISC license.
|
|
149
101
|
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
-
*/const ys=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Pr=Fr("chevron-right",ys);function xs(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const n=Number(a);if(!isNaN(n)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function hs(t){const r=t.flatMap((a,n)=>(a.questions??[]).map((o,c)=>({question:o,groupIndex:n,qIdx:c}))),s=new Map;for(const a of r){const n=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(n)||s.set(n,[]),s.get(n).push(a)}return Array.from(s.entries()).sort(([a],[n])=>a-n).map(([,a])=>a)}const Lr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:n,isLoading:o,isSubmitting:c,error:u,submit:y}=jr(t),[p,b]=i.useState({}),[F,v]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(p).length===0&&b(n)},[n]);const k=i.useMemo(()=>a?hs(a.questionGroups):[],[a]),S=E===k.length-1,M=k[E]??[],Y=i.useCallback((R,g)=>{b(O=>({...O,[R]:g})),v(O=>{const q={...O};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:g}of M){const O=xs(g,p[g.id]??[]);O&&(R[g.id]=O)}return v(g=>({...g,...R})),Object.keys(R).length===0},[M,p]),_=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):s==null||s()},X=async()=>{if(!(!L()||!a))try{const R=a.questionGroups.flatMap(O=>(O.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),g={applicantId:t,questionnarieId:a.id,questionResults:R};await y(g),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):u?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",u.message]})})}):a?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((R,g)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:g===E?"20px":"6px",backgroundColor:g<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},g))})]})]}),e.jsx(te,{className:"space-y-6",children:M.map(({question:R})=>e.jsx(fs,{question:R,value:p[R.id]??[],error:F[R.id],onChange:g=>Y(R.id,g)},R.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Tr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:X,children:"Continue"}):e.jsxs(J,{type:"button",onClick:_,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Pr,{size:14})]})]}),u&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:u.message})})]}):null},fs=({question:t,value:r,error:s,onChange:a})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:u=>a([u.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(pt,{value:r[0]??"",onChange:u=>a([u.target.value]),options:(t.defaultAnswers??[]).map(u=>({value:u,label:u})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===u,onChange:()=>a([u]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(u),onChange:y=>{y.target.checked?a([...r,u]):a(r.filter(p=>p!==u))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})};function gs(t){const r=new Map;for(const s of t){const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push(s)}return Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}const Dr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:n,isSubmitting:o,error:c,submit:u}=wr(t),[y,p]=i.useState({}),[b,F]=i.useState(null),[v,E]=i.useState(0),[A,k]=i.useState({}),S=i.useMemo(()=>a?gs(a.uploadDocumentFiles):[],[a]),M=S[v]??[],Y=v===S.length-1,L=S.length,_=i.useCallback(()=>{const g={};for(const O of M)O.isRequired&&(y[O.id]||[]).length===0&&(g[O.id]=`${O.displayName} is required`);return k(g),Object.keys(g).length===0},[M,y]),U=()=>{_()&&(E(g=>g+1),k({}))},X=()=>{v>0?(E(g=>g-1),k({})):s==null||s()},R=async()=>{if(!(!_()||!a)){F(null);try{const g=await Promise.all(a.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],B=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await xr(G)})));return{uploadDocumentFileId:q.id,valueList:B}})),O={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:g};await u(O),r==null||r()}catch(g){F((g==null?void 0:g.message)||"Failed to submit documents. Please try again.")}}};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):a?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName||"Upload Documents"}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((g,O)=>e.jsx("div",{style:{height:"6px",width:O===v?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:O<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},O))})]})]}),a.description&&v===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:M.map(g=>e.jsx(Ir,{label:g.displayName,subtitle:g.subtitle,accept:g.allowedTypes,multiple:g.multipleFile,maxSize:g.maxEachFileSizeByte,required:g.isRequired,error:A[g.id],value:y[g.id]||[],onChange:O=>{F(null),k(q=>{const Q={...q};return delete Q[g.id],Q}),p(q=>({...q,[g.id]:O}))}},g.id))})}),b&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:X,children:v>0?"Previous":"Back"}),Y?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Mr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:n,isSubmitting:o,error:c,passOverview:u}=Sr(t),y=async()=>{await u(),r==null||r()};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):a?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.description})]}),e.jsx(te,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((p,b)=>p.order-b.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function bs(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function vs(t){return t.valueDataType===De.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function ks(t,r){const s=new Intl.NumberFormat(bs(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,a=>{const n=parseFloat(a);return isNaN(n)?a:s.format(n)})}function js(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===De.Integer||t.valueDataType===De.Money||t.valueDataType===De.DigitOnly;if(n&&a.trim()!==""){const o=Number(a);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!n&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function ws(t){const r=new Map;return t.forEach((s,a)=>{const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function Ss(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const Or=({applicantId:t,onComplete:r,onBack:s})=>{const{config:a}=Ne(),n=a.locale??"en",{criteria:o,initialAnswers:c,isLoading:u,isSubmitting:y,error:p,submit:b}=Nr(t),[F,v]=i.useState({}),[E,A]=i.useState({}),[k,S]=i.useState(0),[M,Y]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(F).length===0&&v(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?ws(o):[],[o]),_=k===L.length-1,U=L[k]??[];i.useEffect(()=>{!u&&o&&o.length===0&&!M&&!y&&(Y(!0),b({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[u,o,M,y,b,t,r]);const X=i.useCallback((Q,B)=>{v(G=>({...G,[Q]:B})),A(G=>{const ae={...G};return delete ae[Q],ae})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:B}of U){const G=js(B,F[B.id]??[]);G&&(Q[B.id]=G)}return A(B=>({...B,...Q})),Object.keys(Q).length===0},[U,F]),g=()=>{R()&&S(Q=>Q+1)},O=()=>{k>0?S(Q=>Q-1):s==null||s()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const ae=(F[G.id]??[]).filter(V=>V&&V.trim());return ae.length>0?{riskCriteriaId:G.id,values:ae}:null}).filter(G=>G!==null);await b({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return u?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!u&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",k+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,B)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:B===k?"20px":"6px",backgroundColor:B<=k?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},B))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Cs,{criterion:Q,value:F[Q.id]??[],error:E[Q.id],locale:n,onChange:B=>X(Q.id,B)},Q.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:O,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Tr,{size:14}),k>0?"Previous":"Back"]}),_?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:g,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Pr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Cs=({criterion:t,value:r,error:s,locale:a,onChange:n})=>{const o=Ss(t),c=t.valueDataType===De.Integer||t.valueDataType===De.Money||t.valueDataType===De.DigitOnly,u=vs(t),y=p=>u?ks(p,a):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>n([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===De.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>n([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:b=>{b.target.checked?n([...r,p]):n(r.filter(F=>F!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(pt,{value:r[0]??"",onChange:p=>n([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},zr=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=Ne(),[n,o]=i.useState(null),[c,u]=i.useState(!1),[y,p]=i.useState(null),b=async F=>{if(F.preventDefault(),n===null){p("Please select an investor type");return}u(!0),p(null);try{const v={applicantId:t,investorType:n};console.log("Submitting investor categorization:",v);const E=await a.setInvestorCategorization(v);console.log("Investor categorization result:",E),r==null||r()}catch(v){console.error("Error submitting investor categorization:",v),p(v.message||"Failed to submit investor categorization")}finally{u(!1)}};return e.jsx("form",{onSubmit:b,children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===je.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===je.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Individual,checked:n===je.Individual,onChange:()=>o(je.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===je.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===je.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Sophisticated,checked:n===je.Sophisticated,onChange:()=>o(je.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===je.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===je.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.HighNetWorth,checked:n===je.HighNetWorth,onChange:()=>o(je.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:n===null,children:"Submit"})]})]})})};function Nt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function mt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Br=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=Ne(),[n,o]=i.useState(null),[c,u]=i.useState(!0),[y,p]=i.useState(!1),[b,F]=i.useState(null),[v,E]=i.useState({}),[A,k]=i.useState(0),[S,M]=i.useState(!1),[Y,L]=i.useState(!1),[_,U]=i.useState(0),[X,R]=i.useState(0),[g,O]=i.useState(null);i.useEffect(()=>{(async()=>{try{u(!0),F(null);const z=await a.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const $=Nt(z.waitTimeSpanForNextTry);$>0&&U($)}}catch(z){F(z.message||"Failed to load appropriateness test")}finally{u(!1)}})()},[t,a]),i.useEffect(()=>{if(!S||A<=0)return;const z=setInterval(()=>{k($=>$<=1?(L(!0),0):$-1)},1e3);return()=>clearInterval(z)},[S,A]),i.useEffect(()=>{if(_<=0)return;const z=setInterval(()=>{U($=>$<=1?0:$-1)},1e3);return()=>clearInterval(z)},[_]),i.useEffect(()=>{Y&&!y&&G()},[Y]);const q=()=>{n&&(M(!0),k(n.testDurationSec),R(0),E({}),F(null))},Q=(z,$)=>{E(me=>({...me,[z]:$}))},B=i.useCallback(async()=>{try{const z=await a.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const $=Nt(z.waitTimeSpanForNextTry);$>0&&U($)}}catch{}},[t,a]),G=async z=>{if(n){if(!Y){const $=n.appropriatenessQuestions.length-Object.keys(v).length;if($>0){F(`Please answer all questions. ${$} remaining.`);return}}p(!0),F(null);try{const $=n.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:v[N.id]||""})),me={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:$};try{const N=await a.fillAppropriatenessTest(me);N.isSuccess?O({success:!0,message:N.message||"Congratulations! You have passed the test."}):(O({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>B(),1e3))}catch(N){if(N.code===400&&N.message)O({success:!1,message:N.message}),setTimeout(()=>B(),1500);else throw N}}catch($){F($.message||"Failed to submit test. Please try again."),ae()}finally{p(!1)}}},ae=()=>{M(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!n)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),b&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:b})]})})});const V=n.testAllowedMaxTry-n.totalFailedTries,he=n.appropriatenessQuestions.length,le=Object.keys(v).length;if(_>0)return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:mt(_)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),b&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]})})]});if(g){const z=()=>{O(null),ae(),F(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:g.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:g.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:g.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:g.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:g.message}),!g.success&&V>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:V})," attempt",V!==1?"s":""," remaining"]})}),!g.success&&V<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(be,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:g.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[V>0&&_<=0&&e.jsx(J,{type:"button",onClick:z,children:"Retake Test"}),V>0&&_>0&&e.jsx(J,{type:"button",onClick:z,children:"OK"}),V<=0&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle})]}),e.jsxs(te,{children:[n.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(lt,{icon:"questions",label:"Questions",value:String(n.totalQuestionCount)}),e.jsx(lt,{icon:"time",label:"Time Limit",value:mt(n.testDurationSec)}),e.jsx(lt,{icon:"target",label:"Pass Requirement",value:`${n.testCorrectAnswerPassLimit} correct`}),e.jsx(lt,{icon:"retry",label:"Attempts Left",value:String(V),variant:V<=1?"warning":"default"})]}),b&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",b]})]}),V<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:V<=0,children:"Start Test"})]})})]});const de=n.appropriatenessQuestions[X],fe=X===he-1,I=le===he,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",X+1," of ",he]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:mt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${le/he*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[le," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[V," attempt",V!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(Rs,{question:de,index:X,selectedAnswer:v[de.id],onSelect:z=>Q(de.id,z),disabled:y}),he>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:n.appropriatenessQuestions.map((z,$)=>e.jsx("button",{type:"button",onClick:()=>R($),style:{width:"28px",height:"28px",borderRadius:"8px",border:$===X?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:v[z.id]?$===X?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":$===X?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:v[z.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:$+1},z.id))}),Y&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),b&&!Y&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{X>0?R(z=>z-1):s==null||s()},disabled:y,children:X>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!fe&&e.jsx(J,{type:"button",onClick:()=>R(z=>z+1),children:"Next"}),(fe||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!Y,style:{opacity:I||Y?1:.5},children:Y?"Submitting...":"Submit Test"})]})]})})]})},Ns={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},lt=({icon:t,label:r,value:s,variant:a="default"})=>{const n=a==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:n?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:n?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:n?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Ns[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:n?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},Rs=({question:t,selectedAnswer:r,onSelect:s,disabled:a})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((n,o)=>{const c=r===n;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:a?"default":"pointer",transition:"all 0.15s ease",opacity:a?.6:1},onMouseEnter:u=>{!a&&!c&&(u.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:u=>{c||(u.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:n,checked:c,onChange:()=>s(n),disabled:a,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:n})]},o)})})]}),_r=({applicantId:t,onComplete:r,onBack:s})=>{var Qe,ze,Xe,We;const{applicantService:a,baseInformationService:n,identityService:o,config:c,currentTheme:u}=Ne(),{identityData:y,provider:p,token:b,isLoading:F,error:v,requestIdentity:E,restartIdentity:A}=Cr(t),[k,S]=i.useState(null),[M,Y]=i.useState(null),[L,_]=i.useState([]),[U,X]=i.useState([]),[R,g]=i.useState(!0),[O,q]=i.useState(!1),[Q,B]=i.useState(null),[G,ae]=i.useState(!1),V=i.useRef(!1),[he,le]=i.useState({}),[de,fe]=i.useState({}),I=u!=null&&u.reviewPageFields&&u.reviewPageFields.length>0?u.reviewPageFields[0]:null,W=!!(u!=null&&u.reviewPageDisabled),z=i.useRef(!1);z.current=W;const $=Ke.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){V.current||(V.current=!0,E().then(()=>q(!0)).catch(D=>console.error("[Identity] Auto-request failed:",D)).finally(()=>g(!1)));return}(async()=>{try{const[D,K,H]=await Promise.all([a.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);Y(D);const Z=new Set,m=K.map(h=>({value:h.abbreviation3||h.abbreviation,label:h.name})).filter(h=>!h.value||Z.has(h.value)?!1:(Z.add(h.value),!0));_(m);const C=new Set,T=H.filter(h=>h.countryCode).map(h=>({value:h.countryCode,label:`${h.countryCode} – ${h.name}`})).filter(h=>C.has(h.value)?!1:(C.add(h.value),!0));X(T);const d=D.applicantRequestData;if(le({firstName:(d==null?void 0:d.firstName)||"",lastName:(d==null?void 0:d.lastName)||"",email:(d==null?void 0:d.email)||"",dateOfBirth:(d==null?void 0:d.dateOfBirth)||"",title:(d==null?void 0:d.title)||"",salutation:(d==null?void 0:d.salutation)||"",phonenumber:(d==null?void 0:d.phonenumber)||"",mobileCountryCode:(d==null?void 0:d.mobileCountryCode)||"",street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",taxCountry:(d==null?void 0:d.taxCountry)||"",countryOfBirth:(d==null?void 0:d.countryOfBirth)||"",placeOfBirth:(d==null?void 0:d.placeOfBirth)||"",educationLevel:(d==null?void 0:d.educationLevel)||"",occupation:(d==null?void 0:d.occupation)||"",taxNumber:(d==null?void 0:d.taxNumber)||"",defaultLanguage:(d==null?void 0:d.defaultLanguage)||""}),$.reset({street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",phonenumber:(d==null?void 0:d.phonenumber)||""}),D.kycRecords&&D.kycRecords.length>0&&D.kycRecords[0].providerTokenObject!==null&&!V.current&&z.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),V.current=!0;try{await E(),q(!0)}catch(h){console.error("[Identity] Auto-request failed:",h)}}}catch(D){console.error("Error loading applicant data:",D)}finally{g(!1)}})()},[t]),i.useEffect(()=>{y&&!O&&z.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,O]),i.useEffect(()=>{if(b){if(b.expiresAt){const x=new Date(b.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),ae(!0),B("Your verification session has expired. Please restart.");return}}if(b.url)try{const D=new URL(b.url).toString().toLowerCase();if(D.includes("expired")||D.includes("invalid")||D.includes("error")){console.warn("[Identity] Token URL indicates expiration"),ae(!0),B("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(b.status==="expired"||b.error==="expired"||b.expired===!0){console.warn("[Identity] Token object indicates expiration"),ae(!0),B("Your verification session has expired. Please restart.");return}}},[b]);const me=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&b&&!k&&O&&!G){const x=p;if(me){console.log("[Sumsub] Fetching access token for Web SDK…"),B(null),(async()=>{try{const D=await o.refreshSumsubToken(t),K=_e.parseProviderConfig(p,b,c);K.accessToken=D,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=_e.createProvider(p,K);H.onComplete(Z=>{console.log("[Sumsub] Verification complete:",Z),r==null||r()}),H.onError(Z=>{console.error("[Sumsub] SDK error:",Z),(typeof Z=="string"?Z:(Z==null?void 0:Z.message)||"Unknown error").toLowerCase().includes("expired")&&(ae(!0),B("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(D){console.error("[Sumsub] Initialization error:",D),B(`Failed to initialize: ${D.message||D}`),String(D.message||D).toLowerCase().includes("expired")&&ae(!0)}})();return}if(b.url){console.log("[Identity] Loading provider URL for user verification:",b.url),B(null);try{if(new URL(b.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const D=_e.parseProviderConfig(p,b,c);_e.createProvider(p,D).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(D){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",D)}}S({type:"url",url:b.url})}catch(D){console.error("[Identity] Invalid URL:",D),B("Invalid verification URL. Please restart."),ae(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),B(null);try{const D=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,D);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var m;console.error("[SardinAI] Failed to initialize:",H);const Z=((m=H.message)==null?void 0:m.toLowerCase())||"";Z.includes("expired")||Z.includes("invalid")||Z.includes("401")||Z.includes("400")?(ae(!0),B("Session expired or invalid. Please restart verification.")):B(`Failed to initialize: ${H.message}`)})}catch(D){console.error("[SardinAI] Error creating provider:",D),B(`Configuration error: ${D.message}`)}return}try{B(null);const D=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,D);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),B(`Failed to initialize: ${H.message}`)}),S(K)}catch(D){console.error("[Identity] Provider setup error:",D),B(`Setup error: ${D.message}`)}}return()=>{if(k&&k.destroy)try{k.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,b,k,O,r,G,me,t,c,o]);const N=async()=>{try{B(null),ae(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{B(null),ae(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),B(x.message||"Failed to restart verification")}};if(R||F)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(O&&(Q||G))return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:F,children:F?"Restarting...":"Restart Verification"})]})]});if(O&&y){const x=p;return me?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:F,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:F?"not-allowed":"pointer",opacity:F?.5:1},children:F?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),s&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):b!=null&&b.url?e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:F,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:b.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:D=>{var K,H,Z;console.log("[Identity] Iframe loaded");try{const m=D.target,C=m.contentDocument||((K=m.contentWindow)==null?void 0:K.document);if(C){const T=((Z=(H=C.body)==null?void 0:H.textContent)==null?void 0:Z.toLowerCase())||"";(T.includes("expired")||T.includes("invalid")||T.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),ae(!0),B("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]})}const ue=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ne=(x=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[x]||"col-span-4",ve=(x,D)=>{if(!D&&D!==0)return"—";if(ue.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===D);return K?K.label:String(D)}return String(D)},Te=({helpText:x})=>{const[D,K]=i.useState(!1),H=i.useRef(null),[,Z]=i.useState({top:0,left:0}),m=()=>{if(H.current){const C=H.current.getBoundingClientRect();Z({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:m,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),D&&ut.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ke=(x,D)=>D?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Te,{helpText:D})})]}):x,Oe=(x,D)=>{const K=`cf-${D}`,H=x.paramName??"",Z=de[H];if(x.customType==="br")return e.jsx("div",{className:ne(x.colSpan),style:{minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{className:ne(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{className:ne(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{className:ne(x.colSpan),children:ke(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const m=Z==="true"||Z===!0;return e.jsx("div",{className:ne(x.colSpan),children:ke(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:C=>fe(T=>({...T,[H]:String(C.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const m=Array.isArray(Z)?Z:Z?[Z]:[],C=T=>{x.singleSelect?fe(d=>({...d,[H]:m[0]===T?[]:[T]})):fe(d=>({...d,[H]:m.includes(T)?m.filter(l=>l!==T):[...m,T]}))};return e.jsx("div",{className:ne(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(T=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.includes(T.value),onChange:()=>C(T.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:T.label})]},T.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{className:ne(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(m=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:m.value,checked:Z===m.value,onChange:()=>fe(C=>({...C,[H]:m.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.label})]},m.value))]}),x.helpText)},K):e.jsx("div",{className:ne(x.colSpan),children:ke(e.jsx(ye,{label:x.displayText||x.label||H,value:String(Z??""),onChange:m=>fe(C=>({...C,[H]:m.target.value}))}),x.helpText)},K)},Ze=(x,D)=>{if(x.isCustom)return Oe(x,D);const K=x.name??"",H=Ye[K],Z=x.displayText||(H==null?void 0:H.label)||K,m=he[K]??"",C=K==="mobileCountryCode",T=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{className:ne(x.colSpan??2),children:ke(e.jsx(Me,{label:Z,value:String(m),onChange:d=>le(l=>({...l,[K]:d})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${D}`):T?e.jsx("div",{className:ne(x.colSpan??2),children:ke(e.jsx(Me,{label:Z,value:String(m),onChange:d=>le(l=>({...l,[K]:d})),options:[{value:"",label:`Select ${Z.toLowerCase()}…`},...L]}),x.helpText)},`ec-${D}`):e.jsx("div",{className:ne(x.colSpan??2),children:ke(e.jsx(ye,{label:Z,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(m),onChange:d=>le(l=>({...l,[K]:d.target.value}))}),x.helpText)},`ei-${D}`):e.jsx("div",{className:ne(x.colSpan??2),children:ke(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Z}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ve(K,m)})]}),x.helpText)},`ro-${D}`)};if(I){const x=I.title||"Review Your Information",D=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:D})]}),e.jsx(te,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:I.fields.map((K,H)=>Ze(K,H))})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:$.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Qe=M==null?void 0:M.applicantRequestData)==null?void 0:Qe.firstName)||""} ${((ze=M==null?void 0:M.applicantRequestData)==null?void 0:ze.lastName)||""}`.trim()},{label:"Email",value:(Xe=M==null?void 0:M.applicantRequestData)==null?void 0:Xe.email},{label:"Date of Birth",value:((We=M==null?void 0:M.applicantRequestData)==null?void 0:We.dateOfBirth)||"Not provided"}].map(({label:x,value:D})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:D})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ke.Controller,{control:$.control,name:"country",render:({field:x})=>e.jsx(Me,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(Ke.Controller,{control:$.control,name:"nationality",render:({field:x})=>e.jsx(Me,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ke.Controller,{control:$.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(Ke.Controller,{control:$.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ke.Controller,{control:$.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(Ke.Controller,{control:$.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(Ke.Controller,{control:$.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})},ht=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:o})=>{const u=t===qe.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===qe.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===qe.Pending||t===qe.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Ve.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Ve.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Ve.UnderReview||r===Ve.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===it.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===it.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===it.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${u.iconBg}`,children:e.jsx("span",{className:`text-5xl ${u.iconColor}`,children:u.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(vt,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?qe[t]:Ve[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a||u.message}),u.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),u.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),u.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?qe[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Ve[r]})]})]})})]}),e.jsxs(be,{className:"flex justify-center gap-4",children:[u.type==="success"&&n&&e.jsx(J,{onClick:n,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),n&&e.jsx(J,{onClick:n,children:"Try Again"})]}),u.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},$r=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),st=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=Ne(),n=t||(a==null?void 0:a.title)||"",o=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),c=!!n;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx($r,{config:a.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},ct=["firstName","lastName","email","phonenumber","dateOfBirth"];function et(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const nt={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},Rt=({helpText:t,children:r})=>{const[s,a]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>a(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>a(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?ut.createPortal(n,document.body):null]})},Is=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var K,H,Z,m,C,T,d;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:u,isLoading:y}=bt(),p=t||((K=n.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((H=n.applicantForm)==null?void 0:H.externalRefId)||"",F=((Z=n.applicantForm)==null?void 0:Z.email)||"",v=((m=n.applicantForm)==null?void 0:m.hiddenValues)||{},E=((C=n.applicantForm)==null?void 0:C.initialValues)||{},k=(((T=n.applicantForm)==null?void 0:T.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),M=i.useMemo(()=>{const l=new Set(ct),h=c==null?void 0:c.applicantFormRequiredFields;if(h)for(const P of h)l.add(P);if(S)for(const P of S)for(const f of P.fields)!f.isCustom&&f.name&&f.required&&l.add(f.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),Y=i.useMemo(()=>{var P;if(S){const f=S.flatMap(j=>j.fields).filter(j=>!j.isCustom&&j.name).map(j=>j.name),w=new Set(f);for(const j of ct)w.add(j);return Array.from(w)}let l;(P=n.applicantForm)!=null&&P.visibleFields?l=n.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=$t;const h=new Set(l);for(const f of ct)h.add(f);return Array.from(h)},[(d=n.applicantForm)==null?void 0:d.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),_=i.useMemo(()=>{var h,P;const l=new Set;if(S)for(const f of S)for(const w of f.fields)!w.isCustom&&w.name&&L.has(w.name)&&l.add(w.countriesType??((h=Ye[w.name])==null?void 0:h.countriesType));else for(const f of Y)L.has(f)&&l.add((P=Ye[f])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[Y,S]),[U,X]=i.useState({}),[R,g]=i.useState(!0),O=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=_.filter(f=>{const w=f!=null?String(f):"all";return!q.current.has(w)&&!O.current.has(w)});if(l.length===0){_.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&g(!1);return}g(!0);const h=l.map(f=>f!=null?String(f):"all");h.forEach(f=>O.current.add(f)),(async()=>{try{const f=await Promise.all(l.map(async w=>{const j=w!=null?String(w):"all",ce=await o.getCountries("",n.locale||"en",w),se=w===40,xe=new Set,Ie=ce.map(ie=>se&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(j),O.current.delete(j),[j,Ie]}));X(w=>({...w,...Object.fromEntries(f)}))}catch(f){h.forEach(w=>O.current.delete(w)),console.error("Failed to load countries:",f)}finally{_.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&g(!1)}})()},[_,c]);const Q=(l,h)=>{var w;const P=h??((w=Ye[l])==null?void 0:w.countriesType),f=P!=null?String(P):"all";return U[f]||[]},B={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(v).filter(([l])=>l in B)),ae=Object.fromEntries(Object.entries(E).filter(([l])=>l in B)),[V,he]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:F,dateOfBirth:"",phonenumber:"",externalRefId:b,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...ae}),le=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,fe]=i.useState({...le}),[I,W]=i.useState(0),[z,$]=i.useState({}),[me,N]=i.useState(null),[re,ue]=i.useState(!1),ne=(l,h)=>he(P=>({...P,[l]:h})),ve=(l,h)=>fe(P=>({...P,[l]:h})),Te=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ke=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,Ze=l=>{var P;const h={};for(const f of l.fields)if(f.isCustom){if(f.customType==="paragraph"||f.customType==="html"||f.customType==="br"||f.customType==="link")continue;if(f.required&&f.paramName){const w=de[f.paramName],j=f.displayText||f.label||f.paramName;f.customType==="checkbox"||f.customType==="link_checkbox"?w!=="true"&&(h[f.paramName]=`${j} is required.`):(!w||w.trim()==="")&&(h[f.paramName]=`${j} is required.`)}}else if(f.name){const w=f.name;if(M.includes(w)&&et(V[w])){const j=f.displayText||((P=Ye[w])==null?void 0:P.label)||w;h[w]=`${j} is required.`}}return h},Qe=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Te(l)){$({}),ke>=0?W(ke):await ze();return}const h=Ze(l);if(Object.keys(h).length>0){$(h);return}$({}),ke>=0?W(ke):await ze()},ze=async()=>{if(S){let l={};for(const h of S)Te(h)&&(l={...l,...Ze(h)});if(Object.keys(l).length>0){$(l);return}}ue(!0),N(null);try{if(!V.externalRefId||V.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:V.workflowKey,externalRefId:V.externalRefId.trim()};if(S){for(const w of S)if(Te(w)){for(const j of w.fields)if(!j.isCustom&&j.name){const ce=j.name,se=V[ce];et(se)||(l[ce]=se)}}for(const w of ct)if(l[w]===void 0){const j=V[w];et(j)||(l[w]=j)}}else Y.forEach(w=>{if(w==="externalRefId")return;const j=V[w];et(j)||(l[w]=j)});const h=[];if(S){for(const w of S)if(Te(w))for(const j of w.fields){if(!j.isCustom||!j.paramName||j.customType==="paragraph"||j.customType==="html"||j.customType==="br"||j.customType==="link")continue;const ce=de[j.paramName]??"";let se;if(j.customType==="checkbox"||j.customType==="link_checkbox")se=ce==="true"?"yes":"no";else if(se=ce,!se&&!j.required)continue;h.push({paramName:j.paramName,value:se})}}for(const[w,j]of Object.entries(G))l[w]===void 0&&!et(j)&&(l[w]=j);const P=new Set(h.map(w=>w.paramName));for(const[w,j]of Object.entries(le))!P.has(w)&&j&&h.push({paramName:w,value:j});h.length>0&&(l.applicantAdditionalDatas=h);const f=await u(l);s(f.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{ue(!1)}},Xe=async l=>{var h;l.preventDefault();for(const P of M)if(et(V[P])){const f=((h=Ye[P])==null?void 0:h.label)||P;N(`${f} is required.`);return}await ze()},We=(l,h,P,f,w)=>{var kt;const j=Ye[l];if(!j)return null;const ce=M.includes(l),se=z[l],xe=P||j.label,Ie=l in ae,ie=h??l,Pe={required:ce},Be=w?w!=="placeholder":k,Ue=Be?xe:void 0,Hr=Be?"...":xe;switch(j.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,f);return e.jsx(Me,{...Pe,label:Ue,value:V[l]||"",onChange:Ge=>ne(l,Ge),options:[{value:"",label:`Select ${Hr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:se},ie)}if(l==="salutation")return e.jsx(Me,{...Pe,label:Ue,value:((kt=V[l])==null?void 0:kt.toString())||"",onChange:Ce=>ne(l,Ce?Number(Ce):null),options:[{value:"",label:Be?"Select salutation...":xe},{value:ot.Male.toString(),label:"Male"},{value:ot.Female.toString(),label:"Female"},{value:ot.Other.toString(),label:"Other"}],readOnly:Ie,error:se},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?xt.filter(Ge=>c.allowedLanguages.includes(Ge.value)):xt;return e.jsx(Me,{...Pe,label:Ue,value:V[l]||"",onChange:Ge=>ne(l,Ge),options:[{value:"",label:Be?"Select language...":xe},...Ce],readOnly:Ie,error:se},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,f);return e.jsx(Rr,{...Pe,label:Ue,value:V[l]||[],onChange:Ge=>ne(l,Ge),options:Ce,placeholder:Be?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Pe,type:"date",label:Ue,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:se},ie);case"email":return e.jsx(ye,{...Pe,type:"email",label:Ue,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:se},ie);case"tel":return e.jsx(ye,{...Pe,type:"tel",label:Ue,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:se},ie);default:return e.jsx(ye,{...Pe,type:"text",label:Ue,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>ne(l,Ce.target.value),readOnly:Ie,error:se},ie)}},x=(l,h)=>{const P=l.labelMode?l.labelMode!=="placeholder":k;if(l.customType==="paragraph"){const j=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:j}},`custom-${h}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${h}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${h}`);if(l.customType==="link"){const j=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[j,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${h}`)}if(!l.paramName)return null;const f=z[l.paramName],w=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:nt}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),f&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:f})]},`custom-${h}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:{...nt,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:j=>j.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),f&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:f})]},`custom-${h}`);if(l.customType==="group_checkbox"){const j=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(ce=>{const se=l.singleSelect?de[l.paramName]===ce.value:j.includes(ce.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:se,onChange:xe=>{if(l.singleSelect)ve(l.paramName,xe.target.checked?ce.value:"");else{const Ie=xe.target.checked?[...j,ce.value]:j.filter(ie=>ie!==ce.value);ve(l.paramName,Ie.join(","))}},className:"metakyc-option-input",style:nt}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:ce.label})]},ce.value)})}),f&&e.jsx("p",{className:"text-red-500 text-xs",children:f})]},`custom-${h}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(j=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===j.value,onChange:()=>ve(l.paramName,j.value),name:`radio-group-${l.paramName}-${h}`,className:"metakyc-option-input",style:nt}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:j.label})]},j.value))}),f&&e.jsx("p",{className:"text-red-500 text-xs",children:f})]},`custom-${h}`):e.jsx(ye,{type:"text",label:P?`${w}${l.required?" *":""}`:void 0,placeholder:P?void 0:w,value:de[l.paramName]||"",onChange:j=>ve(l.paramName,j.target.value),required:l.required,error:f},`custom-${h}`)},D=(l,h)=>{const P=Te(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(Rt,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:f=>ve(l.conditionalOn,f.target.checked?"true":"false"),className:"metakyc-option-input",style:nt}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:l.fields.map((f,w)=>{const j=f.colSpan===1?"col-span-1":f.colSpan===2?"col-span-2":f.colSpan===3?"col-span-3":"col-span-4",ce=f.isCustom?`custom-${w}-${f.paramName}`:`builtin-${f.name}-${w}`;return e.jsx("div",{className:j,children:e.jsx(Rt,{helpText:f.helpText,children:f.isCustom?x(f,w):We(f.name,ce,f.displayText,f.countriesType,f.labelMode)})},ce)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],h=Oe===-1,P=ke===-1,f=S.length,w=Te(l),j=Object.values(z);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(st,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||j.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),j.map((ce,se)=>e.jsx("p",{className:"text-red-600 text-sm",children:ce},se))]}),f>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[S.map((ce,se)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${se===I?"flex-1":"w-8"}`,style:se===I?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:se<I?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},se)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[I+1," / ",f]})]}),D(l)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!h&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),$({})},disabled:re||y,children:"Previous"}),h&&a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?ze:Qe,children:P?l.conditionalOn&&!w?"Skip & Submit":"Submit":l.conditionalOn&&!w?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Xe,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(st,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[me&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:Y.map(l=>e.jsx("div",{className:"col-span-4",children:We(l)},l))})]}),e.jsxs(be,{className:"flex justify-between",children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},It=["companyName","email"];function yt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Es=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var We,x,D,K,H,Z;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:u,isLoading:y}=bt(),p=t||((We=n.applicantForm)==null?void 0:We.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((x=n.applicantForm)==null?void 0:x.externalRefId)||"",F=((D=n.applicantForm)==null?void 0:D.email)||"",v=((K=n.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=n.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",k=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const m=new Set(It),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const T of C)m.add(T);if(k)for(const T of k)for(const d of T.fields)!d.isCustom&&d.name&&d.required&&m.add(d.name);return Array.from(m)},[c==null?void 0:c.companyFormRequiredFields,k]),M=i.useMemo(()=>{var m;if(k){const C=k.flatMap(d=>d.fields).filter(d=>!d.isCustom&&d.name).map(d=>d.name),T=new Set(C);for(const d of It)T.add(d);return Array.from(T)}return(m=n.applicantForm)!=null&&m.visibleFields?n.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:_t},[(Z=n.applicantForm)==null?void 0:Z.visibleFields,c==null?void 0:c.companyFormVisibleFields,k]),Y=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,T;const m=new Set;if(k)for(const d of k)for(const l of d.fields)!l.isCustom&&l.name&&Y.has(l.name)&&m.add(l.countriesType??((C=Je[l.name])==null?void 0:C.countriesType));else for(const d of M)Y.has(d)&&m.add((T=Je[d])==null?void 0:T.countriesType);return m.size===0&&m.add(void 0),Array.from(m)},[M,k]),[_,U]=i.useState({}),[X,R]=i.useState(!0),g=i.useRef(new Set),O=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const m=L.filter(d=>{const l=d!=null?String(d):"all";return!O.current.has(l)&&!g.current.has(l)});if(m.length===0){L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=m.map(d=>d!=null?String(d):"all");C.forEach(d=>g.current.add(d)),(async()=>{try{const d=await Promise.all(m.map(async l=>{const h=l!=null?String(l):"all",P=await o.getCountries("",n.locale||"en",l),f=new Set,w=P.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||f.has(j.value)?!1:(f.add(j.value),!0));return O.current.add(h),g.current.delete(h),[h,w]}));U(l=>({...l,...Object.fromEntries(d)}))}catch(d){C.forEach(l=>g.current.delete(l)),console.error("Failed to load countries:",d)}finally{L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(m,C)=>{var l;const T=C??((l=Je[m])==null?void 0:l.countriesType),d=T!=null?String(T):"all";return _[d]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},B=Object.fromEntries(Object.entries(v).filter(([m])=>m in Q)),[G,ae]=i.useState({workflowKey:p,companyName:"",email:F,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:b,...B}),[V,he]=i.useState({}),[le,de]=i.useState(0),[fe,I]=i.useState({}),[W,z]=i.useState(null),[$,me]=i.useState(!1),N=(m,C)=>ae(T=>({...T,[m]:C})),re=(m,C)=>he(T=>({...T,[m]:C})),ue=m=>!m.conditionalOn||V[m.conditionalOn]==="true",ne=k&&le<k.length-1?le+1:-1,ve=k&&le>0?le-1:-1,Te=m=>{var T;const C={};for(const d of m.fields)if(d.isCustom){if(d.customType==="paragraph"||d.customType==="html"||d.customType==="br"||d.customType==="link")continue;if(d.required&&d.paramName){const l=V[d.paramName],h=d.displayText||d.label||d.paramName;d.customType==="checkbox"||d.customType==="link_checkbox"?l!=="true"&&(C[d.paramName]=`${h} is required.`):(!l||l.trim()==="")&&(C[d.paramName]=`${h} is required.`)}}else if(d.name){const l=d.name;if(S.includes(l)&&yt(G[l])){const h=d.displayText||((T=Je[l])==null?void 0:T.label)||l;C[l]=`${h} is required.`}}return C},ke=async()=>{if(!k)return;const m=k[le];if(m.conditionalOn&&!ue(m)){I({}),ne>=0?de(ne):await Oe();return}const C=Te(m);if(Object.keys(C).length>0){I(C);return}I({}),ne>=0?de(ne):await Oe()},Oe=async()=>{var m;if(k){let C={};for(const T of k)ue(T)&&(C={...C,...Te(T)});if(Object.keys(C).length>0){I(C);return}}me(!0),z(null);try{const C={workflowKey:G.workflowKey,externalRefId:((m=G.externalRefId)==null?void 0:m.trim())||void 0},T=k?k.filter(h=>ue(h)).flatMap(h=>h.fields).filter(h=>!h.isCustom&&h.name).map(h=>h.name):M;for(const h of T){const P=G[h];if(!yt(P))switch(h){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[h]=P;break}}const d=[];if(k){for(const h of k)if(ue(h))for(const P of h.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const f=V[P.paramName]??"";let w;if(P.customType==="checkbox"||P.customType==="link_checkbox")w=f==="true"?"yes":"no";else if(w=f,!w&&!P.required)continue;d.push({paramName:P.paramName,value:w})}}d.length>0&&(C.applicantAdditionalDatas=d);const l=await u(C);s(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),z(C.message||"Failed to create company applicant")}finally{me(!1)}},Ze=async m=>{var C;m.preventDefault();for(const T of S)if(yt(G[T])){const d=((C=Je[T])==null?void 0:C.label)||T;z(`${d} is required.`);return}await Oe()},Qe=(m,C,T,d,l)=>{const h=Je[m];if(!h)return null;const P=S.includes(m),f=fe[m],w=T||h.label,j=m in B,ce=C??m,se=l?l!=="placeholder":A,xe=se?w:void 0,Ie=se?"...":w;switch(h.type){case"select":if(m==="countryResidence"||m==="addressCountry"){const ie=q(m,d);return e.jsx(Me,{required:P,label:xe,value:G[m]||"",onChange:Pe=>N(m,Pe),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:X,readOnly:j,error:f},ce)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce)}},ze=(m,C)=>{if(m.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m.displayText||m.label||""}},`custom-${C}`);if(m.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:m.label||""}},`custom-${C}`);if(m.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(m.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:m.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:m.displayText||m.label||m.linkText||m.linkUrl||""})},`custom-${C}`);if(!m.paramName)return null;const T=fe[m.paramName],d=m.displayText||m.label||m.paramName,l=m.labelMode?m.labelMode!=="placeholder":A;return m.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:V[m.paramName]==="true",onChange:h=>re(m.paramName,h.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[d,m.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),T&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:T})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${d}${m.required?" *":""}`:void 0,placeholder:l?void 0:d,value:V[m.paramName]||"",onChange:h=>re(m.paramName,h.target.value),required:m.required,error:T},`custom-${C}`)},Xe=m=>{const C=ue(m);return e.jsxs("div",{className:"space-y-4",children:[m.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:C,onChange:T=>re(m.conditionalOn,T.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:m.conditionalOn})]}),C&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:m.fields.map((T,d)=>{const l=T.colSpan===1?"col-span-1":T.colSpan===2?"col-span-2":T.colSpan===3?"col-span-3":"col-span-4",h=T.isCustom?`custom-${d}-${T.paramName}`:`builtin-${T.name}-${d}`;return e.jsx("div",{className:l,children:T.isCustom?ze(T,d):Qe(T.name,h,T.displayText,T.countriesType,T.labelMode)},h)})})]})};if(!c||X)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(k){const m=k[le]??k[0],C=ve===-1,T=ne===-1,d=k.length,l=ue(m),h=Object.values(fe);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(st,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(m.title||m.subtitle)&&e.jsxs("div",{className:"mb-4",children:[m.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.subtitle})]}),(W||h.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),h.map((P,f)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},f))]}),d>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[k.map((P,f)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${f===le?"flex-1":"w-8"}`,style:f===le?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:f<le?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},f)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[le+1," / ",d]})]}),Xe(m)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(ve),I({})},disabled:$||y,children:"Previous"}),C&&a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,disabled:$||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:$||y,onClick:T?Oe:ke,children:T?m.conditionalOn&&!l?"Skip & Submit":"Submit":m.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Ze,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(st,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:M.map(m=>e.jsx("div",{className:"col-span-4",children:Qe(m)},m))})]}),e.jsxs(be,{className:"flex justify-between",children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,disabled:$||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:$||y,children:"Register Company"})]})]})})})},As=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:o,currentStep:c,steps:u,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:b,isLoading:F,error:v,moveBack:E,refreshProgress:A}=kr(t),[k,S]=i.useState(!1),M=i.useRef(null);if(i.useEffect(()=>{v&&s&&s(v)},[v,s]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),i.useEffect(()=>{b&&S(!1)},[b]),F||!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v.message})]})})})});if(b&&!k)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Fe.Finished||o.status===Fe.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ht,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Fe.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const Y=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=u.filter(q=>q.visibility!==!1),X=U.findIndex(q=>q.order===c.order),R=X>=0?X+1:1,g=U.length,O=g>1?X/(g-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(st,{}),e.jsxs(vt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",g]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${O}%`,transition:"width 0.4s ease"}})})}),e.jsx(Fs,{ref:M,visibleSteps:U,currentVisibleStepIndex:X,getStepFallbackName:Y})]})},_=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Lr,{...U});case oe.UploadDocument:return e.jsx(Dr,{...U});case oe.Overview:return e.jsx(Mr,{...U});case oe.IdentitySdk:return e.jsx(_r,{...U});case oe.RiskScoring:return e.jsx(Or,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx(zr,{...U});case oe.AppropriatenessTest:return e.jsx(Br,{...U});case oe.ManualReview:return e.jsx(ht,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[L(),_()]})},Fs=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},a)=>{const n=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(a,()=>n.current),i.useEffect(()=>{if(o.current&&n.current){const c=n.current,u=o.current,y=u.offsetLeft-c.offsetWidth/2+u.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:n,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,u)=>{const y=u<r,p=u===r,b=y||p,F=c.displayName||c.name||s(c.action)||`Step ${u+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...b?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):u+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:F})]}),u<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Ts(t){return He.z.object({questionResults:He.z.any()}).passthrough()}function Ps(t){let r=He.z.array(He.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(a=>a.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(a=>a.trim());r=r.refine(a=>a?a.every(n=>s.some(o=>o.endsWith("/*")?n.type.startsWith(o.slice(0,-2)):n.type===o)):!0,{message:"Invalid file type"})}return r}function Ls(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=Ps(s)}),He.z.object(r)}function Ds(t){return He.z.any()}function Ms(t){return He.z.string().min(1,"This question is required")}function Os(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=Ms()}),He.z.object(r)}const zs=He.z.any();exports.ALLOWED_LANGUAGES=xt;exports.ApplicantProgressOnHoldReason=Et;exports.ApplicantProgressStatus=Fe;exports.ApplicantService=Kt;exports.ApplicantStatus=Ft;exports.AppropriatenessQuestionType=Mt;exports.AppropriatenessTestService=Yt;exports.AppropriatenessTestStep=Br;exports.Badge=vt;exports.BaseInformationService=Zt;exports.Button=J;exports.COMPANY_FIELD_METADATA=Je;exports.Card=ee;exports.CardContent=te;exports.CardFooter=be;exports.CardHeader=ge;exports.CountriesType=$e;exports.CreateApplicantForm=Is;exports.CreateCompanyApplicantForm=Es;exports.CriteriaBuiltInType=zt;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=_t;exports.DEFAULT_VISIBLE_FIELDS=$t;exports.DocumentReviewStatus=Dt;exports.EndpointBuilder=Wt;exports.ErrorHandler=tt;exports.EventEmitter=or;exports.FIELD_METADATA=Ye;exports.FileType=Lt;exports.FileUpload=Ir;exports.GenderType=ot;exports.Header=st;exports.HttpClient=Ut;exports.IdentityProviderManager=_e;exports.IdentityService=Jt;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=_r;exports.Input=ye;exports.InvestorCategorizationService=Xt;exports.InvestorCategorizationStep=zr;exports.InvestorCategorizationType=je;exports.InvestorCategoryType=Bt;exports.KycProcessStatus=Tt;exports.KycStatus=qe;exports.KycStatusDisplay=ht;exports.KycWorkflow=As;exports.Logo=$r;exports.MetaKYCContext=gt;exports.MetaKYCError=Le;exports.MetaKYCProvider=Zr;exports.MultiSelect=Rr;exports.OnfidoProvider=pr;exports.OverviewService=Qt;exports.OverviewStep=Mr;exports.PhoneInput=Er;exports.QuestionnaireService=qt;exports.QuestionnaireStep=Lr;exports.ReviewStatus=Ve;exports.RiskCriteriaType=Ot;exports.RiskLevel=At;exports.RiskScoringService=Gt;exports.RiskScoringStep=Or;exports.SardinAIProvider=mr;exports.SearchableSelect=Me;exports.Select=pt;exports.Spinner=Ee;exports.StepRouter=cr;exports.SumsubProvider=ur;exports.ThemeManager=yr;exports.ThemePreset=we;exports.ThemeService=ir;exports.UploadDocumentService=Vt;exports.UploadDocumentStep=Dr;exports.UserType=Pt;exports.ValueDataType=De;exports.WorkflowOrchestrator=dr;exports.WorkflowResultType=it;exports.WorkflowState=lr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=zs;exports.clearAllStorage=ss;exports.clearApplicantId=gr;exports.clearWorkflowState=vr;exports.cn=Se;exports.corporateTheme=er;exports.defaultConfig=Ht;exports.defaultTheme=Re;exports.fileToBase64=xr;exports.fintechTheme=tr;exports.formatFileSize=dt;exports.generateAppropriatenessSchema=Os;exports.generateQuestionnaireSchema=Ts;exports.generateRiskScoringSchema=Ds;exports.generateUploadDocumentSchema=Ls;exports.getAcceptString=ts;exports.getApplicantId=fr;exports.getThemePreset=rt;exports.getWorkflowState=rs;exports.healthcareTheme=rr;exports.isScriptLoaded=Vr;exports.loadScript=ft;exports.minimalTheme=ar;exports.modernTheme=sr;exports.removeScript=Yr;exports.saveApplicantId=hr;exports.saveWorkflowState=br;exports.themePresets=nr;exports.useApplicant=bt;exports.useAppropriatenessTest=as;exports.useIdentityVerification=Cr;exports.useKycWorkflow=kr;exports.useMetaKYC=Ne;exports.useOverview=Sr;exports.useQuestionnaire=jr;exports.useRiskScoring=Nr;exports.useUploadDocument=wr;exports.validateFileSize=Xr;exports.validateFileType=es;
|
|
102
|
+
*/const xs=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Lr=Tr("chevron-right",xs);function hs(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}if(n!==""){const a=Number(n);if(!isNaN(a)&&n.trim()!==""){if(t.min!==void 0&&t.min!==null&&a<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&a>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function fs(t){const r=t.flatMap((n,a)=>(n.questions??[]).map((o,c)=>({question:o,groupIndex:a,qIdx:c}))),s=new Map;for(const n of r){const a=n.question.pageNumber!=null&&n.question.pageNumber>0?n.question.pageNumber:1;s.has(a)||s.set(a,[]),s.get(a).push(n)}return Array.from(s.entries()).sort(([n],[a])=>n-a).map(([,n])=>n)}const Dr=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:n,initialAnswers:a,isLoading:o,isSubmitting:c,error:d,submit:y}=wr(t),[p,b]=i.useState({}),[F,v]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{a&&Object.keys(a).length>0&&Object.keys(p).length===0&&b(a)},[a]);const k=i.useMemo(()=>n?fs(n.questionGroups):[],[n]),S=E===k.length-1,M=k[E]??[],Y=i.useCallback((R,g)=>{b(O=>({...O,[R]:g})),v(O=>{const q={...O};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:g}of M){const O=hs(g,p[g.id]??[]);O&&(R[g.id]=O)}return v(g=>({...g,...R})),Object.keys(R).length===0},[M,p]),B=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):s==null||s()},X=async()=>{if(!(!L()||!n))try{const R=n.questionGroups.flatMap(O=>(O.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),g={applicantId:t,questionnarieId:n.id,questionResults:R};await y(g),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):d?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",d.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.subtitle}),k.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",k.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:k.map((R,g)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:g===E?"20px":"6px",backgroundColor:g<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},g))})]})]}),e.jsx(te,{className:"space-y-6",children:M.map(({question:R})=>e.jsx(gs,{question:R,value:p[R.id]??[],error:F[R.id],onChange:g=>Y(R.id,g)},R.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:X,children:"Continue"}):e.jsxs(J,{type:"button",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),d&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:d.message})})]}):null},gs=({question:t,value:r,error:s,onChange:n})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:d=>n([d.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),o==="single-select"&&e.jsx(mt,{value:r[0]??"",onChange:d=>n([d.target.value]),options:(t.defaultAnswers??[]).map(d=>({value:d,label:d})),placeholder:"Select an option…",error:s,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===d,onChange:()=>n([d]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(d),onChange:y=>{y.target.checked?n([...r,d]):n(r.filter(p=>p!==d))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&o==="text"&&null]})};function bs(t){const r=new Map;for(const s of t){const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push(s)}return Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}const Mr=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:n,isLoading:a,isSubmitting:o,error:c,submit:d}=Sr(t),[y,p]=i.useState({}),[b,F]=i.useState(null),[v,E]=i.useState(0),[A,k]=i.useState({}),S=i.useMemo(()=>n?bs(n.uploadDocumentFiles):[],[n]),M=S[v]??[],Y=v===S.length-1,L=S.length,B=i.useCallback(()=>{const g={};for(const O of M)O.isRequired&&(y[O.id]||[]).length===0&&(g[O.id]=`${O.displayName} is required`);return k(g),Object.keys(g).length===0},[M,y]),U=()=>{B()&&(E(g=>g+1),k({}))},X=()=>{v>0?(E(g=>g-1),k({})):s==null||s()},R=async()=>{if(!(!B()||!n)){F(null);try{const g=await Promise.all(n.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],$=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await hr(G)})));return{uploadDocumentFileId:q.id,valueList:$}})),O={applicantId:t,uploadDocumentId:n.id,uploadDocumentResults:g};await d(O),r==null||r()}catch(g){F((g==null?void 0:g.message)||"Failed to submit documents. Please try again.")}}};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName||"Upload Documents"}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((g,O)=>e.jsx("div",{style:{height:"6px",width:O===v?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:O<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},O))})]})]}),n.description&&v===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:M.map(g=>e.jsx(Er,{label:g.displayName,subtitle:g.subtitle,accept:g.allowedTypes,multiple:g.multipleFile,maxSize:g.maxEachFileSizeByte,required:g.isRequired,error:A[g.id],value:y[g.id]||[],onChange:O=>{F(null),k(q=>{const Q={...q};return delete Q[g.id],Q}),p(q=>({...q,[g.id]:O}))}},g.id))})}),b&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:X,children:v>0?"Previous":"Back"}),Y?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Or=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:n,isLoading:a,isSubmitting:o,error:c,passOverview:d}=Cr(t),y=async()=>{await d(),r==null||r()};return a?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):n?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:n.title||"Overview"}),n.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n.description})]}),e.jsx(te,{className:"space-y-8",children:n.steps&&n.steps.length>0?n.steps.sort((p,b)=>p.order-b.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function vs(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function ks(t){return t.valueDataType===De.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function js(t,r){const s=new Intl.NumberFormat(vs(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,n=>{const a=parseFloat(n);return isNaN(a)?n:s.format(a)})}function ws(t,r){const s=!r||r.length===0||r.every(n=>!n||!n.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const n=r[0]??"";if(n&&t.regex)try{if(!new RegExp(t.regex).test(n))return t.errorMessage||"Invalid format"}catch{}const a=t.valueDataType===De.Integer||t.valueDataType===De.Money||t.valueDataType===De.DigitOnly;if(a&&n.trim()!==""){const o=Number(n);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!a&&n!==""){if(t.min!==void 0&&t.min!==null&&n.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&n.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Ss(t){const r=new Map;return t.forEach((s,n)=>{const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push({criterion:s,idx:n})}),Array.from(r.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}function Cs(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const zr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:n}=Ne(),a=n.locale??"en",{criteria:o,initialAnswers:c,isLoading:d,isSubmitting:y,error:p,submit:b}=Rr(t),[F,v]=i.useState({}),[E,A]=i.useState({}),[k,S]=i.useState(0),[M,Y]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(F).length===0&&v(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?Ss(o):[],[o]),B=k===L.length-1,U=L[k]??[];i.useEffect(()=>{!d&&o&&o.length===0&&!M&&!y&&(Y(!0),b({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[d,o,M,y,b,t,r]);const X=i.useCallback((Q,$)=>{v(G=>({...G,[Q]:$})),A(G=>{const ne={...G};return delete ne[Q],ne})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:$}of U){const G=ws($,F[$.id]??[]);G&&(Q[$.id]=G)}return A($=>({...$,...Q})),Object.keys(Q).length===0},[U,F]),g=()=>{R()&&S(Q=>Q+1)},O=()=>{k>0?S(Q=>Q-1):s==null||s()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const ne=(F[G.id]??[]).filter(V=>V&&V.trim());return ne.length>0?{riskCriteriaId:G.id,values:ne}:null}).filter(G=>G!==null);await b({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return d?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!d&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",k+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===k?"20px":"6px",backgroundColor:$<=k?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Ns,{criterion:Q,value:F[Q.id]??[],error:E[Q.id],locale:a,onChange:$=>X(Q.id,$)},Q.id))}),e.jsxs(be,{className:"flex items-center justify-between",children:[e.jsxs(J,{type:"button",variant:"outline",onClick:O,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Pr,{size:14}),k>0?"Previous":"Back"]}),B?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:g,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Lr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Ns=({criterion:t,value:r,error:s,locale:n,onChange:a})=>{const o=Cs(t),c=t.valueDataType===De.Integer||t.valueDataType===De.Money||t.valueDataType===De.DigitOnly,d=ks(t),y=p=>d?js(p,n):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>a([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===De.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>a([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(p),onChange:b=>{b.target.checked?a([...r,p]):a(r.filter(F=>F!==p))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),o==="country"&&e.jsx(mt,{value:r[0]??"",onChange:p=>a([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},$r=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!1),[y,p]=i.useState(null),b=async F=>{if(F.preventDefault(),a===null){p("Please select an investor type");return}d(!0),p(null);try{const v={applicantId:t,investorType:a};console.log("Submitting investor categorization:",v);const E=await n.setInvestorCategorization(v);console.log("Investor categorization result:",E),r==null||r()}catch(v){console.error("Error submitting investor categorization:",v),p(v.message||"Failed to submit investor categorization")}finally{d(!1)}};return e.jsx("form",{onSubmit:b,children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Individual,checked:a===je.Individual,onChange:()=>o(je.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.Sophisticated,checked:a===je.Sophisticated,onChange:()=>o(je.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:a===je.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:a===je.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:je.HighNetWorth,checked:a===je.HighNetWorth,onChange:()=>o(je.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:a===null,children:"Submit"})]})]})})};function Rt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function yt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Br=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:n}=Ne(),[a,o]=i.useState(null),[c,d]=i.useState(!0),[y,p]=i.useState(!1),[b,F]=i.useState(null),[v,E]=i.useState({}),[A,k]=i.useState(0),[S,M]=i.useState(!1),[Y,L]=i.useState(!1),[B,U]=i.useState(0),[X,R]=i.useState(0),[g,O]=i.useState(null);i.useEffect(()=>{(async()=>{try{d(!0),F(null);const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch(z){F(z.message||"Failed to load appropriateness test")}finally{d(!1)}})()},[t,n]),i.useEffect(()=>{if(!S||A<=0)return;const z=setInterval(()=>{k(_=>_<=1?(L(!0),0):_-1)},1e3);return()=>clearInterval(z)},[S,A]),i.useEffect(()=>{if(B<=0)return;const z=setInterval(()=>{U(_=>_<=1?0:_-1)},1e3);return()=>clearInterval(z)},[B]),i.useEffect(()=>{Y&&!y&&G()},[Y]);const q=()=>{a&&(M(!0),k(a.testDurationSec),R(0),E({}),F(null))},Q=(z,_)=>{E(me=>({...me,[z]:_}))},$=i.useCallback(async()=>{try{const z=await n.getAppropriatenessTest(t);if(o(z),z.waitTimeSpanForNextTry&&z.waitTimeSpanForNextTry!=="00:00:00"){const _=Rt(z.waitTimeSpanForNextTry);_>0&&U(_)}}catch{}},[t,n]),G=async z=>{if(a){if(!Y){const _=a.appropriatenessQuestions.length-Object.keys(v).length;if(_>0){F(`Please answer all questions. ${_} remaining.`);return}}p(!0),F(null);try{const _=a.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:v[N.id]||""})),me={applicantId:t,appropriatenessTestId:a.id,appropriatenessQuestionResults:_};try{const N=await n.fillAppropriatenessTest(me);N.isSuccess?O({success:!0,message:N.message||"Congratulations! You have passed the test."}):(O({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>$(),1e3))}catch(N){if(N.code===400&&N.message)O({success:!1,message:N.message}),setTimeout(()=>$(),1500);else throw N}}catch(_){F(_.message||"Failed to submit test. Please try again."),ne()}finally{p(!1)}}},ne=()=>{M(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!a)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),b&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:b})]})})});const V=a.testAllowedMaxTry-a.totalFailedTries,he=a.appropriatenessQuestions.length,le=Object.keys(v).length;if(B>0)return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:yt(B)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),b&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]})})]});if(g){const z=()=>{O(null),ne(),F(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:g.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:g.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:g.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:g.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:g.message}),!g.success&&V>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:V})," attempt",V!==1?"s":""," remaining"]})}),!g.success&&V<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(be,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:g.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[V>0&&B<=0&&e.jsx(J,{type:"button",onClick:z,children:"Retake Test"}),V>0&&B>0&&e.jsx(J,{type:"button",onClick:z,children:"OK"}),V<=0&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle})]}),e.jsxs(te,{children:[a.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(ct,{icon:"questions",label:"Questions",value:String(a.totalQuestionCount)}),e.jsx(ct,{icon:"time",label:"Time Limit",value:yt(a.testDurationSec)}),e.jsx(ct,{icon:"target",label:"Pass Requirement",value:`${a.testCorrectAnswerPassLimit} correct`}),e.jsx(ct,{icon:"retry",label:"Attempts Left",value:String(V),variant:V<=1?"warning":"default"})]}),b&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",b]})]}),V<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:V<=0,children:"Start Test"})]})})]});const de=a.appropriatenessQuestions[X],fe=X===he-1,I=le===he,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",X+1," of ",he]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:yt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${le/he*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[le," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[V," attempt",V!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(Is,{question:de,index:X,selectedAnswer:v[de.id],onSelect:z=>Q(de.id,z),disabled:y}),he>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:a.appropriatenessQuestions.map((z,_)=>e.jsx("button",{type:"button",onClick:()=>R(_),style:{width:"28px",height:"28px",borderRadius:"8px",border:_===X?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:v[z.id]?_===X?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":_===X?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:v[z.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:_+1},z.id))}),Y&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),b&&!Y&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:b})})]}),e.jsx(be,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{X>0?R(z=>z-1):s==null||s()},disabled:y,children:X>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!fe&&e.jsx(J,{type:"button",onClick:()=>R(z=>z+1),children:"Next"}),(fe||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!Y,style:{opacity:I||Y?1:.5},children:Y?"Submitting...":"Submit Test"})]})]})})]})},Rs={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},ct=({icon:t,label:r,value:s,variant:n="default"})=>{const a=n==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:a?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:a?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:a?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Rs[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:a?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},Is=({question:t,selectedAnswer:r,onSelect:s,disabled:n})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((a,o)=>{const c=r===a;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:n?"default":"pointer",transition:"all 0.15s ease",opacity:n?.6:1},onMouseEnter:d=>{!n&&!c&&(d.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:d=>{c||(d.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:a,checked:c,onChange:()=>s(a),disabled:n,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:a})]},o)})})]}),_r=({applicantId:t,onComplete:r,onBack:s})=>{var Ge,ze,et,Ue;const{applicantService:n,baseInformationService:a,identityService:o,config:c,currentTheme:d}=Ne(),{identityData:y,provider:p,token:b,isLoading:F,error:v,requestIdentity:E,restartIdentity:A}=Nr(t),[k,S]=i.useState(null),[M,Y]=i.useState(null),[L,B]=i.useState([]),[U,X]=i.useState([]),[R,g]=i.useState(!0),[O,q]=i.useState(!1),[Q,$]=i.useState(null),[G,ne]=i.useState(!1),V=i.useRef(!1),[he,le]=i.useState({}),[de,fe]=i.useState({}),I=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,W=!!(d!=null&&d.reviewPageDisabled),z=i.useRef(!1);z.current=W;const _=qe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){V.current||(V.current=!0,E().then(()=>q(!0)).catch(D=>console.error("[Identity] Auto-request failed:",D)).finally(()=>g(!1)));return}(async()=>{try{const[D,K,H]=await Promise.all([n.getApplicantData(t),a.getCountries("","en"),a.getCountries("","en",40)]);Y(D);const Z=new Set,m=K.map(h=>({value:h.abbreviation3||h.abbreviation,label:h.name})).filter(h=>!h.value||Z.has(h.value)?!1:(Z.add(h.value),!0));B(m);const C=new Set,T=H.filter(h=>h.countryCode).map(h=>({value:h.countryCode,label:`${h.countryCode} – ${h.name}`})).filter(h=>C.has(h.value)?!1:(C.add(h.value),!0));X(T);const u=D.applicantRequestData;if(le({firstName:(u==null?void 0:u.firstName)||"",lastName:(u==null?void 0:u.lastName)||"",email:(u==null?void 0:u.email)||"",dateOfBirth:(u==null?void 0:u.dateOfBirth)||"",title:(u==null?void 0:u.title)||"",salutation:(u==null?void 0:u.salutation)||"",phonenumber:(u==null?void 0:u.phonenumber)||"",mobileCountryCode:(u==null?void 0:u.mobileCountryCode)||"",street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",taxCountry:(u==null?void 0:u.taxCountry)||"",countryOfBirth:(u==null?void 0:u.countryOfBirth)||"",placeOfBirth:(u==null?void 0:u.placeOfBirth)||"",educationLevel:(u==null?void 0:u.educationLevel)||"",occupation:(u==null?void 0:u.occupation)||"",taxNumber:(u==null?void 0:u.taxNumber)||"",defaultLanguage:(u==null?void 0:u.defaultLanguage)||""}),_.reset({street:(u==null?void 0:u.street)||"",streetNumber:(u==null?void 0:u.streetNumber)||"",city:(u==null?void 0:u.city)||"",zip:(u==null?void 0:u.zip)||"",country:(u==null?void 0:u.country)||"",nationality:(u==null?void 0:u.nationality)||"",phonenumber:(u==null?void 0:u.phonenumber)||""}),D.kycRecords&&D.kycRecords.length>0&&D.kycRecords[0].providerTokenObject!==null&&!V.current&&z.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),V.current=!0;try{await E(),q(!0)}catch(h){console.error("[Identity] Auto-request failed:",h)}}}catch(D){console.error("Error loading applicant data:",D)}finally{g(!1)}})()},[t]),i.useEffect(()=>{y&&!O&&z.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,O]),i.useEffect(()=>{if(b){if(b.expiresAt){const x=new Date(b.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),ne(!0),$("Your verification session has expired. Please restart.");return}}if(b.url)try{const D=new URL(b.url).toString().toLowerCase();if(D.includes("expired")||D.includes("invalid")||D.includes("error")){console.warn("[Identity] Token URL indicates expiration"),ne(!0),$("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(b.status==="expired"||b.error==="expired"||b.expired===!0){console.warn("[Identity] Token object indicates expiration"),ne(!0),$("Your verification session has expired. Please restart.");return}}},[b]);const me=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&b&&!k&&O&&!G){const x=p;if(me){console.log("[Sumsub] Fetching access token for Web SDK…"),$(null),(async()=>{try{const D=await o.refreshSumsubToken(t),K=_e.parseProviderConfig(p,b,c);K.accessToken=D,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=_e.createProvider(p,K);H.onComplete(Z=>{console.log("[Sumsub] Verification complete:",Z),r==null||r()}),H.onError(Z=>{console.error("[Sumsub] SDK error:",Z),(typeof Z=="string"?Z:(Z==null?void 0:Z.message)||"Unknown error").toLowerCase().includes("expired")&&(ne(!0),$("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(D){console.error("[Sumsub] Initialization error:",D),$(`Failed to initialize: ${D.message||D}`),String(D.message||D).toLowerCase().includes("expired")&&ne(!0)}})();return}if(b.url){console.log("[Identity] Loading provider URL for user verification:",b.url),$(null);try{if(new URL(b.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const D=_e.parseProviderConfig(p,b,c);_e.createProvider(p,D).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(D){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",D)}}S({type:"url",url:b.url})}catch(D){console.error("[Identity] Invalid URL:",D),$("Invalid verification URL. Please restart."),ne(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),$(null);try{const D=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,D);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var m;console.error("[SardinAI] Failed to initialize:",H);const Z=((m=H.message)==null?void 0:m.toLowerCase())||"";Z.includes("expired")||Z.includes("invalid")||Z.includes("401")||Z.includes("400")?(ne(!0),$("Session expired or invalid. Please restart verification.")):$(`Failed to initialize: ${H.message}`)})}catch(D){console.error("[SardinAI] Error creating provider:",D),$(`Configuration error: ${D.message}`)}return}try{$(null);const D=_e.parseProviderConfig(p,b,c),K=_e.createProvider(p,D);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),$(`Failed to initialize: ${H.message}`)}),S(K)}catch(D){console.error("[Identity] Provider setup error:",D),$(`Setup error: ${D.message}`)}}return()=>{if(k&&k.destroy)try{k.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,b,k,O,r,G,me,t,c,o]);const N=async()=>{try{$(null),ne(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{$(null),ne(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),$(x.message||"Failed to restart verification")}};if(R||F)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(v)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",v.message]})})});if(O&&(Q||G))return e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:F,children:F?"Restarting...":"Restart Verification"})]})]});if(O&&y){const x=p;return me?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:F,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:F?"not-allowed":"pointer",opacity:F?.5:1},children:F?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),s&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):b!=null&&b.url?e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:F,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:b.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:D=>{var K,H,Z;console.log("[Identity] Iframe loaded");try{const m=D.target,C=m.contentDocument||((K=m.contentWindow)==null?void 0:K.document);if(C){const T=((Z=(H=C.body)==null?void 0:H.textContent)==null?void 0:Z.toLowerCase())||"";(T.includes("expired")||T.includes("invalid")||T.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),ne(!0),$("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(be,{children:e.jsx(J,{variant:"outline",onClick:s,children:"Back"})})]})}const ue=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ae=(x=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[x]||"col-span-4",ve=(x,D)=>{if(!D&&D!==0)return"—";if(ue.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===D);return K?K.label:String(D)}return String(D)},Te=({helpText:x})=>{const[D,K]=i.useState(!1),H=i.useRef(null),[,Z]=i.useState({top:0,left:0}),m=()=>{if(H.current){const C=H.current.getBoundingClientRect();Z({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:m,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),D&&pt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ke=(x,D)=>D?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Te,{helpText:D})})]}):x,Oe=(x,D)=>{const K=`cf-${D}`,H=x.paramName??"",Z=de[H];if(x.customType==="br")return e.jsx("div",{className:ae(x.colSpan),style:{minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{className:ae(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{className:ae(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{className:ae(x.colSpan),children:ke(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const m=Z==="true"||Z===!0;return e.jsx("div",{className:ae(x.colSpan),children:ke(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!m,onChange:C=>fe(T=>({...T,[H]:String(C.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const m=Array.isArray(Z)?Z:Z?[Z]:[],C=T=>{x.singleSelect?fe(u=>({...u,[H]:m[0]===T?[]:[T]})):fe(u=>({...u,[H]:m.includes(T)?m.filter(l=>l!==T):[...m,T]}))};return e.jsx("div",{className:ae(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(T=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.includes(T.value),onChange:()=>C(T.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:T.label})]},T.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{className:ae(x.colSpan),children:ke(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(m=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:m.value,checked:Z===m.value,onChange:()=>fe(C=>({...C,[H]:m.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.label})]},m.value))]}),x.helpText)},K):e.jsx("div",{className:ae(x.colSpan),children:ke(e.jsx(ye,{label:x.displayText||x.label||H,value:String(Z??""),onChange:m=>fe(C=>({...C,[H]:m.target.value}))}),x.helpText)},K)},Xe=(x,D)=>{if(x.isCustom)return Oe(x,D);const K=x.name??"",H=Qe[K],Z=x.displayText||(H==null?void 0:H.label)||K,m=he[K]??"",C=K==="mobileCountryCode",T=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{className:ae(x.colSpan??2),children:ke(e.jsx(Me,{label:Z,value:String(m),onChange:u=>le(l=>({...l,[K]:u})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${D}`):T?e.jsx("div",{className:ae(x.colSpan??2),children:ke(e.jsx(Me,{label:Z,value:String(m),onChange:u=>le(l=>({...l,[K]:u})),options:[{value:"",label:`Select ${Z.toLowerCase()}…`},...L]}),x.helpText)},`ec-${D}`):e.jsx("div",{className:ae(x.colSpan??2),children:ke(e.jsx(ye,{label:Z,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(m),onChange:u=>le(l=>({...l,[K]:u.target.value}))}),x.helpText)},`ei-${D}`):e.jsx("div",{className:ae(x.colSpan??2),children:ke(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:Z}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ve(K,m)})]}),x.helpText)},`ro-${D}`)};if(I){const x=I.title||"Review Your Information",D=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:D})]}),e.jsx(te,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:I.fields.map((K,H)=>Xe(K,H))})}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:_.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(ge,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Ge=M==null?void 0:M.applicantRequestData)==null?void 0:Ge.firstName)||""} ${((ze=M==null?void 0:M.applicantRequestData)==null?void 0:ze.lastName)||""}`.trim()},{label:"Email",value:(et=M==null?void 0:M.applicantRequestData)==null?void 0:et.email},{label:"Date of Birth",value:((Ue=M==null?void 0:M.applicantRequestData)==null?void 0:Ue.dateOfBirth)||"Not provided"}].map(({label:x,value:D})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:D})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"country",render:({field:x})=>e.jsx(Me,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(qe.Controller,{control:_.control,name:"nationality",render:({field:x})=>e.jsx(Me,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(qe.Controller,{control:_.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(qe.Controller,{control:_.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(qe.Controller,{control:_.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(qe.Controller,{control:_.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(be,{className:"flex justify-between",children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})},ft=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:n,onContinue:a,onContactSupport:o})=>{const d=t===Ve.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Ve.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Ve.Pending||t===Ve.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Ye.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Ye.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Ye.UnderReview||r===Ye.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===ot.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===ot.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===ot.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${d.iconBg}`,children:e.jsx("span",{className:`text-5xl ${d.iconColor}`,children:d.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(kt,{variant:d.type==="success"?"success":d.type==="error"?"danger":d.type==="pending"?"warning":"info",children:t!=null?Ve[t]:Ye[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:n||d.message}),d.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),d.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),d.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Ve[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Ye[r]})]})]})})]}),e.jsxs(be,{className:"flex justify-center gap-4",children:[d.type==="success"&&a&&e.jsx(J,{onClick:a,size:"lg",children:"Continue"}),d.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),a&&e.jsx(J,{onClick:a,children:"Try Again"})]}),d.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Hr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),nt=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:n}=Ne(),a=t||(n==null?void 0:n.title)||"",o=!!(n!=null&&n.logo&&n.logo.visible&&n.logo.url),c=!!a;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx(Hr,{config:n.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:a})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},dt=["firstName","lastName","email","phonenumber","dateOfBirth"];function tt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const it={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},It=({helpText:t,children:r})=>{const[s,n]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const a=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>n(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>n(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>n(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&a?pt.createPortal(a,document.body):null]})},Es=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var K,H,Z,m,C,T,u;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:d,isLoading:y}=vt(),p=t||((K=a.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((H=a.applicantForm)==null?void 0:H.externalRefId)||"",F=((Z=a.applicantForm)==null?void 0:Z.email)||"",v=((m=a.applicantForm)==null?void 0:m.hiddenValues)||{},E=((C=a.applicantForm)==null?void 0:C.initialValues)||{},k=(((T=a.applicantForm)==null?void 0:T.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),M=i.useMemo(()=>{const l=new Set(dt),h=c==null?void 0:c.applicantFormRequiredFields;if(h)for(const P of h)l.add(P);if(S)for(const P of S)for(const f of P.fields)!f.isCustom&&f.name&&f.required&&l.add(f.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),Y=i.useMemo(()=>{var P;if(S){const f=S.flatMap(j=>j.fields).filter(j=>!j.isCustom&&j.name).map(j=>j.name),w=new Set(f);for(const j of dt)w.add(j);return Array.from(w)}let l;(P=a.applicantForm)!=null&&P.visibleFields?l=a.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=Ht;const h=new Set(l);for(const f of dt)h.add(f);return Array.from(h)},[(u=a.applicantForm)==null?void 0:u.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),B=i.useMemo(()=>{var h,P;const l=new Set;if(S)for(const f of S)for(const w of f.fields)!w.isCustom&&w.name&&L.has(w.name)&&l.add(w.countriesType??((h=Qe[w.name])==null?void 0:h.countriesType));else for(const f of Y)L.has(f)&&l.add((P=Qe[f])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[Y,S]),[U,X]=i.useState({}),[R,g]=i.useState(!0),O=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=B.filter(f=>{const w=f!=null?String(f):"all";return!q.current.has(w)&&!O.current.has(w)});if(l.length===0){B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&g(!1);return}g(!0);const h=l.map(f=>f!=null?String(f):"all");h.forEach(f=>O.current.add(f)),(async()=>{try{const f=await Promise.all(l.map(async w=>{const j=w!=null?String(w):"all",ce=await o.getCountries("",a.locale||"en",w),se=w===40,xe=new Set,Ie=ce.map(ie=>se&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(j),O.current.delete(j),[j,Ie]}));X(w=>({...w,...Object.fromEntries(f)}))}catch(f){h.forEach(w=>O.current.delete(w)),console.error("Failed to load countries:",f)}finally{B.every(w=>{const j=w!=null?String(w):"all";return q.current.has(j)})&&g(!1)}})()},[B,c]);const Q=(l,h)=>{var w;const P=h??((w=Qe[l])==null?void 0:w.countriesType),f=P!=null?String(P):"all";return U[f]||[]},$={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(v).filter(([l])=>l in $)),ne=Object.fromEntries(Object.entries(E).filter(([l])=>l in $)),[V,he]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:F,dateOfBirth:"",phonenumber:"",externalRefId:b,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...ne}),le=Object.fromEntries(Object.entries(v).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,fe]=i.useState({...le}),[I,W]=i.useState(0),[z,_]=i.useState({}),[me,N]=i.useState(null),[re,ue]=i.useState(!1),ae=(l,h)=>he(P=>({...P,[l]:h})),ve=(l,h)=>fe(P=>({...P,[l]:h})),Te=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ke=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,Xe=l=>{var P;const h={};for(const f of l.fields)if(f.isCustom){if(f.customType==="paragraph"||f.customType==="html"||f.customType==="br"||f.customType==="link")continue;if(f.required&&f.paramName){const w=de[f.paramName],j=f.displayText||f.label||f.paramName;f.customType==="checkbox"||f.customType==="link_checkbox"?w!=="true"&&(h[f.paramName]=`${j} is required.`):(!w||w.trim()==="")&&(h[f.paramName]=`${j} is required.`)}}else if(f.name){const w=f.name;if(M.includes(w)&&tt(V[w])){const j=f.displayText||((P=Qe[w])==null?void 0:P.label)||w;h[w]=`${j} is required.`}}return h},Ge=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Te(l)){_({}),ke>=0?W(ke):await ze();return}const h=Xe(l);if(Object.keys(h).length>0){_(h);return}_({}),ke>=0?W(ke):await ze()},ze=async()=>{if(S){let l={};for(const h of S)Te(h)&&(l={...l,...Xe(h)});if(Object.keys(l).length>0){_(l);return}}ue(!0),N(null);try{if(!V.externalRefId||V.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:V.workflowKey,externalRefId:V.externalRefId.trim()};if(S){for(const w of S)if(Te(w)){for(const j of w.fields)if(!j.isCustom&&j.name){const ce=j.name,se=V[ce];tt(se)||(l[ce]=se)}}for(const w of dt)if(l[w]===void 0){const j=V[w];tt(j)||(l[w]=j)}}else Y.forEach(w=>{if(w==="externalRefId")return;const j=V[w];tt(j)||(l[w]=j)});const h=[];if(S){for(const w of S)if(Te(w))for(const j of w.fields){if(!j.isCustom||!j.paramName||j.customType==="paragraph"||j.customType==="html"||j.customType==="br"||j.customType==="link")continue;const ce=de[j.paramName]??"";let se;if(j.customType==="checkbox"||j.customType==="link_checkbox")se=ce==="true"?"yes":"no";else if(se=ce,!se&&!j.required)continue;h.push({paramName:j.paramName,value:se})}}for(const[w,j]of Object.entries(G))l[w]===void 0&&!tt(j)&&(l[w]=j);const P=new Set(h.map(w=>w.paramName));for(const[w,j]of Object.entries(le))!P.has(w)&&j&&h.push({paramName:w,value:j});h.length>0&&(l.applicantAdditionalDatas=h);const f=await d(l);s(f.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{ue(!1)}},et=async l=>{var h;l.preventDefault();for(const P of M)if(tt(V[P])){const f=((h=Qe[P])==null?void 0:h.label)||P;N(`${f} is required.`);return}await ze()},Ue=(l,h,P,f,w)=>{var jt;const j=Qe[l];if(!j)return null;const ce=M.includes(l),se=z[l],xe=P||j.label,Ie=l in ne,ie=h??l,Pe={required:ce},$e=w?w!=="placeholder":k,Ke=$e?xe:void 0,Wr=$e?"...":xe;switch(j.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,f);return e.jsx(Me,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ae(l,Je),options:[{value:"",label:`Select ${Wr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:se},ie)}if(l==="salutation")return e.jsx(Me,{...Pe,label:Ke,value:((jt=V[l])==null?void 0:jt.toString())||"",onChange:Ce=>ae(l,Ce?Number(Ce):null),options:[{value:"",label:$e?"Select salutation...":xe},{value:lt.Male.toString(),label:"Male"},{value:lt.Female.toString(),label:"Female"},{value:lt.Other.toString(),label:"Other"}],readOnly:Ie,error:se},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?ht.filter(Je=>c.allowedLanguages.includes(Je.value)):ht;return e.jsx(Me,{...Pe,label:Ke,value:V[l]||"",onChange:Je=>ae(l,Je),options:[{value:"",label:$e?"Select language...":xe},...Ce],readOnly:Ie,error:se},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,f);return e.jsx(Ir,{...Pe,label:Ke,value:V[l]||[],onChange:Je=>ae(l,Je),options:Ce,placeholder:$e?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Pe,type:"date",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);case"email":return e.jsx(ye,{...Pe,type:"email",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);case"tel":return e.jsx(ye,{...Pe,type:"tel",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie);default:return e.jsx(ye,{...Pe,type:"text",label:Ke,placeholder:$e?void 0:xe,value:V[l]||"",onChange:Ce=>ae(l,Ce.target.value),readOnly:Ie,error:se},ie)}},x=(l,h)=>{const P=l.labelMode?l.labelMode!=="placeholder":k;if(l.customType==="paragraph"){const j=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:j}},`custom-${h}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${h}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${h}`);if(l.customType==="link"){const j=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[j,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${h}`)}if(!l.paramName)return null;const f=z[l.paramName],w=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),f&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:f})]},`custom-${h}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:de[l.paramName]==="true",onChange:j=>ve(l.paramName,j.target.checked?"true":"false"),className:"metakyc-option-input",style:{...it,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[w," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:j=>j.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),f&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:f})]},`custom-${h}`);if(l.customType==="group_checkbox"){const j=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(ce=>{const se=l.singleSelect?de[l.paramName]===ce.value:j.includes(ce.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:se,onChange:xe=>{if(l.singleSelect)ve(l.paramName,xe.target.checked?ce.value:"");else{const Ie=xe.target.checked?[...j,ce.value]:j.filter(ie=>ie!==ce.value);ve(l.paramName,Ie.join(","))}},className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:ce.label})]},ce.value)})}),f&&e.jsx("p",{className:"text-red-500 text-xs",children:f})]},`custom-${h}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[w,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(j=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===j.value,onChange:()=>ve(l.paramName,j.value),name:`radio-group-${l.paramName}-${h}`,className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:j.label})]},j.value))}),f&&e.jsx("p",{className:"text-red-500 text-xs",children:f})]},`custom-${h}`):e.jsx(ye,{type:"text",label:P?`${w}${l.required?" *":""}`:void 0,placeholder:P?void 0:w,value:de[l.paramName]||"",onChange:j=>ve(l.paramName,j.target.value),required:l.required,error:f},`custom-${h}`)},D=(l,h)=>{const P=Te(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(It,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:P,onChange:f=>ve(l.conditionalOn,f.target.checked?"true":"false"),className:"metakyc-option-input",style:it}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:l.fields.map((f,w)=>{const j=f.colSpan===1?"col-span-1":f.colSpan===2?"col-span-2":f.colSpan===3?"col-span-3":"col-span-4",ce=f.isCustom?`custom-${w}-${f.paramName}`:`builtin-${f.name}-${w}`;return e.jsx("div",{className:j,children:e.jsx(It,{helpText:f.helpText,children:f.isCustom?x(f,w):Ue(f.name,ce,f.displayText,f.countriesType,f.labelMode)})},ce)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],h=Oe===-1,P=ke===-1,f=S.length,w=Te(l),j=Object.values(z);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(me||j.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[me&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]}),j.map((ce,se)=>e.jsx("p",{className:"text-red-600 text-sm",children:ce},se))]}),f>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[S.map((ce,se)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${se===I?"flex-1":"w-8"}`,style:se===I?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:se<I?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},se)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[I+1," / ",f]})]}),D(l)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!h&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),_({})},disabled:re||y,children:"Previous"}),h&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?ze:Ge,children:P?l.conditionalOn&&!w?"Skip & Submit":"Submit":l.conditionalOn&&!w?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:et,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[me&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",me]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:Y.map(l=>e.jsx("div",{className:"col-span-4",children:Ue(l)},l))})]}),e.jsxs(be,{className:"flex justify-between",children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},Et=["companyName","email"];function xt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const As=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:n})=>{var Ue,x,D,K,H,Z;const{config:a,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:d,isLoading:y}=vt(),p=t||((Ue=a.applicantForm)==null?void 0:Ue.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const b=r||((x=a.applicantForm)==null?void 0:x.externalRefId)||"",F=((D=a.applicantForm)==null?void 0:D.email)||"",v=((K=a.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=a.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",k=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const m=new Set(Et),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const T of C)m.add(T);if(k)for(const T of k)for(const u of T.fields)!u.isCustom&&u.name&&u.required&&m.add(u.name);return Array.from(m)},[c==null?void 0:c.companyFormRequiredFields,k]),M=i.useMemo(()=>{var m;if(k){const C=k.flatMap(u=>u.fields).filter(u=>!u.isCustom&&u.name).map(u=>u.name),T=new Set(C);for(const u of Et)T.add(u);return Array.from(T)}return(m=a.applicantForm)!=null&&m.visibleFields?a.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:_t},[(Z=a.applicantForm)==null?void 0:Z.visibleFields,c==null?void 0:c.companyFormVisibleFields,k]),Y=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,T;const m=new Set;if(k)for(const u of k)for(const l of u.fields)!l.isCustom&&l.name&&Y.has(l.name)&&m.add(l.countriesType??((C=Ze[l.name])==null?void 0:C.countriesType));else for(const u of M)Y.has(u)&&m.add((T=Ze[u])==null?void 0:T.countriesType);return m.size===0&&m.add(void 0),Array.from(m)},[M,k]),[B,U]=i.useState({}),[X,R]=i.useState(!0),g=i.useRef(new Set),O=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const m=L.filter(u=>{const l=u!=null?String(u):"all";return!O.current.has(l)&&!g.current.has(l)});if(m.length===0){L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=m.map(u=>u!=null?String(u):"all");C.forEach(u=>g.current.add(u)),(async()=>{try{const u=await Promise.all(m.map(async l=>{const h=l!=null?String(l):"all",P=await o.getCountries("",a.locale||"en",l),f=new Set,w=P.map(j=>({value:j.abbreviation3||j.abbreviation,label:j.name})).filter(j=>!j.value||f.has(j.value)?!1:(f.add(j.value),!0));return O.current.add(h),g.current.delete(h),[h,w]}));U(l=>({...l,...Object.fromEntries(u)}))}catch(u){C.forEach(l=>g.current.delete(l)),console.error("Failed to load countries:",u)}finally{L.every(l=>O.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(m,C)=>{var l;const T=C??((l=Ze[m])==null?void 0:l.countriesType),u=T!=null?String(T):"all";return B[u]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},$=Object.fromEntries(Object.entries(v).filter(([m])=>m in Q)),[G,ne]=i.useState({workflowKey:p,companyName:"",email:F,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:b,...$}),[V,he]=i.useState({}),[le,de]=i.useState(0),[fe,I]=i.useState({}),[W,z]=i.useState(null),[_,me]=i.useState(!1),N=(m,C)=>ne(T=>({...T,[m]:C})),re=(m,C)=>he(T=>({...T,[m]:C})),ue=m=>!m.conditionalOn||V[m.conditionalOn]==="true",ae=k&&le<k.length-1?le+1:-1,ve=k&&le>0?le-1:-1,Te=m=>{var T;const C={};for(const u of m.fields)if(u.isCustom){if(u.customType==="paragraph"||u.customType==="html"||u.customType==="br"||u.customType==="link")continue;if(u.required&&u.paramName){const l=V[u.paramName],h=u.displayText||u.label||u.paramName;u.customType==="checkbox"||u.customType==="link_checkbox"?l!=="true"&&(C[u.paramName]=`${h} is required.`):(!l||l.trim()==="")&&(C[u.paramName]=`${h} is required.`)}}else if(u.name){const l=u.name;if(S.includes(l)&&xt(G[l])){const h=u.displayText||((T=Ze[l])==null?void 0:T.label)||l;C[l]=`${h} is required.`}}return C},ke=async()=>{if(!k)return;const m=k[le];if(m.conditionalOn&&!ue(m)){I({}),ae>=0?de(ae):await Oe();return}const C=Te(m);if(Object.keys(C).length>0){I(C);return}I({}),ae>=0?de(ae):await Oe()},Oe=async()=>{var m;if(k){let C={};for(const T of k)ue(T)&&(C={...C,...Te(T)});if(Object.keys(C).length>0){I(C);return}}me(!0),z(null);try{const C={workflowKey:G.workflowKey,externalRefId:((m=G.externalRefId)==null?void 0:m.trim())||void 0},T=k?k.filter(h=>ue(h)).flatMap(h=>h.fields).filter(h=>!h.isCustom&&h.name).map(h=>h.name):M;for(const h of T){const P=G[h];if(!xt(P))switch(h){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[h]=P;break}}const u=[];if(k){for(const h of k)if(ue(h))for(const P of h.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const f=V[P.paramName]??"";let w;if(P.customType==="checkbox"||P.customType==="link_checkbox")w=f==="true"?"yes":"no";else if(w=f,!w&&!P.required)continue;u.push({paramName:P.paramName,value:w})}}u.length>0&&(C.applicantAdditionalDatas=u);const l=await d(C);s(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),z(C.message||"Failed to create company applicant")}finally{me(!1)}},Xe=async m=>{var C;m.preventDefault();for(const T of S)if(xt(G[T])){const u=((C=Ze[T])==null?void 0:C.label)||T;z(`${u} is required.`);return}await Oe()},Ge=(m,C,T,u,l)=>{const h=Ze[m];if(!h)return null;const P=S.includes(m),f=fe[m],w=T||h.label,j=m in $,ce=C??m,se=l?l!=="placeholder":A,xe=se?w:void 0,Ie=se?"...":w;switch(h.type){case"select":if(m==="countryResidence"||m==="addressCountry"){const ie=q(m,u);return e.jsx(Me,{required:P,label:xe,value:G[m]||"",onChange:Pe=>N(m,Pe),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:X,readOnly:j,error:f},ce)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:se?void 0:w,value:G[m]||"",onChange:ie=>N(m,ie.target.value),readOnly:j,error:f},ce)}},ze=(m,C)=>{if(m.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:m.displayText||m.label||""}},`custom-${C}`);if(m.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:m.label||""}},`custom-${C}`);if(m.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(m.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:m.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:m.displayText||m.label||m.linkText||m.linkUrl||""})},`custom-${C}`);if(!m.paramName)return null;const T=fe[m.paramName],u=m.displayText||m.label||m.paramName,l=m.labelMode?m.labelMode!=="placeholder":A;return m.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:V[m.paramName]==="true",onChange:h=>re(m.paramName,h.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[u,m.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),T&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:T})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${u}${m.required?" *":""}`:void 0,placeholder:l?void 0:u,value:V[m.paramName]||"",onChange:h=>re(m.paramName,h.target.value),required:m.required,error:T},`custom-${C}`)},et=m=>{const C=ue(m);return e.jsxs("div",{className:"space-y-4",children:[m.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:C,onChange:T=>re(m.conditionalOn,T.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:m.conditionalOn})]}),C&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:m.fields.map((T,u)=>{const l=T.colSpan===1?"col-span-1":T.colSpan===2?"col-span-2":T.colSpan===3?"col-span-3":"col-span-4",h=T.isCustom?`custom-${u}-${T.paramName}`:`builtin-${T.name}-${u}`;return e.jsx("div",{className:l,children:T.isCustom?ze(T,u):Ge(T.name,h,T.displayText,T.countriesType,T.labelMode)},h)})})]})};if(!c||X)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(k){const m=k[le]??k[0],C=ve===-1,T=ae===-1,u=k.length,l=ue(m),h=Object.values(fe);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(m.title||m.subtitle)&&e.jsxs("div",{className:"mb-4",children:[m.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.subtitle})]}),(W||h.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),h.map((P,f)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},f))]}),u>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[k.map((P,f)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${f===le?"flex-1":"w-8"}`,style:f===le?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:f<le?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},f)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[le+1," / ",u]})]}),et(m)]}),e.jsxs(be,{className:"flex justify-between",children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(ve),I({})},disabled:_||y,children:"Previous"}),C&&n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:_||y,onClick:T?Oe:ke,children:T?m.conditionalOn&&!l?"Skip & Submit":"Submit":m.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Xe,children:e.jsxs(ee,{children:[e.jsx(ge,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:M.map(m=>e.jsx("div",{className:"col-span-4",children:Ge(m)},m))})]}),e.jsxs(be,{className:"flex justify-between",children:[n&&e.jsx(J,{type:"button",variant:"outline",onClick:n,disabled:_||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:_||y,children:"Register Company"})]})]})})})},Fs=({applicantId:t,onComplete:r,onError:s,theme:n="light",className:a})=>{const{progress:o,currentStep:c,steps:d,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:b,isLoading:F,error:v,moveBack:E,refreshProgress:A}=jr(t),[k,S]=i.useState(!1),M=i.useRef(null);if(i.useEffect(()=>{v&&s&&s(v)},[v,s]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{n==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[n]),i.useEffect(()=>{b&&S(!1)},[b]),F||!o)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(v)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:v.message})]})})})});if(b&&!k)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Fe.Finished||o.status===Fe.OnHold)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${a||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Fe.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const Y=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=d.filter(q=>q.visibility!==!1),X=U.findIndex(q=>q.order===c.order),R=X>=0?X+1:1,g=U.length,O=g>1?X/(g-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(nt,{}),e.jsxs(kt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",g]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${O}%`,transition:"width 0.4s ease"}})})}),e.jsx(Ts,{ref:M,visibleSteps:U,currentVisibleStepIndex:X,getStepFallbackName:Y})]})},B=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Dr,{...U});case oe.UploadDocument:return e.jsx(Mr,{...U});case oe.Overview:return e.jsx(Or,{...U});case oe.IdentitySdk:return e.jsx(_r,{...U});case oe.RiskScoring:return e.jsx(zr,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx($r,{...U});case oe.AppropriatenessTest:return e.jsx(Br,{...U});case oe.ManualReview:return e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${a||""}`,children:[L(),B()]})},Ts=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},n)=>{const a=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(n,()=>a.current),i.useEffect(()=>{if(o.current&&a.current){const c=a.current,d=o.current,y=d.offsetLeft-c.offsetWidth/2+d.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:a,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,d)=>{const y=d<r,p=d===r,b=y||p,F=c.displayName||c.name||s(c.action)||`Step ${d+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...b?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):d+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:F})]}),d<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Ps(t){return We.z.object({questionResults:We.z.any()}).passthrough()}function Ls(t){let r=We.z.array(We.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(n=>n.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(n=>n.trim());r=r.refine(n=>n?n.every(a=>s.some(o=>o.endsWith("/*")?a.type.startsWith(o.slice(0,-2)):a.type===o)):!0,{message:"Invalid file type"})}return r}function Ds(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const n=`file_${s.id}`;r[n]=Ls(s)}),We.z.object(r)}function Ms(t){return We.z.any()}function Os(t){return We.z.string().min(1,"This question is required")}function zs(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const n=`question_${s.id}`;r[n]=Os()}),We.z.object(r)}const $s=We.z.any();exports.ALLOWED_LANGUAGES=ht;exports.ApplicantProgressOnHoldReason=At;exports.ApplicantProgressStatus=Fe;exports.ApplicantService=qt;exports.ApplicantStatus=Tt;exports.AppropriatenessQuestionType=Ot;exports.AppropriatenessTestService=Qt;exports.AppropriatenessTestStep=Br;exports.Badge=kt;exports.BaseInformationService=Xt;exports.Button=J;exports.COMPANY_FIELD_METADATA=Ze;exports.Card=ee;exports.CardContent=te;exports.CardFooter=be;exports.CardHeader=ge;exports.CountriesType=He;exports.CreateApplicantForm=Es;exports.CreateCompanyApplicantForm=As;exports.CriteriaBuiltInType=$t;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=_t;exports.DEFAULT_VISIBLE_FIELDS=Ht;exports.DocumentReviewStatus=Mt;exports.EndpointBuilder=Ut;exports.ErrorHandler=rt;exports.EventEmitter=lr;exports.FIELD_METADATA=Qe;exports.FileType=Dt;exports.FileUpload=Er;exports.GenderType=lt;exports.Header=nt;exports.HttpClient=Kt;exports.IdentityProviderManager=_e;exports.IdentityService=Zt;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=_r;exports.Input=ye;exports.InvestorCategorizationService=er;exports.InvestorCategorizationStep=$r;exports.InvestorCategorizationType=je;exports.InvestorCategoryType=Bt;exports.KycProcessStatus=Pt;exports.KycStatus=Ve;exports.KycStatusDisplay=ft;exports.KycWorkflow=Fs;exports.Logo=Hr;exports.MetaKYCContext=bt;exports.MetaKYCError=Le;exports.MetaKYCProvider=Xr;exports.MultiSelect=Ir;exports.OnfidoProvider=mr;exports.OverviewService=Gt;exports.OverviewStep=Or;exports.PhoneInput=Ar;exports.QuestionnaireService=Vt;exports.QuestionnaireStep=Dr;exports.ReviewStatus=Ye;exports.RiskCriteriaType=zt;exports.RiskLevel=Ft;exports.RiskScoringService=Jt;exports.RiskScoringStep=zr;exports.SardinAIProvider=yr;exports.SearchableSelect=Me;exports.Select=mt;exports.Spinner=Ee;exports.StepRouter=dr;exports.SumsubProvider=pr;exports.ThemeManager=xr;exports.ThemePreset=we;exports.ThemeService=or;exports.UploadDocumentService=Yt;exports.UploadDocumentStep=Mr;exports.UserType=Lt;exports.ValueDataType=De;exports.WorkflowOrchestrator=ur;exports.WorkflowResultType=ot;exports.WorkflowState=cr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=$s;exports.clearAllStorage=ns;exports.clearApplicantId=br;exports.clearWorkflowState=kr;exports.cn=Se;exports.corporateTheme=tr;exports.defaultConfig=Wt;exports.defaultTheme=Re;exports.fileToBase64=hr;exports.fintechTheme=rr;exports.formatFileSize=ut;exports.generateAppropriatenessSchema=zs;exports.generateQuestionnaireSchema=Ps;exports.generateRiskScoringSchema=Ms;exports.generateUploadDocumentSchema=Ds;exports.getAcceptString=rs;exports.getApplicantId=gr;exports.getThemePreset=st;exports.getWorkflowState=ss;exports.healthcareTheme=sr;exports.isScriptLoaded=Yr;exports.loadScript=gt;exports.minimalTheme=ar;exports.modernTheme=nr;exports.removeScript=Qr;exports.saveApplicantId=fr;exports.saveWorkflowState=vr;exports.themePresets=ir;exports.useApplicant=vt;exports.useAppropriatenessTest=as;exports.useIdentityVerification=Nr;exports.useKycWorkflow=jr;exports.useMetaKYC=Ne;exports.useOverview=Cr;exports.useQuestionnaire=wr;exports.useRiskScoring=Rr;exports.useUploadDocument=Sr;exports.validateFileSize=es;exports.validateFileType=ts;
|
|
151
103
|
//# sourceMappingURL=index.cjs.map
|