@vpdev2/metakyc-sdk 1.0.29 → 1.0.30
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/components/core/MultiSelect.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +11 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/core/MultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,
|
|
1
|
+
{"version":3,"file":"MultiSelect.d.ts","sourceRoot":"","sources":["../../../src/components/core/MultiSelect.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACrC,OAAO,EAAE,iBAAiB,EAAE,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAuJlD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var er=Object.defineProperty;var tr=(t,e,s)=>e in t?er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var K=(t,e,s)=>tr(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rr=require("axios"),l=require("react"),r=require("react/jsx-runtime"),U=require("react-hook-form"),ce=require("zod");function sr(t){const e=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(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Ie=sr(l);var M=(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))(M||{}),fe=(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))(fe||{}),se=(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))(se||{}),Le=(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))(Le||{}),Te=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Te||{}),ue=(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))(ue||{}),me=(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))(me||{}),Me=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Me||{}),Oe=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Oe||{}),re=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(re||{}),ze=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ze||{}),ye=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(ye||{}),Be=(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))(Be||{}),_e=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(_e||{}),Ue=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Ue||{}),we=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(we||{}),$e=(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))($e||{}),Ke=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(Ke||{}),Z=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(Z||{}),qe=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(qe||{});const He=[{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"}],Ve=["firstName","lastName","email","phonenumber","dateOfBirth","street","streetNumber","zip","city","country","nationality","taxCountry","taxNumber"],nr=["firstName","lastName","title","email","dateOfBirth","phonenumber","mobileCountryCode","street","streetNumber","zip","city","country","nationality","otherNationality","defaultLanguage","taxCountry","placeOfBirth","countryOfBirth","salutation","educationLevel","occupation","taxNumber","externalRefId"],Ye={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},title:{label:"Title",type:"text"},email:{label:"Email",type:"email"},dateOfBirth:{label:"Date of Birth",type:"date"},phonenumber:{label:"Phone Number",type:"tel"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},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"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},defaultLanguage:{label:"Default Language",type:"select"},taxCountry:{label:"Tax Country",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},countryOfBirth:{label:"Country of Birth",type:"select"},salutation:{label:"Salutation",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"},taxNumber:{label:"Tax Number",type:"text"},externalRefId:{label:"External Reference ID",type:"text"}};var V=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(V||{});const We={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Qe{constructor(e){this.config=e}build(e,s){const n=`${e}.${s}`;if(this.config.customPaths&&this.config.customPaths[n])return this.config.customPaths[n];switch(this.config.pattern){case"host-controller":return`/api/${e}/${s}`;case"application-service":return`/services/app/${this.getServiceName(e)}/${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(e){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[e]||e}}class ie extends Error{constructor(s,n,a,i,o){super(s);K(this,"response");this.code=n,this.details=a,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,ie.prototype)}}class he{static handleApiError(e){return new ie(e.message||"An unknown error occurred",e.code,e.details||void 0,e.validationErrors||void 0)}static handleAxiosError(e){if(e.response){const s=e.response.data;return s&&s.error?new ie(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,e.response):s&&s.result&&s.result.message?new ie(s.result.message,e.response.status,`HTTP ${e.response.status}: ${e.response.statusText}`,void 0,e.response):new ie((s==null?void 0:s.message)||e.message||"Request failed",e.response.status,`HTTP ${e.response.status}: ${e.response.statusText}`,void 0,e.response)}else return e.request?new ie("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ie(e.message||"An unexpected error occurred",0,e.toString())}static isMetaKYCError(e){return e instanceof ie}}class Ge{constructor(e){K(this,"axiosInstance");K(this,"endpointBuilder");K(this,"config");this.config={...We,...e},this.endpointBuilder=new Qe(this.config.endpoints),this.axiosInstance=rr.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(i=>setTimeout(i,1e3*n._retryCount)),this.axiosInstance(n)):Promise.reject(s)})}buildEndpoint(e,s){return this.endpointBuilder.build(e,s)}async get(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.get(a,{params:n});return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async post(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.post(a,n);return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async put(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.put(a,n);return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async delete(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.delete(a,{params:n});return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}handleResponse(e){const s=e.data;if(!s.success&&s.error)throw he.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class Ze{constructor(e){this.httpClient=e}async createApplicant(e){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",e)).result}async createCompanyApplicant(e){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",e)).result}async duplicateApplicant(e){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",e)).result}async getProgress(e){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:e})).result}async getProgressStatus(e){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:e})).result}async getApplicantData(e){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:e})).result}async getApplicantStatus(e){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:e})).result}async stopProgress(e){await this.httpClient.get("Applicant","StopProgress",{applicantId:e})}async progressStepBack(e){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:e})}async setLanguage(e,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:e,language:s})}async activateApplicant(e){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:e})}async deleteApplicant(e){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:e})}async checkApplicantExists(e){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:e})).result}}class Je{constructor(e){this.httpClient=e}async getQuestionnaire(e){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:e})).result}async fillQuestionnaire(e){return(await this.httpClient.post("Applicant","FillQuestionnarie",e)).result}}class Xe{constructor(e){this.httpClient=e}async getUploadDocument(e){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:e})).result}async fillUploadDocument(e){await this.httpClient.post("Applicant","FillUploadDocument",e)}async reviewUploadDocument(e){await this.httpClient.post("UploadDocument","ReviewUploadDocument",e)}}class et{constructor(e){this.httpClient=e}async getAppropriatenessTest(e){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:e})).result}async fillAppropriatenessTest(e){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",e)).result}}class tt{constructor(e){this.httpClient=e}async getOverviewData(e){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:e})).result}async passOverview(e){await this.httpClient.get("Applicant","PassOverview",{applicantId:e})}}class rt{constructor(e){this.httpClient=e}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(e){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:e})).result}async submitRiskScoring(e){return(await this.httpClient.post("Applicant","RiskScoringRequest",e)).result}}class st{constructor(e){this.httpClient=e}async identityRequest(e){console.log("[IdentityService] Calling IdentityRequest with input:",e);const s=await this.httpClient.post("Applicant","IdentityRequest",e);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(e){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",e)).result}async restartIdentityRequest(e){const s={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(e){const s={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class nt{constructor(e){this.httpClient=e}async getCountries(e,s,n){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:e||"",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 at{constructor(e){this.httpClient=e}async setInvestorCategorization(e){return(await this.httpClient.post("Applicant","SetInvestorCategorization",e)).result}async getInvestorCategorization(e){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:e})).result}}const W={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"}}},it={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"}},ot={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"}},lt={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"}}},ct={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"}},dt={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"}},ut={[V.Default]:W,[V.Corporate]:it,[V.Fintech]:ot,[V.Healthcare]:lt,[V.Modern]:ct,[V.Minimal]:dt};function ge(t){return ut[t]||W}class mt{constructor(e){this.httpClient=e}async getThemeConfiguration(){var e;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return ge(V.Default);let n=s.result.preset?ge(s.result.preset):ge(V.Default);return 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:{...(e=n.darkMode)==null?void 0:e.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(n.applicantFormVisibleFields=s.result.applicantFormVisibleFields),n}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),ge(V.Default)}}async saveThemeConfiguration(e){await this.httpClient.post("Tenant","SaveThemeConfiguration",e)}getAvailablePresets(){return[{id:V.Default,name:"Default"},{id:V.Corporate,name:"Corporate"},{id:V.Fintech,name:"Fintech"},{id:V.Healthcare,name:"Healthcare"},{id:V.Modern,name:"Modern"},{id:V.Minimal,name:"Minimal"}]}getPreviewTheme(e,s){const n=ge(e);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 pt{constructor(){K(this,"listeners",new Map)}on(e,s){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(s),()=>{this.off(e,s)}}off(e,s){const n=this.listeners.get(e);n&&n.delete(s)}emit(e,s){const n=this.listeners.get(e);n&&n.forEach(a=>{try{a(s)}catch(i){console.error(`Error in event listener for "${e}":`,i)}})}clear(){this.listeners.clear()}clearEvent(e){this.listeners.delete(e)}}class ht{constructor(){K(this,"events",new pt);K(this,"_applicantId",null);K(this,"_progress",null);K(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var e;return((e=this._progress)==null?void 0:e.currentStep)||null}get steps(){var e;return((e=this._progress)==null?void 0:e.stepInfoList)||[]}get status(){var e;return((e=this._progress)==null?void 0:e.status)||se.None}get workflowResult(){var e;return((e=this._progress)==null?void 0:e.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===se.Finished}get isOnHold(){return this.status===se.OnHold}get isInProgress(){return this.status===se.InProgress}setApplicantId(e){this._applicantId=e}updateProgress(e){var n,a;const s=(n=this._progress)==null?void 0:n.currentStep;this._progress=e,this._applicantId=e.applicantId,this._error=null,this.events.emit("progressUpdated",e),(s==null?void 0:s.order)!==((a=e.currentStep)==null?void 0:a.order)&&this.events.emit("stepChanged",e.currentStep),this.events.emit("statusChanged",e.status),e.status===se.Finished&&e.workflowResult&&this.events.emit("completed",e.workflowResult)}setError(e){this._error=e,this.events.emit("error",e)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(e){return this.events.on("progressUpdated",e)}onStepChanged(e){return this.events.on("stepChanged",e)}onStatusChanged(e){return this.events.on("statusChanged",e)}onError(e){return this.events.on("error",e)}onCompleted(e){return this.events.on("completed",e)}clearListeners(){this.events.clear()}}class gt{constructor(){K(this,"handlers",new Map)}registerHandler(e,s){this.handlers.set(e,s)}getHandler(e){return this.handlers.get(e)}hasHandler(e){return this.handlers.has(e)}async loadStepData(e,s){const n=this.getHandler(e);if(!n)throw new Error(`No handler registered for step action: ${M[e]}`);return n.loadData(s)}async submitStepData(e,s){const n=this.getHandler(e);if(!n)throw new Error(`No handler registered for step action: ${M[e]}`);return n.submitData(s)}}class xt{constructor(e,s,n,a,i,o,c,d){K(this,"state");K(this,"stepRouter");this.applicantService=e,this.questionnaireService=s,this.uploadDocumentService=n,this.appropriatenessTestService=a,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=d,this.state=new ht,this.stepRouter=new gt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(M.Questionaries,{loadData:e=>this.questionnaireService.getQuestionnaire(e),submitData:async e=>{await this.questionnaireService.fillQuestionnaire(e)}}),this.stepRouter.registerHandler(M.UploadDocument,{loadData:e=>this.uploadDocumentService.getUploadDocument(e),submitData:e=>this.uploadDocumentService.fillUploadDocument(e)}),this.stepRouter.registerHandler(M.AppropriatenessTest,{loadData:e=>this.appropriatenessTestService.getAppropriatenessTest(e),submitData:async e=>{await this.appropriatenessTestService.fillAppropriatenessTest(e)}}),this.stepRouter.registerHandler(M.Overview,{loadData:e=>this.overviewService.getOverviewData(e),submitData:e=>this.overviewService.passOverview(e.applicantId)}),this.stepRouter.registerHandler(M.RiskScoring,{loadData:e=>this.riskScoringService.getRiskCriterias(e),submitData:async e=>{await this.riskScoringService.submitRiskScoring(e)}}),this.stepRouter.registerHandler(M.IdentitySdk,{loadData:async e=>({applicantId:e,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(M.InvestorCategorization,{loadData:e=>this.investorCategorizationService.getInvestorCategorization(e),submitData:async e=>{await this.investorCategorizationService.setInvestorCategorization(e)}}),this.stepRouter.registerHandler(M.ManualReview,{loadData:async e=>({applicantId:e,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(M.AdditionalData,{loadData:async e=>({applicantId:e,message:"Additional data required"}),submitData:async()=>{}})}async initialize(e){try{this.state.setApplicantId(e);const s=await this.applicantService.getProgress(e);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 e=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(e),e}catch(e){throw this.state.setError(e),e}}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(e){throw this.state.setError(e),e}}async submitCurrentStep(e){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,e),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(e){throw this.state.setError(e),e}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function Ce(t,e){return new Promise((s,n)=>{if(e&&document.getElementById(e)){s();return}const a=document.createElement("script");a.src=t,e&&(a.id=e),a.async=!0,a.onload=()=>s(),a.onerror=()=>n(new Error(`Failed to load script: ${t}`)),document.head.appendChild(a)})}function ar(t){return!!document.getElementById(t)}function ir(t){const e=document.getElementById(t);e&&e.remove()}class ft{constructor(e){K(this,"sdk",null);K(this,"config");this.config=e}async loadSDK(){await Ce("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(e){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${e}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(e){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&e(s)})}onError(e){this.sdk&&this.sdk.on("idCheck.onError",e)}}class yt{constructor(e){K(this,"sdk",null);K(this,"config");this.config=e}async loadSDK(){await Ce("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(e){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:e,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 bt{constructor(e){K(this,"sardineContext",null);K(this,"config");K(this,"sessionKey");this.config=e,this.sessionKey=e.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const s=Math.random()*16|0;return(e==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:e,region:s}=this.config;if(e==="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((e,s)=>{if(window._Sardine){e();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"),e()},a.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(a,i):document.head.appendChild(a)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const e=this.getSardineHost(),{clientId:s,environment:n,flow:a,enableBiometrics:i,enablePortScanning:o}=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:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,u)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",u);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(e),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(e){throw console.error("[SardinAI] Initialization failed:",e),e}}addNoScriptFallback(e){const s=document.createElement("noscript"),n=document.createElement("img"),{clientId:a,flow:i}=this.config;n.src=`https://${e}/v1/a.png?clientId=${a}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,n.style.display="none",s.appendChild(n),document.body.appendChild(s)}updateConfig(e){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}e.sessionKey&&(this.sessionKey=e.sessionKey),this.sardineContext.updateConfig({...e,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 pe{static createProvider(e,s){switch(e){case re.Sumsub:return new ft(s);case re.Onfido:return new yt(s);case re.SardinAI:return new bt(s);default:throw new Error(`Unsupported identity provider: ${e}`)}}static parseProviderConfig(e,s,n){var a;switch(e){case re.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case re.Onfido:return{token:s.token||s.sdkToken};case re.SardinAI:const i=((a=n==null?void 0:n.identityProviders)==null?void 0:a.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${e}`)}}}class vt{constructor(e){K(this,"currentTheme",W);K(this,"customStyleElement",null);K(this,"container");this.container=e||document.documentElement}applyTheme(e){this.currentTheme=this.mergeWithDefault(e),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(e){var n;const s={primary:e.primary,"primary-hover":e.primaryHover,"primary-light":e.primaryLight,"primary-dark":e.primaryDark,secondary:e.secondary,"secondary-hover":e.secondaryHover,success:e.success,warning:e.warning,danger:e.danger,info:e.info,background:e.background,surface:e.surface,border:e.border,"text-primary":e.textPrimary,"text-secondary":e.textSecondary,"text-muted":e.textMuted};Object.entries(s).forEach(([a,i])=>{this.container.style.setProperty(`--metakyc-${a}`,i)}),(n=this.currentTheme.darkMode)!=null&&n.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(e){Object.entries(e).forEach(([s,n])=>{if(n){const a=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)}})}applyTypography(e){e&&(e.fontFamily&&this.container.style.setProperty("--metakyc-font-family",e.fontFamily),e.headingFont&&this.container.style.setProperty("--metakyc-heading-font",e.headingFont),e.fontSize&&Object.entries(e.fontSize).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,n)}),e.fontWeight&&Object.entries(e.fontWeight).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,n.toString())}))}applySpacing(e){e&&Object.entries(e).forEach(([s,n])=>{const a=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)})}injectCustomCSS(e){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=e,document.head.appendChild(this.customStyleElement)}mergeWithDefault(e){var s;return{name:e.name||W.name,title:e.title||W.title,logo:{...W.logo,...e.logo},colors:{...W.colors,...e.colors},typography:e.typography?{...W.typography,...e.typography}:W.typography,spacing:e.spacing?{...W.spacing,...e.spacing}:W.spacing,customCSS:e.customCSS,darkMode:e.darkMode?{colors:{...(s=W.darkMode)==null?void 0:s.colors,...e.darkMode.colors}}:W.darkMode,applicantFormVisibleFields:e.applicantFormVisibleFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(W)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ae=l.createContext(null),or=({config:t,children:e})=>{const[s,n]=l.useState(null),a=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const d=new Ge(t),u=new Ze(d),x=new Je(d),f=new Xe(d),g=new et(d),b=new tt(d),p=new rt(d),y=new st(d),h=new nt(d),m=new at(d),N=new mt(d),k=new vt;return{httpClient:d,applicantService:u,questionnaireService:x,uploadDocumentService:f,appropriatenessTestService:g,overviewService:b,riskScoringService:p,identityService:y,baseInformationService:h,investorCategorizationService:m,themeService:N,themeManager:k}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new xt(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(a.current||i.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"),o.themeManager.applyTheme(t.theme),n(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const u=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(u),n(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",u)}catch(u){console.warn("[MetaKYC] Failed to load theme, using default:",u),n(o.themeManager.getCurrentTheme()),i.current=!0}finally{a.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),r.jsx(Ae.Provider,{value:c,children:e})};function ee(){const t=l.useContext(Ae);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function wt(t){return new Promise((e,s)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const i=n.result.split(",")[1];e(i)},n.onerror=a=>s(a)})}function lr(t,e){return t.size<=e}function cr(t,e){return e.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 ve(t){if(t===0)return"0 Bytes";const e=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return Math.round(t/Math.pow(e,n)*100)/100+" "+s[n]}function dr(t){return t}function Y(...t){return t.filter(Boolean).join(" ")}const xe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function jt(t){try{localStorage.setItem(xe.APPLICANT_ID,t.toString())}catch(e){console.warn("Failed to save applicant ID to storage:",e)}}function kt(){try{const t=localStorage.getItem(xe.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function St(){try{localStorage.removeItem(xe.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Nt(t){try{localStorage.setItem(xe.WORKFLOW_STATE,JSON.stringify(t))}catch(e){console.warn("Failed to save workflow state to storage:",e)}}function ur(){try{const t=localStorage.getItem(xe.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Ct(){try{localStorage.removeItem(xe.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function mr(){St(),Ct()}function At(t){const{createOrchestrator:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(null),u=t||kt();l.useEffect(()=>{d.current||(d.current=e())},[e]),l.useEffect(()=>{var k;s&&u&&(jt(u),Nt({applicantId:u,currentStepOrder:(k=s.currentStep)==null?void 0:k.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,u]);const x=l.useRef(!1),f=l.useRef(!1),g=l.useCallback(async()=>{if(!(!u||!d.current)){if(x.current){console.log("[Workflow] Load already in progress, skipping...");return}x.current=!0,i(!0),c(null);try{const k=await d.current.initialize(u);n(k),f.current=!0}catch(k){c(k)}finally{i(!1),x.current=!1}}},[u]);l.useEffect(()=>{u&&!f.current&&g()},[u,g]);const b=l.useCallback(async()=>{if(d.current){if(x.current){console.log("[Workflow] Refresh already in progress, skipping...");return}x.current=!0,i(!0),c(null);try{const k=await d.current.refreshProgress();n(k)}catch(k){c(k)}finally{i(!1),x.current=!1}}},[]),p=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const k=await d.current.moveToNextStep();n(k)}catch(k){c(k)}finally{i(!1)}}},[]),y=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const k=await d.current.moveToPreviousStep();n(k)}catch(k){c(k)}finally{i(!1)}}},[]),h=l.useCallback(async k=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(k);const j=await d.current.refreshProgress();n(j)}catch(j){throw c(j),j}finally{i(!1)}}},[]),m=Ie.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((k,j)=>k.order-j.order):[],[s==null?void 0:s.stepInfoList]),N=Ie.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:u,currentStep:(s==null?void 0:s.currentStep)||null,steps:m,status:(s==null?void 0:s.status)||se.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:N,isLoading:a,error:o,isComplete:(s==null?void 0:s.status)===se.Finished,isOnHold:(s==null?void 0:s.status)===se.OnHold,refreshProgress:b,moveToNext:p,moveBack:y,submitCurrentStep:h,orchestrator:d.current}}function Et(t){const{questionnaireService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=l.useRef(!1),f=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[Questionnaire] Load already in progress, skipping...");return}x.current=!0,i(!0),u(null);try{const p=await e.getQuestionnaire(t);n(p),f.current=t}catch(p){u(p)}finally{i(!1),x.current=!1}}},[t,e]);l.useEffect(()=>{t&&f.current!==t&&g()},[t]);const b=l.useCallback(async p=>{c(!0),u(null);try{return await e.fillQuestionnaire(p)}catch(y){throw u(y),y}finally{c(!1)}},[e]);return{questionnaire:s,isLoading:a,isSubmitting:o,error:d,load:g,submit:b}}function It(t){const{uploadDocumentService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(0),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[UploadDocument] Load already in progress, skipping...");return}g.current=!0,i(!0),f(null);try{const h=await e.getUploadDocument(t);n(h),b.current=t}catch(h){f(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(0),f(null);try{await e.fillUploadDocument(h),u(100)}catch(m){throw f(m),m}finally{c(!1)}},[e]);return{uploadDocument:s,isLoading:a,isSubmitting:o,uploadProgress:d,error:x,load:p,submit:y}}function pr(t){const{appropriatenessTestService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const h=await e.getAppropriatenessTest(t);n(h),b.current=t}catch(h){u(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(null);try{const m=await e.fillAppropriatenessTest(h);return f(m),m}catch(m){throw u(m),m}finally{c(!1)}},[e]);return{test:s,result:x,isLoading:a,isSubmitting:o,error:d,load:p,submit:y}}function Rt(t){const{overviewService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=l.useRef(!1),f=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[Overview] Load already in progress, skipping...");return}x.current=!0,i(!0),u(null);try{const p=await e.getOverviewData(t);n(p),f.current=t}catch(p){u(p)}finally{i(!1),x.current=!1}}},[t,e]);l.useEffect(()=>{t&&f.current!==t&&g()},[t]);const b=l.useCallback(async()=>{if(t){c(!0),u(null);try{await e.passOverview(t)}catch(p){throw u(p),p}finally{c(!1)}}},[t,e]);return{overview:s,isLoading:a,isSubmitting:o,error:d,load:g,passOverview:b}}function Dt(t){const{identityService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async(g,b)=>{if(t){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const p={applicantId:t,restart:!1,redirectUrl:g||"",ttl:b||604800};console.log("Identity request input:",p);const y=await e.identityRequest(p);return console.log("Identity request result:",y),n(y),y}catch(p){throw c(p),p}finally{i(!1),d.current=!1}}},[t,e]),x=l.useCallback(async(g,b)=>{if(t){i(!0),c(null);try{const p={applicantId:t,restart:!1,redirectUrl:g,ttl:b},y=await e.identityCompanyRequest(p);return n(y),y}catch(p){throw c(p),p}finally{i(!1)}}},[t,e]),f=l.useCallback(async()=>{if(t){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",g);const b=await e.identityRequest(g);return console.log("Restart identity result:",b),n(b),b}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[t,e]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:a,error:o,requestIdentity:u,requestCompanyIdentity:x,restartIdentity:f}}function Pt(t){const{riskScoringService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[RiskScoring] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const h=await e.getRiskCriterias(t);n(h),b.current=t}catch(h){u(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(null);try{const m=await e.submitRiskScoring(h);return f(m),m}catch(m){throw u(m),m}finally{c(!1)}},[e]);return{criteria:s,result:x,isLoading:a,isSubmitting:o,error:d,load:p,submit:y}}function Ft(){const{applicantService:t,config:e}=ee(),[s,n]=l.useState(!1),[a,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){const p=Math.random()*16|0;return(b==="x"?p:p&3|8).toString(16)}),u=l.useCallback(async b=>{var p;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,n(!0),i(null);try{if(b.applicantAdditionalDatas||(b.applicantAdditionalDatas=[]),(p=e.identityProviders)!=null&&p.sardinai){const h=d();console.log("[SardinAI] Generated session key:",h),b.applicantAdditionalDatas.push({paramName:"sessionKey",value:h})}return await t.createApplicant(b)}catch(y){throw i(y),y}finally{n(!1),o.current=!1}},[t,e]),x=l.useCallback(async b=>{n(!0),i(null);try{return await t.createCompanyApplicant(b)}catch(p){throw i(p),p}finally{n(!1)}},[t]),f=l.useCallback(async b=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,n(!0),i(null);try{return await t.getApplicantData(b)}catch(p){throw i(p),p}finally{n(!1),c.current=!1}},[t]),g=l.useCallback(async b=>{n(!0),i(null);try{await t.stopProgress(b)}catch(p){throw i(p),p}finally{n(!1)}},[t]);return{isLoading:s,error:a,createApplicant:u,createCompanyApplicant:x,getApplicantData:f,stopProgress:g}}const _=({children:t,variant:e="primary",size:s="md",isLoading:n=!1,disabled:a,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},u={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return r.jsxs("button",{className:Y(c,d[e],u[s],i),disabled:a||n,...o,children:[n&&r.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:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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]})},J=l.forwardRef(({label:t,error:e,helperText:s,leftIcon:n,rightIcon:a,className:i,...o},c)=>r.jsxs("div",{className:"w-full",children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[n&&r.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:n}),r.jsx("input",{ref:c,className:Y("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",e?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",n?"pl-10":"",a?"pr-10":"",i),...o}),a&&r.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:a})]}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e}),!e&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));J.displayName="Input";const F=({children:t,className:e,...s})=>r.jsx("div",{className:Y("metakyc-card rounded-xl shadow-sm border",e),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),Q=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4 border-b",e),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),L=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4",e),...s,children:t}),X=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4 border-t",e),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),oe=({children:t,variant:e="default",className:s,...n})=>{const a={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return r.jsx("span",{className:Y("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",a[e],s),...n,children:t})},ne=({size:t="md",className:e,...s})=>{const n={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return r.jsx("div",{className:Y("flex items-center justify-center",e),...s,children:r.jsxs("svg",{className:Y("animate-spin text-primary-500",n[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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"})]})})},le=l.forwardRef(({label:t,error:e,helperText:s,options:n,placeholder:a,className:i,...o},c)=>r.jsxs("div",{className:"w-full",children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("select",{ref:c,className:Y("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",e?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...o,children:[a&&r.jsx("option",{value:"",disabled:!0,children:a},"__placeholder__"),n.map((d,u)=>r.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${u}`))]}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e}),!e&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));le.displayName="Select";const Lt=({label:t,value:e,onChange:s,options:n,placeholder:a="Select...",disabled:i=!1,required:o=!1})=>{const[c,d]=l.useState(!1),[u,x]=l.useState(""),f=l.useRef(null);l.useEffect(()=>{const h=m=>{f.current&&!f.current.contains(m.target)&&(d(!1),x(""))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const g=n.filter(h=>h.label.toLowerCase().includes(u.toLowerCase())),b=h=>{i||(e.includes(h)?s(e.filter(m=>m!==h)):s([...e,h]))},p=(h,m)=>{m.stopPropagation(),i||s(e.filter(N=>N!==h))},y=h=>{var m;return((m=n.find(N=>N.value===h))==null?void 0:m.label)||h};return r.jsxs("div",{className:"w-full",ref:f,children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&r.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[r.jsxs("div",{onClick:()=>!i&&d(!c),className:Y("min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[e.length===0?r.jsx("span",{className:"text-gray-400 dark:text-gray-500 leading-6",children:a}):r.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:e.map(h=>r.jsxs("span",{className:"inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[y(h),!i&&r.jsx("button",{type:"button",onClick:m=>p(h,m),className:"hover:text-blue-600 dark:hover:text-blue-200 text-base leading-none -mr-0.5",children:"×"})]},h))}),r.jsx("span",{className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&r.jsxs("div",{className:"absolute z-50 w-full mt-1 rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-lg",children:[r.jsx("div",{className:"p-2 border-b border-gray-100 dark:border-gray-700",children:r.jsx("input",{type:"text",value:u,onChange:h=>x(h.target.value),placeholder:"Search...",autoFocus:!0,onClick:h=>h.stopPropagation(),className:"w-full px-2 py-1.5 text-sm rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500"})}),r.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:g.length===0?r.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):g.map(h=>r.jsxs("li",{onClick:()=>b(h.value),className:Y("flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",e.includes(h.value)&&"bg-blue-50 dark:bg-blue-900/20"),children:[r.jsx("input",{type:"checkbox",checked:e.includes(h.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),r.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:h.label})]},h.value))}),e.length>0&&r.jsx("div",{className:"p-2 border-t border-gray-100 dark:border-gray-700",children:r.jsxs("button",{type:"button",onClick:()=>{s([]),x("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",e.length," selected)"]})})]})]})]})},Tt=({label:t,error:e,accept:s,multiple:n=!1,maxSize:a,onChange:i,value:o=[],className:c})=>{const[d,u]=l.useState(!1),x=l.useRef(null),f=m=>{if(!m)return;const N=Array.from(m);if(a&&N.filter(j=>j.size>a).length>0){const j=ve(a);alert(`Some files exceed the maximum size of ${j}`);return}i==null||i(n?[...o,...N]:[N[0]])},g=m=>{m.preventDefault(),u(!0)},b=()=>{u(!1)},p=m=>{m.preventDefault(),u(!1),f(m.dataTransfer.files)},y=()=>{var m;(m=x.current)==null||m.click()},h=m=>{const N=o.filter((k,j)=>j!==m);i==null||i(N)};return r.jsxs("div",{className:Y("w-full",c),children:[t&&r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),r.jsxs("div",{className:Y("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",e&&"border-danger-500"),onDragOver:g,onDragLeave:b,onDrop:p,onClick:y,children:[r.jsx("input",{ref:x,type:"file",className:"hidden",accept:s,multiple:n,onChange:m=>f(m.target.files)}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:r.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),a&&r.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",ve(a)]})]})]}),o.length>0&&r.jsx("div",{className:"mt-3 space-y-2",children:o.map((m,N)=>r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[r.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),r.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:m.name}),r.jsxs("span",{className:"text-xs text-gray-500",children:["(",ve(m.size),")"]})]}),r.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),h(N)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:r.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},N))}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e})]})},Mt=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:e,className:s,...n},a)=>r.jsxs("div",{className:"w-full",children:[n.label&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[n.label,n.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:t,onChange:i=>e==null?void 0:e(i.target.value),className:Y("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),r.jsx(J,{ref:a,type:"tel",className:Y("flex-1",s),...n,label:""})]}),n.error&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:n.error})]}));Mt.displayName="PhoneInput";const Re=(t,e,s)=>{if(t&&"reportValidity"in t){const n=U.get(s,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Se=(t,e)=>{for(const s in e.fields){const n=e.fields[s];n&&n.ref&&"reportValidity"in n.ref?Re(n.ref,s,t):n&&n.refs&&n.refs.forEach(a=>Re(a,s,t))}},De=(t,e)=>{e.shouldUseNativeValidation&&Se(t,e);const s={};for(const n in t){const a=U.get(e.fields,n),i=Object.assign(t[n]||{},{ref:a&&a.ref});if(hr(e.names||Object.keys(t),n)){const o=Object.assign({},U.get(s,n));U.set(o,"root",i),U.set(s,n,o)}else U.set(s,n,i)}return s},hr=(t,e)=>{const s=Pe(e);return t.some(n=>Pe(n).match(`^${s}\\.\\d+`))};function Pe(t){return t.replace(/\]|\[/g,"")}function Ot(t,e,s){function n(c,d){var u;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(u=c._zod).traits??(u.traits=new Set),c._zod.traits.add(t),e(c,d);for(const x in o.prototype)x in c||Object.defineProperty(c,x,{value:o.prototype[x].bind(c)});c._zod.constr=o,c._zod.def=d}const a=(s==null?void 0:s.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:t});function o(c){var d;const u=s!=null&&s.Parent?new i:this;n(u,c),(d=u._zod).deferred??(d.deferred=[]);for(const x of u._zod.deferred)x();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>{var d,u;return s!=null&&s.Parent&&c instanceof s.Parent?!0:(u=(d=c==null?void 0:c._zod)==null?void 0:d.traits)==null?void 0:u.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class gr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const xr={};function zt(t){return xr}function fr(t,e){return typeof e=="bigint"?e.toString():e}const Bt=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function be(t){return typeof t=="string"?t:t==null?void 0:t.message}function _t(t,e,s){var a,i,o,c,d,u;const n={...t,path:t.path??[]};if(!t.message){const x=be((o=(i=(a=t.inst)==null?void 0:a._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??be((c=e==null?void 0:e.error)==null?void 0:c.call(e,t))??be((d=s.customError)==null?void 0:d.call(s,t))??be((u=s.localeError)==null?void 0:u.call(s,t))??"Invalid input";n.message=x}return delete n.inst,delete n.continue,e!=null&&e.reportInput||delete n.input,n}const Ut=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,fr,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},yr=Ot("$ZodError",Ut),$t=Ot("$ZodError",Ut,{Parent:Error}),br=t=>(e,s,n,a)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:s,issues:[]},i);if(o instanceof Promise)throw new gr;if(o.issues.length){const c=new((a==null?void 0:a.Err)??t)(o.issues.map(d=>_t(d,i,zt())));throw Bt(c,a==null?void 0:a.callee),c}return o.value},vr=br($t),wr=t=>async(e,s,n,a)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:s,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new((a==null?void 0:a.Err)??t)(o.issues.map(d=>_t(d,i,zt())));throw Bt(c,a==null?void 0:a.callee),c}return o.value},jr=wr($t);function Fe(t,e){try{var s=t()}catch(n){return e(n)}return s&&s.then?s.then(void 0,e):s}function kr(t,e){for(var s={};t.length;){var n=t[0],a=n.code,i=n.message,o=n.path.join(".");if(!s[o])if("unionErrors"in n){var c=n.unionErrors[0].errors[0];s[o]={message:c.message,type:c.code}}else s[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(x){return x.errors.forEach(function(f){return t.push(f)})}),e){var d=s[o].types,u=d&&d[n.code];s[o]=U.appendErrors(o,e,s,a,u?[].concat(u,n.message):n.message)}t.shift()}return s}function Sr(t,e){for(var s={};t.length;){var n=t[0],a=n.code,i=n.message,o=n.path.join(".");if(!s[o])if(n.code==="invalid_union"&&n.errors.length>0){var c=n.errors[0][0];s[o]={message:c.message,type:c.code}}else s[o]={message:i,type:a};if(n.code==="invalid_union"&&n.errors.forEach(function(x){return x.forEach(function(f){return t.push(f)})}),e){var d=s[o].types,u=d&&d[n.code];s[o]=U.appendErrors(o,e,s,a,u?[].concat(u,n.message):n.message)}t.shift()}return s}function Kt(t,e,s){if(s===void 0&&(s={}),function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def}(t))return function(n,a,i){try{return Promise.resolve(Fe(function(){return Promise.resolve(t[s.mode==="sync"?"parse":"parseAsync"](n,e)).then(function(o){return i.shouldUseNativeValidation&&Se({},i),{errors:{},values:s.raw?Object.assign({},n):o}})},function(o){if(function(c){return Array.isArray(c==null?void 0:c.issues)}(o))return{values:{},errors:De(kr(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if(function(n){return"_zod"in n&&typeof n._zod=="object"}(t))return function(n,a,i){try{return Promise.resolve(Fe(function(){return Promise.resolve((s.mode==="sync"?vr:jr)(t,n,e)).then(function(o){return i.shouldUseNativeValidation&&Se({},i),{errors:{},values:s.raw?Object.assign({},n):o}})},function(o){if(function(c){return c instanceof yr}(o))return{values:{},errors:De(Sr(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function qt(t){return ce.z.object({questionResults:ce.z.any()}).passthrough()}function Nr(t){let e=ce.z.array(ce.z.instanceof(File));if(t.isRequired?e=e.min(1,`${t.displayName} is required`):e=e.optional(),t.multipleFile||(e=e.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(e=e.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());e=e.refine(n=>n?n.every(a=>s.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-2)):a.type===i)):!0,{message:"Invalid file type"})}return e}function Cr(t){const e={};return t.uploadDocumentFiles.forEach(s=>{const n=`file_${s.id}`;e[n]=Nr(s)}),ce.z.object(e)}function Ht(t){return ce.z.any()}function Ar(t){return ce.z.string().min(1,"This question is required")}function Er(t){const e={};return t.appropriatenessQuestions.forEach(s=>{const n=`question_${s.id}`;e[n]=Ar()}),ce.z.object(e)}const Ir=ce.z.any(),Vt=({applicantId:t,onComplete:e,onBack:s})=>{const{questionnaire:n,isLoading:a,isSubmitting:i,error:o,submit:c}=Et(t),d=l.useMemo(()=>n?{questionResults:n.questionGroups.map(y=>y.questions.map(h=>({questionId:h.id,values:[]})))}:{questionResults:[]},[n]),u=n?qt():null,{control:x,handleSubmit:f,formState:{errors:g}}=U.useForm({resolver:u?Kt(u):void 0,defaultValues:d}),b=async p=>{if(n)try{console.log("Form submitted with data:",p);const y=n.questionGroups.flatMap((m,N)=>m.questions.map((k,j)=>{var T,P,C;return{questionId:k.id,values:((C=(P=(T=p.questionResults)==null?void 0:T[N])==null?void 0:P[j])==null?void 0:C.values)||[]}}));console.log("Question results to submit:",y);const h={applicantId:t,questionnarieId:n.id,questionResults:y};console.log("Final input:",h),await c(h),e==null||e()}catch(y){console.error("Error submitting questionnaire:",y)}};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",o.message]})})}):n?r.jsx("form",{onSubmit:f(b),children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),r.jsx(L,{className:"space-y-8",children:n.questionGroups.flatMap((p,y)=>p.questions.map((h,m)=>{const k=h.defaultAnswers&&h.defaultAnswers.length>0?h.showAsDropdown?h.canMultipleAnswer?"multi-select":"single-select":h.canMultipleAnswer?"checkbox":"radio":"text";return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[h.text,h.isRequired&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),k==="text"&&r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values.0`,render:({field:j})=>{var T,P,C,S;return r.jsx(J,{value:j.value||"",onChange:j.onChange,onBlur:j.onBlur,name:j.name,placeholder:"Enter your answer...",error:(S=(C=(P=(T=g.questionResults)==null?void 0:T[y])==null?void 0:P[m])==null?void 0:C.values)==null?void 0:S.message})}}),(k==="single-select"||k==="radio")&&r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values.0`,render:({field:j})=>{var T,P,C,S;return r.jsx(le,{value:j.value||"",onChange:j.onChange,onBlur:j.onBlur,name:j.name,options:h.defaultAnswers.map(I=>({value:I,label:I})),placeholder:"Select an option...",error:(S=(C=(P=(T=g.questionResults)==null?void 0:T[y])==null?void 0:P[m])==null?void 0:C.values)==null?void 0:S.message})}}),(k==="checkbox"||k==="multi-select")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:"Choose one or more options"}),r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values`,render:({field:{value:j=[],onChange:T}})=>r.jsx("div",{className:"space-y-2",children:h.defaultAnswers.map((P,C)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:Array.isArray(j)&&j.includes(P),onChange:S=>{const I=Array.isArray(j)?j:[],O=S.target.checked?[...I,P]:I.filter(H=>H!==P);T(O)},className:"h-4 w-4 text-primary-500 rounded border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:P})]},`answer-${y}-${m}-${C}`))})})]})]},h.id)}))}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,onClick:()=>{console.log("Continue button clicked"),console.log("Form errors:",g)},children:"Continue"})]}),o&&r.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded",children:r.jsxs("p",{className:"text-red-600 text-sm",children:["Error: ",o.message]})})]})}):null},Yt=({applicantId:t,onComplete:e,onBack:s})=>{const{uploadDocument:n,isLoading:a,isSubmitting:i,error:o,submit:c}=It(t),[d,u]=l.useState({}),x=async f=>{if(f.preventDefault(),!n)return;const g=await Promise.all(n.uploadDocumentFiles.map(async p=>{const y=d[p.id]||[],h=await Promise.all(y.map(async m=>({fileName:m.name,fileData:await wt(m)})));return{uploadDocumentFileId:p.id,valueList:h}})),b={applicantId:t,uploadDocumentId:n.id,uploadDocumentResults:g};await c(b),e==null||e()};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",o.message]})})}):n?r.jsx("form",{onSubmit:x,children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),r.jsx(L,{className:"space-y-6",children:n.uploadDocumentFiles.map(f=>r.jsx(Tt,{label:f.displayName,accept:f.allowedTypes,multiple:f.multipleFile,maxSize:f.maxEachFileSizeByte,value:d[f.id]||[],onChange:g=>{u(b=>({...b,[f.id]:g}))}},f.id))}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,children:"Continue"})]})]})}):null},Wt=({applicantId:t,onComplete:e,onBack:s})=>{const{overview:n,isLoading:a,isSubmitting:i,error:o,passOverview:c}=Rt(t),d=async()=>{await c(),e==null||e()};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",o.message]})})}):n?r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.title||"Overview"}),n.description&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.description})]}),r.jsx(L,{className:"space-y-8",children:n.steps&&n.steps.length>0?n.steps.sort((u,x)=>u.order-x.order).map(u=>r.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[r.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:r.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:u.order+1})}),r.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[r.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:u.title}),u.description&&r.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:u.description})]})]},u.order)):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{onClick:d,isLoading:i,children:"Continue"})]})]}):null},Qt=({applicantId:t,onComplete:e,onBack:s})=>{const{criteria:n,isLoading:a,isSubmitting:i,error:o,submit:c}=Pt(t),[d,u]=l.useState(!1),x=l.useMemo(()=>!n||n.length===0?{criteriaValueInputs:[]}:{criteriaValueInputs:n.map(m=>({riskCriteriaId:m.id,values:[""]}))},[n]),f=n&&n.length>0?Ht():null,{control:g,handleSubmit:b,formState:{errors:p}}=U.useForm({resolver:f?Kt(f):void 0,defaultValues:x});l.useEffect(()=>{!a&&n&&n.length===0&&!d&&!i&&(u(!0),c({applicantId:t,criteriaValueInputs:[]}).then(()=>e==null?void 0:e()).catch(console.error))},[a,n,d,i,c,t,e]);const y=async m=>{if(n)try{console.log("Risk scoring form submitted:",m),console.log("Criteria metadata:",n);const N=m.criteriaValueInputs.map((j,T)=>{const P=j.values||[],C=Array.isArray(P)?P.filter(S=>S&&S.trim()):P&&P.toString().trim()?[P.toString()]:[];return C.length===0?null:{riskCriteriaId:n[T].id,values:C}}).filter(j=>j!==null);console.log("Risk scoring criteriaValueInputs to submit:",N);const k={applicantId:t,criteriaValueInputs:N};console.log("Final risk scoring input:",k),await c(k),console.log("Risk scoring submitted successfully!"),e==null||e()}catch(N){throw console.error("Error submitting risk scoring:",N),N}},h=m=>m.builtInType===1?"country":!m.defaultValues||m.defaultValues.length===0?"text":m.multipleValue?"checkbox":"radio";return a?r.jsx(F,{children:r.jsxs(L,{children:[r.jsx(ne,{className:"my-8"}),r.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading risk scoring criteria..."})]})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",o.message]})})}):!a&&n&&n.length===0?r.jsx(F,{children:r.jsxs(L,{children:[r.jsx(ne,{className:"my-8"}),r.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400",children:"No risk scoring criteria required. Moving to next step..."})]})}):n?r.jsx("form",{onSubmit:b(y),children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please answer the following questions for risk evaluation"})]}),r.jsx(L,{className:"space-y-8",children:n.map((m,N)=>{var j,T,P;const k=h(m);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[m.displayName,m.isRequired&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),m.description&&r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m.description}),k==="text"&&r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:C})=>{var S,I,O;return r.jsx(J,{...C,value:C.value||"",type:m.valueDataType===we.DigitOnly?"number":"text",placeholder:"Enter your answer...",error:(O=(I=(S=p.criteriaValueInputs)==null?void 0:S[N])==null?void 0:I.values)==null?void 0:O.message,onKeyDown:H=>{m.valueDataType===we.DigitOnly&&["e","E","+","-","."].includes(H.key)&&H.preventDefault()}})}}),k==="radio"&&m.defaultValues&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Choose one option"}),r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:{value:C,onChange:S}})=>r.jsx("div",{className:"space-y-2",children:m.defaultValues.map((I,O)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"radio",checked:C===I,onChange:()=>S(I),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:I})]},`${N}-${O}`))})})]}),k==="checkbox"&&m.defaultValues&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Choose one or more options"}),r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values`,render:({field:{value:C=[],onChange:S}})=>r.jsx("div",{className:"space-y-2",children:m.defaultValues.map((I,O)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:Array.isArray(C)&&C.includes(I),onChange:H=>{const $=Array.isArray(C)?C:[],R=H.target.checked?[...$,I]:$.filter(E=>E!==I);S(R)},className:"h-4 w-4 text-primary-500 rounded border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:I})]},`${N}-${O}`))})})]}),k==="country"&&r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:C})=>{var S,I,O;return r.jsx(le,{...C,options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"}],placeholder:"Select a country...",error:(O=(I=(S=p.criteriaValueInputs)==null?void 0:S[N])==null?void 0:I.values)==null?void 0:O.message})}}),((P=(T=(j=p.criteriaValueInputs)==null?void 0:j[N])==null?void 0:T.values)==null?void 0:P.message)&&r.jsx("p",{className:"text-sm text-danger-500 mt-1",children:p.criteriaValueInputs[N].values.message})]},m.id)})}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,onClick:()=>{console.log("Risk scoring submit button clicked"),console.log("Form errors:",p)},children:"Continue"})]}),o&&r.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded",children:r.jsxs("p",{className:"text-red-600 text-sm",children:["Error: ",o.message]})})]})}):null},Gt=({applicantId:t,onComplete:e,onBack:s})=>{const{investorCategorizationService:n}=ee(),[a,i]=l.useState(null),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=async f=>{if(f.preventDefault(),a===null){u("Please select an investor type");return}c(!0),u(null);try{const g={applicantId:t,investorType:a};console.log("Submitting investor categorization:",g);const b=await n.setInvestorCategorization(g);console.log("Investor categorization result:",b),e==null||e()}catch(g){console.error("Error submitting investor categorization:",g),u(g.message||"Failed to submit investor categorization")}finally{c(!1)}};return r.jsx("form",{onSubmit:x,children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",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"})]}),r.jsxs(L,{className:"space-y-4",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),r.jsx("label",{className:`
|
|
1
|
+
"use strict";var er=Object.defineProperty;var tr=(t,e,s)=>e in t?er(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var K=(t,e,s)=>tr(t,typeof e!="symbol"?e+"":e,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const rr=require("axios"),l=require("react"),r=require("react/jsx-runtime"),U=require("react-hook-form"),ce=require("zod");function sr(t){const e=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(e,s,n.get?n:{enumerable:!0,get:()=>t[s]})}}return e.default=t,Object.freeze(e)}const Ie=sr(l);var M=(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))(M||{}),fe=(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))(fe||{}),se=(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))(se||{}),Le=(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))(Le||{}),Te=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Te||{}),ue=(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))(ue||{}),me=(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))(me||{}),Me=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Me||{}),Oe=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Oe||{}),re=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(re||{}),ze=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(ze||{}),ye=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(ye||{}),Be=(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))(Be||{}),_e=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(_e||{}),Ue=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))(Ue||{}),we=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Decimal=2]="Decimal",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(we||{}),$e=(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))($e||{}),Ke=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(Ke||{}),Z=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(Z||{}),qe=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(qe||{});const He=[{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"}],Ve=["firstName","lastName","email","phonenumber","dateOfBirth","street","streetNumber","zip","city","country","nationality","taxCountry","taxNumber"],nr=["firstName","lastName","title","email","dateOfBirth","phonenumber","mobileCountryCode","street","streetNumber","zip","city","country","nationality","otherNationality","defaultLanguage","taxCountry","placeOfBirth","countryOfBirth","salutation","educationLevel","occupation","taxNumber","externalRefId"],Ye={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},title:{label:"Title",type:"text"},email:{label:"Email",type:"email"},dateOfBirth:{label:"Date of Birth",type:"date"},phonenumber:{label:"Phone Number",type:"tel"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},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"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},defaultLanguage:{label:"Default Language",type:"select"},taxCountry:{label:"Tax Country",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},countryOfBirth:{label:"Country of Birth",type:"select"},salutation:{label:"Salutation",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"},taxNumber:{label:"Tax Number",type:"text"},externalRefId:{label:"External Reference ID",type:"text"}};var V=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(V||{});const We={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class Qe{constructor(e){this.config=e}build(e,s){const n=`${e}.${s}`;if(this.config.customPaths&&this.config.customPaths[n])return this.config.customPaths[n];switch(this.config.pattern){case"host-controller":return`/api/${e}/${s}`;case"application-service":return`/services/app/${this.getServiceName(e)}/${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(e){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[e]||e}}class ie extends Error{constructor(s,n,a,i,o){super(s);K(this,"response");this.code=n,this.details=a,this.validationErrors=i,this.name="MetaKYCError",this.response=o,Object.setPrototypeOf(this,ie.prototype)}}class he{static handleApiError(e){return new ie(e.message||"An unknown error occurred",e.code,e.details||void 0,e.validationErrors||void 0)}static handleAxiosError(e){if(e.response){const s=e.response.data;return s&&s.error?new ie(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,e.response):s&&s.result&&s.result.message?new ie(s.result.message,e.response.status,`HTTP ${e.response.status}: ${e.response.statusText}`,void 0,e.response):new ie((s==null?void 0:s.message)||e.message||"Request failed",e.response.status,`HTTP ${e.response.status}: ${e.response.statusText}`,void 0,e.response)}else return e.request?new ie("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ie(e.message||"An unexpected error occurred",0,e.toString())}static isMetaKYCError(e){return e instanceof ie}}class Ge{constructor(e){K(this,"axiosInstance");K(this,"endpointBuilder");K(this,"config");this.config={...We,...e},this.endpointBuilder=new Qe(this.config.endpoints),this.axiosInstance=rr.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(i=>setTimeout(i,1e3*n._retryCount)),this.axiosInstance(n)):Promise.reject(s)})}buildEndpoint(e,s){return this.endpointBuilder.build(e,s)}async get(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.get(a,{params:n});return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async post(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.post(a,n);return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async put(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.put(a,n);return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}async delete(e,s,n){try{const a=this.buildEndpoint(e,s),i=await this.axiosInstance.delete(a,{params:n});return this.handleResponse(i)}catch(a){throw he.handleAxiosError(a)}}handleResponse(e){const s=e.data;if(!s.success&&s.error)throw he.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class Ze{constructor(e){this.httpClient=e}async createApplicant(e){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",e)).result}async createCompanyApplicant(e){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",e)).result}async duplicateApplicant(e){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",e)).result}async getProgress(e){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:e})).result}async getProgressStatus(e){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:e})).result}async getApplicantData(e){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:e})).result}async getApplicantStatus(e){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:e})).result}async stopProgress(e){await this.httpClient.get("Applicant","StopProgress",{applicantId:e})}async progressStepBack(e){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:e})}async setLanguage(e,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:e,language:s})}async activateApplicant(e){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:e})}async deleteApplicant(e){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:e})}async checkApplicantExists(e){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:e})).result}}class Je{constructor(e){this.httpClient=e}async getQuestionnaire(e){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:e})).result}async fillQuestionnaire(e){return(await this.httpClient.post("Applicant","FillQuestionnarie",e)).result}}class Xe{constructor(e){this.httpClient=e}async getUploadDocument(e){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:e})).result}async fillUploadDocument(e){await this.httpClient.post("Applicant","FillUploadDocument",e)}async reviewUploadDocument(e){await this.httpClient.post("UploadDocument","ReviewUploadDocument",e)}}class et{constructor(e){this.httpClient=e}async getAppropriatenessTest(e){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:e})).result}async fillAppropriatenessTest(e){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",e)).result}}class tt{constructor(e){this.httpClient=e}async getOverviewData(e){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:e})).result}async passOverview(e){await this.httpClient.get("Applicant","PassOverview",{applicantId:e})}}class rt{constructor(e){this.httpClient=e}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(e){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:e})).result}async submitRiskScoring(e){return(await this.httpClient.post("Applicant","RiskScoringRequest",e)).result}}class st{constructor(e){this.httpClient=e}async identityRequest(e){console.log("[IdentityService] Calling IdentityRequest with input:",e);const s=await this.httpClient.post("Applicant","IdentityRequest",e);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(e){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",e)).result}async restartIdentityRequest(e){const s={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(e){const s={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class nt{constructor(e){this.httpClient=e}async getCountries(e,s,n){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:e||"",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 at{constructor(e){this.httpClient=e}async setInvestorCategorization(e){return(await this.httpClient.post("Applicant","SetInvestorCategorization",e)).result}async getInvestorCategorization(e){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:e})).result}}const W={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"}}},it={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"}},ot={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"}},lt={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"}}},ct={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"}},dt={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"}},ut={[V.Default]:W,[V.Corporate]:it,[V.Fintech]:ot,[V.Healthcare]:lt,[V.Modern]:ct,[V.Minimal]:dt};function ge(t){return ut[t]||W}class mt{constructor(e){this.httpClient=e}async getThemeConfiguration(){var e;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return ge(V.Default);let n=s.result.preset?ge(s.result.preset):ge(V.Default);return 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:{...(e=n.darkMode)==null?void 0:e.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(n.applicantFormVisibleFields=s.result.applicantFormVisibleFields),n}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),ge(V.Default)}}async saveThemeConfiguration(e){await this.httpClient.post("Tenant","SaveThemeConfiguration",e)}getAvailablePresets(){return[{id:V.Default,name:"Default"},{id:V.Corporate,name:"Corporate"},{id:V.Fintech,name:"Fintech"},{id:V.Healthcare,name:"Healthcare"},{id:V.Modern,name:"Modern"},{id:V.Minimal,name:"Minimal"}]}getPreviewTheme(e,s){const n=ge(e);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 pt{constructor(){K(this,"listeners",new Map)}on(e,s){return this.listeners.has(e)||this.listeners.set(e,new Set),this.listeners.get(e).add(s),()=>{this.off(e,s)}}off(e,s){const n=this.listeners.get(e);n&&n.delete(s)}emit(e,s){const n=this.listeners.get(e);n&&n.forEach(a=>{try{a(s)}catch(i){console.error(`Error in event listener for "${e}":`,i)}})}clear(){this.listeners.clear()}clearEvent(e){this.listeners.delete(e)}}class ht{constructor(){K(this,"events",new pt);K(this,"_applicantId",null);K(this,"_progress",null);K(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var e;return((e=this._progress)==null?void 0:e.currentStep)||null}get steps(){var e;return((e=this._progress)==null?void 0:e.stepInfoList)||[]}get status(){var e;return((e=this._progress)==null?void 0:e.status)||se.None}get workflowResult(){var e;return((e=this._progress)==null?void 0:e.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===se.Finished}get isOnHold(){return this.status===se.OnHold}get isInProgress(){return this.status===se.InProgress}setApplicantId(e){this._applicantId=e}updateProgress(e){var n,a;const s=(n=this._progress)==null?void 0:n.currentStep;this._progress=e,this._applicantId=e.applicantId,this._error=null,this.events.emit("progressUpdated",e),(s==null?void 0:s.order)!==((a=e.currentStep)==null?void 0:a.order)&&this.events.emit("stepChanged",e.currentStep),this.events.emit("statusChanged",e.status),e.status===se.Finished&&e.workflowResult&&this.events.emit("completed",e.workflowResult)}setError(e){this._error=e,this.events.emit("error",e)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(e){return this.events.on("progressUpdated",e)}onStepChanged(e){return this.events.on("stepChanged",e)}onStatusChanged(e){return this.events.on("statusChanged",e)}onError(e){return this.events.on("error",e)}onCompleted(e){return this.events.on("completed",e)}clearListeners(){this.events.clear()}}class gt{constructor(){K(this,"handlers",new Map)}registerHandler(e,s){this.handlers.set(e,s)}getHandler(e){return this.handlers.get(e)}hasHandler(e){return this.handlers.has(e)}async loadStepData(e,s){const n=this.getHandler(e);if(!n)throw new Error(`No handler registered for step action: ${M[e]}`);return n.loadData(s)}async submitStepData(e,s){const n=this.getHandler(e);if(!n)throw new Error(`No handler registered for step action: ${M[e]}`);return n.submitData(s)}}class xt{constructor(e,s,n,a,i,o,c,d){K(this,"state");K(this,"stepRouter");this.applicantService=e,this.questionnaireService=s,this.uploadDocumentService=n,this.appropriatenessTestService=a,this.overviewService=i,this.riskScoringService=o,this.investorCategorizationService=d,this.state=new ht,this.stepRouter=new gt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(M.Questionaries,{loadData:e=>this.questionnaireService.getQuestionnaire(e),submitData:async e=>{await this.questionnaireService.fillQuestionnaire(e)}}),this.stepRouter.registerHandler(M.UploadDocument,{loadData:e=>this.uploadDocumentService.getUploadDocument(e),submitData:e=>this.uploadDocumentService.fillUploadDocument(e)}),this.stepRouter.registerHandler(M.AppropriatenessTest,{loadData:e=>this.appropriatenessTestService.getAppropriatenessTest(e),submitData:async e=>{await this.appropriatenessTestService.fillAppropriatenessTest(e)}}),this.stepRouter.registerHandler(M.Overview,{loadData:e=>this.overviewService.getOverviewData(e),submitData:e=>this.overviewService.passOverview(e.applicantId)}),this.stepRouter.registerHandler(M.RiskScoring,{loadData:e=>this.riskScoringService.getRiskCriterias(e),submitData:async e=>{await this.riskScoringService.submitRiskScoring(e)}}),this.stepRouter.registerHandler(M.IdentitySdk,{loadData:async e=>({applicantId:e,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(M.InvestorCategorization,{loadData:e=>this.investorCategorizationService.getInvestorCategorization(e),submitData:async e=>{await this.investorCategorizationService.setInvestorCategorization(e)}}),this.stepRouter.registerHandler(M.ManualReview,{loadData:async e=>({applicantId:e,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(M.AdditionalData,{loadData:async e=>({applicantId:e,message:"Additional data required"}),submitData:async()=>{}})}async initialize(e){try{this.state.setApplicantId(e);const s=await this.applicantService.getProgress(e);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 e=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(e),e}catch(e){throw this.state.setError(e),e}}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(e){throw this.state.setError(e),e}}async submitCurrentStep(e){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,e),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(e){throw this.state.setError(e),e}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function Ce(t,e){return new Promise((s,n)=>{if(e&&document.getElementById(e)){s();return}const a=document.createElement("script");a.src=t,e&&(a.id=e),a.async=!0,a.onload=()=>s(),a.onerror=()=>n(new Error(`Failed to load script: ${t}`)),document.head.appendChild(a)})}function ar(t){return!!document.getElementById(t)}function ir(t){const e=document.getElementById(t);e&&e.remove()}class ft{constructor(e){K(this,"sdk",null);K(this,"config");this.config=e}async loadSDK(){await Ce("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(e){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${e}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(e){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&e(s)})}onError(e){this.sdk&&this.sdk.on("idCheck.onError",e)}}class yt{constructor(e){K(this,"sdk",null);K(this,"config");this.config=e}async loadSDK(){await Ce("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(e){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:e,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 bt{constructor(e){K(this,"sardineContext",null);K(this,"config");K(this,"sessionKey");this.config=e,this.sessionKey=e.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const s=Math.random()*16|0;return(e==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:e,region:s}=this.config;if(e==="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((e,s)=>{if(window._Sardine){e();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"),e()},a.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(a,i):document.head.appendChild(a)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const e=this.getSardineHost(),{clientId:s,environment:n,flow:a,enableBiometrics:i,enablePortScanning:o}=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:i!==!1,enablePortScanning:o===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,u)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",u);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(e),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(e){throw console.error("[SardinAI] Initialization failed:",e),e}}addNoScriptFallback(e){const s=document.createElement("noscript"),n=document.createElement("img"),{clientId:a,flow:i}=this.config;n.src=`https://${e}/v1/a.png?clientId=${a}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,n.style.display="none",s.appendChild(n),document.body.appendChild(s)}updateConfig(e){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}e.sessionKey&&(this.sessionKey=e.sessionKey),this.sardineContext.updateConfig({...e,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 pe{static createProvider(e,s){switch(e){case re.Sumsub:return new ft(s);case re.Onfido:return new yt(s);case re.SardinAI:return new bt(s);default:throw new Error(`Unsupported identity provider: ${e}`)}}static parseProviderConfig(e,s,n){var a;switch(e){case re.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case re.Onfido:return{token:s.token||s.sdkToken};case re.SardinAI:const i=((a=n==null?void 0:n.identityProviders)==null?void 0:a.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${e}`)}}}class vt{constructor(e){K(this,"currentTheme",W);K(this,"customStyleElement",null);K(this,"container");this.container=e||document.documentElement}applyTheme(e){this.currentTheme=this.mergeWithDefault(e),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(e){var n;const s={primary:e.primary,"primary-hover":e.primaryHover,"primary-light":e.primaryLight,"primary-dark":e.primaryDark,secondary:e.secondary,"secondary-hover":e.secondaryHover,success:e.success,warning:e.warning,danger:e.danger,info:e.info,background:e.background,surface:e.surface,border:e.border,"text-primary":e.textPrimary,"text-secondary":e.textSecondary,"text-muted":e.textMuted};Object.entries(s).forEach(([a,i])=>{this.container.style.setProperty(`--metakyc-${a}`,i)}),(n=this.currentTheme.darkMode)!=null&&n.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(e){Object.entries(e).forEach(([s,n])=>{if(n){const a=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)}})}applyTypography(e){e&&(e.fontFamily&&this.container.style.setProperty("--metakyc-font-family",e.fontFamily),e.headingFont&&this.container.style.setProperty("--metakyc-heading-font",e.headingFont),e.fontSize&&Object.entries(e.fontSize).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,n)}),e.fontWeight&&Object.entries(e.fontWeight).forEach(([s,n])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,n.toString())}))}applySpacing(e){e&&Object.entries(e).forEach(([s,n])=>{const a=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(a,n)})}injectCustomCSS(e){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=e,document.head.appendChild(this.customStyleElement)}mergeWithDefault(e){var s;return{name:e.name||W.name,title:e.title||W.title,logo:{...W.logo,...e.logo},colors:{...W.colors,...e.colors},typography:e.typography?{...W.typography,...e.typography}:W.typography,spacing:e.spacing?{...W.spacing,...e.spacing}:W.spacing,customCSS:e.customCSS,darkMode:e.darkMode?{colors:{...(s=W.darkMode)==null?void 0:s.colors,...e.darkMode.colors}}:W.darkMode,applicantFormVisibleFields:e.applicantFormVisibleFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(W)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(e){return e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ae=l.createContext(null),or=({config:t,children:e})=>{const[s,n]=l.useState(null),a=l.useRef(!1),i=l.useRef(!1),o=l.useMemo(()=>{const d=new Ge(t),u=new Ze(d),x=new Je(d),f=new Xe(d),g=new et(d),b=new tt(d),p=new rt(d),y=new st(d),h=new nt(d),m=new at(d),N=new mt(d),k=new vt;return{httpClient:d,applicantService:u,questionnaireService:x,uploadDocumentService:f,appropriatenessTestService:g,overviewService:b,riskScoringService:p,identityService:y,baseInformationService:h,investorCategorizationService:m,themeService:N,themeManager:k}},[t]),c=l.useMemo(()=>({config:t,...o,currentTheme:s,createOrchestrator:()=>new xt(o.applicantService,o.questionnaireService,o.uploadDocumentService,o.appropriatenessTestService,o.overviewService,o.riskScoringService,o.identityService,o.investorCategorizationService)}),[t,o,s]);return l.useEffect(()=>((async()=>{if(a.current||i.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"),o.themeManager.applyTheme(t.theme),n(o.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const u=await o.themeService.getThemeConfiguration();o.themeManager.applyTheme(u),n(o.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",u)}catch(u){console.warn("[MetaKYC] Failed to load theme, using default:",u),n(o.themeManager.getCurrentTheme()),i.current=!0}finally{a.current=!1}})(),()=>{o.themeManager.cleanup()}),[]),r.jsx(Ae.Provider,{value:c,children:e})};function ee(){const t=l.useContext(Ae);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function wt(t){return new Promise((e,s)=>{const n=new FileReader;n.readAsDataURL(t),n.onload=()=>{const i=n.result.split(",")[1];e(i)},n.onerror=a=>s(a)})}function lr(t,e){return t.size<=e}function cr(t,e){return e.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 ve(t){if(t===0)return"0 Bytes";const e=1024,s=["Bytes","KB","MB","GB"],n=Math.floor(Math.log(t)/Math.log(e));return Math.round(t/Math.pow(e,n)*100)/100+" "+s[n]}function dr(t){return t}function Y(...t){return t.filter(Boolean).join(" ")}const xe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function jt(t){try{localStorage.setItem(xe.APPLICANT_ID,t.toString())}catch(e){console.warn("Failed to save applicant ID to storage:",e)}}function kt(){try{const t=localStorage.getItem(xe.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function St(){try{localStorage.removeItem(xe.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function Nt(t){try{localStorage.setItem(xe.WORKFLOW_STATE,JSON.stringify(t))}catch(e){console.warn("Failed to save workflow state to storage:",e)}}function ur(){try{const t=localStorage.getItem(xe.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Ct(){try{localStorage.removeItem(xe.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function mr(){St(),Ct()}function At(t){const{createOrchestrator:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(null),u=t||kt();l.useEffect(()=>{d.current||(d.current=e())},[e]),l.useEffect(()=>{var k;s&&u&&(jt(u),Nt({applicantId:u,currentStepOrder:(k=s.currentStep)==null?void 0:k.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,u]);const x=l.useRef(!1),f=l.useRef(!1),g=l.useCallback(async()=>{if(!(!u||!d.current)){if(x.current){console.log("[Workflow] Load already in progress, skipping...");return}x.current=!0,i(!0),c(null);try{const k=await d.current.initialize(u);n(k),f.current=!0}catch(k){c(k)}finally{i(!1),x.current=!1}}},[u]);l.useEffect(()=>{u&&!f.current&&g()},[u,g]);const b=l.useCallback(async()=>{if(d.current){if(x.current){console.log("[Workflow] Refresh already in progress, skipping...");return}x.current=!0,i(!0),c(null);try{const k=await d.current.refreshProgress();n(k)}catch(k){c(k)}finally{i(!1),x.current=!1}}},[]),p=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const k=await d.current.moveToNextStep();n(k)}catch(k){c(k)}finally{i(!1)}}},[]),y=l.useCallback(async()=>{if(d.current){i(!0),c(null);try{const k=await d.current.moveToPreviousStep();n(k)}catch(k){c(k)}finally{i(!1)}}},[]),h=l.useCallback(async k=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(k);const j=await d.current.refreshProgress();n(j)}catch(j){throw c(j),j}finally{i(!1)}}},[]),m=Ie.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((k,j)=>k.order-j.order):[],[s==null?void 0:s.stepInfoList]),N=Ie.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:u,currentStep:(s==null?void 0:s.currentStep)||null,steps:m,status:(s==null?void 0:s.status)||se.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:N,isLoading:a,error:o,isComplete:(s==null?void 0:s.status)===se.Finished,isOnHold:(s==null?void 0:s.status)===se.OnHold,refreshProgress:b,moveToNext:p,moveBack:y,submitCurrentStep:h,orchestrator:d.current}}function Et(t){const{questionnaireService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=l.useRef(!1),f=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[Questionnaire] Load already in progress, skipping...");return}x.current=!0,i(!0),u(null);try{const p=await e.getQuestionnaire(t);n(p),f.current=t}catch(p){u(p)}finally{i(!1),x.current=!1}}},[t,e]);l.useEffect(()=>{t&&f.current!==t&&g()},[t]);const b=l.useCallback(async p=>{c(!0),u(null);try{return await e.fillQuestionnaire(p)}catch(y){throw u(y),y}finally{c(!1)}},[e]);return{questionnaire:s,isLoading:a,isSubmitting:o,error:d,load:g,submit:b}}function It(t){const{uploadDocumentService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(0),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[UploadDocument] Load already in progress, skipping...");return}g.current=!0,i(!0),f(null);try{const h=await e.getUploadDocument(t);n(h),b.current=t}catch(h){f(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(0),f(null);try{await e.fillUploadDocument(h),u(100)}catch(m){throw f(m),m}finally{c(!1)}},[e]);return{uploadDocument:s,isLoading:a,isSubmitting:o,uploadProgress:d,error:x,load:p,submit:y}}function pr(t){const{appropriatenessTestService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const h=await e.getAppropriatenessTest(t);n(h),b.current=t}catch(h){u(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(null);try{const m=await e.fillAppropriatenessTest(h);return f(m),m}catch(m){throw u(m),m}finally{c(!1)}},[e]);return{test:s,result:x,isLoading:a,isSubmitting:o,error:d,load:p,submit:y}}function Rt(t){const{overviewService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=l.useRef(!1),f=l.useRef(null),g=l.useCallback(async()=>{if(t){if(x.current){console.log("[Overview] Load already in progress, skipping...");return}x.current=!0,i(!0),u(null);try{const p=await e.getOverviewData(t);n(p),f.current=t}catch(p){u(p)}finally{i(!1),x.current=!1}}},[t,e]);l.useEffect(()=>{t&&f.current!==t&&g()},[t]);const b=l.useCallback(async()=>{if(t){c(!0),u(null);try{await e.passOverview(t)}catch(p){throw u(p),p}finally{c(!1)}}},[t,e]);return{overview:s,isLoading:a,isSubmitting:o,error:d,load:g,passOverview:b}}function Dt(t){const{identityService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(null),d=l.useRef(!1),u=l.useCallback(async(g,b)=>{if(t){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const p={applicantId:t,restart:!1,redirectUrl:g||"",ttl:b||604800};console.log("Identity request input:",p);const y=await e.identityRequest(p);return console.log("Identity request result:",y),n(y),y}catch(p){throw c(p),p}finally{i(!1),d.current=!1}}},[t,e]),x=l.useCallback(async(g,b)=>{if(t){i(!0),c(null);try{const p={applicantId:t,restart:!1,redirectUrl:g,ttl:b},y=await e.identityCompanyRequest(p);return n(y),y}catch(p){throw c(p),p}finally{i(!1)}}},[t,e]),f=l.useCallback(async()=>{if(t){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",g);const b=await e.identityRequest(g);return console.log("Restart identity result:",b),n(b),b}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[t,e]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:a,error:o,requestIdentity:u,requestCompanyIdentity:x,restartIdentity:f}}function Pt(t){const{riskScoringService:e}=ee(),[s,n]=l.useState(null),[a,i]=l.useState(!1),[o,c]=l.useState(!1),[d,u]=l.useState(null),[x,f]=l.useState(null),g=l.useRef(!1),b=l.useRef(null),p=l.useCallback(async()=>{if(t){if(g.current){console.log("[RiskScoring] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const h=await e.getRiskCriterias(t);n(h),b.current=t}catch(h){u(h)}finally{i(!1),g.current=!1}}},[t,e]);l.useEffect(()=>{t&&b.current!==t&&p()},[t]);const y=l.useCallback(async h=>{c(!0),u(null);try{const m=await e.submitRiskScoring(h);return f(m),m}catch(m){throw u(m),m}finally{c(!1)}},[e]);return{criteria:s,result:x,isLoading:a,isSubmitting:o,error:d,load:p,submit:y}}function Ft(){const{applicantService:t,config:e}=ee(),[s,n]=l.useState(!1),[a,i]=l.useState(null),o=l.useRef(!1),c=l.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(b){const p=Math.random()*16|0;return(b==="x"?p:p&3|8).toString(16)}),u=l.useCallback(async b=>{var p;if(o.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");o.current=!0,n(!0),i(null);try{if(b.applicantAdditionalDatas||(b.applicantAdditionalDatas=[]),(p=e.identityProviders)!=null&&p.sardinai){const h=d();console.log("[SardinAI] Generated session key:",h),b.applicantAdditionalDatas.push({paramName:"sessionKey",value:h})}return await t.createApplicant(b)}catch(y){throw i(y),y}finally{n(!1),o.current=!1}},[t,e]),x=l.useCallback(async b=>{n(!0),i(null);try{return await t.createCompanyApplicant(b)}catch(p){throw i(p),p}finally{n(!1)}},[t]),f=l.useCallback(async b=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,n(!0),i(null);try{return await t.getApplicantData(b)}catch(p){throw i(p),p}finally{n(!1),c.current=!1}},[t]),g=l.useCallback(async b=>{n(!0),i(null);try{await t.stopProgress(b)}catch(p){throw i(p),p}finally{n(!1)}},[t]);return{isLoading:s,error:a,createApplicant:u,createCompanyApplicant:x,getApplicantData:f,stopProgress:g}}const _=({children:t,variant:e="primary",size:s="md",isLoading:n=!1,disabled:a,className:i,...o})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},u={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return r.jsxs("button",{className:Y(c,d[e],u[s],i),disabled:a||n,...o,children:[n&&r.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:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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]})},J=l.forwardRef(({label:t,error:e,helperText:s,leftIcon:n,rightIcon:a,className:i,...o},c)=>r.jsxs("div",{className:"w-full",children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[n&&r.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:n}),r.jsx("input",{ref:c,className:Y("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",e?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",n?"pl-10":"",a?"pr-10":"",i),...o}),a&&r.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:a})]}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e}),!e&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));J.displayName="Input";const F=({children:t,className:e,...s})=>r.jsx("div",{className:Y("metakyc-card rounded-xl shadow-sm border",e),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),Q=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4 border-b",e),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),L=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4",e),...s,children:t}),X=({children:t,className:e,...s})=>r.jsx("div",{className:Y("px-6 py-4 border-t",e),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:t}),oe=({children:t,variant:e="default",className:s,...n})=>{const a={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return r.jsx("span",{className:Y("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",a[e],s),...n,children:t})},ne=({size:t="md",className:e,...s})=>{const n={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return r.jsx("div",{className:Y("flex items-center justify-center",e),...s,children:r.jsxs("svg",{className:Y("animate-spin text-primary-500",n[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.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"})]})})},le=l.forwardRef(({label:t,error:e,helperText:s,options:n,placeholder:a,className:i,...o},c)=>r.jsxs("div",{className:"w-full",children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("select",{ref:c,className:Y("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",e?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...o,children:[a&&r.jsx("option",{value:"",disabled:!0,children:a},"__placeholder__"),n.map((d,u)=>r.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${u}`))]}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e}),!e&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));le.displayName="Select";const Lt=({label:t,value:e,onChange:s,options:n,placeholder:a="Select...",disabled:i=!1,required:o=!1})=>{const[c,d]=l.useState(!1),[u,x]=l.useState(""),f=l.useRef(null);l.useEffect(()=>{const h=m=>{f.current&&!f.current.contains(m.target)&&(d(!1),x(""))};return document.addEventListener("mousedown",h),()=>document.removeEventListener("mousedown",h)},[]);const g=n.filter(h=>h.label.toLowerCase().includes(u.toLowerCase())),b=h=>{i||(e.includes(h)?s(e.filter(m=>m!==h)):s([...e,h]))},p=(h,m)=>{m.stopPropagation(),i||s(e.filter(N=>N!==h))},y=h=>{var m;return((m=n.find(N=>N.value===h))==null?void 0:m.label)||h};return r.jsxs("div",{className:"w-full metakyc-multiselect",ref:f,children:[t&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[t,o&&r.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[r.jsxs("div",{onClick:()=>!i&&d(!c),className:Y("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[e.length===0?r.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:a}):r.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:e.map(h=>r.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[y(h),!i&&r.jsx("button",{type:"button",onClick:m=>p(h,m),className:"hover:text-blue-600 dark:hover:text-blue-200 text-base leading-none -mr-0.5",children:"×"})]},h))}),r.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&r.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg border border-gray-200 dark:border-gray-600 bg-white dark:bg-gray-800 shadow-lg",children:[r.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2 border-b border-gray-100 dark:border-gray-700",children:r.jsx("input",{type:"text",value:u,onChange:h=>x(h.target.value),placeholder:"Search...",autoFocus:!0,onClick:h=>h.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded border border-gray-200 dark:border-gray-600 bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none focus:ring-1 focus:ring-blue-500"})}),r.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:g.length===0?r.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):g.map(h=>r.jsxs("li",{onClick:()=>b(h.value),className:Y("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",e.includes(h.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[r.jsx("input",{type:"checkbox",checked:e.includes(h.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),r.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:h.label})]},h.value))}),e.length>0&&r.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:r.jsxs("button",{type:"button",onClick:()=>{s([]),x("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",e.length," selected)"]})})]})]})]})},Tt=({label:t,error:e,accept:s,multiple:n=!1,maxSize:a,onChange:i,value:o=[],className:c})=>{const[d,u]=l.useState(!1),x=l.useRef(null),f=m=>{if(!m)return;const N=Array.from(m);if(a&&N.filter(j=>j.size>a).length>0){const j=ve(a);alert(`Some files exceed the maximum size of ${j}`);return}i==null||i(n?[...o,...N]:[N[0]])},g=m=>{m.preventDefault(),u(!0)},b=()=>{u(!1)},p=m=>{m.preventDefault(),u(!1),f(m.dataTransfer.files)},y=()=>{var m;(m=x.current)==null||m.click()},h=m=>{const N=o.filter((k,j)=>j!==m);i==null||i(N)};return r.jsxs("div",{className:Y("w-full",c),children:[t&&r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:t}),r.jsxs("div",{className:Y("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",e&&"border-danger-500"),onDragOver:g,onDragLeave:b,onDrop:p,onClick:y,children:[r.jsx("input",{ref:x,type:"file",className:"hidden",accept:s,multiple:n,onChange:m=>f(m.target.files)}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:r.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),a&&r.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",ve(a)]})]})]}),o.length>0&&r.jsx("div",{className:"mt-3 space-y-2",children:o.map((m,N)=>r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[r.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),r.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:m.name}),r.jsxs("span",{className:"text-xs text-gray-500",children:["(",ve(m.size),")"]})]}),r.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),h(N)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:r.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},N))}),e&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:e})]})},Mt=l.forwardRef(({countryCode:t="+1",onCountryCodeChange:e,className:s,...n},a)=>r.jsxs("div",{className:"w-full",children:[n.label&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[n.label,n.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:t,onChange:i=>e==null?void 0:e(i.target.value),className:Y("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),r.jsx(J,{ref:a,type:"tel",className:Y("flex-1",s),...n,label:""})]}),n.error&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:n.error})]}));Mt.displayName="PhoneInput";const Re=(t,e,s)=>{if(t&&"reportValidity"in t){const n=U.get(s,e);t.setCustomValidity(n&&n.message||""),t.reportValidity()}},Se=(t,e)=>{for(const s in e.fields){const n=e.fields[s];n&&n.ref&&"reportValidity"in n.ref?Re(n.ref,s,t):n&&n.refs&&n.refs.forEach(a=>Re(a,s,t))}},De=(t,e)=>{e.shouldUseNativeValidation&&Se(t,e);const s={};for(const n in t){const a=U.get(e.fields,n),i=Object.assign(t[n]||{},{ref:a&&a.ref});if(hr(e.names||Object.keys(t),n)){const o=Object.assign({},U.get(s,n));U.set(o,"root",i),U.set(s,n,o)}else U.set(s,n,i)}return s},hr=(t,e)=>{const s=Pe(e);return t.some(n=>Pe(n).match(`^${s}\\.\\d+`))};function Pe(t){return t.replace(/\]|\[/g,"")}function Ot(t,e,s){function n(c,d){var u;Object.defineProperty(c,"_zod",{value:c._zod??{},enumerable:!1}),(u=c._zod).traits??(u.traits=new Set),c._zod.traits.add(t),e(c,d);for(const x in o.prototype)x in c||Object.defineProperty(c,x,{value:o.prototype[x].bind(c)});c._zod.constr=o,c._zod.def=d}const a=(s==null?void 0:s.Parent)??Object;class i extends a{}Object.defineProperty(i,"name",{value:t});function o(c){var d;const u=s!=null&&s.Parent?new i:this;n(u,c),(d=u._zod).deferred??(d.deferred=[]);for(const x of u._zod.deferred)x();return u}return Object.defineProperty(o,"init",{value:n}),Object.defineProperty(o,Symbol.hasInstance,{value:c=>{var d,u;return s!=null&&s.Parent&&c instanceof s.Parent?!0:(u=(d=c==null?void 0:c._zod)==null?void 0:d.traits)==null?void 0:u.has(t)}}),Object.defineProperty(o,"name",{value:t}),o}class gr extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}const xr={};function zt(t){return xr}function fr(t,e){return typeof e=="bigint"?e.toString():e}const Bt=Error.captureStackTrace?Error.captureStackTrace:(...t)=>{};function be(t){return typeof t=="string"?t:t==null?void 0:t.message}function _t(t,e,s){var a,i,o,c,d,u;const n={...t,path:t.path??[]};if(!t.message){const x=be((o=(i=(a=t.inst)==null?void 0:a._zod.def)==null?void 0:i.error)==null?void 0:o.call(i,t))??be((c=e==null?void 0:e.error)==null?void 0:c.call(e,t))??be((d=s.customError)==null?void 0:d.call(s,t))??be((u=s.localeError)==null?void 0:u.call(s,t))??"Invalid input";n.message=x}return delete n.inst,delete n.continue,e!=null&&e.reportInput||delete n.input,n}const Ut=(t,e)=>{t.name="$ZodError",Object.defineProperty(t,"_zod",{value:t._zod,enumerable:!1}),Object.defineProperty(t,"issues",{value:e,enumerable:!1}),Object.defineProperty(t,"message",{get(){return JSON.stringify(e,fr,2)},enumerable:!0}),Object.defineProperty(t,"toString",{value:()=>t.message,enumerable:!1})},yr=Ot("$ZodError",Ut),$t=Ot("$ZodError",Ut,{Parent:Error}),br=t=>(e,s,n,a)=>{const i=n?Object.assign(n,{async:!1}):{async:!1},o=e._zod.run({value:s,issues:[]},i);if(o instanceof Promise)throw new gr;if(o.issues.length){const c=new((a==null?void 0:a.Err)??t)(o.issues.map(d=>_t(d,i,zt())));throw Bt(c,a==null?void 0:a.callee),c}return o.value},vr=br($t),wr=t=>async(e,s,n,a)=>{const i=n?Object.assign(n,{async:!0}):{async:!0};let o=e._zod.run({value:s,issues:[]},i);if(o instanceof Promise&&(o=await o),o.issues.length){const c=new((a==null?void 0:a.Err)??t)(o.issues.map(d=>_t(d,i,zt())));throw Bt(c,a==null?void 0:a.callee),c}return o.value},jr=wr($t);function Fe(t,e){try{var s=t()}catch(n){return e(n)}return s&&s.then?s.then(void 0,e):s}function kr(t,e){for(var s={};t.length;){var n=t[0],a=n.code,i=n.message,o=n.path.join(".");if(!s[o])if("unionErrors"in n){var c=n.unionErrors[0].errors[0];s[o]={message:c.message,type:c.code}}else s[o]={message:i,type:a};if("unionErrors"in n&&n.unionErrors.forEach(function(x){return x.errors.forEach(function(f){return t.push(f)})}),e){var d=s[o].types,u=d&&d[n.code];s[o]=U.appendErrors(o,e,s,a,u?[].concat(u,n.message):n.message)}t.shift()}return s}function Sr(t,e){for(var s={};t.length;){var n=t[0],a=n.code,i=n.message,o=n.path.join(".");if(!s[o])if(n.code==="invalid_union"&&n.errors.length>0){var c=n.errors[0][0];s[o]={message:c.message,type:c.code}}else s[o]={message:i,type:a};if(n.code==="invalid_union"&&n.errors.forEach(function(x){return x.forEach(function(f){return t.push(f)})}),e){var d=s[o].types,u=d&&d[n.code];s[o]=U.appendErrors(o,e,s,a,u?[].concat(u,n.message):n.message)}t.shift()}return s}function Kt(t,e,s){if(s===void 0&&(s={}),function(n){return"_def"in n&&typeof n._def=="object"&&"typeName"in n._def}(t))return function(n,a,i){try{return Promise.resolve(Fe(function(){return Promise.resolve(t[s.mode==="sync"?"parse":"parseAsync"](n,e)).then(function(o){return i.shouldUseNativeValidation&&Se({},i),{errors:{},values:s.raw?Object.assign({},n):o}})},function(o){if(function(c){return Array.isArray(c==null?void 0:c.issues)}(o))return{values:{},errors:De(kr(o.errors,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};if(function(n){return"_zod"in n&&typeof n._zod=="object"}(t))return function(n,a,i){try{return Promise.resolve(Fe(function(){return Promise.resolve((s.mode==="sync"?vr:jr)(t,n,e)).then(function(o){return i.shouldUseNativeValidation&&Se({},i),{errors:{},values:s.raw?Object.assign({},n):o}})},function(o){if(function(c){return c instanceof yr}(o))return{values:{},errors:De(Sr(o.issues,!i.shouldUseNativeValidation&&i.criteriaMode==="all"),i)};throw o}))}catch(o){return Promise.reject(o)}};throw new Error("Invalid input: not a Zod schema")}function qt(t){return ce.z.object({questionResults:ce.z.any()}).passthrough()}function Nr(t){let e=ce.z.array(ce.z.instanceof(File));if(t.isRequired?e=e.min(1,`${t.displayName} is required`):e=e.optional(),t.multipleFile||(e=e.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(e=e.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());e=e.refine(n=>n?n.every(a=>s.some(i=>i.endsWith("/*")?a.type.startsWith(i.slice(0,-2)):a.type===i)):!0,{message:"Invalid file type"})}return e}function Cr(t){const e={};return t.uploadDocumentFiles.forEach(s=>{const n=`file_${s.id}`;e[n]=Nr(s)}),ce.z.object(e)}function Ht(t){return ce.z.any()}function Ar(t){return ce.z.string().min(1,"This question is required")}function Er(t){const e={};return t.appropriatenessQuestions.forEach(s=>{const n=`question_${s.id}`;e[n]=Ar()}),ce.z.object(e)}const Ir=ce.z.any(),Vt=({applicantId:t,onComplete:e,onBack:s})=>{const{questionnaire:n,isLoading:a,isSubmitting:i,error:o,submit:c}=Et(t),d=l.useMemo(()=>n?{questionResults:n.questionGroups.map(y=>y.questions.map(h=>({questionId:h.id,values:[]})))}:{questionResults:[]},[n]),u=n?qt():null,{control:x,handleSubmit:f,formState:{errors:g}}=U.useForm({resolver:u?Kt(u):void 0,defaultValues:d}),b=async p=>{if(n)try{console.log("Form submitted with data:",p);const y=n.questionGroups.flatMap((m,N)=>m.questions.map((k,j)=>{var T,P,C;return{questionId:k.id,values:((C=(P=(T=p.questionResults)==null?void 0:T[N])==null?void 0:P[j])==null?void 0:C.values)||[]}}));console.log("Question results to submit:",y);const h={applicantId:t,questionnarieId:n.id,questionResults:y};console.log("Final input:",h),await c(h),e==null||e()}catch(y){console.error("Error submitting questionnaire:",y)}};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",o.message]})})}):n?r.jsx("form",{onSubmit:f(b),children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),r.jsx(L,{className:"space-y-8",children:n.questionGroups.flatMap((p,y)=>p.questions.map((h,m)=>{const k=h.defaultAnswers&&h.defaultAnswers.length>0?h.showAsDropdown?h.canMultipleAnswer?"multi-select":"single-select":h.canMultipleAnswer?"checkbox":"radio":"text";return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[h.text,h.isRequired&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),k==="text"&&r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values.0`,render:({field:j})=>{var T,P,C,S;return r.jsx(J,{value:j.value||"",onChange:j.onChange,onBlur:j.onBlur,name:j.name,placeholder:"Enter your answer...",error:(S=(C=(P=(T=g.questionResults)==null?void 0:T[y])==null?void 0:P[m])==null?void 0:C.values)==null?void 0:S.message})}}),(k==="single-select"||k==="radio")&&r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values.0`,render:({field:j})=>{var T,P,C,S;return r.jsx(le,{value:j.value||"",onChange:j.onChange,onBlur:j.onBlur,name:j.name,options:h.defaultAnswers.map(I=>({value:I,label:I})),placeholder:"Select an option...",error:(S=(C=(P=(T=g.questionResults)==null?void 0:T[y])==null?void 0:P[m])==null?void 0:C.values)==null?void 0:S.message})}}),(k==="checkbox"||k==="multi-select")&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400 mb-2",children:"Choose one or more options"}),r.jsx(U.Controller,{control:x,name:`questionResults.${y}.${m}.values`,render:({field:{value:j=[],onChange:T}})=>r.jsx("div",{className:"space-y-2",children:h.defaultAnswers.map((P,C)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:Array.isArray(j)&&j.includes(P),onChange:S=>{const I=Array.isArray(j)?j:[],O=S.target.checked?[...I,P]:I.filter(H=>H!==P);T(O)},className:"h-4 w-4 text-primary-500 rounded border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:P})]},`answer-${y}-${m}-${C}`))})})]})]},h.id)}))}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,onClick:()=>{console.log("Continue button clicked"),console.log("Form errors:",g)},children:"Continue"})]}),o&&r.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded",children:r.jsxs("p",{className:"text-red-600 text-sm",children:["Error: ",o.message]})})]})}):null},Yt=({applicantId:t,onComplete:e,onBack:s})=>{const{uploadDocument:n,isLoading:a,isSubmitting:i,error:o,submit:c}=It(t),[d,u]=l.useState({}),x=async f=>{if(f.preventDefault(),!n)return;const g=await Promise.all(n.uploadDocumentFiles.map(async p=>{const y=d[p.id]||[],h=await Promise.all(y.map(async m=>({fileName:m.name,fileData:await wt(m)})));return{uploadDocumentFileId:p.id,valueList:h}})),b={applicantId:t,uploadDocumentId:n.id,uploadDocumentResults:g};await c(b),e==null||e()};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading document requirements: ",o.message]})})}):n?r.jsx("form",{onSubmit:x,children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.displayName}),n.subtitle&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.subtitle})]}),r.jsx(L,{className:"space-y-6",children:n.uploadDocumentFiles.map(f=>r.jsx(Tt,{label:f.displayName,accept:f.allowedTypes,multiple:f.multipleFile,maxSize:f.maxEachFileSizeByte,value:d[f.id]||[],onChange:g=>{u(b=>({...b,[f.id]:g}))}},f.id))}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,children:"Continue"})]})]})}):null},Wt=({applicantId:t,onComplete:e,onBack:s})=>{const{overview:n,isLoading:a,isSubmitting:i,error:o,passOverview:c}=Rt(t),d=async()=>{await c(),e==null||e()};return a?r.jsx(F,{children:r.jsx(L,{children:r.jsx(ne,{className:"my-8"})})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",o.message]})})}):n?r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:n.title||"Overview"}),n.description&&r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:n.description})]}),r.jsx(L,{className:"space-y-8",children:n.steps&&n.steps.length>0?n.steps.sort((u,x)=>u.order-x.order).map(u=>r.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[r.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:r.jsx("div",{className:"w-8 h-8 rounded-full bg-primary-500 text-white flex items-center justify-center font-medium text-sm",children:u.order+1})}),r.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[r.jsx("span",{className:"metakyc-step-title text-sm font-semibold text-gray-900 dark:text-white",children:u.title}),u.description&&r.jsx("p",{className:"metakyc-step-description text-sm text-gray-600 dark:text-gray-400",children:u.description})]})]},u.order)):r.jsx("div",{className:"text-center py-8",children:r.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Loading overview data..."})})}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{onClick:d,isLoading:i,children:"Continue"})]})]}):null},Qt=({applicantId:t,onComplete:e,onBack:s})=>{const{criteria:n,isLoading:a,isSubmitting:i,error:o,submit:c}=Pt(t),[d,u]=l.useState(!1),x=l.useMemo(()=>!n||n.length===0?{criteriaValueInputs:[]}:{criteriaValueInputs:n.map(m=>({riskCriteriaId:m.id,values:[""]}))},[n]),f=n&&n.length>0?Ht():null,{control:g,handleSubmit:b,formState:{errors:p}}=U.useForm({resolver:f?Kt(f):void 0,defaultValues:x});l.useEffect(()=>{!a&&n&&n.length===0&&!d&&!i&&(u(!0),c({applicantId:t,criteriaValueInputs:[]}).then(()=>e==null?void 0:e()).catch(console.error))},[a,n,d,i,c,t,e]);const y=async m=>{if(n)try{console.log("Risk scoring form submitted:",m),console.log("Criteria metadata:",n);const N=m.criteriaValueInputs.map((j,T)=>{const P=j.values||[],C=Array.isArray(P)?P.filter(S=>S&&S.trim()):P&&P.toString().trim()?[P.toString()]:[];return C.length===0?null:{riskCriteriaId:n[T].id,values:C}}).filter(j=>j!==null);console.log("Risk scoring criteriaValueInputs to submit:",N);const k={applicantId:t,criteriaValueInputs:N};console.log("Final risk scoring input:",k),await c(k),console.log("Risk scoring submitted successfully!"),e==null||e()}catch(N){throw console.error("Error submitting risk scoring:",N),N}},h=m=>m.builtInType===1?"country":!m.defaultValues||m.defaultValues.length===0?"text":m.multipleValue?"checkbox":"radio";return a?r.jsx(F,{children:r.jsxs(L,{children:[r.jsx(ne,{className:"my-8"}),r.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading risk scoring criteria..."})]})}):o?r.jsx(F,{children:r.jsx(L,{children:r.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",o.message]})})}):!a&&n&&n.length===0?r.jsx(F,{children:r.jsxs(L,{children:[r.jsx(ne,{className:"my-8"}),r.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400",children:"No risk scoring criteria required. Moving to next step..."})]})}):n?r.jsx("form",{onSubmit:b(y),children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please answer the following questions for risk evaluation"})]}),r.jsx(L,{className:"space-y-8",children:n.map((m,N)=>{var j,T,P;const k=h(m);return r.jsxs("div",{className:"space-y-2",children:[r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300",children:[m.displayName,m.isRequired&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),m.description&&r.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:m.description}),k==="text"&&r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:C})=>{var S,I,O;return r.jsx(J,{...C,value:C.value||"",type:m.valueDataType===we.DigitOnly?"number":"text",placeholder:"Enter your answer...",error:(O=(I=(S=p.criteriaValueInputs)==null?void 0:S[N])==null?void 0:I.values)==null?void 0:O.message,onKeyDown:H=>{m.valueDataType===we.DigitOnly&&["e","E","+","-","."].includes(H.key)&&H.preventDefault()}})}}),k==="radio"&&m.defaultValues&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Choose one option"}),r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:{value:C,onChange:S}})=>r.jsx("div",{className:"space-y-2",children:m.defaultValues.map((I,O)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"radio",checked:C===I,onChange:()=>S(I),className:"h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:I})]},`${N}-${O}`))})})]}),k==="checkbox"&&m.defaultValues&&r.jsxs("div",{className:"space-y-2",children:[r.jsx("p",{className:"text-sm text-gray-600 dark:text-gray-400",children:"Choose one or more options"}),r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values`,render:({field:{value:C=[],onChange:S}})=>r.jsx("div",{className:"space-y-2",children:m.defaultValues.map((I,O)=>r.jsxs("label",{className:"flex items-center space-x-2 cursor-pointer",children:[r.jsx("input",{type:"checkbox",checked:Array.isArray(C)&&C.includes(I),onChange:H=>{const $=Array.isArray(C)?C:[],R=H.target.checked?[...$,I]:$.filter(E=>E!==I);S(R)},className:"h-4 w-4 text-primary-500 rounded border-gray-300 focus:ring-primary-500"}),r.jsx("span",{className:"text-sm",children:I})]},`${N}-${O}`))})})]}),k==="country"&&r.jsx(U.Controller,{control:g,name:`criteriaValueInputs.${N}.values.0`,render:({field:C})=>{var S,I,O;return r.jsx(le,{...C,options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"}],placeholder:"Select a country...",error:(O=(I=(S=p.criteriaValueInputs)==null?void 0:S[N])==null?void 0:I.values)==null?void 0:O.message})}}),((P=(T=(j=p.criteriaValueInputs)==null?void 0:j[N])==null?void 0:T.values)==null?void 0:P.message)&&r.jsx("p",{className:"text-sm text-danger-500 mt-1",children:p.criteriaValueInputs[N].values.message})]},m.id)})}),r.jsxs(X,{className:"flex justify-between",children:[s&&r.jsx(_,{type:"button",variant:"outline",onClick:s,children:"Back"}),r.jsx(_,{type:"submit",isLoading:i,onClick:()=>{console.log("Risk scoring submit button clicked"),console.log("Form errors:",p)},children:"Continue"})]}),o&&r.jsx("div",{className:"mt-4 p-4 bg-red-50 border border-red-200 rounded",children:r.jsxs("p",{className:"text-red-600 text-sm",children:["Error: ",o.message]})})]})}):null},Gt=({applicantId:t,onComplete:e,onBack:s})=>{const{investorCategorizationService:n}=ee(),[a,i]=l.useState(null),[o,c]=l.useState(!1),[d,u]=l.useState(null),x=async f=>{if(f.preventDefault(),a===null){u("Please select an investor type");return}c(!0),u(null);try{const g={applicantId:t,investorType:a};console.log("Submitting investor categorization:",g);const b=await n.setInvestorCategorization(g);console.log("Investor categorization result:",b),e==null||e()}catch(g){console.error("Error submitting investor categorization:",g),u(g.message||"Failed to submit investor categorization")}finally{c(!1)}};return r.jsx("form",{onSubmit:x,children:r.jsxs(F,{children:[r.jsxs(Q,{children:[r.jsx("h2",{className:"text-lg font-bold text-gray-900 dark:text-white",children:"Which statement best describes you?"}),r.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-2",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"})]}),r.jsxs(L,{className:"space-y-4",children:[r.jsx("p",{className:"text-sm font-medium text-gray-700 dark:text-gray-300 mb-3",children:"Choose one"}),r.jsx("label",{className:`
|
|
2
2
|
block p-4 border-2 rounded-lg cursor-pointer transition-all
|
|
3
3
|
${a===Z.Individual?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-200 dark:border-gray-700 hover:border-gray-300 dark:hover:border-gray-600"}
|
|
4
4
|
`,children:r.jsxs("div",{className:"flex items-start",children:[r.jsx("input",{type:"radio",name:"investorType",value:Z.Individual,checked:a===Z.Individual,onChange:()=>i(Z.Individual),className:"mt-1 h-4 w-4 text-primary-500 border-gray-300 focus:ring-primary-500"}),r.jsxs("div",{className:"ml-3",children:[r.jsx("div",{className:"text-base font-semibold text-gray-900 dark:text-white",children:"Individual investor"}),r.jsx("div",{className:"text-sm text-gray-600 dark:text-gray-400 mt-1",children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),r.jsx("label",{className:`
|