@vpdev2/metakyc 1.0.9 → 1.0.10
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/identity/providers/sumsub.d.ts.map +1 -1
- package/dist/index.cjs +35 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +685 -697
- package/dist/index.js.map +1 -1
- package/dist/theme/theme-manager.d.ts +9 -23
- package/dist/theme/theme-manager.d.ts.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Vr=Object.defineProperty;var Yr=(t,r,a)=>r in t?Vr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a;var pe=(t,r,a)=>Yr(t,typeof r!="symbol"?r+"":r,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qr=require("axios"),i=require("react"),e=require("react/jsx-runtime"),pt=require("react-dom"),Ve=require("react-hook-form"),Ue=require("zod");function Gr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(r,a,s.get?s:{enumerable:!0,get:()=>t[a]})}}return r.default=t,Object.freeze(r)}const St=Gr(i);var oe=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(oe||{}),ot=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(ot||{}),Te=(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))(Te||{}),Ft=(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))(Ft||{}),Pt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Pt||{}),Ye=(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))(Ye||{}),Qe=(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))(Qe||{}),Lt=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Lt||{}),Dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Dt||{}),Ae=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(Ae||{}),Mt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Mt||{}),lt=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(lt||{}),zt=(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))(zt||{}),Ot=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Ot||{}),$t=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))($t||{}),Me=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(Me||{}),Bt=(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))(Bt||{}),_t=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(_t||{}),we=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(we||{}),Ht=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Ht||{});const We={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ge={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"select",countriesType:We.PhoneNumber},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select",countriesType:We.Address},nationality:{label:"Nationality",type:"select",countriesType:We.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:We.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:We.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:We.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Ze={companyName:{label:"Company Name",type:"text"},email:{label:"Email",type:"email"},phone:{label:"Phone",type:"tel"},registrationNumber:{label:"Registration Number",type:"text"},countryResidence:{label:"Country of Residence",type:"select",countriesType:We.Address},legalAddress:{label:"Legal Address",type:"text"},incorporatedOn:{label:"Incorporation Date",type:"date"},controlScheme:{label:"Control Scheme",type:"text"},taxId:{label:"Tax ID",type:"text"},registrationLocation:{label:"Registration Location",type:"text"},website:{label:"Website",type:"text"},postalAddress:{label:"Postal Address",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},city:{label:"City",type:"text"},state:{label:"State / Province",type:"text"},postalCode:{label:"Postal Code",type:"text"},addressCountry:{label:"Address Country",type:"select",countriesType:We.Address},lei:{label:"LEI",type:"text"}},Wt=["companyName","email","phone","registrationNumber"],Ut=["firstName","lastName","email","phonenumber","dateOfBirth"],ht=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var je=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(je||{});const Kt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class qt{constructor(r){this.config=r}build(r,a){const s=`${r}.${a}`;if(this.config.customPaths&&this.config.customPaths[s])return this.config.customPaths[s];switch(this.config.pattern){case"host-controller":return`/api/${r}/${a}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${a}`;case"custom":throw new Error(`Custom endpoint path not found for ${s}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class De extends Error{constructor(a,s,n,o,c){super(a);pe(this,"response");this.code=s,this.details=n,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,De.prototype)}}class at{static handleApiError(r){return new De(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const a=r.response.data;return a&&a.error?new De(a.error.message||"An unknown error occurred",a.error.code,a.error.details||void 0,a.error.validationErrors||void 0,r.response):a&&a.result&&a.result.message?new De(a.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new De((a==null?void 0:a.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new De("No response from server",0,"The request was made but no response was received. Please check your network connection."):new De(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof De}}class Vt{constructor(r){pe(this,"axiosInstance");pe(this,"endpointBuilder");pe(this,"config");this.config={...Kt,...r},this.endpointBuilder=new qt(this.config.endpoints),this.axiosInstance=Qr.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(a=>{if(a.headers["Abp-TenantId"]=this.config.tenantId.toString(),this.config.getAccessToken){const s=this.config.getAccessToken();s&&(a.headers.Authorization=`Bearer ${s}`)}else this.config.apiKey&&(a.headers.ApiKey=this.config.apiKey,a.headers["X-API-KEY"]=this.config.apiKey);return this.config.locale&&(a.headers["Accept-Language"]=this.config.locale),a},a=>Promise.reject(a)),this.axiosInstance.interceptors.response.use(a=>a,async a=>{var n;const s=a.config;return((n=a.response)==null?void 0:n.status)>=500&&!s._retry&&(s._retry=!0,s._retryCount=(s._retryCount||0)+1,s._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,1e3*s._retryCount)),this.axiosInstance(s)):Promise.reject(a)})}buildEndpoint(r,a){return this.endpointBuilder.build(r,a)}async get(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.get(n,{params:s});return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async post(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.post(n,s);return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async put(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.put(n,s);return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async delete(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.delete(n,{params:s});return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}handleResponse(r){const a=r.data;if(!a.success&&a.error)throw at.handleApiError(a.error);return a}getAxiosInstance(){return this.axiosInstance}}class Yt{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,a){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:a})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class Qt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class Gt{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class Jt{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class Xt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class Zt{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class er{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const a=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",a),a.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const a={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",a),this.identityRequest(a)}async restartIdentityCompanyRequest(r){const a={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(a)}async refreshSumsubToken(r){console.log("[IdentityService] Refreshing Sumsub token for applicant:",r);const a=await this.httpClient.post("Applicant","RefreshSumsubToken",{applicantId:r});return console.log("[IdentityService] Sumsub token refresh result:",a),a.result.accessToken}}class tr{constructor(r){this.httpClient=r}async getCountries(r,a,s){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:a||"en",type:s})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class rr{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const Re={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},ar={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"}},sr={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"}},nr={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"}}},ir={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"}},or={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"}},lr={[je.Default]:Re,[je.Corporate]:ar,[je.Fintech]:sr,[je.Healthcare]:nr,[je.Modern]:ir,[je.Minimal]:or};function st(t){return lr[t]||Re}class cr{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const a=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!a.result.isEnabled)return st(je.Default);let s=a.result.preset?st(a.result.preset):st(je.Default);if(a.result.title&&(s.title=a.result.title),a.result.logo&&(s.logo={...s.logo,...a.result.logo}),a.result.colors&&(s.colors={...s.colors,...a.result.colors}),a.result.typography&&(s.typography={...s.typography,...a.result.typography}),a.result.spacing&&(s.spacing={...s.spacing,...a.result.spacing}),a.result.customCSS&&(s.customCSS=a.result.customCSS),a.result.darkMode&&(s.darkMode={colors:{...(r=s.darkMode)==null?void 0:r.colors,...a.result.darkMode.colors}}),a.result.applicantFormVisibleFields&&a.result.applicantFormVisibleFields.length>0&&(s.applicantFormVisibleFields=a.result.applicantFormVisibleFields),a.result.applicantFormRequiredFields&&a.result.applicantFormRequiredFields.length>0&&(s.applicantFormRequiredFields=a.result.applicantFormRequiredFields),a.result.allowedLanguages&&a.result.allowedLanguages.length>0&&(s.allowedLanguages=a.result.allowedLanguages),a.result.applicantFormPages)try{const n=typeof a.result.applicantFormPages=="string"?JSON.parse(a.result.applicantFormPages):a.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(s.applicantFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(a.result.reviewPageFields)try{const n=typeof a.result.reviewPageFields=="string"?JSON.parse(a.result.reviewPageFields):a.result.reviewPageFields;Array.isArray(n)&&n.length>0&&(s.reviewPageFields=n)}catch{}if(a.result.reviewPageDisabled&&(s.reviewPageDisabled=!0),a.result.fieldLabelMode==="placeholder"&&(s.fieldLabelMode="placeholder"),a.result.companyFormVisibleFields&&a.result.companyFormVisibleFields.length>0&&(s.companyFormVisibleFields=a.result.companyFormVisibleFields),a.result.companyFormRequiredFields&&a.result.companyFormRequiredFields.length>0&&(s.companyFormRequiredFields=a.result.companyFormRequiredFields),a.result.companyFormPages)try{const n=typeof a.result.companyFormPages=="string"?JSON.parse(a.result.companyFormPages):a.result.companyFormPages;Array.isArray(n)&&n.length>0&&(s.companyFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(a.result.companyReviewPageFields)try{const n=typeof a.result.companyReviewPageFields=="string"?JSON.parse(a.result.companyReviewPageFields):a.result.companyReviewPageFields;Array.isArray(n)&&n.length>0&&(s.companyReviewPageFields=n)}catch{}return s}catch(a){return console.warn("[ThemeService] Failed to fetch theme configuration:",a),st(je.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:je.Default,name:"Default"},{id:je.Corporate,name:"Corporate"},{id:je.Fintech,name:"Fintech"},{id:je.Healthcare,name:"Healthcare"},{id:je.Modern,name:"Modern"},{id:je.Minimal,name:"Minimal"}]}getPreviewTheme(r,a){const s=st(r);return a?{...s,...a,logo:{...s.logo,...a.logo},colors:{...s.colors,...a.colors},typography:a.typography?{...s.typography,...a.typography}:s.typography,spacing:a.spacing?{...s.spacing,...a.spacing}:s.spacing}:s}}class dr{constructor(){pe(this,"listeners",new Map)}on(r,a){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(a),()=>{this.off(r,a)}}off(r,a){const s=this.listeners.get(r);s&&s.delete(a)}emit(r,a){const s=this.listeners.get(r);s&&s.forEach(n=>{try{n(a)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class mr{constructor(){pe(this,"events",new dr);pe(this,"_applicantId",null);pe(this,"_progress",null);pe(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||Te.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===Te.Finished}get isOnHold(){return this.status===Te.OnHold}get isInProgress(){return this.status===Te.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var s,n;const a=(s=this._progress)==null?void 0:s.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(a==null?void 0:a.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===Te.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class pr{constructor(){pe(this,"handlers",new Map)}registerHandler(r,a){this.handlers.set(r,a)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,a){const s=this.getHandler(r);if(!s)throw new Error(`No handler registered for step action: ${oe[r]}`);return s.loadData(a)}async submitStepData(r,a){const s=this.getHandler(r);if(!s)throw new Error(`No handler registered for step action: ${oe[r]}`);return s.submitData(a)}}class ur{constructor(r,a,s,n,o,c,d,y){pe(this,"state");pe(this,"stepRouter");this.applicantService=r,this.questionnaireService=a,this.uploadDocumentService=s,this.appropriatenessTestService=n,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=y,this.state=new mr,this.stepRouter=new pr,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(oe.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(oe.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(oe.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(oe.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(oe.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(oe.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(oe.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const a=await this.applicantService.getProgress(r);return this.state.updateProgress(a),a}catch(a){throw this.state.setError(a),a}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(a){throw this.state.setError(a),a}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function kt(t,r){return new Promise((a,s)=>{if(r&&document.getElementById(r)){a();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>a(),n.onerror=()=>s(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function Jr(t){return!!document.getElementById(t)}function Xr(t){const r=document.getElementById(t);r&&r.remove()}const Zr="https://static.sumsub.com/idensic/static/sns-websdk-builder.js";function _e(t,r){try{return getComputedStyle(document.documentElement).getPropertyValue(t).trim()||r}catch{return r}}function ea(){const t=_e("--metakyc-primary","#2563eb"),r=_e("--metakyc-primary-hover","#1d4ed8"),a=_e("--metakyc-background","#ffffff"),s=_e("--metakyc-surface","#f9fafb"),n=_e("--metakyc-text-primary","#111827"),o=_e("--metakyc-text-secondary","#6b7280"),c=_e("--metakyc-text-muted","#9ca3af"),d=_e("--metakyc-border","#e5e7eb");return`
|
|
1
|
+
"use strict";var Yr=Object.defineProperty;var Vr=(t,r,a)=>r in t?Yr(t,r,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[r]=a;var pe=(t,r,a)=>Vr(t,typeof r!="symbol"?r+"":r,a);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Qr=require("axios"),i=require("react"),e=require("react/jsx-runtime"),pt=require("react-dom"),Ye=require("react-hook-form"),Ue=require("zod");function Gr(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const a in t)if(a!=="default"){const s=Object.getOwnPropertyDescriptor(t,a);Object.defineProperty(r,a,s.get?s:{enumerable:!0,get:()=>t[a]})}}return r.default=t,Object.freeze(r)}const St=Gr(i);var oe=(t=>(t[t.IdentitySdk=0]="IdentitySdk",t[t.RiskScoring=1]="RiskScoring",t[t.Questionaries=2]="Questionaries",t[t.AdditionalData=3]="AdditionalData",t[t.AppropriatenessTest=4]="AppropriatenessTest",t[t.UploadDocument=5]="UploadDocument",t[t.ManualReview=6]="ManualReview",t[t.Overview=7]="Overview",t[t.InvestorCategorization=8]="InvestorCategorization",t))(oe||{}),ot=(t=>(t[t.NotStarted=0]="NotStarted",t[t.InProgress=1]="InProgress",t[t.Success=2]="Success",t[t.PartialSuccess=3]="PartialSuccess",t[t.Failed=4]="Failed",t[t.Skipped=5]="Skipped",t[t.AdminReview=6]="AdminReview",t[t.SkippedAndAdminReview=7]="SkippedAndAdminReview",t))(ot||{}),Fe=(t=>(t[t.None=0]="None",t[t.InProgress=1]="InProgress",t[t.Finished=2]="Finished",t[t.OnHold=3]="OnHold",t[t.IdentityPending=4]="IdentityPending",t))(Fe||{}),Tt=(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))(Tt||{}),Pt=(t=>(t[t.LowRisk=0]="LowRisk",t[t.MediumRisk=1]="MediumRisk",t[t.HighRisk=2]="HighRisk",t[t.Alert=3]="Alert",t))(Pt||{}),Ve=(t=>(t[t.None=0]="None",t[t.Pending=1]="Pending",t[t.Approved=2]="Approved",t[t.Rejected=3]="Rejected",t[t.ResendRequested=4]="ResendRequested",t[t.Unknown=5]="Unknown",t[t.InProgress=6]="InProgress",t))(Ve||{}),Qe=(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))(Qe||{}),Lt=(t=>(t[t.ProviderResultPending=0]="ProviderResultPending",t[t.ProviderResultReceived=1]="ProviderResultReceived",t[t.Canceled=2]="Canceled",t[t.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",t))(Lt||{}),Dt=(t=>(t[t.None=0]="None",t[t.ProviderResultPending=1]="ProviderResultPending",t[t.ProviderResultReceived=2]="ProviderResultReceived",t[t.Canceled=3]="Canceled",t))(Dt||{}),Ae=(t=>(t[t.Onfido=0]="Onfido",t[t.Sumsub=2]="Sumsub",t[t.SardinAI=3]="SardinAI",t))(Ae||{}),Mt=(t=>(t[t.Individual=0]="Individual",t[t.Company=1]="Company",t))(Mt||{}),lt=(t=>(t[t.Male=0]="Male",t[t.Female=1]="Female",t[t.Other=2]="Other",t))(lt||{}),zt=(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))(zt||{}),Ot=(t=>(t[t.Pending=0]="Pending",t[t.Approved=1]="Approved",t[t.Rejected=2]="Rejected",t[t.RequiresRevision=3]="RequiresRevision",t))(Ot||{}),$t=(t=>(t[t.SingleChoice=0]="SingleChoice",t[t.MultipleChoice=1]="MultipleChoice",t[t.Text=2]="Text",t))($t||{}),Me=(t=>(t[t.String=0]="String",t[t.Integer=1]="Integer",t[t.Money=2]="Money",t[t.Boolean=3]="Boolean",t[t.Date=4]="Date",t[t.Country=5]="Country",t[t.DigitOnly=6]="DigitOnly",t))(Me||{}),Bt=(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))(Bt||{}),_t=(t=>(t[t.None=0]="None",t[t.Country=1]="Country",t))(_t||{}),we=(t=>(t[t.Individual=0]="Individual",t[t.Sophisticated=1]="Sophisticated",t[t.HighNetWorth=2]="HighNetWorth",t[t.Business=3]="Business",t))(we||{}),Ht=(t=>(t[t.Retail=0]="Retail",t[t.Professional=1]="Professional",t[t.EligibleCounterparty=2]="EligibleCounterparty",t))(Ht||{});const We={Nationality:10,Address:20,CountryOfBirth:30,PhoneNumber:40,UboAddress:50},Ge={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},email:{label:"Email",type:"email"},phonenumber:{label:"Phone Number",type:"tel"},dateOfBirth:{label:"Date of Birth",type:"date"},salutation:{label:"Salutation",type:"select"},title:{label:"Title",type:"text"},mobileCountryCode:{label:"Mobile Country Code",type:"select",countriesType:We.PhoneNumber},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP / Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select",countriesType:We.Address},nationality:{label:"Nationality",type:"select",countriesType:We.Nationality},otherNationality:{label:"Other Nationalities",type:"multiselect",countriesType:We.Nationality},countryOfBirth:{label:"Country of Birth",type:"select",countriesType:We.CountryOfBirth},placeOfBirth:{label:"Place of Birth",type:"text"},taxCountry:{label:"Tax Country",type:"select",countriesType:We.Address},taxNumber:{label:"Tax Number",type:"text"},defaultLanguage:{label:"Default Language",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"}},Ze={companyName:{label:"Company Name",type:"text"},email:{label:"Email",type:"email"},phone:{label:"Phone",type:"tel"},registrationNumber:{label:"Registration Number",type:"text"},countryResidence:{label:"Country of Residence",type:"select",countriesType:We.Address},legalAddress:{label:"Legal Address",type:"text"},incorporatedOn:{label:"Incorporation Date",type:"date"},controlScheme:{label:"Control Scheme",type:"text"},taxId:{label:"Tax ID",type:"text"},registrationLocation:{label:"Registration Location",type:"text"},website:{label:"Website",type:"text"},postalAddress:{label:"Postal Address",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},city:{label:"City",type:"text"},state:{label:"State / Province",type:"text"},postalCode:{label:"Postal Code",type:"text"},addressCountry:{label:"Address Country",type:"select",countriesType:We.Address},lei:{label:"LEI",type:"text"}},Wt=["companyName","email","phone","registrationNumber"],Ut=["firstName","lastName","email","phonenumber","dateOfBirth"],ht=[{value:"EN",label:"English"},{value:"DE",label:"German"},{value:"FR",label:"French"},{value:"ES",label:"Spanish"},{value:"IT",label:"Italian"},{value:"PT",label:"Portuguese"},{value:"NL",label:"Dutch"},{value:"PL",label:"Polish"},{value:"RU",label:"Russian"},{value:"ZH",label:"Chinese"},{value:"JA",label:"Japanese"},{value:"AR",label:"Arabic"},{value:"TR",label:"Turkish"},{value:"SV",label:"Swedish"},{value:"DA",label:"Danish"},{value:"FI",label:"Finnish"},{value:"NO",label:"Norwegian"}];var je=(t=>(t.Default="default",t.Corporate="corporate",t.Fintech="fintech",t.Healthcare="healthcare",t.Modern="modern",t.Minimal="minimal",t))(je||{});const Kt={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class qt{constructor(r){this.config=r}build(r,a){const s=`${r}.${a}`;if(this.config.customPaths&&this.config.customPaths[s])return this.config.customPaths[s];switch(this.config.pattern){case"host-controller":return`/api/${r}/${a}`;case"application-service":return`/services/app/${this.getServiceName(r)}/${a}`;case"custom":throw new Error(`Custom endpoint path not found for ${s}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(r){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[r]||r}}class De extends Error{constructor(a,s,n,o,c){super(a);pe(this,"response");this.code=s,this.details=n,this.validationErrors=o,this.name="MetaKYCError",this.response=c,Object.setPrototypeOf(this,De.prototype)}}class at{static handleApiError(r){return new De(r.message||"An unknown error occurred",r.code,r.details||void 0,r.validationErrors||void 0)}static handleAxiosError(r){if(r.response){const a=r.response.data;return a&&a.error?new De(a.error.message||"An unknown error occurred",a.error.code,a.error.details||void 0,a.error.validationErrors||void 0,r.response):a&&a.result&&a.result.message?new De(a.result.message,r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response):new De((a==null?void 0:a.message)||r.message||"Request failed",r.response.status,`HTTP ${r.response.status}: ${r.response.statusText}`,void 0,r.response)}else return r.request?new De("No response from server",0,"The request was made but no response was received. Please check your network connection."):new De(r.message||"An unexpected error occurred",0,r.toString())}static isMetaKYCError(r){return r instanceof De}}class Yt{constructor(r){pe(this,"axiosInstance");pe(this,"endpointBuilder");pe(this,"config");this.config={...Kt,...r},this.endpointBuilder=new qt(this.config.endpoints),this.axiosInstance=Qr.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(a=>{if(a.headers["Abp-TenantId"]=this.config.tenantId.toString(),this.config.getAccessToken){const s=this.config.getAccessToken();s&&(a.headers.Authorization=`Bearer ${s}`)}else this.config.apiKey&&(a.headers.ApiKey=this.config.apiKey,a.headers["X-API-KEY"]=this.config.apiKey);return this.config.locale&&(a.headers["Accept-Language"]=this.config.locale),a},a=>Promise.reject(a)),this.axiosInstance.interceptors.response.use(a=>a,async a=>{var n;const s=a.config;return((n=a.response)==null?void 0:n.status)>=500&&!s._retry&&(s._retry=!0,s._retryCount=(s._retryCount||0)+1,s._retryCount<(this.config.retries||3))?(await new Promise(o=>setTimeout(o,1e3*s._retryCount)),this.axiosInstance(s)):Promise.reject(a)})}buildEndpoint(r,a){return this.endpointBuilder.build(r,a)}async get(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.get(n,{params:s});return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async post(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.post(n,s);return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async put(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.put(n,s);return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}async delete(r,a,s){try{const n=this.buildEndpoint(r,a),o=await this.axiosInstance.delete(n,{params:s});return this.handleResponse(o)}catch(n){throw at.handleAxiosError(n)}}handleResponse(r){const a=r.data;if(!a.success&&a.error)throw at.handleApiError(a.error);return a}getAxiosInstance(){return this.axiosInstance}}class Vt{constructor(r){this.httpClient=r}async createApplicant(r){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",r)).result}async createCompanyApplicant(r){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",r)).result}async duplicateApplicant(r){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",r)).result}async getProgress(r){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:r})).result}async getProgressStatus(r){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:r})).result}async getApplicantData(r){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:r})).result}async getApplicantStatus(r){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:r})).result}async stopProgress(r){await this.httpClient.get("Applicant","StopProgress",{applicantId:r})}async progressStepBack(r){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:r})}async setLanguage(r,a){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:r,language:a})}async activateApplicant(r){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:r})}async deleteApplicant(r){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:r})}async checkApplicantExists(r){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:r})).result}}class Qt{constructor(r){this.httpClient=r}async getQuestionnaire(r){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:r})).result}async fillQuestionnaire(r){return(await this.httpClient.post("Applicant","FillQuestionnarie",r)).result}}class Gt{constructor(r){this.httpClient=r}async getUploadDocument(r){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:r})).result}async fillUploadDocument(r){await this.httpClient.post("Applicant","FillUploadDocument",r)}async reviewUploadDocument(r){await this.httpClient.post("UploadDocument","ReviewUploadDocument",r)}}class Jt{constructor(r){this.httpClient=r}async getAppropriatenessTest(r){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:r})).result}async fillAppropriatenessTest(r){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",r)).result}}class Xt{constructor(r){this.httpClient=r}async getOverviewData(r){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:r})).result}async passOverview(r){await this.httpClient.get("Applicant","PassOverview",{applicantId:r})}}class Zt{constructor(r){this.httpClient=r}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(r){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:r})).result}async submitRiskScoring(r){return(await this.httpClient.post("Applicant","RiskScoringRequest",r)).result}}class er{constructor(r){this.httpClient=r}async identityRequest(r){console.log("[IdentityService] Calling IdentityRequest with input:",r);const a=await this.httpClient.post("Applicant","IdentityRequest",r);return console.log("[IdentityService] IdentityRequest response:",a),a.result}async identityCompanyRequest(r){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",r)).result}async restartIdentityRequest(r){const a={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",a),this.identityRequest(a)}async restartIdentityCompanyRequest(r){const a={applicantId:r,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(a)}async refreshSumsubToken(r){console.log("[IdentityService] Refreshing Sumsub token for applicant:",r);const a=await this.httpClient.post("Applicant","RefreshSumsubToken",{applicantId:r});return console.log("[IdentityService] Sumsub token refresh result:",a),a.result.accessToken}}class tr{constructor(r){this.httpClient=r}async getCountries(r,a,s){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:r||"",lng:a||"en",type:s})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class rr{constructor(r){this.httpClient=r}async setInvestorCategorization(r){return(await this.httpClient.post("Applicant","SetInvestorCategorization",r)).result}async getInvestorCategorization(r){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:r})).result}}const Re={name:"Default",title:"KYC Verification",logo:{url:"",height:"40px",visible:!0},colors:{primary:"#2563eb",primaryHover:"#1d4ed8",primaryLight:"#dbeafe",primaryDark:"#1e40af",secondary:"#64748b",secondaryHover:"#475569",success:"#10b981",warning:"#f59e0b",danger:"#ef4444",info:"#3b82f6",background:"#ffffff",surface:"#f9fafb",border:"#e5e7eb",textPrimary:"#111827",textSecondary:"#6b7280",textMuted:"#9ca3af"},typography:{fontFamily:"Inter, system-ui, -apple-system, sans-serif",fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.875rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},spacing:{borderRadius:"0.5rem",cardPadding:"1.5rem",inputHeight:"2.5rem"},darkMode:{colors:{background:"#111827",surface:"#1f2937",border:"#374151",textPrimary:"#f9fafb",textSecondary:"#d1d5db",textMuted:"#9ca3af"}}},ar={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"}},sr={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"}},nr={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"}}},ir={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"}},or={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"}},lr={[je.Default]:Re,[je.Corporate]:ar,[je.Fintech]:sr,[je.Healthcare]:nr,[je.Modern]:ir,[je.Minimal]:or};function st(t){return lr[t]||Re}class cr{constructor(r){this.httpClient=r}async getThemeConfiguration(){var r;try{const a=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!a.result.isEnabled)return st(je.Default);let s=a.result.preset?st(a.result.preset):st(je.Default);if(a.result.title&&(s.title=a.result.title),a.result.logo&&(s.logo={...s.logo,...a.result.logo}),a.result.colors&&(s.colors={...s.colors,...a.result.colors}),a.result.typography&&(s.typography={...s.typography,...a.result.typography}),a.result.spacing&&(s.spacing={...s.spacing,...a.result.spacing}),a.result.customCSS&&(s.customCSS=a.result.customCSS),a.result.darkMode&&(s.darkMode={colors:{...(r=s.darkMode)==null?void 0:r.colors,...a.result.darkMode.colors}}),a.result.applicantFormVisibleFields&&a.result.applicantFormVisibleFields.length>0&&(s.applicantFormVisibleFields=a.result.applicantFormVisibleFields),a.result.applicantFormRequiredFields&&a.result.applicantFormRequiredFields.length>0&&(s.applicantFormRequiredFields=a.result.applicantFormRequiredFields),a.result.allowedLanguages&&a.result.allowedLanguages.length>0&&(s.allowedLanguages=a.result.allowedLanguages),a.result.applicantFormPages)try{const n=typeof a.result.applicantFormPages=="string"?JSON.parse(a.result.applicantFormPages):a.result.applicantFormPages;Array.isArray(n)&&n.length>0&&(s.applicantFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(a.result.reviewPageFields)try{const n=typeof a.result.reviewPageFields=="string"?JSON.parse(a.result.reviewPageFields):a.result.reviewPageFields;Array.isArray(n)&&n.length>0&&(s.reviewPageFields=n)}catch{}if(a.result.reviewPageDisabled&&(s.reviewPageDisabled=!0),a.result.fieldLabelMode==="placeholder"&&(s.fieldLabelMode="placeholder"),a.result.companyFormVisibleFields&&a.result.companyFormVisibleFields.length>0&&(s.companyFormVisibleFields=a.result.companyFormVisibleFields),a.result.companyFormRequiredFields&&a.result.companyFormRequiredFields.length>0&&(s.companyFormRequiredFields=a.result.companyFormRequiredFields),a.result.companyFormPages)try{const n=typeof a.result.companyFormPages=="string"?JSON.parse(a.result.companyFormPages):a.result.companyFormPages;Array.isArray(n)&&n.length>0&&(s.companyFormPages=n.map(o=>{const c=!o._v||o._v<4;return{...o,fields:(o.fields||[]).map(d=>({...d,colSpan:c?d.colSpan===1?2:4:Math.min(4,Math.max(1,d.colSpan??4))}))}}))}catch{}if(a.result.companyReviewPageFields)try{const n=typeof a.result.companyReviewPageFields=="string"?JSON.parse(a.result.companyReviewPageFields):a.result.companyReviewPageFields;Array.isArray(n)&&n.length>0&&(s.companyReviewPageFields=n)}catch{}return s}catch(a){return console.warn("[ThemeService] Failed to fetch theme configuration:",a),st(je.Default)}}async saveThemeConfiguration(r){await this.httpClient.post("Tenant","SaveThemeConfiguration",r)}getAvailablePresets(){return[{id:je.Default,name:"Default"},{id:je.Corporate,name:"Corporate"},{id:je.Fintech,name:"Fintech"},{id:je.Healthcare,name:"Healthcare"},{id:je.Modern,name:"Modern"},{id:je.Minimal,name:"Minimal"}]}getPreviewTheme(r,a){const s=st(r);return a?{...s,...a,logo:{...s.logo,...a.logo},colors:{...s.colors,...a.colors},typography:a.typography?{...s.typography,...a.typography}:s.typography,spacing:a.spacing?{...s.spacing,...a.spacing}:s.spacing}:s}}class dr{constructor(){pe(this,"listeners",new Map)}on(r,a){return this.listeners.has(r)||this.listeners.set(r,new Set),this.listeners.get(r).add(a),()=>{this.off(r,a)}}off(r,a){const s=this.listeners.get(r);s&&s.delete(a)}emit(r,a){const s=this.listeners.get(r);s&&s.forEach(n=>{try{n(a)}catch(o){console.error(`Error in event listener for "${r}":`,o)}})}clear(){this.listeners.clear()}clearEvent(r){this.listeners.delete(r)}}class mr{constructor(){pe(this,"events",new dr);pe(this,"_applicantId",null);pe(this,"_progress",null);pe(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var r;return((r=this._progress)==null?void 0:r.currentStep)||null}get steps(){var r;return((r=this._progress)==null?void 0:r.stepInfoList)||[]}get status(){var r;return((r=this._progress)==null?void 0:r.status)||Fe.None}get workflowResult(){var r;return((r=this._progress)==null?void 0:r.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===Fe.Finished}get isOnHold(){return this.status===Fe.OnHold}get isInProgress(){return this.status===Fe.InProgress}setApplicantId(r){this._applicantId=r}updateProgress(r){var s,n;const a=(s=this._progress)==null?void 0:s.currentStep;this._progress=r,this._applicantId=r.applicantId,this._error=null,this.events.emit("progressUpdated",r),(a==null?void 0:a.order)!==((n=r.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",r.currentStep),this.events.emit("statusChanged",r.status),r.status===Fe.Finished&&r.workflowResult&&this.events.emit("completed",r.workflowResult)}setError(r){this._error=r,this.events.emit("error",r)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(r){return this.events.on("progressUpdated",r)}onStepChanged(r){return this.events.on("stepChanged",r)}onStatusChanged(r){return this.events.on("statusChanged",r)}onError(r){return this.events.on("error",r)}onCompleted(r){return this.events.on("completed",r)}clearListeners(){this.events.clear()}}class pr{constructor(){pe(this,"handlers",new Map)}registerHandler(r,a){this.handlers.set(r,a)}getHandler(r){return this.handlers.get(r)}hasHandler(r){return this.handlers.has(r)}async loadStepData(r,a){const s=this.getHandler(r);if(!s)throw new Error(`No handler registered for step action: ${oe[r]}`);return s.loadData(a)}async submitStepData(r,a){const s=this.getHandler(r);if(!s)throw new Error(`No handler registered for step action: ${oe[r]}`);return s.submitData(a)}}class ur{constructor(r,a,s,n,o,c,d,y){pe(this,"state");pe(this,"stepRouter");this.applicantService=r,this.questionnaireService=a,this.uploadDocumentService=s,this.appropriatenessTestService=n,this.overviewService=o,this.riskScoringService=c,this.investorCategorizationService=y,this.state=new mr,this.stepRouter=new pr,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(oe.Questionaries,{loadData:r=>this.questionnaireService.getQuestionnaire(r),submitData:async r=>{await this.questionnaireService.fillQuestionnaire(r)}}),this.stepRouter.registerHandler(oe.UploadDocument,{loadData:r=>this.uploadDocumentService.getUploadDocument(r),submitData:r=>this.uploadDocumentService.fillUploadDocument(r)}),this.stepRouter.registerHandler(oe.AppropriatenessTest,{loadData:r=>this.appropriatenessTestService.getAppropriatenessTest(r),submitData:async r=>{await this.appropriatenessTestService.fillAppropriatenessTest(r)}}),this.stepRouter.registerHandler(oe.Overview,{loadData:r=>this.overviewService.getOverviewData(r),submitData:r=>this.overviewService.passOverview(r.applicantId)}),this.stepRouter.registerHandler(oe.RiskScoring,{loadData:r=>this.riskScoringService.getRiskCriterias(r),submitData:async r=>{await this.riskScoringService.submitRiskScoring(r)}}),this.stepRouter.registerHandler(oe.IdentitySdk,{loadData:async r=>({applicantId:r,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.InvestorCategorization,{loadData:r=>this.investorCategorizationService.getInvestorCategorization(r),submitData:async r=>{await this.investorCategorizationService.setInvestorCategorization(r)}}),this.stepRouter.registerHandler(oe.ManualReview,{loadData:async r=>({applicantId:r,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(oe.AdditionalData,{loadData:async r=>({applicantId:r,message:"Additional data required"}),submitData:async()=>{}})}async initialize(r){try{this.state.setApplicantId(r);const a=await this.applicantService.getProgress(r);return this.state.updateProgress(a),a}catch(a){throw this.state.setError(a),a}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const r=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(r),r}catch(r){throw this.state.setError(r),r}}async getCurrentStepData(){if(!this.state.currentStep)throw new Error("No current step available");if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.stepRouter.loadStepData(this.state.currentStep.action,this.state.applicantId)}catch(r){throw this.state.setError(r),r}}async submitCurrentStep(r){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,r),await this.refreshProgress()}catch(a){throw this.state.setError(a),a}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(r){throw this.state.setError(r),r}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function kt(t,r){return new Promise((a,s)=>{if(r&&document.getElementById(r)){a();return}const n=document.createElement("script");n.src=t,r&&(n.id=r),n.async=!0,n.onload=()=>a(),n.onerror=()=>s(new Error(`Failed to load script: ${t}`)),document.head.appendChild(n)})}function Jr(t){return!!document.getElementById(t)}function Xr(t){const r=document.getElementById(t);r&&r.remove()}const Zr="https://static.sumsub.com/idensic/static/sns-websdk-builder.js";function _e(t,r){try{const a=document.querySelector(".metakyc-sdk")||document.documentElement;return getComputedStyle(a).getPropertyValue(t).trim()||r}catch{return r}}function ea(){const t=_e("--metakyc-primary","#2563eb"),r=_e("--metakyc-primary-hover","#1d4ed8"),a=_e("--metakyc-background","#ffffff"),s=_e("--metakyc-surface","#f9fafb"),n=_e("--metakyc-text-primary","#111827"),o=_e("--metakyc-text-secondary","#6b7280"),c=_e("--metakyc-text-muted","#9ca3af"),d=_e("--metakyc-border","#e5e7eb");return`
|
|
2
2
|
body, html { font-family: ${_e("--metakyc-font-family","-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif")} !important; background-color: ${a} !important; }
|
|
3
3
|
p, span, label, div { color: ${n}; }
|
|
4
4
|
h1, h2, h3, h4 { color: ${n}; }
|
|
@@ -18,8 +18,16 @@ select { background-color: ${a}; color: ${n}; border: 1px solid ${d}; border-rad
|
|
|
18
18
|
.subtitle { color: ${c}; }
|
|
19
19
|
a { color: ${t}; }
|
|
20
20
|
a:hover { color: ${r}; }
|
|
21
|
-
`.trim()}class yr{constructor(r){pe(this,"sdk",null);pe(this,"config");pe(this,"completeCallback",null);pe(this,"errorCallback",null);this.config=r}async loadSDK(){if(!window.snsWebSdk&&(await kt(Zr,"sumsub-websdk"),!window.snsWebSdk))throw new Error("Sumsub Web SDK failed to load from CDN")}async initialize(r){await this.loadSDK();const a={lang:this.config.lang||"en"};if(this.config.applicantEmail&&(a.email=this.config.applicantEmail),this.config.applicantPhone&&(a.phone=this.config.applicantPhone),this.config.theme&&(a.theme=this.config.theme),this.config.customizationName&&(a.customizationName=this.config.customizationName),!this.config.customizationName){const n={};this.config.customCss&&(n.customCss=this.config.customCss),this.config.customCssStr&&(n.customCssStr=this.config.customCssStr),n.customCssStr||(n.customCssStr=ea()),a.uiConf=n}const s=window.snsWebSdk.init(this.config.accessToken,()=>this.config.onTokenRefresh()).withConf(a).withOptions({addViewportTag:!1,adaptIframeHeight:this.config.adaptIframeHeight!==!1}).on("idCheck.onStepCompleted",n=>{console.log("[Sumsub] Step completed:",n)}).on("idCheck.applicantStatus",n=>{var o,c;console.log("[Sumsub] Applicant status:",n),((n==null?void 0:n.reviewStatus)==="completed"||((o=n==null?void 0:n.reviewResult)==null?void 0:o.reviewAnswer)==="GREEN")&&((c=this.completeCallback)==null||c.call(this,n))}).on("idCheck.onError",n=>{var o;console.error("[Sumsub] Error:",n),(o=this.errorCallback)==null||o.call(this,n)}).onMessage((n,o)=>{var c;console.log("[Sumsub] Message:",n,o),n==="idCheck.onApplicantSubmitted"&&((c=this.completeCallback)==null||c.call(this,o))});this.sdk=s.build(),this.sdk.launch(`#${r}`)}destroy(){if(this.sdk){try{this.sdk.destroy()}catch{}this.sdk=null}}onComplete(r){this.completeCallback=r}onError(r){this.errorCallback=r}}class xr{constructor(r){pe(this,"sdk",null);pe(this,"config");this.config=r}async loadSDK(){await kt("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:a=>{this.config.onError&&this.config.onError(a)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class gr{constructor(r){pe(this,"sardineContext",null);pe(this,"config");pe(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const a=Math.random()*16|0;return(r==="x"?a:a&3|8).toString(16)})}getSardineHost(){const{environment:r,region:a}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(a){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,a)=>{if(window._Sardine){r();return}const s=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${s}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{a(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(n,o):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:a,environment:s,flow:n,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:a,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:s||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:d=>{console.log(`[SardinAI] Device ID: ${d.deviceId}`)},onConfigUpdate:(d,y,p)=>{switch(d){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",y);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",d)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const a=document.createElement("noscript"),s=document.createElement("img"),{clientId:n,flow:o}=this.config;s.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${o||"kyc"}&ns=1`,s.style.display="none",a.appendChild(s),document.body.appendChild(a)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(a,s,n)=>{switch(a){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",s);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class He{static createProvider(r,a){switch(r){case Ae.Sumsub:return new yr(a);case Ae.Onfido:return new xr(a);case Ae.SardinAI:return new gr(a);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,a,s){var n,o;switch(r){case Ae.Sumsub:const c=((n=s==null?void 0:s.identityProviders)==null?void 0:n.sumsub)||{};return{accessToken:a.accessToken||a.token,applicantEmail:a.email,applicantPhone:a.phone,externalUserId:a.externalUserId,lang:c.lang||a.lang||"en",theme:c.theme,customizationName:c.customizationName,customCss:c.customCss,adaptIframeHeight:c.adaptIframeHeight};case Ae.Onfido:return{token:a.token||a.sdkToken};case Ae.SardinAI:const d=((o=s==null?void 0:s.identityProviders)==null?void 0:o.sardinai)||{};return{clientId:d.clientId||a.clientId,sessionKey:d.sessionKey||a.sessionKey,environment:d.environment||a.environment||"production",flow:d.flow||a.flow,region:d.region,enableBiometrics:d.enableBiometrics,enablePortScanning:d.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}
|
|
22
|
-
/* ── metakyc-
|
|
21
|
+
`.trim()}class yr{constructor(r){pe(this,"sdk",null);pe(this,"config");pe(this,"completeCallback",null);pe(this,"errorCallback",null);this.config=r}async loadSDK(){if(!window.snsWebSdk&&(await kt(Zr,"sumsub-websdk"),!window.snsWebSdk))throw new Error("Sumsub Web SDK failed to load from CDN")}async initialize(r){await this.loadSDK();const a={lang:this.config.lang||"en"};if(this.config.applicantEmail&&(a.email=this.config.applicantEmail),this.config.applicantPhone&&(a.phone=this.config.applicantPhone),this.config.theme&&(a.theme=this.config.theme),this.config.customizationName&&(a.customizationName=this.config.customizationName),!this.config.customizationName){const n={};this.config.customCss&&(n.customCss=this.config.customCss),this.config.customCssStr&&(n.customCssStr=this.config.customCssStr),n.customCssStr||(n.customCssStr=ea()),a.uiConf=n}const s=window.snsWebSdk.init(this.config.accessToken,()=>this.config.onTokenRefresh()).withConf(a).withOptions({addViewportTag:!1,adaptIframeHeight:this.config.adaptIframeHeight!==!1}).on("idCheck.onStepCompleted",n=>{console.log("[Sumsub] Step completed:",n)}).on("idCheck.applicantStatus",n=>{var o,c;console.log("[Sumsub] Applicant status:",n),((n==null?void 0:n.reviewStatus)==="completed"||((o=n==null?void 0:n.reviewResult)==null?void 0:o.reviewAnswer)==="GREEN")&&((c=this.completeCallback)==null||c.call(this,n))}).on("idCheck.onError",n=>{var o;console.error("[Sumsub] Error:",n),(o=this.errorCallback)==null||o.call(this,n)}).onMessage((n,o)=>{var c;console.log("[Sumsub] Message:",n,o),n==="idCheck.onApplicantSubmitted"&&((c=this.completeCallback)==null||c.call(this,o))});this.sdk=s.build(),this.sdk.launch(`#${r}`)}destroy(){if(this.sdk){try{this.sdk.destroy()}catch{}this.sdk=null}}onComplete(r){this.completeCallback=r}onError(r){this.errorCallback=r}}class xr{constructor(r){pe(this,"sdk",null);pe(this,"config");this.config=r}async loadSDK(){await kt("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(r){if(window.Onfido||await this.loadSDK(),!window.Onfido)throw new Error("Onfido SDK failed to load");this.sdk=window.Onfido.init({token:this.config.token,containerId:r,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:a=>{this.config.onError&&this.config.onError(a)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class gr{constructor(r){pe(this,"sardineContext",null);pe(this,"config");pe(this,"sessionKey");this.config=r,this.sessionKey=r.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){const a=Math.random()*16|0;return(r==="x"?a:a&3|8).toString(16)})}getSardineHost(){const{environment:r,region:a}=this.config;if(r==="sandbox")return"api.sandbox.sardine.ai";switch(a){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((r,a)=>{if(window._Sardine){r();return}const s=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${s}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),r()},n.onerror=()=>{a(new Error("Failed to load SardinAI SDK"))};const o=document.getElementsByTagName("script")[0];o&&o.parentNode?o.parentNode.insertBefore(n,o):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const r=this.getSardineHost(),{clientId:a,environment:s,flow:n,enableBiometrics:o,enablePortScanning:c}=this.config;this.sardineContext=window._Sardine.createContext({clientId:a,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:s||"production",parentElement:document.body,enableBiometrics:o!==!1,enablePortScanning:c===!0,region:this.config.region,onDeviceResponse:d=>{console.log(`[SardinAI] Device ID: ${d.deviceId}`)},onConfigUpdate:(d,y,p)=>{switch(d){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",p);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",y);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",d)}}}),this.addNoScriptFallback(r),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(r){throw console.error("[SardinAI] Initialization failed:",r),r}}addNoScriptFallback(r){const a=document.createElement("noscript"),s=document.createElement("img"),{clientId:n,flow:o}=this.config;s.src=`https://${r}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${o||"kyc"}&ns=1`,s.style.display="none",a.appendChild(s),document.body.appendChild(a)}updateConfig(r){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}r.sessionKey&&(this.sessionKey=r.sessionKey),this.sardineContext.updateConfig({...r,onConfigUpdate:(a,s,n)=>{switch(a){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",s);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class He{static createProvider(r,a){switch(r){case Ae.Sumsub:return new yr(a);case Ae.Onfido:return new xr(a);case Ae.SardinAI:return new gr(a);default:throw new Error(`Unsupported identity provider: ${r}`)}}static parseProviderConfig(r,a,s){var n,o;switch(r){case Ae.Sumsub:const c=((n=s==null?void 0:s.identityProviders)==null?void 0:n.sumsub)||{};return{accessToken:a.accessToken||a.token,applicantEmail:a.email,applicantPhone:a.phone,externalUserId:a.externalUserId,lang:c.lang||a.lang||"en",theme:c.theme,customizationName:c.customizationName,customCss:c.customCss,adaptIframeHeight:c.adaptIframeHeight};case Ae.Onfido:return{token:a.token||a.sdkToken};case Ae.SardinAI:const d=((o=s==null?void 0:s.identityProviders)==null?void 0:o.sardinai)||{};return{clientId:d.clientId||a.clientId,sessionKey:d.sessionKey||a.sessionKey,environment:d.environment||a.environment||"production",flow:d.flow||a.flow,region:d.region,enableBiometrics:d.enableBiometrics,enablePortScanning:d.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${r}`)}}}class hr{constructor(){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"themeStyleElement",null)}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.injectThemeCSS(),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}injectThemeCSS(){var d;this.themeStyleElement&&this.themeStyleElement.remove();const r=this.currentTheme.colors,a=this.currentTheme.typography,s=this.currentTheme.spacing,n={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};a!=null&&a.fontFamily&&(n["font-family"]=a.fontFamily),a!=null&&a.headingFont&&(n["heading-font"]=a.headingFont),a!=null&&a.fontSize&&Object.entries(a.fontSize).forEach(([y,p])=>{n[`font-size-${y}`]=p}),a!=null&&a.fontWeight&&Object.entries(a.fontWeight).forEach(([y,p])=>{n[`font-weight-${y}`]=String(p)}),s&&Object.entries(s).forEach(([y,p])=>{n[this.kebabCase(y)]=p});const c=`
|
|
22
|
+
/* ── metakyc-theme-vars: scoped CSS variables ──────────────────────────────── */
|
|
23
|
+
.metakyc-sdk,
|
|
24
|
+
.metakyc-searchable-select-dropdown,
|
|
25
|
+
.metakyc-multiselect-dropdown {
|
|
26
|
+
${Object.entries(n).filter(([,y])=>!!y).map(([y,p])=>` --metakyc-${y}: ${p} !important;`).join(`
|
|
27
|
+
`)}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* ── metakyc-input-overrides: hardened input styling ───────────────────────── */
|
|
23
31
|
.metakyc-sdk input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="range"]),
|
|
24
32
|
.metakyc-sdk select,
|
|
25
33
|
.metakyc-sdk textarea,
|
|
@@ -49,7 +57,21 @@ a:hover { color: ${r}; }
|
|
|
49
57
|
position: relative !important;
|
|
50
58
|
z-index: 2 !important;
|
|
51
59
|
}
|
|
52
|
-
`}class hr{constructor(r){pe(this,"currentTheme",Re);pe(this,"customStyleElement",null);pe(this,"inputStyleElement",null);pe(this,"container");this.container=r||document.documentElement}applyTheme(r){this.currentTheme=this.mergeWithDefault(r),this.applyColors(this.currentTheme.colors),this.currentTheme.typography&&this.applyTypography(this.currentTheme.typography),this.currentTheme.spacing&&this.applySpacing(this.currentTheme.spacing),this.currentTheme.customCSS&&this.injectCustomCSS(this.currentTheme.customCSS),console.log("[ThemeManager] Theme applied:",this.currentTheme.name||"Custom")}applyColors(r){var s;const a={primary:r.primary,"primary-hover":r.primaryHover,"primary-light":r.primaryLight,"primary-dark":r.primaryDark,secondary:r.secondary,"secondary-hover":r.secondaryHover,success:r.success,warning:r.warning,danger:r.danger,info:r.info,background:r.background,surface:r.surface,border:r.border,"text-primary":r.textPrimary,"text-secondary":r.textSecondary,"text-muted":r.textMuted,"input-bg":r.inputBg||r.background,"input-text":r.inputText||r.textPrimary,"input-border":r.inputBorder||r.border,"input-border-focus":r.inputBorderFocus||r.primary,"input-placeholder":r.inputPlaceholder||r.textMuted};Object.entries(a).forEach(([n,o])=>{o&&this.container.style.setProperty(`--metakyc-${n}`,o)}),this.injectInputColors(),(s=this.currentTheme.darkMode)!=null&&s.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(r){Object.entries(r).forEach(([a,s])=>{if(s){const n=`--metakyc-dark-${this.kebabCase(a)}`;this.container.style.setProperty(n,s)}})}applyTypography(r){r&&(r.fontFamily&&this.container.style.setProperty("--metakyc-font-family",r.fontFamily),r.headingFont&&this.container.style.setProperty("--metakyc-heading-font",r.headingFont),r.fontSize&&Object.entries(r.fontSize).forEach(([a,s])=>{this.container.style.setProperty(`--metakyc-font-size-${a}`,s)}),r.fontWeight&&Object.entries(r.fontWeight).forEach(([a,s])=>{this.container.style.setProperty(`--metakyc-font-weight-${a}`,s.toString())}))}applySpacing(r){r&&Object.entries(r).forEach(([a,s])=>{const n=`--metakyc-${this.kebabCase(a)}`;this.container.style.setProperty(n,s)})}injectInputColors(){this.inputStyleElement&&this.inputStyleElement.remove(),this.inputStyleElement=document.createElement("style"),this.inputStyleElement.id="metakyc-input-colors",this.inputStyleElement.textContent=ta(),this.customStyleElement&&this.customStyleElement.parentNode?document.head.insertBefore(this.inputStyleElement,this.customStyleElement):document.head.appendChild(this.inputStyleElement)}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var a;return{name:r.name||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(a=Re.darkMode)==null?void 0:a.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.inputStyleElement&&(this.inputStyleElement.remove(),this.inputStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const bt=i.createContext(null),fr="1.0.9",ra='.metakyc-sdk .pointer-events-none{pointer-events:none}.metakyc-sdk .visible{visibility:visible}.metakyc-sdk .static{position:static}.metakyc-sdk .fixed{position:fixed}.metakyc-sdk .absolute{position:absolute}.metakyc-sdk .relative{position:relative}.metakyc-sdk .inset-y-0{top:0;bottom:0}.metakyc-sdk .left-0{left:0}.metakyc-sdk .right-0{right:0}.metakyc-sdk .right-3{right:.75rem}.metakyc-sdk .top-1\\/2{top:50%}.metakyc-sdk .mx-4{margin-left:1rem;margin-right:1rem}.metakyc-sdk .mx-6{margin-left:1.5rem;margin-right:1.5rem}.metakyc-sdk .mx-auto{margin-left:auto;margin-right:auto}.metakyc-sdk .my-8{margin-top:2rem;margin-bottom:2rem}.metakyc-sdk .-ml-1{margin-left:-.25rem}.metakyc-sdk .mb-0\\.5{margin-bottom:.125rem}.metakyc-sdk .mb-1{margin-bottom:.25rem}.metakyc-sdk .mb-2{margin-bottom:.5rem}.metakyc-sdk .mb-3{margin-bottom:.75rem}.metakyc-sdk .mb-4{margin-bottom:1rem}.metakyc-sdk .mb-6{margin-bottom:1.5rem}.metakyc-sdk .ml-0\\.5{margin-left:.125rem}.metakyc-sdk .ml-1{margin-left:.25rem}.metakyc-sdk .ml-3{margin-left:.75rem}.metakyc-sdk .mr-2{margin-right:.5rem}.metakyc-sdk .mr-3{margin-right:.75rem}.metakyc-sdk .mt-0\\.5{margin-top:.125rem}.metakyc-sdk .mt-1{margin-top:.25rem}.metakyc-sdk .mt-2{margin-top:.5rem}.metakyc-sdk .mt-3{margin-top:.75rem}.metakyc-sdk .mt-4{margin-top:1rem}.metakyc-sdk .mt-6{margin-top:1.5rem}.metakyc-sdk .block{display:block}.metakyc-sdk .inline-block{display:inline-block}.metakyc-sdk .inline{display:inline}.metakyc-sdk .flex{display:flex}.metakyc-sdk .inline-flex{display:inline-flex}.metakyc-sdk .grid{display:grid}.metakyc-sdk .hidden{display:none}.metakyc-sdk .h-12{height:3rem}.metakyc-sdk .h-16{height:4rem}.metakyc-sdk .h-24{height:6rem}.metakyc-sdk .h-4{height:1rem}.metakyc-sdk .h-6{height:1.5rem}.metakyc-sdk .h-8{height:2rem}.metakyc-sdk .h-full{height:100%}.metakyc-sdk .max-h-52{max-height:13rem}.metakyc-sdk .min-h-\\[400px\\]{min-height:400px}.metakyc-sdk .w-12{width:3rem}.metakyc-sdk .w-16{width:4rem}.metakyc-sdk .w-20{width:5rem}.metakyc-sdk .w-24{width:6rem}.metakyc-sdk .w-4{width:1rem}.metakyc-sdk .w-6{width:1.5rem}.metakyc-sdk .w-8{width:2rem}.metakyc-sdk .w-full{width:100%}.metakyc-sdk .max-w-md{max-width:28rem}.metakyc-sdk .flex-1{flex:1 1 0%}.metakyc-sdk .flex-shrink-0{flex-shrink:0}.metakyc-sdk .-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.metakyc-sdk .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes spin{to{transform:rotate(360deg)}}.metakyc-sdk .animate-spin{animation:spin 1s linear infinite}.metakyc-sdk .cursor-not-allowed{cursor:not-allowed}.metakyc-sdk .cursor-pointer{cursor:pointer}.metakyc-sdk .resize{resize:both}.metakyc-sdk .list-inside{list-style-position:inside}.metakyc-sdk .list-disc{list-style-type:disc}.metakyc-sdk .list-none{list-style-type:none}.metakyc-sdk .grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.metakyc-sdk .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.metakyc-sdk .flex-col{flex-direction:column}.metakyc-sdk .flex-wrap{flex-wrap:wrap}.metakyc-sdk .items-start{align-items:flex-start}.metakyc-sdk .items-center{align-items:center}.metakyc-sdk .justify-center{justify-content:center}.metakyc-sdk .justify-between{justify-content:space-between}.metakyc-sdk .gap-1{gap:.25rem}.metakyc-sdk .gap-1\\.5{gap:.375rem}.metakyc-sdk .gap-2{gap:.5rem}.metakyc-sdk .gap-4{gap:1rem}.metakyc-sdk :is(.space-x-3>:not([hidden])~:not([hidden])){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.metakyc-sdk :is(.space-y-1>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-1\\.5>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-6>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-8>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.metakyc-sdk .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.metakyc-sdk .rounded{border-radius:.25rem}.metakyc-sdk .rounded-full{border-radius:9999px}.metakyc-sdk .rounded-lg{border-radius:.5rem}.metakyc-sdk .rounded-xl{border-radius:.75rem}.metakyc-sdk .border{border-width:1px}.metakyc-sdk .border-0{border-width:0px}.metakyc-sdk .border-2{border-width:2px}.metakyc-sdk .border-b{border-bottom-width:1px}.metakyc-sdk .border-t{border-top-width:1px}.metakyc-sdk .border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-danger-500{border-color:var(--metakyc-danger, #EF4444)}.metakyc-sdk .border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.metakyc-sdk .bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.metakyc-sdk .p-3{padding:.75rem}.metakyc-sdk .p-4{padding:1rem}.metakyc-sdk .px-2{padding-left:.5rem;padding-right:.5rem}.metakyc-sdk .px-2\\.5{padding-left:.625rem;padding-right:.625rem}.metakyc-sdk .px-3{padding-left:.75rem;padding-right:.75rem}.metakyc-sdk .px-4{padding-left:1rem;padding-right:1rem}.metakyc-sdk .px-6{padding-left:1.5rem;padding-right:1.5rem}.metakyc-sdk .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.metakyc-sdk .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.metakyc-sdk .py-12{padding-top:3rem;padding-bottom:3rem}.metakyc-sdk .py-2{padding-top:.5rem;padding-bottom:.5rem}.metakyc-sdk .py-3{padding-top:.75rem;padding-bottom:.75rem}.metakyc-sdk .py-4{padding-top:1rem;padding-bottom:1rem}.metakyc-sdk .py-8{padding-top:2rem;padding-bottom:2rem}.metakyc-sdk .pb-4{padding-bottom:1rem}.metakyc-sdk .pl-10{padding-left:2.5rem}.metakyc-sdk .pl-3{padding-left:.75rem}.metakyc-sdk .pr-10{padding-right:2.5rem}.metakyc-sdk .pr-3{padding-right:.75rem}.metakyc-sdk .pr-6{padding-right:1.5rem}.metakyc-sdk .pt-6{padding-top:1.5rem}.metakyc-sdk .text-left{text-align:left}.metakyc-sdk .text-center{text-align:center}.metakyc-sdk .text-right{text-align:right}.metakyc-sdk .text-2xl{font-size:1.5rem;line-height:2rem}.metakyc-sdk .text-3xl{font-size:1.875rem;line-height:2.25rem}.metakyc-sdk .text-5xl{font-size:3rem;line-height:1}.metakyc-sdk .text-base{font-size:1rem;line-height:1.5rem}.metakyc-sdk .text-lg{font-size:1.125rem;line-height:1.75rem}.metakyc-sdk .text-sm{font-size:.875rem;line-height:1.25rem}.metakyc-sdk .text-xl{font-size:1.25rem;line-height:1.75rem}.metakyc-sdk .text-xs{font-size:.75rem;line-height:1rem}.metakyc-sdk .font-bold{font-weight:700}.metakyc-sdk .font-medium{font-weight:500}.metakyc-sdk .font-semibold{font-weight:600}.metakyc-sdk .uppercase{text-transform:uppercase}.metakyc-sdk .lowercase{text-transform:lowercase}.metakyc-sdk .tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.metakyc-sdk .leading-6{line-height:1.5rem}.metakyc-sdk .text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-danger-500{color:var(--metakyc-danger, #EF4444)}.metakyc-sdk .text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-900{--tw-text-opacity: 1;color:rgb(20 83 45 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-primary,.metakyc-sdk .text-primary-500{color:var(--metakyc-primary, #3B82F6)}.metakyc-sdk .text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-secondary{color:var(--metakyc-secondary, #64748b)}.metakyc-sdk .text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.metakyc-sdk .underline{text-decoration-line:underline}.metakyc-sdk .opacity-25{opacity:.25}.metakyc-sdk .opacity-50{opacity:.5}.metakyc-sdk .opacity-60{opacity:.6}.metakyc-sdk .opacity-75{opacity:.75}.metakyc-sdk .shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.metakyc-sdk .outline{outline-style:solid}.metakyc-sdk .blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.metakyc-sdk .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.metakyc-sdk .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .duration-200{transition-duration:.2s}.metakyc-sdk .grid{display:grid!important}.metakyc-sdk .flex{display:flex!important}.metakyc-sdk .inline-flex{display:inline-flex!important}.metakyc-sdk .hidden{display:none!important}.metakyc-sdk .block{display:block!important}.metakyc-sdk .grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))!important}.metakyc-sdk .col-span-1{grid-column:span 1 / span 1!important}.metakyc-sdk .col-span-2{grid-column:span 2 / span 2!important}.metakyc-sdk .col-span-3{grid-column:span 3 / span 3!important}.metakyc-sdk .col-span-4{grid-column:span 4 / span 4!important}.metakyc-sdk .gap-1{gap:.25rem!important}.metakyc-sdk .gap-2{gap:.5rem!important}.metakyc-sdk .gap-3{gap:.75rem!important}.metakyc-sdk .gap-4{gap:1rem!important}.metakyc-sdk .gap-6{gap:1.5rem!important}.metakyc-sdk .gap-8{gap:2rem!important}.metakyc-sdk .flex-col{flex-direction:column!important}.metakyc-sdk .flex-row{flex-direction:row!important}.metakyc-sdk .flex-wrap{flex-wrap:wrap!important}.metakyc-sdk .flex-1{flex:1 1 0%!important}.metakyc-sdk .flex-shrink-0{flex-shrink:0!important}.metakyc-sdk .items-center{align-items:center!important}.metakyc-sdk .items-start{align-items:flex-start!important}.metakyc-sdk .items-end{align-items:flex-end!important}.metakyc-sdk .justify-between{justify-content:space-between!important}.metakyc-sdk .justify-center{justify-content:center!important}.metakyc-sdk .justify-end{justify-content:flex-end!important}.metakyc-sdk .justify-start{justify-content:flex-start!important}.metakyc-sdk .space-y-1>*+*{margin-top:.25rem!important}.metakyc-sdk .space-y-1\\.5>*+*{margin-top:.375rem!important}.metakyc-sdk .space-y-2>*+*{margin-top:.5rem!important}.metakyc-sdk .space-y-3>*+*{margin-top:.75rem!important}.metakyc-sdk .space-y-4>*+*{margin-top:1rem!important}.metakyc-sdk .space-y-6>*+*{margin-top:1.5rem!important}.metakyc-sdk .w-full{width:100%!important}.metakyc-sdk .relative{position:relative!important}.metakyc-sdk .absolute{position:absolute!important}.metakyc-sdk .overflow-hidden{overflow:hidden!important}.metakyc-sdk .overflow-auto{overflow:auto!important}.metakyc-sdk .overflow-x-auto{overflow-x:auto!important}@media (min-width: 768px){.metakyc-sdk .md\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))!important}.metakyc-sdk .md\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))!important}}.metakyc-sdk *,.metakyc-sdk *:before,.metakyc-sdk *:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--metakyc-border, #e5e7eb)}.metakyc-sdk{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}.metakyc-sdk img,.metakyc-sdk video{max-width:100%;height:auto}.metakyc-sdk h1,.metakyc-sdk h2,.metakyc-sdk h3,.metakyc-sdk h4,.metakyc-sdk h5,.metakyc-sdk h6,.metakyc-sdk p{margin:0}.metakyc-sdk ol,.metakyc-sdk ul{list-style:none;margin:0;padding:0}.metakyc-sdk button,.metakyc-sdk input,.metakyc-sdk optgroup,.metakyc-sdk select,.metakyc-sdk textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.metakyc-sdk button,.metakyc-sdk [role=button]{cursor:pointer}.metakyc-sdk a{color:inherit;text-decoration:inherit}.metakyc-sdk input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]),.metakyc-sdk select,.metakyc-sdk textarea,.metakyc-sdk .metakyc-searchable-select-trigger,.metakyc-sdk .metakyc-multiselect-trigger{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important}.metakyc-sdk input::-moz-placeholder,.metakyc-sdk textarea::-moz-placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-sdk input::placeholder,.metakyc-sdk textarea::placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-sdk input:not([type=checkbox]):not([type=radio]):focus,.metakyc-sdk select:focus,.metakyc-sdk textarea:focus{outline:none!important;border-color:var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb)) 20%,transparent)!important}.metakyc-sdk input[type=checkbox],.metakyc-sdk input[type=radio]{appearance:none!important;-webkit-appearance:none!important;-moz-appearance:none!important;width:16px!important;height:16px!important;min-width:16px!important;min-height:16px!important;max-width:16px!important;max-height:16px!important;flex-shrink:0!important;cursor:pointer!important;background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;border:1.5px solid var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important;position:relative!important;transition:background-color .15s,border-color .15s!important;vertical-align:middle!important;display:inline-block!important;padding:0!important;margin:0!important;color-scheme:light!important}.metakyc-sdk input[type=checkbox]{border-radius:4px!important}.metakyc-sdk input[type=radio]{border-radius:50%!important}.metakyc-sdk input[type=checkbox]:checked,.metakyc-sdk input[type=radio]:checked{background-color:var(--metakyc-primary, #2563eb)!important;border-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk input[type=checkbox]:checked:after{content:""!important;display:block!important;position:absolute!important;left:4px!important;top:1px!important;width:5px!important;height:9px!important;border:2px solid #ffffff!important;border-top:none!important;border-left:none!important;transform:rotate(45deg)!important}.metakyc-sdk input[type=radio]:checked:after{content:""!important;display:block!important;position:absolute!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:6px!important;height:6px!important;border-radius:50%!important;background:#fff!important}.metakyc-sdk input[type=checkbox]:focus,.metakyc-sdk input[type=radio]:focus{outline:none!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-primary, #2563eb) 30%,transparent)!important}.metakyc-searchable-select-dropdown,.metakyc-multiselect-dropdown{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important}.metakyc-searchable-select-dropdown input,.metakyc-multiselect-dropdown input{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important}.metakyc-searchable-select-dropdown input::-moz-placeholder,.metakyc-multiselect-dropdown input::-moz-placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-searchable-select-dropdown input::placeholder,.metakyc-multiselect-dropdown input::placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-searchable-select-dropdown input:focus,.metakyc-multiselect-dropdown input:focus{outline:none!important;background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb)) 20%,transparent)!important}.metakyc-searchable-select-dropdown li:hover,.metakyc-multiselect-dropdown li:hover{background-color:var(--metakyc-surface, var(--metakyc-background, #f9fafb))!important}.metakyc-sdk .metakyc-help-btn{color:var(--metakyc-primary, #2563eb)!important;border-color:var(--metakyc-primary, #2563eb)!important;background:transparent!important;position:relative!important;z-index:2!important}.metakyc-sdk .metakyc-overview-step-item,.metakyc-sdk .metakyc-overview-step-item *,.metakyc-sdk .metakyc-step-content,.metakyc-sdk .metakyc-step-content *,.metakyc-sdk .metakyc-step-title,.metakyc-sdk .metakyc-step-title *,.metakyc-sdk .metakyc-step-icon,.metakyc-sdk .metakyc-step-icon *,.metakyc-sdk .metakyc-step-description,.metakyc-sdk .metakyc-step-description *{border-top-width:0!important;border-bottom-width:0!important;border-left-width:0!important;border-right-width:0!important;border-top-style:none!important;border-bottom-style:none!important;border-left-style:none!important;border-right-style:none!important;border-top-color:transparent!important;border-bottom-color:transparent!important;border-left-color:transparent!important;border-right-color:transparent!important;border:0!important;box-shadow:none!important;outline:none!important;outline-width:0!important;outline-style:none!important;text-decoration:none!important;text-decoration-line:none!important}.metakyc-sdk .metakyc-overview-step-item:before,.metakyc-sdk .metakyc-overview-step-item:after,.metakyc-sdk .metakyc-overview-step-item *:before,.metakyc-sdk .metakyc-overview-step-item *:after,.metakyc-sdk .metakyc-step-content:before,.metakyc-sdk .metakyc-step-content:after,.metakyc-sdk .metakyc-step-content *:before,.metakyc-sdk .metakyc-step-content *:after,.metakyc-sdk .metakyc-step-title:before,.metakyc-sdk .metakyc-step-title:after,.metakyc-sdk .metakyc-step-description:before,.metakyc-sdk .metakyc-step-description:after{content:none!important;display:none!important;visibility:hidden!important;border:none!important;box-shadow:none!important;outline:none!important;background:none!important;height:0!important;width:0!important}.metakyc-sdk .metakyc-overview-step-item{border-width:0!important;border-style:none!important;border:0!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-step-content{border-width:0!important;border-style:none!important;border:0!important;padding-top:0!important;margin-top:0!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-step-title{border-width:0!important;border-style:none!important;border:0!important;padding-top:0!important;margin-top:0!important;box-shadow:none!important;outline:none!important;text-decoration:none!important}.metakyc-sdk{color:var(--metakyc-text-primary, #111827)!important;font-family:var(--metakyc-font-family, inherit)!important;padding:1.5rem!important}.metakyc-sdk h1,.metakyc-sdk h2,.metakyc-sdk h3,.metakyc-sdk h4,.metakyc-sdk h5,.metakyc-sdk h6{color:var(--metakyc-text-primary, #111827);letter-spacing:normal}.metakyc-sdk .text-gray-900{color:var(--metakyc-text-primary, #111827)!important}.metakyc-sdk .text-gray-800{color:var(--metakyc-text-primary, #1f2937)!important}.metakyc-sdk .text-gray-700{color:var(--metakyc-text-secondary, #374151)!important}.metakyc-sdk .text-gray-600{color:var(--metakyc-text-secondary, #6b7280)!important}.metakyc-sdk .text-gray-500{color:var(--metakyc-text-muted, #6b7280)!important}.metakyc-sdk .text-gray-400{color:var(--metakyc-text-muted, #9ca3af)!important}.metakyc-sdk .text-gray-300{color:var(--metakyc-text-muted, #d1d5db)!important}.metakyc-sdk .text-white{color:#fff!important}.metakyc-sdk .bg-white{background-color:var(--metakyc-background, #ffffff)!important}.metakyc-sdk .bg-gray-50{background-color:var(--metakyc-surface, #f9fafb)!important}.metakyc-sdk .bg-gray-100{background-color:var(--metakyc-surface, #f3f4f6)!important}.metakyc-sdk .bg-gray-200{background-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .bg-gray-800{background-color:var(--metakyc-surface, #1f2937)!important}.metakyc-sdk .border-gray-100,.metakyc-sdk .border-gray-200,.metakyc-sdk .border-gray-300{border-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .border-t{border-top-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .border-b{border-bottom-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .divide-gray-200>*{border-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .bg-primary-500,.metakyc-sdk .bg-primary-600{background-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .bg-primary-50,.metakyc-sdk .bg-primary-100{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .text-primary-500,.metakyc-sdk .text-primary-600,.metakyc-sdk .text-primary-800{color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .text-primary-900{color:var(--metakyc-primary-dark, #1e40af)!important}.metakyc-sdk .border-primary-500,.metakyc-sdk .border-primary-600{border-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .hover\\:bg-primary-50:hover{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .hover\\:bg-primary-600:hover{background-color:var(--metakyc-primary-hover, #1d4ed8)!important}.metakyc-sdk .bg-blue-600{background-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .bg-blue-100{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .text-blue-600,.metakyc-sdk .text-blue-400{color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .hover\\:bg-blue-700:hover{background-color:var(--metakyc-primary-hover, #1d4ed8)!important}.metakyc-sdk .metakyc-overview-steps h3:before,.metakyc-sdk .metakyc-overview-steps h3:after{content:none!important;display:none!important}.metakyc-sdk .metakyc-overview-steps *:before,.metakyc-sdk .metakyc-overview-steps *:after{content:none!important;display:none!important}.metakyc-sdk .metakyc-stepper-scroll::-webkit-scrollbar{display:none!important;height:0!important;width:0!important}.metakyc-sdk .metakyc-file-dropzone:hover{border-color:var(--metakyc-primary, #2563eb)!important;background-color:color-mix(in srgb,var(--metakyc-primary, #2563eb) 3%,var(--metakyc-background, #ffffff))!important}.metakyc-sdk .metakyc-file-item:hover{background-color:color-mix(in srgb,var(--metakyc-surface, #f9fafb) 80%,var(--metakyc-border, #e5e7eb))!important}.metakyc-sdk .metakyc-file-upload label{color:var(--metakyc-text-primary, #111827)!important}.metakyc-sdk .metakyc-file-upload p{margin:0!important;line-height:1.4!important}.metakyc-sdk .metakyc-file-item button{background:transparent!important;border:none!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-file-dropzone{box-shadow:none!important;outline:none!important}.metakyc-sdk .hover\\:opacity-90:hover{opacity:.9}.metakyc-sdk .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.metakyc-sdk .focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.metakyc-sdk .focus\\:ring-offset-0:focus{--tw-ring-offset-width: 0px}.metakyc-sdk .focus\\:ring-offset-1:focus{--tw-ring-offset-width: 1px}.metakyc-sdk .disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.metakyc-sdk .disabled\\:opacity-50:disabled{opacity:.5}.metakyc-sdk .disabled\\:opacity-60:disabled{opacity:.6}.metakyc-sdk .dark\\:border-blue-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 64 175 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-green-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(22 101 52 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-red-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(153 27 27 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-yellow-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(133 77 14 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:bg-blue-900\\/20:is(.dark *){background-color:#1e3a8a33}.metakyc-sdk .dark\\:bg-blue-900\\/30:is(.dark *){background-color:#1e3a8a4d}.metakyc-sdk .dark\\:bg-green-900\\/20:is(.dark *){background-color:#14532d33}.metakyc-sdk .dark\\:bg-green-900\\/30:is(.dark *){background-color:#14532d4d}.metakyc-sdk .dark\\:bg-red-900\\/20:is(.dark *){background-color:#7f1d1d33}.metakyc-sdk .dark\\:bg-red-900\\/30:is(.dark *){background-color:#7f1d1d4d}.metakyc-sdk .dark\\:bg-yellow-900\\/20:is(.dark *){background-color:#713f1233}.metakyc-sdk .dark\\:bg-yellow-900\\/30:is(.dark *){background-color:#713f124d}.metakyc-sdk .dark\\:text-blue-100:is(.dark *){--tw-text-opacity: 1;color:rgb(219 234 254 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-blue-200:is(.dark *){--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-gray-500:is(.dark *){--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-100:is(.dark *){--tw-text-opacity: 1;color:rgb(220 252 231 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-200:is(.dark *){--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-100:is(.dark *){--tw-text-opacity: 1;color:rgb(254 226 226 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-white:is(.dark *){--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-yellow-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}@media (min-width: 768px){.metakyc-sdk .md\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}',Ct="metakyc-sdk-styles";let yt=!1;function aa(){if(yt||typeof document>"u")return;if(document.getElementById(Ct)){yt=!0;return}const t=document.createElement("style");t.id=Ct,t.textContent=ra,document.head.appendChild(t),yt=!0}const sa=({config:t,children:r})=>{aa();const[a,s]=i.useState(null),n=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Vt(t),p=new Yt(y),f=new Qt(y),T=new Gt(y),b=new Jt(y),E=new Xt(y),A=new Zt(y),v=new er(y),S=new tr(y),M=new rr(y),Y=new cr(y),L=new hr;return{httpClient:y,applicantService:p,questionnaireService:f,uploadDocumentService:T,appropriatenessTestService:b,overviewService:E,riskScoringService:A,identityService:v,baseInformationService:S,investorCategorizationService:M,themeService:Y,themeManager:L}},[t]),d=i.useMemo(()=>({config:t,...c,currentTheme:a,createOrchestrator:()=>new ur(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,a]);return i.useEffect(()=>((async()=>{if(n.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),s(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),s(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),s(c.themeManager.getCurrentTheme()),o.current=!0}finally{n.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsxs(bt.Provider,{value:d,children:[t.showVersion&&e.jsxs("div",{style:{fontSize:"0.625rem",color:"var(--metakyc-text-muted, #9ca3af)",opacity:.5,textAlign:"right",padding:"2px 8px",userSelect:"none",pointerEvents:"none",letterSpacing:"0.02em",lineHeight:1},children:["SDK v",fr]}),r]})};function Ne(){const t=i.useContext(bt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function kr(t){return new Promise((r,a)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const o=s.result.split(",")[1];r(o)},s.onerror=n=>a(n)})}function na(t,r){return t.size<=r}function ia(t,r){return r.split(",").map(s=>s.trim()).some(s=>{if(s.endsWith("/*")){const n=s.slice(0,-2);return t.type.startsWith(n)}return t.type===s})}function mt(t){if(t===0)return"0 Bytes";const r=1024,a=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,s)*100)/100+" "+a[s]}function oa(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const it={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function br(t){try{localStorage.setItem(it.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function vr(){try{const t=localStorage.getItem(it.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function wr(){try{localStorage.removeItem(it.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function jr(t){try{localStorage.setItem(it.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function la(){try{const t=localStorage.getItem(it.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Sr(){try{localStorage.removeItem(it.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function ca(){wr(),Sr()}function Cr(t){const{createOrchestrator:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(null),p=t||vr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;a&&p&&(br(p),jr({applicantId:p,currentStepOrder:(L=a.currentStep)==null?void 0:L.order,status:a.status,lastUpdated:new Date().toISOString(),workflowKey:a.workFlowKey,nextWorkflowKey:a.nextWorkflowKey}))},[a,p]);const f=i.useRef(!1),T=i.useRef(!1),b=i.useCallback(async()=>{if(!(!p||!y.current)){if(f.current){console.log("[Workflow] Load already in progress, skipping...");return}f.current=!0,o(!0),d(null);try{const L=await y.current.initialize(p);s(L),T.current=!0}catch(L){d(L)}finally{o(!1),f.current=!1}}},[p]);i.useEffect(()=>{p&&!T.current&&b()},[p,b]);const E=i.useCallback(async()=>{if(y.current){if(f.current){console.log("[Workflow] Refresh already in progress, skipping...");return}f.current=!0,o(!0),d(null);try{const L=await y.current.refreshProgress();s(L)}catch(L){d(L)}finally{o(!1),f.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToNextStep();s(L)}catch(L){d(L)}finally{o(!1)}}},[]),v=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToPreviousStep();s(L)}catch(L){d(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),d(null);try{await y.current.submitCurrentStep(L);const B=await y.current.refreshProgress();s(B)}catch(B){throw d(B),B}finally{o(!1)}}},[]),M=St.useMemo(()=>a!=null&&a.stepInfoList?[...a.stepInfoList].sort((L,B)=>L.order-B.order):[],[a==null?void 0:a.stepInfoList]),Y=St.useMemo(()=>a?a.nextWorkflowKey&&a.nextWorkflowKey!==a.workFlowKey:!1,[a]);return{progress:a,applicantId:p,currentStep:(a==null?void 0:a.currentStep)||null,steps:M,status:(a==null?void 0:a.status)||Te.None,workflowResult:(a==null?void 0:a.workflowResult)||null,workflowKey:a==null?void 0:a.workFlowKey,nextWorkflowKey:a==null?void 0:a.nextWorkflowKey,hasWorkflowChanged:Y,isLoading:n,error:c,isComplete:(a==null?void 0:a.status)===Te.Finished,isOnHold:(a==null?void 0:a.status)===Te.OnHold,refreshProgress:E,moveToNext:A,moveBack:v,submitCurrentStep:S,orchestrator:y.current}}function Nr(t){const{questionnaireService:r,applicantService:a}=Ne(),[s,n]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,f]=i.useState(!1),[T,b]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),v=i.useCallback(async()=>{var M,Y;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),b(null);try{const[L,B]=await Promise.all([r.getQuestionnaire(t),a.getApplicantData(t).catch(()=>null)]);if(n(L),(M=B==null?void 0:B.questionnaireResults)!=null&&M.length&&L){const U=new Map;for(const h of B.questionnaireResults)h.question&&((Y=h.answers)!=null&&Y.length)&&U.set(h.question.trim().toLowerCase(),h.answers);const Z={},R=L.questionGroups.flatMap(h=>h.questions??[]);for(const h of R){const z=h.text.trim().toLowerCase();U.has(z)&&(Z[h.id]=U.get(z))}c(Z)}A.current=t}catch(L){b(L)}finally{y(!1),E.current=!1}}},[t,r,a]);i.useEffect(()=>{t&&A.current!==t&&v()},[t]);const S=i.useCallback(async M=>{f(!0),b(null);try{return await r.fillQuestionnaire(M)}catch(Y){throw b(Y),Y}finally{f(!1)}},[r]);return{questionnaire:s,initialAnswers:o,isLoading:d,isSubmitting:p,error:T,load:v,submit:S}}function Rr(t){const{uploadDocumentService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(0),[f,T]=i.useState(null),b=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(b.current){console.log("[UploadDocument] Load already in progress, skipping...");return}b.current=!0,o(!0),T(null);try{const S=await r.getUploadDocument(t);s(S),E.current=t}catch(S){T(S)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const v=i.useCallback(async S=>{d(!0),p(0),T(null);try{await r.fillUploadDocument(S),p(100)}catch(M){throw T(M),M}finally{d(!1)}},[r]);return{uploadDocument:a,isLoading:n,isSubmitting:c,uploadProgress:y,error:f,load:A,submit:v}}function da(t){const{appropriatenessTestService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),[f,T]=i.useState(null),b=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(b.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}b.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);s(S),E.current=t}catch(S){p(S)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const v=i.useCallback(async S=>{d(!0),p(null);try{const M=await r.fillAppropriatenessTest(S);return T(M),M}catch(M){throw p(M),M}finally{d(!1)}},[r]);return{test:a,result:f,isLoading:n,isSubmitting:c,error:y,load:A,submit:v}}function Ir(t){const{overviewService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),f=i.useRef(!1),T=i.useRef(null),b=i.useCallback(async()=>{if(t){if(f.current){console.log("[Overview] Load already in progress, skipping...");return}f.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);s(A),T.current=t}catch(A){p(A)}finally{o(!1),f.current=!1}}},[t,r]);i.useEffect(()=>{t&&T.current!==t&&b()},[t]);const E=i.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{d(!1)}}},[t,r]);return{overview:a,isLoading:n,isSubmitting:c,error:y,load:b,passOverview:E}}function Er(t){const{identityService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(b,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:b||"",ttl:E||604800};console.log("Identity request input:",A);const v=await r.identityRequest(A);return console.log("Identity request result:",v),s(v),v}catch(A){throw d(A),A}finally{o(!1),y.current=!1}}},[t,r]),f=i.useCallback(async(b,E)=>{if(t){o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:b,ttl:E},v=await r.identityCompanyRequest(A);return s(v),v}catch(A){throw d(A),A}finally{o(!1)}}},[t,r]),T=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const b={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",b);const E=await r.identityRequest(b);return console.log("Restart identity result:",E),s(E),E}catch(b){throw d(b),b}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:a,provider:(a==null?void 0:a.provider)||null,token:(a==null?void 0:a.publicProviderTokenObject)||null,isLoading:n,error:c,requestIdentity:p,requestCompanyIdentity:f,restartIdentity:T}}function Ar(t){const{riskScoringService:r,applicantService:a}=Ne(),[s,n]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,f]=i.useState(!1),[T,b]=i.useState(null),[E,A]=i.useState(null),v=i.useRef(!1),S=i.useRef(null),M=i.useCallback(async()=>{var L;if(t){if(v.current){console.log("[RiskScoring] Load already in progress, skipping...");return}v.current=!0,y(!0),b(null);try{const[B,U]=await Promise.all([r.getRiskCriterias(t),a.getApplicantData(t).catch(()=>null)]);if(n(B),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const Z=U.riskScoringResults[0],R={};for(const h of Z.riskCriteriaResults??[])if(h.riskCriteriaId!=null&&h.answer!=null&&h.answer!==""){const z=[...new Set(h.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];z.length>0&&(R[h.riskCriteriaId]=z)}c(R)}S.current=t}catch(B){b(B)}finally{y(!1),v.current=!1}}},[t,r,a]);i.useEffect(()=>{t&&S.current!==t&&M()},[t]);const Y=i.useCallback(async L=>{f(!0),b(null);try{const B=await r.submitRiskScoring(L);return A(B),B}catch(B){throw b(B),B}finally{f(!1)}},[r]);return{criteria:s,initialAnswers:o,result:E,isLoading:d,isSubmitting:p,error:T,load:M,submit:Y}}function vt(){const{applicantService:t,config:r}=Ne(),[a,s]=i.useState(!1),[n,o]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,s(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(v){throw o(v),v}finally{s(!1),c.current=!1}},[t,r]),f=i.useCallback(async E=>{s(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{s(!1)}},[t]),T=i.useCallback(async E=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,s(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{s(!1),d.current=!1}},[t]),b=i.useCallback(async E=>{s(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{s(!1)}},[t]);return{isLoading:a,error:n,createApplicant:p,createCompanyApplicant:f,getApplicantData:T,stopProgress:b}}const ma={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:a="md",isLoading:s=!1,disabled:n,className:o,style:c,...d})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},f={sm:{padding:"0.375rem 0.75rem",fontSize:"0.875rem"},md:{padding:"0.5rem 1rem",fontSize:"0.875rem"},lg:{padding:"0.75rem 1.5rem",fontSize:"1rem"}};return e.jsxs("button",{className:Se(y,p[a],o),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"0.5rem",fontWeight:500,borderWidth:"1px",borderStyle:"solid",cursor:n||s?"not-allowed":"pointer",opacity:n||s?.5:1,lineHeight:"1.25rem",...f[a],...ma[r],...c},disabled:n||s,...d,children:[s&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ye=i.forwardRef(({label:t,error:r,helperText:a,leftIcon:s,rightIcon:n,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[s&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s}),e.jsx("input",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",s?"pl-10":"",n?"pr-10":"",o),style:{minHeight:"38px",backgroundColor:d.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:d.readOnly?"default":void 0,...c},...d}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]}));ye.displayName="Input";const ee=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)",borderWidth:"1px",borderStyle:"solid",borderRadius:"0.75rem",overflow:"hidden",...a},...s,children:t}),he=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-b",r),style:{padding:"1rem 1.5rem",borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:"var(--metakyc-border, #e5e7eb)",...a},...s,children:t}),te=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4",r),style:{padding:"1rem 1.5rem",...a},...s,children:t}),fe=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-t",r),style:{padding:"1rem 1.5rem",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"var(--metakyc-border, #e5e7eb)",...a},...s,children:t}),pa={display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,minWidth:16,minHeight:16,maxWidth:16,maxHeight:16,borderRadius:4,borderWidth:"1.5px",borderStyle:"solid",cursor:"pointer",flexShrink:0,position:"relative",transition:"background-color 0.15s, border-color 0.15s",boxSizing:"border-box",padding:0,margin:0,verticalAlign:"middle"},Fe=({checked:t,onChange:r,disabled:a,style:s})=>{const n="var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",o="var(--metakyc-input-bg, var(--metakyc-background, #ffffff))",c="var(--metakyc-primary, #2563eb)";return e.jsx("span",{role:"checkbox","aria-checked":t,tabIndex:0,onClick:()=>!a&&r(!t),onKeyDown:d=>{(d.key===" "||d.key==="Enter")&&(d.preventDefault(),a||r(!t))},style:{...pa,backgroundColor:t?c:o,borderColor:t?c:n,opacity:a?.5:1,cursor:a?"not-allowed":"pointer",...s},children:t&&e.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none",style:{display:"block",flexShrink:0},children:e.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"#ffffff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})},ua={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},wt=({children:t,variant:r="default",className:a,style:s,...n})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",a),style:{...ua[r],...s},...n,children:t}),Ee=({size:t="md",className:r,...a})=>{const s={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:Se("flex items-center justify-center",r),...a,children:e.jsxs("svg",{className:Se("animate-spin text-primary-500",s[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},ut=i.forwardRef(({label:t,error:r,helperText:a,options:s,placeholder:n,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...d,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),s.map((p,f)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${f}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]}));ut.displayName="Select";const Nt=280,Tr=({label:t,value:r,onChange:a,options:s,placeholder:n="Select...",disabled:o=!1,readOnly:c=!1,required:d=!1})=>{const y=o||c,[p,f]=i.useState(!1),[T,b]=i.useState(""),[E,A]=i.useState(null),[v,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),M=i.useRef(null),Y=i.useRef(null),L=i.useRef(null),B=i.useCallback(()=>{if(!Y.current)return null;const I=Y.current.getBoundingClientRect(),O=window.innerHeight-I.bottom<Nt&&I.top>Nt;return{top:O?I.top:I.bottom+4,left:I.left,width:I.width,openUp:O}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.documentElement),W=(_,ue)=>I.getPropertyValue(_).trim()||ue,O=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:O,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",O)})},[]),Z=i.useCallback(()=>{if(y)return;U();const I=B();I&&A(I),f(!0)},[y,B,U]),R=i.useCallback(()=>{f(!1),b("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var _,ue;const O=W.target;!((_=M.current)!=null&&_.contains(O))&&!((ue=L.current)!=null&&ue.contains(O))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=B();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,B]);const h=s.filter(I=>I.label.toLowerCase().includes(T.toLowerCase())),z=I=>{y||a(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||a(r.filter(O=>O!==I))},Q=I=>{var W;return((W=s.find(O=>O.value===I))==null?void 0:W.label)||I},{bg:$,borderColor:G,textPrimary:ae,textSecondary:V,primaryColor:ke,primaryLight:ce,hoverBg:de}=v,ge=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:T,onChange:I=>b(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:$,color:ae,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.documentElement),O=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=O,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${O}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:h.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:V},children:"No results"}):h.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>z(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?ce:"transparent",color:W?ke:ae,userSelect:"none"},onMouseEnter:O=>{W||(O.currentTarget.style.backgroundColor=de)},onMouseLeave:O=>{W||(O.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(Fe,{checked:W,onChange:()=>{}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{a([]),b("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:M,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Y,onClick:()=>p?R():Z(),className:Se("metakyc-multiselect-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},I))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p?"▲":"▼"})]}),typeof document<"u"&&ge?pt.createPortal(ge,document.body):null]})},Rt=260,ze=({label:t,error:r,helperText:a,options:s,placeholder:n="Select...",value:o,onChange:c,disabled:d=!1,readOnly:y=!1,required:p=!1,className:f})=>{var ue;const T=d||y,[b,E]=i.useState(!1),[A,v]=i.useState(""),[S,M]=i.useState(null),[Y,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),B=i.useCallback(()=>{const N=getComputedStyle(document.documentElement),re=(se,be)=>N.getPropertyValue(se).trim()||be,me=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:me,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",me)})},[]),U=i.useRef(null),Z=i.useRef(null),R=i.useRef(null),h=i.useRef(null),z=i.useCallback(()=>{if(!Z.current)return null;const N=Z.current.getBoundingClientRect(),me=window.innerHeight-N.bottom<Rt&&N.top>Rt;return{top:me?N.top:N.bottom+4,left:N.left,width:N.width,openUp:me}},[]),q=i.useCallback(()=>{if(T)return;B();const N=z();N&&M(N),E(!0)},[T,z,B]),Q=i.useCallback(()=>{E(!1),v("")},[]),$=()=>b?Q():q();i.useEffect(()=>{if(!b)return;const N=re=>{var se,be;const me=re.target;!((se=U.current)!=null&&se.contains(me))&&!((be=R.current)!=null&&be.contains(me))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[b,Q]),i.useEffect(()=>{if(!b)return;const N=()=>{const re=z();re&&M(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[b,z]),i.useEffect(()=>{b&&h.current&&setTimeout(()=>{var N;return(N=h.current)==null?void 0:N.focus()},0)},[b]);const G=s.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),ae=(ue=s.find(N=>N.value===o))==null?void 0:ue.label,V=(N,re)=>{T||re||(c(N),Q())},{bg:ke,border:ce,text:de,textSecondary:ge,primary:I,primaryLight:W,hoverBg:O}=Y,_=b&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${ce}`,backgroundColor:ke,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${ce}`},children:e.jsx("input",{ref:h,type:"text",value:A,onChange:N=>v(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${ce}`,backgroundColor:ke,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.documentElement),me=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=ke,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=me,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${me}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=ke,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ce,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:G.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:ge},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>V(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:me=>{!re&&!N.disabled&&(me.currentTarget.style.backgroundColor=O)},onMouseLeave:me=>{re||(me.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",f),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Z,role:"button",tabIndex:T?-1:0,onClick:$,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),$()),N.key==="Escape"&&Q()},className:Se("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",T?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:ae?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":b?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"38px",outline:b?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:ae||n}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:b?"▲":"▼"})]}),typeof document<"u"&&_?pt.createPortal(_,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]})};ze.displayName="SearchableSelect";function ya(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Fr=({label:t,subtitle:r,error:a,accept:s,multiple:n=!1,maxSize:o,required:c,onChange:d,value:y=[],className:p})=>{const[f,T]=i.useState(!1),[b,E]=i.useState(null),A=i.useRef(null),v=i.useCallback(R=>{if(!R)return;E(null);const h=Array.from(R);if(o&&h.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${mt(o)}`);return}d==null||d(n?[...y,...h]:[h[0]])},[o,n,d,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!0)},[]),M=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1)},[]),Y=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),T(!1),v(R.dataTransfer.files)},[v]),L=()=>{var R;(R=A.current)==null||R.click()},B=R=>{E(null);const h=y.filter((z,q)=>q!==R);d==null||d(h)},U=a||b,Z=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:M,onDrop:Y,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:Z?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:f?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:s,multiple:n,onChange:R=>{v(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:f?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(s||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[s&&e.jsx("span",{children:s}),s&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",mt(o)]})]})]})]})]}),Z&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,h)=>{const z=ya(R),q=z==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):z==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:mt(R.size)})]}),e.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),B(h)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:$=>{$.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",$.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${h}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Pr=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:a,...s},n)=>e.jsxs("div",{className:"w-full",children:[s.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[s.label,s.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:n,type:"tel",className:Se("flex-1",a),...s,label:""})]}),s.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:s.error})]}));Pr.displayName="PhoneInput";/**
|
|
60
|
+
|
|
61
|
+
/* ── Portal dropdowns (rendered at document.body, outside .metakyc-sdk) ────── */
|
|
62
|
+
.metakyc-searchable-select-dropdown,
|
|
63
|
+
.metakyc-multiselect-dropdown {
|
|
64
|
+
background-color: var(--metakyc-input-bg, var(--metakyc-background, #ffffff)) !important;
|
|
65
|
+
border-color: var(--metakyc-input-border, var(--metakyc-border, #d1d5db)) !important;
|
|
66
|
+
color: var(--metakyc-input-text, var(--metakyc-text-primary, #111827)) !important;
|
|
67
|
+
}
|
|
68
|
+
.metakyc-searchable-select-dropdown input,
|
|
69
|
+
.metakyc-multiselect-dropdown input {
|
|
70
|
+
background-color: var(--metakyc-input-bg, var(--metakyc-background, #ffffff)) !important;
|
|
71
|
+
color: var(--metakyc-input-text, var(--metakyc-text-primary, #111827)) !important;
|
|
72
|
+
border-color: var(--metakyc-input-border, var(--metakyc-border, #d1d5db)) !important;
|
|
73
|
+
}
|
|
74
|
+
`;this.themeStyleElement=document.createElement("style"),this.themeStyleElement.id="metakyc-theme-vars",this.themeStyleElement.textContent=c,(d=this.customStyleElement)!=null&&d.parentNode?document.head.insertBefore(this.themeStyleElement,this.customStyleElement):document.head.appendChild(this.themeStyleElement)}injectCustomCSS(r){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=r,document.head.appendChild(this.customStyleElement)}mergeWithDefault(r){var a;return{name:r.name||Re.name,title:r.title||Re.title,logo:{...Re.logo,...r.logo},colors:{...Re.colors,...r.colors},typography:r.typography?{...Re.typography,...r.typography}:Re.typography,spacing:r.spacing?{...Re.spacing,...r.spacing}:Re.spacing,customCSS:r.customCSS,darkMode:r.darkMode?{colors:{...(a=Re.darkMode)==null?void 0:a.colors,...r.darkMode.colors}}:Re.darkMode,applicantFormVisibleFields:r.applicantFormVisibleFields,applicantFormRequiredFields:r.applicantFormRequiredFields,allowedLanguages:r.allowedLanguages,applicantFormPages:r.applicantFormPages,reviewPageFields:r.reviewPageFields,reviewPageDisabled:r.reviewPageDisabled,fieldLabelMode:r.fieldLabelMode,companyFormVisibleFields:r.companyFormVisibleFields,companyFormRequiredFields:r.companyFormRequiredFields,companyFormPages:r.companyFormPages,companyReviewPageFields:r.companyReviewPageFields}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(Re)}cleanup(){this.themeStyleElement&&(this.themeStyleElement.remove(),this.themeStyleElement=null),this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(r){return r.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const bt=i.createContext(null),fr="1.0.10",ta='.metakyc-sdk .pointer-events-none{pointer-events:none}.metakyc-sdk .visible{visibility:visible}.metakyc-sdk .static{position:static}.metakyc-sdk .fixed{position:fixed}.metakyc-sdk .absolute{position:absolute}.metakyc-sdk .relative{position:relative}.metakyc-sdk .inset-y-0{top:0;bottom:0}.metakyc-sdk .left-0{left:0}.metakyc-sdk .right-0{right:0}.metakyc-sdk .right-3{right:.75rem}.metakyc-sdk .top-1\\/2{top:50%}.metakyc-sdk .mx-4{margin-left:1rem;margin-right:1rem}.metakyc-sdk .mx-6{margin-left:1.5rem;margin-right:1.5rem}.metakyc-sdk .mx-auto{margin-left:auto;margin-right:auto}.metakyc-sdk .my-8{margin-top:2rem;margin-bottom:2rem}.metakyc-sdk .-ml-1{margin-left:-.25rem}.metakyc-sdk .mb-0\\.5{margin-bottom:.125rem}.metakyc-sdk .mb-1{margin-bottom:.25rem}.metakyc-sdk .mb-2{margin-bottom:.5rem}.metakyc-sdk .mb-3{margin-bottom:.75rem}.metakyc-sdk .mb-4{margin-bottom:1rem}.metakyc-sdk .mb-6{margin-bottom:1.5rem}.metakyc-sdk .ml-0\\.5{margin-left:.125rem}.metakyc-sdk .ml-1{margin-left:.25rem}.metakyc-sdk .ml-3{margin-left:.75rem}.metakyc-sdk .mr-2{margin-right:.5rem}.metakyc-sdk .mr-3{margin-right:.75rem}.metakyc-sdk .mt-0\\.5{margin-top:.125rem}.metakyc-sdk .mt-1{margin-top:.25rem}.metakyc-sdk .mt-2{margin-top:.5rem}.metakyc-sdk .mt-3{margin-top:.75rem}.metakyc-sdk .mt-4{margin-top:1rem}.metakyc-sdk .mt-6{margin-top:1.5rem}.metakyc-sdk .block{display:block}.metakyc-sdk .inline-block{display:inline-block}.metakyc-sdk .inline{display:inline}.metakyc-sdk .flex{display:flex}.metakyc-sdk .inline-flex{display:inline-flex}.metakyc-sdk .grid{display:grid}.metakyc-sdk .hidden{display:none}.metakyc-sdk .h-12{height:3rem}.metakyc-sdk .h-16{height:4rem}.metakyc-sdk .h-24{height:6rem}.metakyc-sdk .h-4{height:1rem}.metakyc-sdk .h-6{height:1.5rem}.metakyc-sdk .h-8{height:2rem}.metakyc-sdk .h-full{height:100%}.metakyc-sdk .max-h-52{max-height:13rem}.metakyc-sdk .min-h-\\[400px\\]{min-height:400px}.metakyc-sdk .w-12{width:3rem}.metakyc-sdk .w-16{width:4rem}.metakyc-sdk .w-20{width:5rem}.metakyc-sdk .w-24{width:6rem}.metakyc-sdk .w-4{width:1rem}.metakyc-sdk .w-6{width:1.5rem}.metakyc-sdk .w-8{width:2rem}.metakyc-sdk .w-full{width:100%}.metakyc-sdk .max-w-md{max-width:28rem}.metakyc-sdk .flex-1{flex:1 1 0%}.metakyc-sdk .flex-shrink-0{flex-shrink:0}.metakyc-sdk .-translate-y-1\\/2{--tw-translate-y: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.metakyc-sdk .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}@keyframes spin{to{transform:rotate(360deg)}}.metakyc-sdk .animate-spin{animation:spin 1s linear infinite}.metakyc-sdk .cursor-not-allowed{cursor:not-allowed}.metakyc-sdk .cursor-pointer{cursor:pointer}.metakyc-sdk .resize{resize:both}.metakyc-sdk .list-inside{list-style-position:inside}.metakyc-sdk .list-disc{list-style-type:disc}.metakyc-sdk .list-none{list-style-type:none}.metakyc-sdk .grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))}.metakyc-sdk .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}.metakyc-sdk .flex-col{flex-direction:column}.metakyc-sdk .flex-wrap{flex-wrap:wrap}.metakyc-sdk .items-start{align-items:flex-start}.metakyc-sdk .items-center{align-items:center}.metakyc-sdk .justify-center{justify-content:center}.metakyc-sdk .justify-between{justify-content:space-between}.metakyc-sdk .gap-1{gap:.25rem}.metakyc-sdk .gap-1\\.5{gap:.375rem}.metakyc-sdk .gap-2{gap:.5rem}.metakyc-sdk .gap-4{gap:1rem}.metakyc-sdk :is(.space-x-3>:not([hidden])~:not([hidden])){--tw-space-x-reverse: 0;margin-right:calc(.75rem * var(--tw-space-x-reverse));margin-left:calc(.75rem * calc(1 - var(--tw-space-x-reverse)))}.metakyc-sdk :is(.space-y-1>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.25rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.25rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-1\\.5>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.375rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.375rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-2>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(.5rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-4>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(1rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-6>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(1.5rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(1.5rem * var(--tw-space-y-reverse))}.metakyc-sdk :is(.space-y-8>:not([hidden])~:not([hidden])){--tw-space-y-reverse: 0;margin-top:calc(2rem * calc(1 - var(--tw-space-y-reverse)));margin-bottom:calc(2rem * var(--tw-space-y-reverse))}.metakyc-sdk .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.metakyc-sdk .rounded{border-radius:.25rem}.metakyc-sdk .rounded-full{border-radius:9999px}.metakyc-sdk .rounded-lg{border-radius:.5rem}.metakyc-sdk .rounded-xl{border-radius:.75rem}.metakyc-sdk .border{border-width:1px}.metakyc-sdk .border-0{border-width:0px}.metakyc-sdk .border-2{border-width:2px}.metakyc-sdk .border-b{border-bottom-width:1px}.metakyc-sdk .border-t{border-top-width:1px}.metakyc-sdk .border-blue-200{--tw-border-opacity: 1;border-color:rgb(191 219 254 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-danger-500{border-color:var(--metakyc-danger, #EF4444)}.metakyc-sdk .border-green-200{--tw-border-opacity: 1;border-color:rgb(187 247 208 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-red-200{--tw-border-opacity: 1;border-color:rgb(254 202 202 / var(--tw-border-opacity, 1))}.metakyc-sdk .border-yellow-200{--tw-border-opacity: 1;border-color:rgb(254 240 138 / var(--tw-border-opacity, 1))}.metakyc-sdk .bg-blue-100{--tw-bg-opacity: 1;background-color:rgb(219 234 254 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-blue-50{--tw-bg-opacity: 1;background-color:rgb(239 246 255 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-green-100{--tw-bg-opacity: 1;background-color:rgb(220 252 231 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-green-50{--tw-bg-opacity: 1;background-color:rgb(240 253 244 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-red-100{--tw-bg-opacity: 1;background-color:rgb(254 226 226 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-red-50{--tw-bg-opacity: 1;background-color:rgb(254 242 242 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-yellow-100{--tw-bg-opacity: 1;background-color:rgb(254 249 195 / var(--tw-bg-opacity, 1))}.metakyc-sdk .bg-yellow-50{--tw-bg-opacity: 1;background-color:rgb(254 252 232 / var(--tw-bg-opacity, 1))}.metakyc-sdk .p-3{padding:.75rem}.metakyc-sdk .p-4{padding:1rem}.metakyc-sdk .px-2{padding-left:.5rem;padding-right:.5rem}.metakyc-sdk .px-2\\.5{padding-left:.625rem;padding-right:.625rem}.metakyc-sdk .px-3{padding-left:.75rem;padding-right:.75rem}.metakyc-sdk .px-4{padding-left:1rem;padding-right:1rem}.metakyc-sdk .px-6{padding-left:1.5rem;padding-right:1.5rem}.metakyc-sdk .py-0\\.5{padding-top:.125rem;padding-bottom:.125rem}.metakyc-sdk .py-1\\.5{padding-top:.375rem;padding-bottom:.375rem}.metakyc-sdk .py-12{padding-top:3rem;padding-bottom:3rem}.metakyc-sdk .py-2{padding-top:.5rem;padding-bottom:.5rem}.metakyc-sdk .py-3{padding-top:.75rem;padding-bottom:.75rem}.metakyc-sdk .py-4{padding-top:1rem;padding-bottom:1rem}.metakyc-sdk .py-8{padding-top:2rem;padding-bottom:2rem}.metakyc-sdk .pb-4{padding-bottom:1rem}.metakyc-sdk .pl-10{padding-left:2.5rem}.metakyc-sdk .pl-3{padding-left:.75rem}.metakyc-sdk .pr-10{padding-right:2.5rem}.metakyc-sdk .pr-3{padding-right:.75rem}.metakyc-sdk .pr-6{padding-right:1.5rem}.metakyc-sdk .pt-6{padding-top:1.5rem}.metakyc-sdk .text-left{text-align:left}.metakyc-sdk .text-center{text-align:center}.metakyc-sdk .text-right{text-align:right}.metakyc-sdk .text-2xl{font-size:1.5rem;line-height:2rem}.metakyc-sdk .text-3xl{font-size:1.875rem;line-height:2.25rem}.metakyc-sdk .text-5xl{font-size:3rem;line-height:1}.metakyc-sdk .text-base{font-size:1rem;line-height:1.5rem}.metakyc-sdk .text-lg{font-size:1.125rem;line-height:1.75rem}.metakyc-sdk .text-sm{font-size:.875rem;line-height:1.25rem}.metakyc-sdk .text-xl{font-size:1.25rem;line-height:1.75rem}.metakyc-sdk .text-xs{font-size:.75rem;line-height:1rem}.metakyc-sdk .font-bold{font-weight:700}.metakyc-sdk .font-medium{font-weight:500}.metakyc-sdk .font-semibold{font-weight:600}.metakyc-sdk .uppercase{text-transform:uppercase}.metakyc-sdk .lowercase{text-transform:lowercase}.metakyc-sdk .tabular-nums{--tw-numeric-spacing: tabular-nums;font-variant-numeric:var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)}.metakyc-sdk .leading-6{line-height:1.5rem}.metakyc-sdk .text-blue-600{--tw-text-opacity: 1;color:rgb(37 99 235 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-blue-800{--tw-text-opacity: 1;color:rgb(30 64 175 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-blue-900{--tw-text-opacity: 1;color:rgb(30 58 138 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-danger-500{color:var(--metakyc-danger, #EF4444)}.metakyc-sdk .text-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-gray-600{--tw-text-opacity: 1;color:rgb(75 85 99 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-gray-900{--tw-text-opacity: 1;color:rgb(17 24 39 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-600{--tw-text-opacity: 1;color:rgb(22 163 74 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-800{--tw-text-opacity: 1;color:rgb(22 101 52 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-green-900{--tw-text-opacity: 1;color:rgb(20 83 45 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-primary,.metakyc-sdk .text-primary-500{color:var(--metakyc-primary, #3B82F6)}.metakyc-sdk .text-red-500{--tw-text-opacity: 1;color:rgb(239 68 68 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-600{--tw-text-opacity: 1;color:rgb(220 38 38 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-800{--tw-text-opacity: 1;color:rgb(153 27 27 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-red-900{--tw-text-opacity: 1;color:rgb(127 29 29 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-secondary{color:var(--metakyc-secondary, #64748b)}.metakyc-sdk .text-yellow-700{--tw-text-opacity: 1;color:rgb(161 98 7 / var(--tw-text-opacity, 1))}.metakyc-sdk .text-yellow-800{--tw-text-opacity: 1;color:rgb(133 77 14 / var(--tw-text-opacity, 1))}.metakyc-sdk .underline{text-decoration-line:underline}.metakyc-sdk .opacity-25{opacity:.25}.metakyc-sdk .opacity-50{opacity:.5}.metakyc-sdk .opacity-60{opacity:.6}.metakyc-sdk .opacity-75{opacity:.75}.metakyc-sdk .shadow-sm{--tw-shadow: 0 1px 2px 0 rgb(0 0 0 / .05);--tw-shadow-colored: 0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.metakyc-sdk .outline{outline-style:solid}.metakyc-sdk .blur{--tw-blur: blur(8px);filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.metakyc-sdk .filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.metakyc-sdk .transition{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke,opacity,box-shadow,transform,filter,backdrop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-colors{transition-property:color,background-color,border-color,text-decoration-color,fill,stroke;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .transition-opacity{transition-property:opacity;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.metakyc-sdk .duration-200{transition-duration:.2s}.metakyc-sdk .grid{display:grid!important}.metakyc-sdk .flex{display:flex!important}.metakyc-sdk .inline-flex{display:inline-flex!important}.metakyc-sdk .hidden{display:none!important}.metakyc-sdk .block{display:block!important}.metakyc-sdk .grid-cols-1{grid-template-columns:repeat(1,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))!important}.metakyc-sdk .grid-cols-4{grid-template-columns:repeat(4,minmax(0,1fr))!important}.metakyc-sdk .col-span-1{grid-column:span 1 / span 1!important}.metakyc-sdk .col-span-2{grid-column:span 2 / span 2!important}.metakyc-sdk .col-span-3{grid-column:span 3 / span 3!important}.metakyc-sdk .col-span-4{grid-column:span 4 / span 4!important}.metakyc-sdk .gap-1{gap:.25rem!important}.metakyc-sdk .gap-2{gap:.5rem!important}.metakyc-sdk .gap-3{gap:.75rem!important}.metakyc-sdk .gap-4{gap:1rem!important}.metakyc-sdk .gap-6{gap:1.5rem!important}.metakyc-sdk .gap-8{gap:2rem!important}.metakyc-sdk .flex-col{flex-direction:column!important}.metakyc-sdk .flex-row{flex-direction:row!important}.metakyc-sdk .flex-wrap{flex-wrap:wrap!important}.metakyc-sdk .flex-1{flex:1 1 0%!important}.metakyc-sdk .flex-shrink-0{flex-shrink:0!important}.metakyc-sdk .items-center{align-items:center!important}.metakyc-sdk .items-start{align-items:flex-start!important}.metakyc-sdk .items-end{align-items:flex-end!important}.metakyc-sdk .justify-between{justify-content:space-between!important}.metakyc-sdk .justify-center{justify-content:center!important}.metakyc-sdk .justify-end{justify-content:flex-end!important}.metakyc-sdk .justify-start{justify-content:flex-start!important}.metakyc-sdk .space-y-1>*+*{margin-top:.25rem!important}.metakyc-sdk .space-y-1\\.5>*+*{margin-top:.375rem!important}.metakyc-sdk .space-y-2>*+*{margin-top:.5rem!important}.metakyc-sdk .space-y-3>*+*{margin-top:.75rem!important}.metakyc-sdk .space-y-4>*+*{margin-top:1rem!important}.metakyc-sdk .space-y-6>*+*{margin-top:1.5rem!important}.metakyc-sdk .w-full{width:100%!important}.metakyc-sdk .relative{position:relative!important}.metakyc-sdk .absolute{position:absolute!important}.metakyc-sdk .overflow-hidden{overflow:hidden!important}.metakyc-sdk .overflow-auto{overflow:auto!important}.metakyc-sdk .overflow-x-auto{overflow-x:auto!important}@media (min-width: 768px){.metakyc-sdk .md\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))!important}.metakyc-sdk .md\\:grid-cols-3{grid-template-columns:repeat(3,minmax(0,1fr))!important}}.metakyc-sdk *,.metakyc-sdk *:before,.metakyc-sdk *:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:var(--metakyc-border, #e5e7eb)}.metakyc-sdk{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4}.metakyc-sdk img,.metakyc-sdk video{max-width:100%;height:auto}.metakyc-sdk h1,.metakyc-sdk h2,.metakyc-sdk h3,.metakyc-sdk h4,.metakyc-sdk h5,.metakyc-sdk h6,.metakyc-sdk p{margin:0}.metakyc-sdk ol,.metakyc-sdk ul{list-style:none;margin:0;padding:0}.metakyc-sdk button,.metakyc-sdk input,.metakyc-sdk optgroup,.metakyc-sdk select,.metakyc-sdk textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.metakyc-sdk button,.metakyc-sdk [role=button]{cursor:pointer}.metakyc-sdk a{color:inherit;text-decoration:inherit}.metakyc-sdk input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]),.metakyc-sdk select,.metakyc-sdk textarea,.metakyc-sdk .metakyc-searchable-select-trigger,.metakyc-sdk .metakyc-multiselect-trigger{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important}.metakyc-sdk input::-moz-placeholder,.metakyc-sdk textarea::-moz-placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-sdk input::placeholder,.metakyc-sdk textarea::placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-sdk input:not([type=checkbox]):not([type=radio]):focus,.metakyc-sdk select:focus,.metakyc-sdk textarea:focus{outline:none!important;border-color:var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb)) 20%,transparent)!important}.metakyc-sdk input[type=checkbox],.metakyc-sdk input[type=radio]{appearance:none!important;-webkit-appearance:none!important;-moz-appearance:none!important;width:16px!important;height:16px!important;min-width:16px!important;min-height:16px!important;max-width:16px!important;max-height:16px!important;flex-shrink:0!important;cursor:pointer!important;background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;border:1.5px solid var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important;position:relative!important;transition:background-color .15s,border-color .15s!important;vertical-align:middle!important;display:inline-block!important;padding:0!important;margin:0!important;color-scheme:light!important}.metakyc-sdk input[type=checkbox]{border-radius:4px!important}.metakyc-sdk input[type=radio]{border-radius:50%!important}.metakyc-sdk input[type=checkbox]:checked,.metakyc-sdk input[type=radio]:checked{background-color:var(--metakyc-primary, #2563eb)!important;border-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk input[type=checkbox]:checked:after{content:""!important;display:block!important;position:absolute!important;left:4px!important;top:1px!important;width:5px!important;height:9px!important;border:2px solid #ffffff!important;border-top:none!important;border-left:none!important;transform:rotate(45deg)!important}.metakyc-sdk input[type=radio]:checked:after{content:""!important;display:block!important;position:absolute!important;left:50%!important;top:50%!important;transform:translate(-50%,-50%)!important;width:6px!important;height:6px!important;border-radius:50%!important;background:#fff!important}.metakyc-sdk input[type=checkbox]:focus,.metakyc-sdk input[type=radio]:focus{outline:none!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-primary, #2563eb) 30%,transparent)!important}.metakyc-searchable-select-dropdown,.metakyc-multiselect-dropdown{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important}.metakyc-searchable-select-dropdown input,.metakyc-multiselect-dropdown input{background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border, var(--metakyc-border, #d1d5db))!important}.metakyc-searchable-select-dropdown input::-moz-placeholder,.metakyc-multiselect-dropdown input::-moz-placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-searchable-select-dropdown input::placeholder,.metakyc-multiselect-dropdown input::placeholder{color:var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))!important;opacity:1!important}.metakyc-searchable-select-dropdown input:focus,.metakyc-multiselect-dropdown input:focus{outline:none!important;background-color:var(--metakyc-input-bg, var(--metakyc-background, #ffffff))!important;color:var(--metakyc-input-text, var(--metakyc-text-primary, #111827))!important;border-color:var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))!important;box-shadow:0 0 0 2px color-mix(in srgb,var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb)) 20%,transparent)!important}.metakyc-searchable-select-dropdown li:hover,.metakyc-multiselect-dropdown li:hover{background-color:var(--metakyc-surface, var(--metakyc-background, #f9fafb))!important}.metakyc-sdk .metakyc-help-btn{color:var(--metakyc-primary, #2563eb)!important;border-color:var(--metakyc-primary, #2563eb)!important;background:transparent!important;position:relative!important;z-index:2!important}.metakyc-sdk .metakyc-overview-step-item,.metakyc-sdk .metakyc-overview-step-item *,.metakyc-sdk .metakyc-step-content,.metakyc-sdk .metakyc-step-content *,.metakyc-sdk .metakyc-step-title,.metakyc-sdk .metakyc-step-title *,.metakyc-sdk .metakyc-step-icon,.metakyc-sdk .metakyc-step-icon *,.metakyc-sdk .metakyc-step-description,.metakyc-sdk .metakyc-step-description *{border-top-width:0!important;border-bottom-width:0!important;border-left-width:0!important;border-right-width:0!important;border-top-style:none!important;border-bottom-style:none!important;border-left-style:none!important;border-right-style:none!important;border-top-color:transparent!important;border-bottom-color:transparent!important;border-left-color:transparent!important;border-right-color:transparent!important;border:0!important;box-shadow:none!important;outline:none!important;outline-width:0!important;outline-style:none!important;text-decoration:none!important;text-decoration-line:none!important}.metakyc-sdk .metakyc-overview-step-item:before,.metakyc-sdk .metakyc-overview-step-item:after,.metakyc-sdk .metakyc-overview-step-item *:before,.metakyc-sdk .metakyc-overview-step-item *:after,.metakyc-sdk .metakyc-step-content:before,.metakyc-sdk .metakyc-step-content:after,.metakyc-sdk .metakyc-step-content *:before,.metakyc-sdk .metakyc-step-content *:after,.metakyc-sdk .metakyc-step-title:before,.metakyc-sdk .metakyc-step-title:after,.metakyc-sdk .metakyc-step-description:before,.metakyc-sdk .metakyc-step-description:after{content:none!important;display:none!important;visibility:hidden!important;border:none!important;box-shadow:none!important;outline:none!important;background:none!important;height:0!important;width:0!important}.metakyc-sdk .metakyc-overview-step-item{border-width:0!important;border-style:none!important;border:0!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-step-content{border-width:0!important;border-style:none!important;border:0!important;padding-top:0!important;margin-top:0!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-step-title{border-width:0!important;border-style:none!important;border:0!important;padding-top:0!important;margin-top:0!important;box-shadow:none!important;outline:none!important;text-decoration:none!important}.metakyc-sdk{background-color:var(--metakyc-background, #ffffff)!important;color:var(--metakyc-text-primary, #111827)!important;font-family:var(--metakyc-font-family, inherit)!important;padding:1.5rem!important;border-radius:.75rem!important}.metakyc-sdk h1,.metakyc-sdk h2,.metakyc-sdk h3,.metakyc-sdk h4,.metakyc-sdk h5,.metakyc-sdk h6{color:var(--metakyc-text-primary, #111827);letter-spacing:normal}.metakyc-sdk .text-gray-900{color:var(--metakyc-text-primary, #111827)!important}.metakyc-sdk .text-gray-800{color:var(--metakyc-text-primary, #1f2937)!important}.metakyc-sdk .text-gray-700{color:var(--metakyc-text-secondary, #374151)!important}.metakyc-sdk .text-gray-600{color:var(--metakyc-text-secondary, #6b7280)!important}.metakyc-sdk .text-gray-500{color:var(--metakyc-text-muted, #6b7280)!important}.metakyc-sdk .text-gray-400{color:var(--metakyc-text-muted, #9ca3af)!important}.metakyc-sdk .text-gray-300{color:var(--metakyc-text-muted, #d1d5db)!important}.metakyc-sdk .text-white{color:#fff!important}.metakyc-sdk .bg-white{background-color:var(--metakyc-background, #ffffff)!important}.metakyc-sdk .bg-gray-50{background-color:var(--metakyc-surface, #f9fafb)!important}.metakyc-sdk .bg-gray-100{background-color:var(--metakyc-surface, #f3f4f6)!important}.metakyc-sdk .bg-gray-200{background-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .bg-gray-800{background-color:var(--metakyc-surface, #1f2937)!important}.metakyc-sdk .border-gray-100,.metakyc-sdk .border-gray-200,.metakyc-sdk .border-gray-300{border-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .border-t{border-top-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .border-b{border-bottom-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .divide-gray-200>*{border-color:var(--metakyc-border, #e5e7eb)!important}.metakyc-sdk .bg-primary-500,.metakyc-sdk .bg-primary-600{background-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .bg-primary-50,.metakyc-sdk .bg-primary-100{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .text-primary-500,.metakyc-sdk .text-primary-600,.metakyc-sdk .text-primary-800{color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .text-primary-900{color:var(--metakyc-primary-dark, #1e40af)!important}.metakyc-sdk .border-primary-500,.metakyc-sdk .border-primary-600{border-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .hover\\:bg-primary-50:hover{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .hover\\:bg-primary-600:hover{background-color:var(--metakyc-primary-hover, #1d4ed8)!important}.metakyc-sdk .bg-blue-600{background-color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .bg-blue-100{background-color:var(--metakyc-primary-light, #dbeafe)!important}.metakyc-sdk .text-blue-600,.metakyc-sdk .text-blue-400{color:var(--metakyc-primary, #2563eb)!important}.metakyc-sdk .hover\\:bg-blue-700:hover{background-color:var(--metakyc-primary-hover, #1d4ed8)!important}.metakyc-sdk .metakyc-overview-steps h3:before,.metakyc-sdk .metakyc-overview-steps h3:after{content:none!important;display:none!important}.metakyc-sdk .metakyc-overview-steps *:before,.metakyc-sdk .metakyc-overview-steps *:after{content:none!important;display:none!important}.metakyc-sdk .metakyc-stepper-scroll::-webkit-scrollbar{display:none!important;height:0!important;width:0!important}.metakyc-sdk .metakyc-file-dropzone:hover{border-color:var(--metakyc-primary, #2563eb)!important;background-color:color-mix(in srgb,var(--metakyc-primary, #2563eb) 3%,var(--metakyc-background, #ffffff))!important}.metakyc-sdk .metakyc-file-item:hover{background-color:color-mix(in srgb,var(--metakyc-surface, #f9fafb) 80%,var(--metakyc-border, #e5e7eb))!important}.metakyc-sdk .metakyc-file-upload label{color:var(--metakyc-text-primary, #111827)!important}.metakyc-sdk .metakyc-file-upload p{margin:0!important;line-height:1.4!important}.metakyc-sdk .metakyc-file-item button{background:transparent!important;border:none!important;box-shadow:none!important;outline:none!important}.metakyc-sdk .metakyc-file-dropzone{box-shadow:none!important;outline:none!important}.metakyc-sdk .hover\\:opacity-90:hover{opacity:.9}.metakyc-sdk .focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.metakyc-sdk .focus\\:ring-2:focus{--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);box-shadow:var(--tw-ring-offset-shadow),var(--tw-ring-shadow),var(--tw-shadow, 0 0 #0000)}.metakyc-sdk .focus\\:ring-offset-0:focus{--tw-ring-offset-width: 0px}.metakyc-sdk .focus\\:ring-offset-1:focus{--tw-ring-offset-width: 1px}.metakyc-sdk .disabled\\:cursor-not-allowed:disabled{cursor:not-allowed}.metakyc-sdk .disabled\\:opacity-50:disabled{opacity:.5}.metakyc-sdk .disabled\\:opacity-60:disabled{opacity:.6}.metakyc-sdk .dark\\:border-blue-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(30 64 175 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-green-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(22 101 52 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-red-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(153 27 27 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:border-yellow-800:is(.dark *){--tw-border-opacity: 1;border-color:rgb(133 77 14 / var(--tw-border-opacity, 1))}.metakyc-sdk .dark\\:bg-blue-900\\/20:is(.dark *){background-color:#1e3a8a33}.metakyc-sdk .dark\\:bg-blue-900\\/30:is(.dark *){background-color:#1e3a8a4d}.metakyc-sdk .dark\\:bg-green-900\\/20:is(.dark *){background-color:#14532d33}.metakyc-sdk .dark\\:bg-green-900\\/30:is(.dark *){background-color:#14532d4d}.metakyc-sdk .dark\\:bg-red-900\\/20:is(.dark *){background-color:#7f1d1d33}.metakyc-sdk .dark\\:bg-red-900\\/30:is(.dark *){background-color:#7f1d1d4d}.metakyc-sdk .dark\\:bg-yellow-900\\/20:is(.dark *){background-color:#713f1233}.metakyc-sdk .dark\\:bg-yellow-900\\/30:is(.dark *){background-color:#713f124d}.metakyc-sdk .dark\\:text-blue-100:is(.dark *){--tw-text-opacity: 1;color:rgb(219 234 254 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-blue-200:is(.dark *){--tw-text-opacity: 1;color:rgb(191 219 254 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-blue-400:is(.dark *){--tw-text-opacity: 1;color:rgb(96 165 250 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-gray-400:is(.dark *){--tw-text-opacity: 1;color:rgb(156 163 175 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-gray-500:is(.dark *){--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-100:is(.dark *){--tw-text-opacity: 1;color:rgb(220 252 231 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-200:is(.dark *){--tw-text-opacity: 1;color:rgb(187 247 208 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-green-400:is(.dark *){--tw-text-opacity: 1;color:rgb(74 222 128 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-100:is(.dark *){--tw-text-opacity: 1;color:rgb(254 226 226 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 202 202 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-red-400:is(.dark *){--tw-text-opacity: 1;color:rgb(248 113 113 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-white:is(.dark *){--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-yellow-200:is(.dark *){--tw-text-opacity: 1;color:rgb(254 240 138 / var(--tw-text-opacity, 1))}.metakyc-sdk .dark\\:text-yellow-400:is(.dark *){--tw-text-opacity: 1;color:rgb(250 204 21 / var(--tw-text-opacity, 1))}@media (min-width: 768px){.metakyc-sdk .md\\:grid-cols-2{grid-template-columns:repeat(2,minmax(0,1fr))}}',Ct="metakyc-sdk-styles";let yt=!1;function ra(){if(yt||typeof document>"u")return;if(document.getElementById(Ct)){yt=!0;return}const t=document.createElement("style");t.id=Ct,t.textContent=ta,document.head.appendChild(t),yt=!0}const aa=({config:t,children:r})=>{ra();const[a,s]=i.useState(null),n=i.useRef(!1),o=i.useRef(!1),c=i.useMemo(()=>{const y=new Yt(t),p=new Vt(y),f=new Qt(y),F=new Gt(y),b=new Jt(y),E=new Xt(y),A=new Zt(y),v=new er(y),S=new tr(y),M=new rr(y),V=new cr(y),L=new hr;return{httpClient:y,applicantService:p,questionnaireService:f,uploadDocumentService:F,appropriatenessTestService:b,overviewService:E,riskScoringService:A,identityService:v,baseInformationService:S,investorCategorizationService:M,themeService:V,themeManager:L}},[t]),d=i.useMemo(()=>({config:t,...c,currentTheme:a,createOrchestrator:()=>new ur(c.applicantService,c.questionnaireService,c.uploadDocumentService,c.appropriatenessTestService,c.overviewService,c.riskScoringService,c.identityService,c.investorCategorizationService)}),[t,c,a]);return i.useEffect(()=>((async()=>{if(n.current||o.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(t.theme){console.log("[MetaKYC] Applying static theme from config"),c.themeManager.applyTheme(t.theme),s(c.themeManager.getCurrentTheme()),o.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const p=await c.themeService.getThemeConfiguration();c.themeManager.applyTheme(p),s(c.themeManager.getCurrentTheme()),o.current=!0,console.log("[MetaKYC] Theme loaded and applied",p)}catch(p){console.warn("[MetaKYC] Failed to load theme, using default:",p),s(c.themeManager.getCurrentTheme()),o.current=!0}finally{n.current=!1}})(),()=>{c.themeManager.cleanup()}),[]),e.jsxs(bt.Provider,{value:d,children:[t.showVersion&&e.jsxs("div",{style:{fontSize:"0.625rem",color:"var(--metakyc-text-muted, #9ca3af)",opacity:.5,textAlign:"right",padding:"2px 8px",userSelect:"none",pointerEvents:"none",letterSpacing:"0.02em",lineHeight:1},children:["SDK v",fr]}),r]})};function Ne(){const t=i.useContext(bt);if(!t)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return t}async function kr(t){return new Promise((r,a)=>{const s=new FileReader;s.readAsDataURL(t),s.onload=()=>{const o=s.result.split(",")[1];r(o)},s.onerror=n=>a(n)})}function sa(t,r){return t.size<=r}function na(t,r){return r.split(",").map(s=>s.trim()).some(s=>{if(s.endsWith("/*")){const n=s.slice(0,-2);return t.type.startsWith(n)}return t.type===s})}function mt(t){if(t===0)return"0 Bytes";const r=1024,a=["Bytes","KB","MB","GB"],s=Math.floor(Math.log(t)/Math.log(r));return Math.round(t/Math.pow(r,s)*100)/100+" "+a[s]}function ia(t){return t}function Se(...t){return t.filter(Boolean).join(" ")}const it={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function br(t){try{localStorage.setItem(it.APPLICANT_ID,t.toString())}catch(r){console.warn("Failed to save applicant ID to storage:",r)}}function vr(){try{const t=localStorage.getItem(it.APPLICANT_ID);return t?parseInt(t,10):null}catch(t){return console.warn("Failed to retrieve applicant ID from storage:",t),null}}function wr(){try{localStorage.removeItem(it.APPLICANT_ID)}catch(t){console.warn("Failed to clear applicant ID from storage:",t)}}function jr(t){try{localStorage.setItem(it.WORKFLOW_STATE,JSON.stringify(t))}catch(r){console.warn("Failed to save workflow state to storage:",r)}}function oa(){try{const t=localStorage.getItem(it.WORKFLOW_STATE);return t?JSON.parse(t):null}catch(t){return console.warn("Failed to retrieve workflow state from storage:",t),null}}function Sr(){try{localStorage.removeItem(it.WORKFLOW_STATE)}catch(t){console.warn("Failed to clear workflow state from storage:",t)}}function la(){wr(),Sr()}function Cr(t){const{createOrchestrator:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(null),p=t||vr();i.useEffect(()=>{y.current||(y.current=r())},[r]),i.useEffect(()=>{var L;a&&p&&(br(p),jr({applicantId:p,currentStepOrder:(L=a.currentStep)==null?void 0:L.order,status:a.status,lastUpdated:new Date().toISOString(),workflowKey:a.workFlowKey,nextWorkflowKey:a.nextWorkflowKey}))},[a,p]);const f=i.useRef(!1),F=i.useRef(!1),b=i.useCallback(async()=>{if(!(!p||!y.current)){if(f.current){console.log("[Workflow] Load already in progress, skipping...");return}f.current=!0,o(!0),d(null);try{const L=await y.current.initialize(p);s(L),F.current=!0}catch(L){d(L)}finally{o(!1),f.current=!1}}},[p]);i.useEffect(()=>{p&&!F.current&&b()},[p,b]);const E=i.useCallback(async()=>{if(y.current){if(f.current){console.log("[Workflow] Refresh already in progress, skipping...");return}f.current=!0,o(!0),d(null);try{const L=await y.current.refreshProgress();s(L)}catch(L){d(L)}finally{o(!1),f.current=!1}}},[]),A=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToNextStep();s(L)}catch(L){d(L)}finally{o(!1)}}},[]),v=i.useCallback(async()=>{if(y.current){o(!0),d(null);try{const L=await y.current.moveToPreviousStep();s(L)}catch(L){d(L)}finally{o(!1)}}},[]),S=i.useCallback(async L=>{if(y.current){o(!0),d(null);try{await y.current.submitCurrentStep(L);const B=await y.current.refreshProgress();s(B)}catch(B){throw d(B),B}finally{o(!1)}}},[]),M=St.useMemo(()=>a!=null&&a.stepInfoList?[...a.stepInfoList].sort((L,B)=>L.order-B.order):[],[a==null?void 0:a.stepInfoList]),V=St.useMemo(()=>a?a.nextWorkflowKey&&a.nextWorkflowKey!==a.workFlowKey:!1,[a]);return{progress:a,applicantId:p,currentStep:(a==null?void 0:a.currentStep)||null,steps:M,status:(a==null?void 0:a.status)||Fe.None,workflowResult:(a==null?void 0:a.workflowResult)||null,workflowKey:a==null?void 0:a.workFlowKey,nextWorkflowKey:a==null?void 0:a.nextWorkflowKey,hasWorkflowChanged:V,isLoading:n,error:c,isComplete:(a==null?void 0:a.status)===Fe.Finished,isOnHold:(a==null?void 0:a.status)===Fe.OnHold,refreshProgress:E,moveToNext:A,moveBack:v,submitCurrentStep:S,orchestrator:y.current}}function Nr(t){const{questionnaireService:r,applicantService:a}=Ne(),[s,n]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,f]=i.useState(!1),[F,b]=i.useState(null),E=i.useRef(!1),A=i.useRef(null),v=i.useCallback(async()=>{var M,V;if(t){if(E.current){console.log("[Questionnaire] Load already in progress, skipping...");return}E.current=!0,y(!0),b(null);try{const[L,B]=await Promise.all([r.getQuestionnaire(t),a.getApplicantData(t).catch(()=>null)]);if(n(L),(M=B==null?void 0:B.questionnaireResults)!=null&&M.length&&L){const U=new Map;for(const h of B.questionnaireResults)h.question&&((V=h.answers)!=null&&V.length)&&U.set(h.question.trim().toLowerCase(),h.answers);const Z={},R=L.questionGroups.flatMap(h=>h.questions??[]);for(const h of R){const z=h.text.trim().toLowerCase();U.has(z)&&(Z[h.id]=U.get(z))}c(Z)}A.current=t}catch(L){b(L)}finally{y(!1),E.current=!1}}},[t,r,a]);i.useEffect(()=>{t&&A.current!==t&&v()},[t]);const S=i.useCallback(async M=>{f(!0),b(null);try{return await r.fillQuestionnaire(M)}catch(V){throw b(V),V}finally{f(!1)}},[r]);return{questionnaire:s,initialAnswers:o,isLoading:d,isSubmitting:p,error:F,load:v,submit:S}}function Rr(t){const{uploadDocumentService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(0),[f,F]=i.useState(null),b=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(b.current){console.log("[UploadDocument] Load already in progress, skipping...");return}b.current=!0,o(!0),F(null);try{const S=await r.getUploadDocument(t);s(S),E.current=t}catch(S){F(S)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const v=i.useCallback(async S=>{d(!0),p(0),F(null);try{await r.fillUploadDocument(S),p(100)}catch(M){throw F(M),M}finally{d(!1)}},[r]);return{uploadDocument:a,isLoading:n,isSubmitting:c,uploadProgress:y,error:f,load:A,submit:v}}function ca(t){const{appropriatenessTestService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),[f,F]=i.useState(null),b=i.useRef(!1),E=i.useRef(null),A=i.useCallback(async()=>{if(t){if(b.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}b.current=!0,o(!0),p(null);try{const S=await r.getAppropriatenessTest(t);s(S),E.current=t}catch(S){p(S)}finally{o(!1),b.current=!1}}},[t,r]);i.useEffect(()=>{t&&E.current!==t&&A()},[t]);const v=i.useCallback(async S=>{d(!0),p(null);try{const M=await r.fillAppropriatenessTest(S);return F(M),M}catch(M){throw p(M),M}finally{d(!1)}},[r]);return{test:a,result:f,isLoading:n,isSubmitting:c,error:y,load:A,submit:v}}function Ir(t){const{overviewService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(!1),[y,p]=i.useState(null),f=i.useRef(!1),F=i.useRef(null),b=i.useCallback(async()=>{if(t){if(f.current){console.log("[Overview] Load already in progress, skipping...");return}f.current=!0,o(!0),p(null);try{const A=await r.getOverviewData(t);s(A),F.current=t}catch(A){p(A)}finally{o(!1),f.current=!1}}},[t,r]);i.useEffect(()=>{t&&F.current!==t&&b()},[t]);const E=i.useCallback(async()=>{if(t){d(!0),p(null);try{await r.passOverview(t)}catch(A){throw p(A),A}finally{d(!1)}}},[t,r]);return{overview:a,isLoading:n,isSubmitting:c,error:y,load:b,passOverview:E}}function Er(t){const{identityService:r}=Ne(),[a,s]=i.useState(null),[n,o]=i.useState(!1),[c,d]=i.useState(null),y=i.useRef(!1),p=i.useCallback(async(b,E)=>{if(t){if(y.current){console.log("[Identity] Request already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:b||"",ttl:E||604800};console.log("Identity request input:",A);const v=await r.identityRequest(A);return console.log("Identity request result:",v),s(v),v}catch(A){throw d(A),A}finally{o(!1),y.current=!1}}},[t,r]),f=i.useCallback(async(b,E)=>{if(t){o(!0),d(null);try{const A={applicantId:t,restart:!1,redirectUrl:b,ttl:E},v=await r.identityCompanyRequest(A);return s(v),v}catch(A){throw d(A),A}finally{o(!1)}}},[t,r]),F=i.useCallback(async()=>{if(t){if(y.current){console.log("[Identity] Restart already in progress, skipping...");return}y.current=!0,o(!0),d(null);try{const b={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",b);const E=await r.identityRequest(b);return console.log("Restart identity result:",E),s(E),E}catch(b){throw d(b),b}finally{o(!1),y.current=!1}}},[t,r]);return{identityData:a,provider:(a==null?void 0:a.provider)||null,token:(a==null?void 0:a.publicProviderTokenObject)||null,isLoading:n,error:c,requestIdentity:p,requestCompanyIdentity:f,restartIdentity:F}}function Ar(t){const{riskScoringService:r,applicantService:a}=Ne(),[s,n]=i.useState(null),[o,c]=i.useState({}),[d,y]=i.useState(!1),[p,f]=i.useState(!1),[F,b]=i.useState(null),[E,A]=i.useState(null),v=i.useRef(!1),S=i.useRef(null),M=i.useCallback(async()=>{var L;if(t){if(v.current){console.log("[RiskScoring] Load already in progress, skipping...");return}v.current=!0,y(!0),b(null);try{const[B,U]=await Promise.all([r.getRiskCriterias(t),a.getApplicantData(t).catch(()=>null)]);if(n(B),(L=U==null?void 0:U.riskScoringResults)!=null&&L.length){const Z=U.riskScoringResults[0],R={};for(const h of Z.riskCriteriaResults??[])if(h.riskCriteriaId!=null&&h.answer!=null&&h.answer!==""){const z=[...new Set(h.answer.split(",").map(q=>q.trim()).filter(q=>q!==""))];z.length>0&&(R[h.riskCriteriaId]=z)}c(R)}S.current=t}catch(B){b(B)}finally{y(!1),v.current=!1}}},[t,r,a]);i.useEffect(()=>{t&&S.current!==t&&M()},[t]);const V=i.useCallback(async L=>{f(!0),b(null);try{const B=await r.submitRiskScoring(L);return A(B),B}catch(B){throw b(B),B}finally{f(!1)}},[r]);return{criteria:s,initialAnswers:o,result:E,isLoading:d,isSubmitting:p,error:F,load:M,submit:V}}function vt(){const{applicantService:t,config:r}=Ne(),[a,s]=i.useState(!1),[n,o]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),y=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(E){const A=Math.random()*16|0;return(E==="x"?A:A&3|8).toString(16)}),p=i.useCallback(async E=>{var A;if(c.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");c.current=!0,s(!0),o(null);try{if(E.applicantAdditionalDatas||(E.applicantAdditionalDatas=[]),(A=r.identityProviders)!=null&&A.sardinai){const S=y();console.log("[SardinAI] Generated session key:",S),E.applicantAdditionalDatas.push({paramName:"sessionKey",value:S})}return await t.createApplicant(E)}catch(v){throw o(v),v}finally{s(!1),c.current=!1}},[t,r]),f=i.useCallback(async E=>{s(!0),o(null);try{return await t.createCompanyApplicant(E)}catch(A){throw o(A),A}finally{s(!1)}},[t]),F=i.useCallback(async E=>{if(d.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");d.current=!0,s(!0),o(null);try{return await t.getApplicantData(E)}catch(A){throw o(A),A}finally{s(!1),d.current=!1}},[t]),b=i.useCallback(async E=>{s(!0),o(null);try{await t.stopProgress(E)}catch(A){throw o(A),A}finally{s(!1)}},[t]);return{isLoading:a,error:n,createApplicant:p,createCompanyApplicant:f,getApplicantData:F,stopProgress:b}}const da={primary:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",borderColor:"transparent"},secondary:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #e5e7eb)"},outline:{backgroundColor:"transparent",color:"var(--metakyc-primary, #2563eb)",borderColor:"var(--metakyc-primary, #2563eb)"},danger:{backgroundColor:"var(--metakyc-danger, #ef4444)",color:"#ffffff",borderColor:"transparent"},ghost:{backgroundColor:"transparent",color:"var(--metakyc-text-secondary, #6b7280)",borderColor:"transparent"}},J=({children:t,variant:r="primary",size:a="md",isLoading:s=!1,disabled:n,className:o,style:c,...d})=>{const y="inline-flex items-center justify-center rounded-lg font-medium transition-opacity border focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-not-allowed",p={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-sm",lg:"px-6 py-3 text-base"},f={sm:{padding:"0.375rem 0.75rem",fontSize:"0.875rem"},md:{padding:"0.5rem 1rem",fontSize:"0.875rem"},lg:{padding:"0.75rem 1.5rem",fontSize:"1rem"}};return e.jsxs("button",{className:Se(y,p[a],o),style:{display:"inline-flex",alignItems:"center",justifyContent:"center",borderRadius:"0.5rem",fontWeight:500,borderWidth:"1px",borderStyle:"solid",cursor:n||s?"not-allowed":"pointer",opacity:n||s?.5:1,lineHeight:"1.25rem",...f[a],...da[r],...c},disabled:n||s,...d,children:[s&&e.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),t]})},ye=i.forwardRef(({label:t,error:r,helperText:a,leftIcon:s,rightIcon:n,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"relative",children:[s&&e.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:s}),e.jsx("input",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",s?"pl-10":"",n?"pr-10":"",o),style:{minHeight:"38px",backgroundColor:d.readOnly?"var(--metakyc-surface, #f3f4f6)":"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",cursor:d.readOnly?"default":void 0,...c},...d}),n&&e.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-danger, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]}));ye.displayName="Input";const ee=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("metakyc-card rounded-xl shadow-sm border",r),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)",borderWidth:"1px",borderStyle:"solid",borderRadius:"0.75rem",overflow:"hidden",...a},...s,children:t}),he=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-b",r),style:{padding:"1rem 1.5rem",borderBottomWidth:"1px",borderBottomStyle:"solid",borderBottomColor:"var(--metakyc-border, #e5e7eb)",...a},...s,children:t}),te=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4",r),style:{padding:"1rem 1.5rem",...a},...s,children:t}),fe=({children:t,className:r,style:a,...s})=>e.jsx("div",{className:Se("px-6 py-4 border-t",r),style:{padding:"1rem 1.5rem",borderTopWidth:"1px",borderTopStyle:"solid",borderTopColor:"var(--metakyc-border, #e5e7eb)",...a},...s,children:t}),ma={display:"inline-flex",alignItems:"center",justifyContent:"center",width:16,height:16,minWidth:16,minHeight:16,maxWidth:16,maxHeight:16,borderRadius:4,borderWidth:"1.5px",borderStyle:"solid",cursor:"pointer",flexShrink:0,position:"relative",transition:"background-color 0.15s, border-color 0.15s",boxSizing:"border-box",padding:0,margin:0,verticalAlign:"middle"},Te=({checked:t,onChange:r,disabled:a,style:s})=>{const n="var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",o="var(--metakyc-input-bg, var(--metakyc-background, #ffffff))",c="var(--metakyc-primary, #2563eb)";return e.jsx("span",{role:"checkbox","aria-checked":t,tabIndex:0,onClick:()=>!a&&r(!t),onKeyDown:d=>{(d.key===" "||d.key==="Enter")&&(d.preventDefault(),a||r(!t))},style:{...ma,backgroundColor:t?c:o,borderColor:t?c:n,opacity:a?.5:1,cursor:a?"not-allowed":"pointer",...s},children:t&&e.jsx("svg",{width:"10",height:"8",viewBox:"0 0 10 8",fill:"none",style:{display:"block",flexShrink:0},children:e.jsx("path",{d:"M1 4L3.5 6.5L9 1",stroke:"#ffffff",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})})},pa={default:{backgroundColor:"var(--metakyc-surface, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)"},info:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)",color:"var(--metakyc-primary, #2563eb)"},success:{backgroundColor:"#d1fae5",color:"#065f46"},danger:{backgroundColor:"#fee2e2",color:"#991b1b"},warning:{backgroundColor:"#fef3c7",color:"#92400e"}},wt=({children:t,variant:r="default",className:a,style:s,...n})=>e.jsx("span",{className:Se("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",a),style:{...pa[r],...s},...n,children:t}),Ee=({size:t="md",className:r,...a})=>{const s={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return e.jsx("div",{className:Se("flex items-center justify-center",r),...a,children:e.jsxs("svg",{className:Se("animate-spin text-primary-500",s[t]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[e.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),e.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},ut=i.forwardRef(({label:t,error:r,helperText:a,options:s,placeholder:n,className:o,style:c,...d},y)=>e.jsxs("div",{className:"w-full",children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("select",{ref:y,className:Se("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-offset-0","disabled:opacity-60 disabled:cursor-not-allowed",r?"border-danger-500":"",o),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))",borderColor:r?"var(--metakyc-danger, #ef4444)":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",...c},...d,children:[n&&e.jsx("option",{value:"",disabled:!0,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-secondary, #6b7280)"},children:n},"__placeholder__"),s.map((p,f)=>e.jsx("option",{value:p.value,disabled:p.disabled,style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:p.disabled?"var(--metakyc-text-muted, #9ca3af)":"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))"},children:p.label},p.value||`option-${f}`))]}),r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]}));ut.displayName="Select";const Nt=280,Fr=({label:t,value:r,onChange:a,options:s,placeholder:n="Select...",disabled:o=!1,readOnly:c=!1,required:d=!1})=>{const y=o||c,[p,f]=i.useState(!1),[F,b]=i.useState(""),[E,A]=i.useState(null),[v,S]=i.useState({bg:"#ffffff",borderColor:"#d1d5db",textPrimary:"#111827",textSecondary:"#6b7280",primaryColor:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),M=i.useRef(null),V=i.useRef(null),L=i.useRef(null),B=i.useCallback(()=>{if(!V.current)return null;const I=V.current.getBoundingClientRect(),O=window.innerHeight-I.bottom<Nt&&I.top>Nt;return{top:O?I.top:I.bottom+4,left:I.left,width:I.width,openUp:O}},[]),U=i.useCallback(()=>{const I=getComputedStyle(document.querySelector(".metakyc-sdk")||document.documentElement),W=(_,ue)=>I.getPropertyValue(_).trim()||ue,O=W("--metakyc-input-bg",W("--metakyc-background","#ffffff"));S({bg:O,borderColor:W("--metakyc-input-border",W("--metakyc-border","#d1d5db")),textPrimary:W("--metakyc-input-text",W("--metakyc-text-primary","#111827")),textSecondary:W("--metakyc-text-secondary","#6b7280"),primaryColor:W("--metakyc-primary","#2563eb"),primaryLight:W("--metakyc-primary-light","#eff6ff"),hoverBg:W("--metakyc-surface",O)})},[]),Z=i.useCallback(()=>{if(y)return;U();const I=B();I&&A(I),f(!0)},[y,B,U]),R=i.useCallback(()=>{f(!1),b("")},[]);i.useEffect(()=>{if(!p)return;const I=W=>{var _,ue;const O=W.target;!((_=M.current)!=null&&_.contains(O))&&!((ue=L.current)!=null&&ue.contains(O))&&R()};return document.addEventListener("mousedown",I),()=>document.removeEventListener("mousedown",I)},[p,R]),i.useEffect(()=>{if(!p)return;const I=()=>{const W=B();W&&A(W)};return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[p,B]);const h=s.filter(I=>I.label.toLowerCase().includes(F.toLowerCase())),z=I=>{y||a(r.includes(I)?r.filter(W=>W!==I):[...r,I])},q=(I,W)=>{W.stopPropagation(),y||a(r.filter(O=>O!==I))},Q=I=>{var W;return((W=s.find(O=>O.value===I))==null?void 0:W.label)||I},{bg:$,borderColor:G,textPrimary:ae,textSecondary:Y,primaryColor:ke,primaryLight:ce,hoverBg:de}=v,ge=p&&E&&e.jsxs("div",{ref:L,className:"metakyc-multiselect-dropdown",style:{position:"fixed",top:E.openUp?void 0:E.top,bottom:E.openUp?window.innerHeight-E.top+4:void 0,left:E.left,width:E.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${G}`,backgroundColor:$,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${G}`},children:e.jsx("input",{type:"text",value:F,onChange:I=>b(I.target.value),placeholder:"Search...",autoFocus:!0,onClick:I=>I.stopPropagation(),className:"metakyc-multiselect-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${G}`,backgroundColor:$,color:ae,outline:"none",boxSizing:"border-box"},onFocus:I=>{const W=getComputedStyle(document.querySelector(".metakyc-sdk")||document.documentElement),O=W.getPropertyValue("--metakyc-input-border-focus").trim()||W.getPropertyValue("--metakyc-primary").trim()||"#2563eb";I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=O,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow=`0 0 0 2px ${O}33`},onBlur:I=>{I.currentTarget.style.backgroundColor=$,I.currentTarget.style.color=ae,I.currentTarget.style.borderColor=G,I.currentTarget.style.outline="none",I.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"192px",overflowY:"auto"},children:h.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:Y},children:"No results"}):h.map(I=>{const W=r.includes(I.value);return e.jsxs("li",{onClick:()=>z(I.value),className:"metakyc-multiselect-option",style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",fontSize:"13px",cursor:"pointer",backgroundColor:W?ce:"transparent",color:W?ke:ae,userSelect:"none"},onMouseEnter:O=>{W||(O.currentTarget.style.backgroundColor=de)},onMouseLeave:O=>{W||(O.currentTarget.style.backgroundColor="transparent")},children:[e.jsx(Te,{checked:W,onChange:()=>{}}),e.jsx("span",{children:I.label})]},I.value)})}),r.length>0&&e.jsx("div",{style:{padding:"6px 12px",borderTop:`1px solid ${G}`},children:e.jsxs("button",{type:"button",onClick:()=>{a([]),b("")},style:{fontSize:"12px",color:"#ef4444",background:"none",border:"none",cursor:"pointer",padding:0},children:["Clear all (",r.length," selected)"]})})]});return e.jsxs("div",{className:"w-full metakyc-multiselect",ref:M,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,d&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:V,onClick:()=>p?R():Z(),className:Se("metakyc-multiselect-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors relative",y?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",borderColor:p?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",outline:p?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[r.length===0?e.jsx("span",{className:"metakyc-multiselect-placeholder leading-6",style:{color:"var(--metakyc-text-secondary, #9ca3af)"},children:n}):e.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:r.map(I=>e.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{backgroundColor:"var(--metakyc-primary-light, #eff6ff)",color:"var(--metakyc-primary, #2563eb)"},children:[Q(I),!y&&e.jsx("button",{type:"button",onClick:W=>q(I,W),className:"metakyc-multiselect-chip-remove",style:{background:"transparent",border:"none",padding:"0 0 0 2px",margin:0,cursor:"pointer",fontSize:"14px",lineHeight:1,fontWeight:"bold",display:"inline-flex",alignItems:"center",boxShadow:"none",transform:"none",minWidth:0,width:"auto",height:"auto",letterSpacing:"normal",textTransform:"none"},children:"×"})]},I))}),e.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 pointer-events-none text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p?"▲":"▼"})]}),typeof document<"u"&&ge?pt.createPortal(ge,document.body):null]})},Rt=260,ze=({label:t,error:r,helperText:a,options:s,placeholder:n="Select...",value:o,onChange:c,disabled:d=!1,readOnly:y=!1,required:p=!1,className:f})=>{var ue;const F=d||y,[b,E]=i.useState(!1),[A,v]=i.useState(""),[S,M]=i.useState(null),[V,L]=i.useState({bg:"#ffffff",border:"#d1d5db",text:"#111827",textSecondary:"#6b7280",primary:"#2563eb",primaryLight:"#eff6ff",hoverBg:"#f9fafb"}),B=i.useCallback(()=>{const N=getComputedStyle(document.querySelector(".metakyc-sdk")||document.documentElement),re=(se,be)=>N.getPropertyValue(se).trim()||be,me=re("--metakyc-input-bg",re("--metakyc-background","#ffffff"));L({bg:me,border:re("--metakyc-input-border",re("--metakyc-border","#d1d5db")),text:re("--metakyc-input-text",re("--metakyc-text-primary","#111827")),textSecondary:re("--metakyc-text-secondary","#6b7280"),primary:re("--metakyc-primary","#2563eb"),primaryLight:re("--metakyc-primary-light","#eff6ff"),hoverBg:re("--metakyc-surface",me)})},[]),U=i.useRef(null),Z=i.useRef(null),R=i.useRef(null),h=i.useRef(null),z=i.useCallback(()=>{if(!Z.current)return null;const N=Z.current.getBoundingClientRect(),me=window.innerHeight-N.bottom<Rt&&N.top>Rt;return{top:me?N.top:N.bottom+4,left:N.left,width:N.width,openUp:me}},[]),q=i.useCallback(()=>{if(F)return;B();const N=z();N&&M(N),E(!0)},[F,z,B]),Q=i.useCallback(()=>{E(!1),v("")},[]),$=()=>b?Q():q();i.useEffect(()=>{if(!b)return;const N=re=>{var se,be;const me=re.target;!((se=U.current)!=null&&se.contains(me))&&!((be=R.current)!=null&&be.contains(me))&&Q()};return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[b,Q]),i.useEffect(()=>{if(!b)return;const N=()=>{const re=z();re&&M(re)};return window.addEventListener("scroll",N,!0),window.addEventListener("resize",N),()=>{window.removeEventListener("scroll",N,!0),window.removeEventListener("resize",N)}},[b,z]),i.useEffect(()=>{b&&h.current&&setTimeout(()=>{var N;return(N=h.current)==null?void 0:N.focus()},0)},[b]);const G=s.filter(N=>N.label.toLowerCase().includes(A.toLowerCase())||N.value.toLowerCase().includes(A.toLowerCase())),ae=(ue=s.find(N=>N.value===o))==null?void 0:ue.label,Y=(N,re)=>{F||re||(c(N),Q())},{bg:ke,border:ce,text:de,textSecondary:ge,primary:I,primaryLight:W,hoverBg:O}=V,_=b&&S&&e.jsxs("div",{ref:R,className:"metakyc-searchable-select-dropdown",style:{position:"fixed",top:S.openUp?void 0:S.top,bottom:S.openUp?window.innerHeight-S.top+4:void 0,left:S.left,width:S.width,zIndex:99999,borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.18)",border:`1px solid ${ce}`,backgroundColor:ke,overflow:"hidden"},children:[e.jsx("div",{style:{padding:"8px",borderBottom:`1px solid ${ce}`},children:e.jsx("input",{ref:h,type:"text",value:A,onChange:N=>v(N.target.value),placeholder:"Search...",onClick:N=>N.stopPropagation(),className:"metakyc-searchable-select-search w-full",style:{display:"block",width:"100%",padding:"6px 8px",fontSize:"13px",borderRadius:"6px",border:`1px solid ${ce}`,backgroundColor:ke,color:de,outline:"none",boxSizing:"border-box"},onFocus:N=>{const re=getComputedStyle(document.querySelector(".metakyc-sdk")||document.documentElement),me=re.getPropertyValue("--metakyc-input-border-focus").trim()||re.getPropertyValue("--metakyc-primary").trim()||"#2563eb";N.currentTarget.style.backgroundColor=ke,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=me,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow=`0 0 0 2px ${me}33`},onBlur:N=>{N.currentTarget.style.backgroundColor=ke,N.currentTarget.style.color=de,N.currentTarget.style.borderColor=ce,N.currentTarget.style.outline="none",N.currentTarget.style.boxShadow="none"}})}),e.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0",maxHeight:"208px",overflowY:"auto"},children:G.length===0?e.jsx("li",{style:{padding:"8px 12px",fontSize:"13px",color:ge},children:"No results"}):G.map(N=>{const re=N.value===o;return e.jsx("li",{className:"metakyc-searchable-select-option",onClick:()=>Y(N.value,N.disabled),style:{padding:"8px 12px",fontSize:"13px",cursor:N.disabled?"not-allowed":"pointer",opacity:N.disabled?.4:1,backgroundColor:re?W:"transparent",color:re?I:de,userSelect:"none"},onMouseEnter:me=>{!re&&!N.disabled&&(me.currentTarget.style.backgroundColor=O)},onMouseLeave:me=>{re||(me.currentTarget.style.backgroundColor="transparent")},children:N.label},N.value)})})]});return e.jsxs("div",{className:Se("w-full metakyc-searchable-select",f),ref:U,children:[t&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[t,p&&e.jsx("span",{style:{color:"var(--metakyc-error, #ef4444)",marginLeft:"4px"},children:"*"})]}),e.jsxs("div",{ref:Z,role:"button",tabIndex:F?-1:0,onClick:$,onKeyDown:N=>{(N.key==="Enter"||N.key===" ")&&(N.preventDefault(),$()),N.key==="Escape"&&Q()},className:Se("metakyc-searchable-select-trigger","w-full px-3 py-2 rounded-lg border text-sm transition-colors text-left","flex items-center justify-between gap-2","focus:outline-none",F?"opacity-60 cursor-not-allowed":"cursor-pointer"),style:{backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:ae?"var(--metakyc-input-text, var(--metakyc-text-primary, #111827))":"var(--metakyc-input-placeholder, var(--metakyc-text-muted, #9ca3af))",borderColor:r?"var(--metakyc-danger, #ef4444)":b?"var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"var(--metakyc-input-border, var(--metakyc-border, #d1d5db))",minHeight:"38px",outline:b?"2px solid var(--metakyc-input-border-focus, var(--metakyc-primary, #2563eb))":"none",outlineOffset:"-1px"},children:[e.jsx("span",{className:"truncate flex-1",children:ae||n}),e.jsx("span",{className:"flex-shrink-0 text-xs pointer-events-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:b?"▲":"▼"})]}),typeof document<"u"&&_?pt.createPortal(_,document.body):null,r&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-error, #ef4444)"},children:r}),!r&&a&&e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a})]})};ze.displayName="SearchableSelect";function ua(t){const r=t.type;return r.startsWith("image/")?"image":r==="application/pdf"?"pdf":"file"}const Tr=({label:t,subtitle:r,error:a,accept:s,multiple:n=!1,maxSize:o,required:c,onChange:d,value:y=[],className:p})=>{const[f,F]=i.useState(!1),[b,E]=i.useState(null),A=i.useRef(null),v=i.useCallback(R=>{if(!R)return;E(null);const h=Array.from(R);if(o&&h.filter(q=>q.size>o).length>0){E(`File exceeds the maximum size of ${mt(o)}`);return}d==null||d(n?[...y,...h]:[h[0]])},[o,n,d,y]),S=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!0)},[]),M=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1)},[]),V=i.useCallback(R=>{R.preventDefault(),R.stopPropagation(),F(!1),v(R.dataTransfer.files)},[v]),L=()=>{var R;(R=A.current)==null||R.click()},B=R=>{E(null);const h=y.filter((z,q)=>q!==R);d==null||d(h)},U=a||b,Z=y.length>0;return e.jsxs("div",{className:Se("metakyc-file-upload",p),style:{width:"100%"},children:[t&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("label",{style:{display:"block",fontSize:"14px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)"},children:[t,c&&e.jsx("span",{style:{color:"var(--metakyc-danger, #ef4444)",marginLeft:"2px"},children:"*"})]}),r&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:r})]}),e.jsxs("div",{className:"metakyc-file-dropzone",onClick:L,onDragOver:S,onDragLeave:M,onDrop:V,style:{border:`2px dashed ${U?"var(--metakyc-danger, #ef4444)":f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,borderRadius:"12px",padding:Z?"20px":"32px 20px",textAlign:"center",cursor:"pointer",transition:"all 0.2s ease",backgroundColor:f?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)"},children:[e.jsx("input",{ref:A,type:"file",style:{display:"none"},accept:s,multiple:n,onChange:R=>{v(R.target.files),R.target.value=""}}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:f?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"var(--metakyc-surface, #f9fafb)",transition:"background-color 0.2s ease"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:f?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{transition:"stroke 0.2s ease"},children:[e.jsx("path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"}),e.jsx("polyline",{points:"17 8 12 3 7 8"}),e.jsx("line",{x1:"12",y1:"3",x2:"12",y2:"15"})]})}),e.jsxs("div",{children:[e.jsxs("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--metakyc-primary, #2563eb)"},children:"Click to upload"})," ","or drag and drop"]}),(s||o)&&e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:[s&&e.jsx("span",{children:s}),s&&o&&e.jsx("span",{children:" · "}),o&&e.jsxs("span",{children:["Max ",mt(o)]})]})]})]})]}),Z&&e.jsx("div",{style:{marginTop:"12px",display:"flex",flexDirection:"column",gap:"8px"},children:y.map((R,h)=>{const z=ua(R),q=z==="image",Q=q?URL.createObjectURL(R):null;return e.jsxs("div",{className:"metakyc-file-item",style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 12px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)",transition:"background-color 0.15s ease"},children:[e.jsx("div",{style:{width:"40px",height:"40px",borderRadius:"8px",flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",backgroundColor:q?"transparent":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 10%, transparent)"},children:q&&Q?e.jsx("img",{src:Q,alt:R.name,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"8px"}}):z==="pdf"?e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}):e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("p",{style:{fontSize:"13px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)",margin:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:R.name}),e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0,marginTop:"2px"},children:mt(R.size)})]}),e.jsx("button",{type:"button",onClick:$=>{$.stopPropagation(),B(h)},style:{display:"flex",alignItems:"center",justifyContent:"center",width:"28px",height:"28px",borderRadius:"6px",border:"none",backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",cursor:"pointer",flexShrink:0,transition:"all 0.15s ease",padding:0},onMouseEnter:$=>{$.currentTarget.style.backgroundColor="color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",$.currentTarget.style.color="var(--metakyc-danger, #ef4444)"},onMouseLeave:$=>{$.currentTarget.style.backgroundColor="transparent",$.currentTarget.style.color="var(--metakyc-text-muted, #9ca3af)"},children:e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},`${R.name}-${h}`)})}),U&&e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",marginTop:"6px"},children:U})]})},Pr=i.forwardRef(({countryCode:t="+1",onCountryCodeChange:r,className:a,...s},n)=>e.jsxs("div",{className:"w-full",children:[s.label&&e.jsxs("label",{className:"block text-sm font-medium mb-1",style:{color:"var(--metakyc-text-primary, #374151)"},children:[s.label,s.required&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:t,onChange:o=>r==null?void 0:r(o.target.value),className:Se("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-offset-0"),style:{minHeight:"38px",backgroundColor:"var(--metakyc-input-bg, #ffffff)",color:"var(--metakyc-text-primary, #111827)",borderColor:"var(--metakyc-border, #d1d5db)"},placeholder:"+1"}),e.jsx(ye,{ref:n,type:"tel",className:Se("flex-1",a),...s,label:""})]}),s.error&&e.jsx("p",{className:"mt-1 text-sm text-danger-500",children:s.error})]}));Pr.displayName="PhoneInput";/**
|
|
53
75
|
* @license lucide-react v0.574.0 - ISC
|
|
54
76
|
*
|
|
55
77
|
* This source code is licensed under the ISC license.
|
|
@@ -59,45 +81,45 @@ a:hover { color: ${r}; }
|
|
|
59
81
|
*
|
|
60
82
|
* This source code is licensed under the ISC license.
|
|
61
83
|
* See the LICENSE file in the root directory of this source tree.
|
|
62
|
-
*/const
|
|
84
|
+
*/const ya=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
|
|
63
85
|
* @license lucide-react v0.574.0 - ISC
|
|
64
86
|
*
|
|
65
87
|
* This source code is licensed under the ISC license.
|
|
66
88
|
* See the LICENSE file in the root directory of this source tree.
|
|
67
|
-
*/const
|
|
89
|
+
*/const xa=t=>t.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,a,s)=>s?s.toUpperCase():a.toLowerCase());/**
|
|
68
90
|
* @license lucide-react v0.574.0 - ISC
|
|
69
91
|
*
|
|
70
92
|
* This source code is licensed under the ISC license.
|
|
71
93
|
* See the LICENSE file in the root directory of this source tree.
|
|
72
|
-
*/const It=t=>{const r=
|
|
94
|
+
*/const It=t=>{const r=xa(t);return r.charAt(0).toUpperCase()+r.slice(1)};/**
|
|
73
95
|
* @license lucide-react v0.574.0 - ISC
|
|
74
96
|
*
|
|
75
97
|
* This source code is licensed under the ISC license.
|
|
76
98
|
* See the LICENSE file in the root directory of this source tree.
|
|
77
|
-
*/var
|
|
99
|
+
*/var ga={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
|
|
78
100
|
* @license lucide-react v0.574.0 - ISC
|
|
79
101
|
*
|
|
80
102
|
* This source code is licensed under the ISC license.
|
|
81
103
|
* See the LICENSE file in the root directory of this source tree.
|
|
82
|
-
*/const
|
|
104
|
+
*/const ha=t=>{for(const r in t)if(r.startsWith("aria-")||r==="role"||r==="title")return!0;return!1};/**
|
|
83
105
|
* @license lucide-react v0.574.0 - ISC
|
|
84
106
|
*
|
|
85
107
|
* This source code is licensed under the ISC license.
|
|
86
108
|
* See the LICENSE file in the root directory of this source tree.
|
|
87
|
-
*/const
|
|
109
|
+
*/const fa=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:a=2,absoluteStrokeWidth:s,className:n="",children:o,iconNode:c,...d},y)=>i.createElement("svg",{ref:y,...ga,width:r,height:r,stroke:t,strokeWidth:s?Number(a)*24/Number(r):a,className:Lr("lucide",n),...!o&&!ha(d)&&{"aria-hidden":"true"},...d},[...c.map(([p,f])=>i.createElement(p,f)),...Array.isArray(o)?o:[o]]));/**
|
|
88
110
|
* @license lucide-react v0.574.0 - ISC
|
|
89
111
|
*
|
|
90
112
|
* This source code is licensed under the ISC license.
|
|
91
113
|
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const Dr=(t,r)=>{const a=i.forwardRef(({className:s,...n},o)=>i.createElement(
|
|
114
|
+
*/const Dr=(t,r)=>{const a=i.forwardRef(({className:s,...n},o)=>i.createElement(fa,{ref:o,iconNode:r,className:Lr(`lucide-${ya(It(t))}`,`lucide-${t}`,s),...n}));return a.displayName=It(t),a};/**
|
|
93
115
|
* @license lucide-react v0.574.0 - ISC
|
|
94
116
|
*
|
|
95
117
|
* This source code is licensed under the ISC license.
|
|
96
118
|
* See the LICENSE file in the root directory of this source tree.
|
|
97
|
-
*/const
|
|
119
|
+
*/const ka=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Mr=Dr("chevron-left",ka);/**
|
|
98
120
|
* @license lucide-react v0.574.0 - ISC
|
|
99
121
|
*
|
|
100
122
|
* This source code is licensed under the ISC license.
|
|
101
123
|
* See the LICENSE file in the root directory of this source tree.
|
|
102
|
-
*/const va=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],zr=Dr("chevron-right",va);function wa(t,r){const a=!r||r.length===0||r.every(s=>!s||!s.trim());if(t.isRequired&&a)return t.errorMessage||"This field is required";if(!a){const s=r[0]??"";if(s&&t.regex)try{if(!new RegExp(t.regex).test(s))return t.errorMessage||"Invalid format"}catch{}if(s!==""){const n=Number(s);if(!isNaN(n)&&s.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&s.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&s.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function ja(t){const r=t.flatMap((s,n)=>(s.questions??[]).map((o,c)=>({question:o,groupIndex:n,qIdx:c}))),a=new Map;for(const s of r){const n=s.question.pageNumber!=null&&s.question.pageNumber>0?s.question.pageNumber:1;a.has(n)||a.set(n,[]),a.get(n).push(s)}return Array.from(a.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}const Or=({applicantId:t,onComplete:r,onBack:a})=>{const{questionnaire:s,initialAnswers:n,isLoading:o,isSubmitting:c,error:d,submit:y}=Nr(t),[p,f]=i.useState({}),[T,b]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(p).length===0&&f(n)},[n]);const v=i.useMemo(()=>s?ja(s.questionGroups):[],[s]),S=E===v.length-1,M=v[E]??[],Y=i.useCallback((R,h)=>{f(z=>({...z,[R]:h})),b(z=>{const q={...z};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:h}of M){const z=wa(h,p[h.id]??[]);z&&(R[h.id]=z)}return b(h=>({...h,...R})),Object.keys(R).length===0},[M,p]),B=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):a==null||a()},Z=async()=>{if(!(!L()||!s))try{const R=s.questionGroups.flatMap(z=>(z.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),h={applicantId:t,questionnarieId:s.id,questionResults:R};await y(h),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):d?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",d.message]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:s.displayName}),s.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s.subtitle}),v.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",v.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:v.map((R,h)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:h===E?"20px":"6px",backgroundColor:h<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},h))})]})]}),e.jsx(te,{className:"space-y-6",children:M.map(({question:R})=>e.jsx(Sa,{question:R,value:p[R.id]??[],error:T[R.id],onChange:h=>Y(R.id,h)},R.id))}),e.jsxs(fe,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Mr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:Z,children:"Continue"}):e.jsxs(J,{type:"button",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(zr,{size:14})]})]}),d&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:d.message})})]}):null},Sa=({question:t,value:r,error:a,onChange:s})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:d=>s([d.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:a,required:t.isRequired}),o==="single-select"&&e.jsx(ut,{value:r[0]??"",onChange:d=>s([d.target.value]),options:(t.defaultAnswers??[]).map(d=>({value:d,label:d})),placeholder:"Select an option…",error:a,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===d,onChange:()=>s([d]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:r.includes(d),onChange:y=>{s(y?[...r,d]:r.filter(p=>p!==d))}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),a&&o==="text"&&null]})};function Ca(t){const r=new Map;for(const a of t){const s=a.pageNumber!=null&&a.pageNumber>0?a.pageNumber:1;r.has(s)||r.set(s,[]),r.get(s).push(a)}return Array.from(r.entries()).sort(([a],[s])=>a-s).map(([,a])=>a)}const $r=({applicantId:t,onComplete:r,onBack:a})=>{const{uploadDocument:s,isLoading:n,isSubmitting:o,error:c,submit:d}=Rr(t),[y,p]=i.useState({}),[f,T]=i.useState(null),[b,E]=i.useState(0),[A,v]=i.useState({}),S=i.useMemo(()=>s?Ca(s.uploadDocumentFiles):[],[s]),M=S[b]??[],Y=b===S.length-1,L=S.length,B=i.useCallback(()=>{const h={};for(const z of M)z.isRequired&&(y[z.id]||[]).length===0&&(h[z.id]=`${z.displayName} is required`);return v(h),Object.keys(h).length===0},[M,y]),U=()=>{B()&&(E(h=>h+1),v({}))},Z=()=>{b>0?(E(h=>h-1),v({})):a==null||a()},R=async()=>{if(!(!B()||!s)){T(null);try{const h=await Promise.all(s.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],$=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await kr(G)})));return{uploadDocumentFileId:q.id,valueList:$}})),z={applicantId:t,uploadDocumentId:s.id,uploadDocumentResults:h};await d(z),r==null||r()}catch(h){T((h==null?void 0:h.message)||"Failed to submit documents. Please try again.")}}};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:s.displayName||"Upload Documents"}),s.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:s.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",b+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((h,z)=>e.jsx("div",{style:{height:"6px",width:z===b?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:z<=b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},z))})]})]}),s.description&&b===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:s.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:M.map(h=>e.jsx(Fr,{label:h.displayName,subtitle:h.subtitle,accept:h.allowedTypes,multiple:h.multipleFile,maxSize:h.maxEachFileSizeByte,required:h.isRequired,error:A[h.id],value:y[h.id]||[],onChange:z=>{T(null),v(q=>{const Q={...q};return delete Q[h.id],Q}),p(q=>({...q,[h.id]:z}))}},h.id))})}),f&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:Z,children:b>0?"Previous":"Back"}),Y?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Br=({applicantId:t,onComplete:r,onBack:a})=>{const{overview:s,isLoading:n,isSubmitting:o,error:c,passOverview:d}=Ir(t),y=async()=>{await d(),r==null||r()};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:s.title||"Overview"}),s.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s.description})]}),e.jsx(te,{className:"space-y-8",children:s.steps&&s.steps.length>0?s.steps.sort((p,f)=>p.order-f.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function Na(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function Ra(t){return t.valueDataType===Me.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function Ia(t,r){const a=new Intl.NumberFormat(Na(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,s=>{const n=parseFloat(s);return isNaN(n)?s:a.format(n)})}function Ea(t,r){const a=!r||r.length===0||r.every(s=>!s||!s.trim());if(t.isRequired&&a)return t.errorMessage||`${t.displayName} is required`;if(!a){const s=r[0]??"";if(s&&t.regex)try{if(!new RegExp(t.regex).test(s))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly;if(n&&s.trim()!==""){const o=Number(s);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!n&&s!==""){if(t.min!==void 0&&t.min!==null&&s.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&s.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Aa(t){const r=new Map;return t.forEach((a,s)=>{const n=a.pageNumber!=null&&a.pageNumber>0?a.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:a,idx:s})}),Array.from(r.entries()).sort(([a],[s])=>a-s).map(([,a])=>a)}function Ta(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const _r=({applicantId:t,onComplete:r,onBack:a})=>{const{config:s}=Ne(),n=s.locale??"en",{criteria:o,initialAnswers:c,isLoading:d,isSubmitting:y,error:p,submit:f}=Ar(t),[T,b]=i.useState({}),[E,A]=i.useState({}),[v,S]=i.useState(0),[M,Y]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(T).length===0&&b(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?Aa(o):[],[o]),B=v===L.length-1,U=L[v]??[];i.useEffect(()=>{!d&&o&&o.length===0&&!M&&!y&&(Y(!0),f({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[d,o,M,y,f,t,r]);const Z=i.useCallback((Q,$)=>{b(G=>({...G,[Q]:$})),A(G=>{const ae={...G};return delete ae[Q],ae})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:$}of U){const G=Ea($,T[$.id]??[]);G&&(Q[$.id]=G)}return A($=>({...$,...Q})),Object.keys(Q).length===0},[U,T]),h=()=>{R()&&S(Q=>Q+1)},z=()=>{v>0?S(Q=>Q-1):a==null||a()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const ae=(T[G.id]??[]).filter(V=>V&&V.trim());return ae.length>0?{riskCriteriaId:G.id,values:ae}:null}).filter(G=>G!==null);await f({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return d?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!d&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===v?"20px":"6px",backgroundColor:$<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Fa,{criterion:Q,value:T[Q.id]??[],error:E[Q.id],locale:n,onChange:$=>Z(Q.id,$)},Q.id))}),e.jsxs(fe,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:z,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Mr,{size:14}),v>0?"Previous":"Back"]}),B?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:h,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(zr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Fa=({criterion:t,value:r,error:a,locale:s,onChange:n})=>{const o=Ta(t),c=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly,d=Ra(t),y=p=>d?Ia(p,s):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>n([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:a,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===Me.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>n([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:r.includes(p),onChange:f=>{n(f?[...r,p]:r.filter(T=>T!==p))}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),o==="country"&&e.jsx(ut,{value:r[0]??"",onChange:p=>n([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:a,required:t.isRequired})]})},Hr=({applicantId:t,onComplete:r,onBack:a})=>{const{investorCategorizationService:s}=Ne(),[n,o]=i.useState(null),[c,d]=i.useState(!1),[y,p]=i.useState(null),f=async T=>{if(T.preventDefault(),n===null){p("Please select an investor type");return}d(!0),p(null);try{const b={applicantId:t,investorType:n};console.log("Submitting investor categorization:",b);const E=await s.setInvestorCategorization(b);console.log("Investor categorization result:",E),r==null||r()}catch(b){console.error("Error submitting investor categorization:",b),p(b.message||"Failed to submit investor categorization")}finally{d(!1)}};return e.jsx("form",{onSubmit:f,children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.Individual,checked:n===we.Individual,onChange:()=>o(we.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.Sophisticated,checked:n===we.Sophisticated,onChange:()=>o(we.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.HighNetWorth,checked:n===we.HighNetWorth,onChange:()=>o(we.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:n===null,children:"Submit"})]})]})})};function Et(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function xt(t){const r=Math.floor(t/60),a=t%60;return`${r.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}const Wr=({applicantId:t,onComplete:r,onBack:a})=>{const{appropriatenessTestService:s}=Ne(),[n,o]=i.useState(null),[c,d]=i.useState(!0),[y,p]=i.useState(!1),[f,T]=i.useState(null),[b,E]=i.useState({}),[A,v]=i.useState(0),[S,M]=i.useState(!1),[Y,L]=i.useState(!1),[B,U]=i.useState(0),[Z,R]=i.useState(0),[h,z]=i.useState(null);i.useEffect(()=>{(async()=>{try{d(!0),T(null);const O=await s.getAppropriatenessTest(t);if(o(O),O.waitTimeSpanForNextTry&&O.waitTimeSpanForNextTry!=="00:00:00"){const _=Et(O.waitTimeSpanForNextTry);_>0&&U(_)}}catch(O){T(O.message||"Failed to load appropriateness test")}finally{d(!1)}})()},[t,s]),i.useEffect(()=>{if(!S||A<=0)return;const O=setInterval(()=>{v(_=>_<=1?(L(!0),0):_-1)},1e3);return()=>clearInterval(O)},[S,A]),i.useEffect(()=>{if(B<=0)return;const O=setInterval(()=>{U(_=>_<=1?0:_-1)},1e3);return()=>clearInterval(O)},[B]),i.useEffect(()=>{Y&&!y&&G()},[Y]);const q=()=>{n&&(M(!0),v(n.testDurationSec),R(0),E({}),T(null))},Q=(O,_)=>{E(ue=>({...ue,[O]:_}))},$=i.useCallback(async()=>{try{const O=await s.getAppropriatenessTest(t);if(o(O),O.waitTimeSpanForNextTry&&O.waitTimeSpanForNextTry!=="00:00:00"){const _=Et(O.waitTimeSpanForNextTry);_>0&&U(_)}}catch{}},[t,s]),G=async O=>{if(n){if(!Y){const _=n.appropriatenessQuestions.length-Object.keys(b).length;if(_>0){T(`Please answer all questions. ${_} remaining.`);return}}p(!0),T(null);try{const _=n.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:b[N.id]||""})),ue={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:_};try{const N=await s.fillAppropriatenessTest(ue);N.isSuccess?z({success:!0,message:N.message||"Congratulations! You have passed the test."}):(z({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>$(),1e3))}catch(N){if(N.code===400&&N.message)z({success:!1,message:N.message}),setTimeout(()=>$(),1500);else throw N}}catch(_){T(_.message||"Failed to submit test. Please try again."),ae()}finally{p(!1)}}},ae=()=>{M(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!n)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),f&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:f})]})})});const V=n.testAllowedMaxTry-n.totalFailedTries,ke=n.appropriatenessQuestions.length,ce=Object.keys(b).length;if(B>0)return e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:xt(B)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),f&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})})]})})]});if(h){const O=()=>{z(null),ae(),T(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:h.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:h.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:h.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:h.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:h.message}),!h.success&&V>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:V})," attempt",V!==1?"s":""," remaining"]})}),!h.success&&V<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(fe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:h.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[V>0&&B<=0&&e.jsx(J,{type:"button",onClick:O,children:"Retake Test"}),V>0&&B>0&&e.jsx(J,{type:"button",onClick:O,children:"OK"}),V<=0&&a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle})]}),e.jsxs(te,{children:[n.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(ct,{icon:"questions",label:"Questions",value:String(n.totalQuestionCount)}),e.jsx(ct,{icon:"time",label:"Time Limit",value:xt(n.testDurationSec)}),e.jsx(ct,{icon:"target",label:"Pass Requirement",value:`${n.testCorrectAnswerPassLimit} correct`}),e.jsx(ct,{icon:"retry",label:"Attempts Left",value:String(V),variant:V<=1?"warning":"default"})]}),f&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",f]})]}),V<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:a?"space-between":"flex-end",width:"100%"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:V<=0,children:"Start Test"})]})})]});const de=n.appropriatenessQuestions[Z],ge=Z===ke-1,I=ce===ke,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",Z+1," of ",ke]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:xt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${ce/ke*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[ce," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[V," attempt",V!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(La,{question:de,index:Z,selectedAnswer:b[de.id],onSelect:O=>Q(de.id,O),disabled:y}),ke>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:n.appropriatenessQuestions.map((O,_)=>e.jsx("button",{type:"button",onClick:()=>R(_),style:{width:"28px",height:"28px",borderRadius:"8px",border:_===Z?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:b[O.id]?_===Z?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":_===Z?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:b[O.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:_+1},O.id))}),Y&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),f&&!Y&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{Z>0?R(O=>O-1):a==null||a()},disabled:y,children:Z>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!ge&&e.jsx(J,{type:"button",onClick:()=>R(O=>O+1),children:"Next"}),(ge||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!Y,style:{opacity:I||Y?1:.5},children:Y?"Submitting...":"Submit Test"})]})]})})]})},Pa={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},ct=({icon:t,label:r,value:a,variant:s="default"})=>{const n=s==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:n?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:n?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:n?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Pa[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:n?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:a})]})]})},La=({question:t,selectedAnswer:r,onSelect:a,disabled:s})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((n,o)=>{const c=r===n;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:s?"default":"pointer",transition:"all 0.15s ease",opacity:s?.6:1},onMouseEnter:d=>{!s&&!c&&(d.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:d=>{c||(d.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:n,checked:c,onChange:()=>a(n),disabled:s,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:n})]},o)})})]}),Ur=({applicantId:t,onComplete:r,onBack:a})=>{var Je,$e,tt,Ke;const{applicantService:s,baseInformationService:n,identityService:o,config:c,currentTheme:d}=Ne(),{identityData:y,provider:p,token:f,isLoading:T,error:b,requestIdentity:E,restartIdentity:A}=Er(t),[v,S]=i.useState(null),[M,Y]=i.useState(null),[L,B]=i.useState([]),[U,Z]=i.useState([]),[R,h]=i.useState(!0),[z,q]=i.useState(!1),[Q,$]=i.useState(null),[G,ae]=i.useState(!1),V=i.useRef(!1),[ke,ce]=i.useState({}),[de,ge]=i.useState({}),I=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,W=!!(d!=null&&d.reviewPageDisabled),O=i.useRef(!1);O.current=W;const _=Ve.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){V.current||(V.current=!0,E().then(()=>q(!0)).catch(D=>console.error("[Identity] Auto-request failed:",D)).finally(()=>h(!1)));return}(async()=>{try{const[D,K,H]=await Promise.all([s.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);Y(D);const X=new Set,u=K.map(g=>({value:g.abbreviation3||g.abbreviation,label:g.name})).filter(g=>!g.value||X.has(g.value)?!1:(X.add(g.value),!0));B(u);const C=new Set,F=H.filter(g=>g.countryCode).map(g=>({value:g.countryCode,label:`${g.countryCode} – ${g.name}`})).filter(g=>C.has(g.value)?!1:(C.add(g.value),!0));Z(F);const m=D.applicantRequestData;if(ce({firstName:(m==null?void 0:m.firstName)||"",lastName:(m==null?void 0:m.lastName)||"",email:(m==null?void 0:m.email)||"",dateOfBirth:(m==null?void 0:m.dateOfBirth)||"",title:(m==null?void 0:m.title)||"",salutation:(m==null?void 0:m.salutation)||"",phonenumber:(m==null?void 0:m.phonenumber)||"",mobileCountryCode:(m==null?void 0:m.mobileCountryCode)||"",street:(m==null?void 0:m.street)||"",streetNumber:(m==null?void 0:m.streetNumber)||"",city:(m==null?void 0:m.city)||"",zip:(m==null?void 0:m.zip)||"",country:(m==null?void 0:m.country)||"",nationality:(m==null?void 0:m.nationality)||"",taxCountry:(m==null?void 0:m.taxCountry)||"",countryOfBirth:(m==null?void 0:m.countryOfBirth)||"",placeOfBirth:(m==null?void 0:m.placeOfBirth)||"",educationLevel:(m==null?void 0:m.educationLevel)||"",occupation:(m==null?void 0:m.occupation)||"",taxNumber:(m==null?void 0:m.taxNumber)||"",defaultLanguage:(m==null?void 0:m.defaultLanguage)||""}),_.reset({street:(m==null?void 0:m.street)||"",streetNumber:(m==null?void 0:m.streetNumber)||"",city:(m==null?void 0:m.city)||"",zip:(m==null?void 0:m.zip)||"",country:(m==null?void 0:m.country)||"",nationality:(m==null?void 0:m.nationality)||"",phonenumber:(m==null?void 0:m.phonenumber)||""}),D.kycRecords&&D.kycRecords.length>0&&D.kycRecords[0].providerTokenObject!==null&&!V.current&&O.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),V.current=!0;try{await E(),q(!0)}catch(g){console.error("[Identity] Auto-request failed:",g)}}}catch(D){console.error("Error loading applicant data:",D)}finally{h(!1)}})()},[t]),i.useEffect(()=>{y&&!z&&O.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,z]),i.useEffect(()=>{if(f){if(f.expiresAt){const x=new Date(f.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),ae(!0),$("Your verification session has expired. Please restart.");return}}if(f.url)try{const D=new URL(f.url).toString().toLowerCase();if(D.includes("expired")||D.includes("invalid")||D.includes("error")){console.warn("[Identity] Token URL indicates expiration"),ae(!0),$("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(f.status==="expired"||f.error==="expired"||f.expired===!0){console.warn("[Identity] Token object indicates expiration"),ae(!0),$("Your verification session has expired. Please restart.");return}}},[f]);const ue=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&f&&!v&&z&&!G){const x=p;if(ue){console.log("[Sumsub] Fetching access token for Web SDK…"),$(null),(async()=>{try{const D=await o.refreshSumsubToken(t),K=He.parseProviderConfig(p,f,c);K.accessToken=D,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=He.createProvider(p,K);H.onComplete(X=>{console.log("[Sumsub] Verification complete:",X),r==null||r()}),H.onError(X=>{console.error("[Sumsub] SDK error:",X),(typeof X=="string"?X:(X==null?void 0:X.message)||"Unknown error").toLowerCase().includes("expired")&&(ae(!0),$("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(D){console.error("[Sumsub] Initialization error:",D),$(`Failed to initialize: ${D.message||D}`),String(D.message||D).toLowerCase().includes("expired")&&ae(!0)}})();return}if(f.url){console.log("[Identity] Loading provider URL for user verification:",f.url),$(null);try{if(new URL(f.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const D=He.parseProviderConfig(p,f,c);He.createProvider(p,D).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(D){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",D)}}S({type:"url",url:f.url})}catch(D){console.error("[Identity] Invalid URL:",D),$("Invalid verification URL. Please restart."),ae(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),$(null);try{const D=He.parseProviderConfig(p,f,c),K=He.createProvider(p,D);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var u;console.error("[SardinAI] Failed to initialize:",H);const X=((u=H.message)==null?void 0:u.toLowerCase())||"";X.includes("expired")||X.includes("invalid")||X.includes("401")||X.includes("400")?(ae(!0),$("Session expired or invalid. Please restart verification.")):$(`Failed to initialize: ${H.message}`)})}catch(D){console.error("[SardinAI] Error creating provider:",D),$(`Configuration error: ${D.message}`)}return}try{$(null);const D=He.parseProviderConfig(p,f,c),K=He.createProvider(p,D);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),$(`Failed to initialize: ${H.message}`)}),S(K)}catch(D){console.error("[Identity] Provider setup error:",D),$(`Setup error: ${D.message}`)}}return()=>{if(v&&v.destroy)try{v.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,f,v,z,r,G,ue,t,c,o]);const N=async()=>{try{$(null),ae(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{$(null),ae(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),$(x.message||"Failed to restart verification")}};if(R||T)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(b)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",b.message]})})});if(z&&(Q||G))return e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:T,children:T?"Restarting...":"Restart Verification"})]})]});if(z&&y){const x=p;return ue?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:T,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:T?"not-allowed":"pointer",opacity:T?.5:1},children:T?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),a&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]}):f!=null&&f.url?e.jsxs(ee,{children:[e.jsx(he,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:T,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:f.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:D=>{var K,H,X;console.log("[Identity] Iframe loaded");try{const u=D.target,C=u.contentDocument||((K=u.contentWindow)==null?void 0:K.document);if(C){const F=((X=(H=C.body)==null?void 0:H.textContent)==null?void 0:X.toLowerCase())||"";(F.includes("expired")||F.includes("invalid")||F.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),ae(!0),$("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),a&&e.jsx(fe,{children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),a&&e.jsx(fe,{children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]})}const me=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),se=(x=4)=>{const D=Math.min(4,Math.max(1,Number(x)||4));return{gridColumn:`span ${D} / span ${D}`}},be=(x,D)=>{if(!D&&D!==0)return"—";if(me.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===D);return K?K.label:String(D)}return String(D)},Pe=({helpText:x})=>{const[D,K]=i.useState(!1),H=i.useRef(null),[,X]=i.useState({top:0,left:0}),u=()=>{if(H.current){const C=H.current.getBoundingClientRect();X({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:u,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),D&&pt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ve=(x,D)=>D?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Pe,{helpText:D})})]}):x,Oe=(x,D)=>{const K=`cf-${D}`,H=x.paramName??"",X=de[H];if(x.customType==="br")return e.jsx("div",{style:{...se(x.colSpan),minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{style:se(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{style:se(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const u=X==="true"||X===!0;return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx(Fe,{checked:!!u,onChange:C=>ge(F=>({...F,[H]:String(C)})),style:{marginTop:2}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const u=Array.isArray(X)?X:X?[X]:[],C=F=>{x.singleSelect?ge(m=>({...m,[H]:u[0]===F?[]:[F]})):ge(m=>({...m,[H]:u.includes(F)?u.filter(l=>l!==F):[...u,F]}))};return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(F=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx(Fe,{checked:u.includes(F.value),onChange:()=>C(F.value),style:{marginTop:2}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:F.label})]},F.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(u=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:u.value,checked:X===u.value,onChange:()=>ge(C=>({...C,[H]:u.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.label})]},u.value))]}),x.helpText)},K):e.jsx("div",{style:se(x.colSpan),children:ve(e.jsx(ye,{label:x.displayText||x.label||H,value:String(X??""),onChange:u=>ge(C=>({...C,[H]:u.target.value}))}),x.helpText)},K)},et=(x,D)=>{if(x.isCustom)return Oe(x,D);const K=x.name??"",H=Ge[K],X=x.displayText||(H==null?void 0:H.label)||K,u=ke[K]??"",C=K==="mobileCountryCode",F=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ze,{label:X,value:String(u),onChange:m=>ce(l=>({...l,[K]:m})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${D}`):F?e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ze,{label:X,value:String(u),onChange:m=>ce(l=>({...l,[K]:m})),options:[{value:"",label:`Select ${X.toLowerCase()}…`},...L]}),x.helpText)},`ec-${D}`):e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ye,{label:X,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(u),onChange:m=>ce(l=>({...l,[K]:m.target.value}))}),x.helpText)},`ei-${D}`):e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:X}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:be(K,u)})]}),x.helpText)},`ro-${D}`)};if(I){const x=I.title||"Review Your Information",D=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:D})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:I.fields.map((K,H)=>et(K,H))})}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:_.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Je=M==null?void 0:M.applicantRequestData)==null?void 0:Je.firstName)||""} ${(($e=M==null?void 0:M.applicantRequestData)==null?void 0:$e.lastName)||""}`.trim()},{label:"Email",value:(tt=M==null?void 0:M.applicantRequestData)==null?void 0:tt.email},{label:"Date of Birth",value:((Ke=M==null?void 0:M.applicantRequestData)==null?void 0:Ke.dateOfBirth)||"Not provided"}].map(({label:x,value:D})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:D})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ve.Controller,{control:_.control,name:"country",render:({field:x})=>e.jsx(ze,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(Ve.Controller,{control:_.control,name:"nationality",render:({field:x})=>e.jsx(ze,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ve.Controller,{control:_.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(Ve.Controller,{control:_.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ve.Controller,{control:_.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(Ve.Controller,{control:_.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(Ve.Controller,{control:_.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:T,children:"Confirm and Start Verification"})]})]})})},ft=({kycStatus:t,reviewStatus:r,workflowResult:a,customMessage:s,onContinue:n,onContactSupport:o})=>{const d=t===Ye.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Ye.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Ye.Pending||t===Ye.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Qe.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Qe.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Qe.UnderReview||r===Qe.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:a===ot.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:a===ot.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:a===ot.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${d.iconBg}`,children:e.jsx("span",{className:`text-5xl ${d.iconColor}`,children:d.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(wt,{variant:d.type==="success"?"success":d.type==="error"?"danger":d.type==="pending"?"warning":"info",children:t!=null?Ye[t]:Qe[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s||d.message}),d.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),d.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),d.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Ye[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Qe[r]})]})]})})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"center",gap:"1rem"},children:[d.type==="success"&&n&&e.jsx(J,{onClick:n,size:"lg",children:"Continue"}),d.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),n&&e.jsx(J,{onClick:n,children:"Try Again"})]}),d.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Kr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:a=>{console.warn("[Logo] Failed to load logo:",t.url),a.target.style.display="none"}})}),nt=({title:t,subtitle:r,className:a=""})=>{const{currentTheme:s}=Ne(),n=t||(s==null?void 0:s.title)||"",o=!!(s!=null&&s.logo&&s.logo.visible&&s.logo.url),c=!!n;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${a}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx(Kr,{config:s.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},dt=["firstName","lastName","email","phonenumber","dateOfBirth"];function rt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Da={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},At=({helpText:t,children:r})=>{const[a,s]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=a?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>s(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>s(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>s(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?pt.createPortal(n,document.body):null]})},Ma=({workflowKey:t,externalRefId:r,onSuccess:a,onCancel:s})=>{var K,H,X,u,C,F,m;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:d,isLoading:y}=vt(),p=t||((K=n.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const f=r||((H=n.applicantForm)==null?void 0:H.externalRefId)||"",T=((X=n.applicantForm)==null?void 0:X.email)||"",b=((u=n.applicantForm)==null?void 0:u.hiddenValues)||{},E=((C=n.applicantForm)==null?void 0:C.initialValues)||{},v=(((F=n.applicantForm)==null?void 0:F.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),M=i.useMemo(()=>{const l=new Set(dt),g=c==null?void 0:c.applicantFormRequiredFields;if(g)for(const P of g)l.add(P);if(S)for(const P of S)for(const k of P.fields)!k.isCustom&&k.name&&k.required&&l.add(k.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),Y=i.useMemo(()=>{var P;if(S){const k=S.flatMap(w=>w.fields).filter(w=>!w.isCustom&&w.name).map(w=>w.name),j=new Set(k);for(const w of dt)j.add(w);return Array.from(j)}let l;(P=n.applicantForm)!=null&&P.visibleFields?l=n.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=Ut;const g=new Set(l);for(const k of dt)g.add(k);return Array.from(g)},[(m=n.applicantForm)==null?void 0:m.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),B=i.useMemo(()=>{var g,P;const l=new Set;if(S)for(const k of S)for(const j of k.fields)!j.isCustom&&j.name&&L.has(j.name)&&l.add(j.countriesType??((g=Ge[j.name])==null?void 0:g.countriesType));else for(const k of Y)L.has(k)&&l.add((P=Ge[k])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[Y,S]),[U,Z]=i.useState({}),[R,h]=i.useState(!0),z=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=B.filter(k=>{const j=k!=null?String(k):"all";return!q.current.has(j)&&!z.current.has(j)});if(l.length===0){B.every(j=>{const w=j!=null?String(j):"all";return q.current.has(w)})&&h(!1);return}h(!0);const g=l.map(k=>k!=null?String(k):"all");g.forEach(k=>z.current.add(k)),(async()=>{try{const k=await Promise.all(l.map(async j=>{const w=j!=null?String(j):"all",le=await o.getCountries("",n.locale||"en",j),ne=j===40,xe=new Set,Ie=le.map(ie=>ne&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(w),z.current.delete(w),[w,Ie]}));Z(j=>({...j,...Object.fromEntries(k)}))}catch(k){g.forEach(j=>z.current.delete(j)),console.error("Failed to load countries:",k)}finally{B.every(j=>{const w=j!=null?String(j):"all";return q.current.has(w)})&&h(!1)}})()},[B,c]);const Q=(l,g)=>{var j;const P=g??((j=Ge[l])==null?void 0:j.countriesType),k=P!=null?String(P):"all";return U[k]||[]},$={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(b).filter(([l])=>l in $)),ae=Object.fromEntries(Object.entries(E).filter(([l])=>l in $)),[V,ke]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:T,dateOfBirth:"",phonenumber:"",externalRefId:f,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...ae}),ce=Object.fromEntries(Object.entries(b).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,ge]=i.useState({...ce}),[I,W]=i.useState(0),[O,_]=i.useState({}),[ue,N]=i.useState(null),[re,me]=i.useState(!1),se=(l,g)=>ke(P=>({...P,[l]:g})),be=(l,g)=>ge(P=>({...P,[l]:g})),Pe=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ve=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,et=l=>{var P;const g={};for(const k of l.fields)if(k.isCustom){if(k.customType==="paragraph"||k.customType==="html"||k.customType==="br"||k.customType==="link")continue;if(k.required&&k.paramName){const j=de[k.paramName],w=k.displayText||k.label||k.paramName;k.customType==="checkbox"||k.customType==="link_checkbox"?j!=="true"&&(g[k.paramName]=`${w} is required.`):(!j||j.trim()==="")&&(g[k.paramName]=`${w} is required.`)}}else if(k.name){const j=k.name;if(M.includes(j)&&rt(V[j])){const w=k.displayText||((P=Ge[j])==null?void 0:P.label)||j;g[j]=`${w} is required.`}}return g},Je=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Pe(l)){_({}),ve>=0?W(ve):await $e();return}const g=et(l);if(Object.keys(g).length>0){_(g);return}_({}),ve>=0?W(ve):await $e()},$e=async()=>{if(S){let l={};for(const g of S)Pe(g)&&(l={...l,...et(g)});if(Object.keys(l).length>0){_(l);return}}me(!0),N(null);try{if(!V.externalRefId||V.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:V.workflowKey,externalRefId:V.externalRefId.trim()};if(S){for(const j of S)if(Pe(j)){for(const w of j.fields)if(!w.isCustom&&w.name){const le=w.name,ne=V[le];rt(ne)||(l[le]=ne)}}for(const j of dt)if(l[j]===void 0){const w=V[j];rt(w)||(l[j]=w)}}else Y.forEach(j=>{if(j==="externalRefId")return;const w=V[j];rt(w)||(l[j]=w)});const g=[];if(S){for(const j of S)if(Pe(j))for(const w of j.fields){if(!w.isCustom||!w.paramName||w.customType==="paragraph"||w.customType==="html"||w.customType==="br"||w.customType==="link")continue;const le=de[w.paramName]??"";let ne;if(w.customType==="checkbox"||w.customType==="link_checkbox")ne=le==="true"?"yes":"no";else if(ne=le,!ne&&!w.required)continue;g.push({paramName:w.paramName,value:ne})}}for(const[j,w]of Object.entries(G))l[j]===void 0&&!rt(w)&&(l[j]=w);const P=new Set(g.map(j=>j.paramName));for(const[j,w]of Object.entries(ce))!P.has(j)&&w&&g.push({paramName:j,value:w});g.length>0&&(l.applicantAdditionalDatas=g);const k=await d(l);a(k.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{me(!1)}},tt=async l=>{var g;l.preventDefault();for(const P of M)if(rt(V[P])){const k=((g=Ge[P])==null?void 0:g.label)||P;N(`${k} is required.`);return}await $e()},Ke=(l,g,P,k,j)=>{var jt;const w=Ge[l];if(!w)return null;const le=M.includes(l),ne=O[l],xe=P||w.label,Ie=l in ae,ie=g??l,Le={required:le},Be=j?j!=="placeholder":v,qe=Be?xe:void 0,qr=Be?"...":xe;switch(w.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,k);return e.jsx(ze,{...Le,label:qe,value:V[l]||"",onChange:Xe=>se(l,Xe),options:[{value:"",label:`Select ${qr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:ne},ie)}if(l==="salutation")return e.jsx(ze,{...Le,label:qe,value:((jt=V[l])==null?void 0:jt.toString())||"",onChange:Ce=>se(l,Ce?Number(Ce):null),options:[{value:"",label:Be?"Select salutation...":xe},{value:lt.Male.toString(),label:"Male"},{value:lt.Female.toString(),label:"Female"},{value:lt.Other.toString(),label:"Other"}],readOnly:Ie,error:ne},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?ht.filter(Xe=>c.allowedLanguages.includes(Xe.value)):ht;return e.jsx(ze,{...Le,label:qe,value:V[l]||"",onChange:Xe=>se(l,Xe),options:[{value:"",label:Be?"Select language...":xe},...Ce],readOnly:Ie,error:ne},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,k);return e.jsx(Tr,{...Le,label:qe,value:V[l]||[],onChange:Xe=>se(l,Xe),options:Ce,placeholder:Be?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Le,type:"date",label:qe,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);case"email":return e.jsx(ye,{...Le,type:"email",label:qe,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);case"tel":return e.jsx(ye,{...Le,type:"tel",label:qe,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);default:return e.jsx(ye,{...Le,type:"text",label:qe,placeholder:Be?void 0:xe,value:V[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie)}},x=(l,g)=>{const P=l.labelMode?l.labelMode!=="placeholder":v;if(l.customType==="paragraph"){const w=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:w}},`custom-${g}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${g}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${g}`);if(l.customType==="link"){const w=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[w,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${g}`)}if(!l.paramName)return null;const k=O[l.paramName],j=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:de[l.paramName]==="true",onChange:w=>be(l.paramName,w?"true":"false")}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),k&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:k})]},`custom-${g}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:de[l.paramName]==="true",onChange:w=>be(l.paramName,w?"true":"false")}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:w=>w.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),k&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:k})]},`custom-${g}`);if(l.customType==="group_checkbox"){const w=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(le=>{const ne=l.singleSelect?de[l.paramName]===le.value:w.includes(le.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:ne,onChange:xe=>{if(l.singleSelect)be(l.paramName,xe?le.value:"");else{const Ie=xe?[...w,le.value]:w.filter(ie=>ie!==le.value);be(l.paramName,Ie.join(","))}}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:le.label})]},le.value)})}),k&&e.jsx("p",{className:"text-red-500 text-xs",children:k})]},`custom-${g}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(w=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===w.value,onChange:()=>be(l.paramName,w.value),name:`radio-group-${l.paramName}-${g}`,className:"metakyc-option-input",style:Da}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:w.label})]},w.value))}),k&&e.jsx("p",{className:"text-red-500 text-xs",children:k})]},`custom-${g}`):e.jsx(ye,{type:"text",label:P?`${j}${l.required?" *":""}`:void 0,placeholder:P?void 0:j,value:de[l.paramName]||"",onChange:w=>be(l.paramName,w.target.value),required:l.required,error:k},`custom-${g}`)},D=(l,g)=>{const P=Pe(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(At,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Fe,{checked:P,onChange:k=>be(l.conditionalOn,k?"true":"false")}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:l.fields.map((k,j)=>{const w=Math.min(4,Math.max(1,Number(k.colSpan)||4)),le=k.isCustom?`custom-${j}-${k.paramName}`:`builtin-${k.name}-${j}`;return e.jsx("div",{style:{gridColumn:`span ${w} / span ${w}`},children:e.jsx(At,{helpText:k.helpText,children:k.isCustom?x(k,j):Ke(k.name,le,k.displayText,k.countriesType,k.labelMode)})},le)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],g=Oe===-1,P=ve===-1,k=S.length,j=Pe(l),w=Object.values(O);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(ue||w.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[ue&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",ue]}),w.map((le,ne)=>e.jsx("p",{className:"text-red-600 text-sm",children:le},ne))]}),k>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[S.map((le,ne)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...ne===I?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:ne<I?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},ne)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[I+1," / ",k]})]}),D(l)]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!g&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),_({})},disabled:re||y,children:"Previous"}),g&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?$e:Je,children:P?l.conditionalOn&&!j?"Skip & Submit":"Submit":l.conditionalOn&&!j?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:tt,children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[ue&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",ue]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:Y.map(l=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ke(l)},l))})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},Tt=["companyName","email"];function gt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const za=({workflowKey:t,externalRefId:r,onSuccess:a,onCancel:s})=>{var Ke,x,D,K,H,X;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:d,isLoading:y}=vt(),p=t||((Ke=n.applicantForm)==null?void 0:Ke.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const f=r||((x=n.applicantForm)==null?void 0:x.externalRefId)||"",T=((D=n.applicantForm)==null?void 0:D.email)||"",b=((K=n.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=n.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",v=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const u=new Set(Tt),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const F of C)u.add(F);if(v)for(const F of v)for(const m of F.fields)!m.isCustom&&m.name&&m.required&&u.add(m.name);return Array.from(u)},[c==null?void 0:c.companyFormRequiredFields,v]),M=i.useMemo(()=>{var u;if(v){const C=v.flatMap(m=>m.fields).filter(m=>!m.isCustom&&m.name).map(m=>m.name),F=new Set(C);for(const m of Tt)F.add(m);return Array.from(F)}return(u=n.applicantForm)!=null&&u.visibleFields?n.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:Wt},[(X=n.applicantForm)==null?void 0:X.visibleFields,c==null?void 0:c.companyFormVisibleFields,v]),Y=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,F;const u=new Set;if(v)for(const m of v)for(const l of m.fields)!l.isCustom&&l.name&&Y.has(l.name)&&u.add(l.countriesType??((C=Ze[l.name])==null?void 0:C.countriesType));else for(const m of M)Y.has(m)&&u.add((F=Ze[m])==null?void 0:F.countriesType);return u.size===0&&u.add(void 0),Array.from(u)},[M,v]),[B,U]=i.useState({}),[Z,R]=i.useState(!0),h=i.useRef(new Set),z=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const u=L.filter(m=>{const l=m!=null?String(m):"all";return!z.current.has(l)&&!h.current.has(l)});if(u.length===0){L.every(l=>z.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=u.map(m=>m!=null?String(m):"all");C.forEach(m=>h.current.add(m)),(async()=>{try{const m=await Promise.all(u.map(async l=>{const g=l!=null?String(l):"all",P=await o.getCountries("",n.locale||"en",l),k=new Set,j=P.map(w=>({value:w.abbreviation3||w.abbreviation,label:w.name})).filter(w=>!w.value||k.has(w.value)?!1:(k.add(w.value),!0));return z.current.add(g),h.current.delete(g),[g,j]}));U(l=>({...l,...Object.fromEntries(m)}))}catch(m){C.forEach(l=>h.current.delete(l)),console.error("Failed to load countries:",m)}finally{L.every(l=>z.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(u,C)=>{var l;const F=C??((l=Ze[u])==null?void 0:l.countriesType),m=F!=null?String(F):"all";return B[m]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},$=Object.fromEntries(Object.entries(b).filter(([u])=>u in Q)),[G,ae]=i.useState({workflowKey:p,companyName:"",email:T,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:f,...$}),[V,ke]=i.useState({}),[ce,de]=i.useState(0),[ge,I]=i.useState({}),[W,O]=i.useState(null),[_,ue]=i.useState(!1),N=(u,C)=>ae(F=>({...F,[u]:C})),re=(u,C)=>ke(F=>({...F,[u]:C})),me=u=>!u.conditionalOn||V[u.conditionalOn]==="true",se=v&&ce<v.length-1?ce+1:-1,be=v&&ce>0?ce-1:-1,Pe=u=>{var F;const C={};for(const m of u.fields)if(m.isCustom){if(m.customType==="paragraph"||m.customType==="html"||m.customType==="br"||m.customType==="link")continue;if(m.required&&m.paramName){const l=V[m.paramName],g=m.displayText||m.label||m.paramName;m.customType==="checkbox"||m.customType==="link_checkbox"?l!=="true"&&(C[m.paramName]=`${g} is required.`):(!l||l.trim()==="")&&(C[m.paramName]=`${g} is required.`)}}else if(m.name){const l=m.name;if(S.includes(l)&>(G[l])){const g=m.displayText||((F=Ze[l])==null?void 0:F.label)||l;C[l]=`${g} is required.`}}return C},ve=async()=>{if(!v)return;const u=v[ce];if(u.conditionalOn&&!me(u)){I({}),se>=0?de(se):await Oe();return}const C=Pe(u);if(Object.keys(C).length>0){I(C);return}I({}),se>=0?de(se):await Oe()},Oe=async()=>{var u;if(v){let C={};for(const F of v)me(F)&&(C={...C,...Pe(F)});if(Object.keys(C).length>0){I(C);return}}ue(!0),O(null);try{const C={workflowKey:G.workflowKey,externalRefId:((u=G.externalRefId)==null?void 0:u.trim())||void 0},F=v?v.filter(g=>me(g)).flatMap(g=>g.fields).filter(g=>!g.isCustom&&g.name).map(g=>g.name):M;for(const g of F){const P=G[g];if(!gt(P))switch(g){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[g]=P;break}}const m=[];if(v){for(const g of v)if(me(g))for(const P of g.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const k=V[P.paramName]??"";let j;if(P.customType==="checkbox"||P.customType==="link_checkbox")j=k==="true"?"yes":"no";else if(j=k,!j&&!P.required)continue;m.push({paramName:P.paramName,value:j})}}m.length>0&&(C.applicantAdditionalDatas=m);const l=await d(C);a(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),O(C.message||"Failed to create company applicant")}finally{ue(!1)}},et=async u=>{var C;u.preventDefault();for(const F of S)if(gt(G[F])){const m=((C=Ze[F])==null?void 0:C.label)||F;O(`${m} is required.`);return}await Oe()},Je=(u,C,F,m,l)=>{const g=Ze[u];if(!g)return null;const P=S.includes(u),k=ge[u],j=F||g.label,w=u in $,le=C??u,ne=l?l!=="placeholder":A,xe=ne?j:void 0,Ie=ne?"...":j;switch(g.type){case"select":if(u==="countryResidence"||u==="addressCountry"){const ie=q(u,m);return e.jsx(ze,{required:P,label:xe,value:G[u]||"",onChange:Le=>N(u,Le),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:Z,readOnly:w,error:k},le)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le)}},$e=(u,C)=>{if(u.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:u.displayText||u.label||""}},`custom-${C}`);if(u.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:u.label||""}},`custom-${C}`);if(u.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(u.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:u.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:u.displayText||u.label||u.linkText||u.linkUrl||""})},`custom-${C}`);if(!u.paramName)return null;const F=ge[u.paramName],m=u.displayText||u.label||u.paramName,l=u.labelMode?u.labelMode!=="placeholder":A;return u.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx(Fe,{checked:V[u.paramName]==="true",onChange:g=>re(u.paramName,g?"true":"false")}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[m,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),F&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:F})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${m}${u.required?" *":""}`:void 0,placeholder:l?void 0:m,value:V[u.paramName]||"",onChange:g=>re(u.paramName,g.target.value),required:u.required,error:F},`custom-${C}`)},tt=u=>{const C=me(u);return e.jsxs("div",{className:"space-y-4",children:[u.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx(Fe,{checked:C,onChange:F=>re(u.conditionalOn,F?"true":"false")}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:u.conditionalOn})]}),C&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:u.fields.map((F,m)=>{const l=Math.min(4,Math.max(1,Number(F.colSpan)||4)),g=F.isCustom?`custom-${m}-${F.paramName}`:`builtin-${F.name}-${m}`;return e.jsx("div",{style:{gridColumn:`span ${l} / span ${l}`},children:F.isCustom?$e(F,m):Je(F.name,g,F.displayText,F.countriesType,F.labelMode)},g)})})]})};if(!c||Z)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(v){const u=v[ce]??v[0],C=be===-1,F=se===-1,m=v.length,l=me(u),g=Object.values(ge);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(u.title||u.subtitle)&&e.jsxs("div",{className:"mb-4",children:[u.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),u.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.subtitle})]}),(W||g.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),g.map((P,k)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},k))]}),m>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[v.map((P,k)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...k===ce?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:k<ce?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},k)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[ce+1," / ",m]})]}),tt(u)]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(be),I({})},disabled:_||y,children:"Previous"}),C&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:_||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:_||y,onClick:F?Oe:ve,children:F?u.conditionalOn&&!l?"Skip & Submit":"Submit":u.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:et,children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:M.map(u=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Je(u)},u))})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:_||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:_||y,children:"Register Company"})]})]})})})},Oa=({applicantId:t,onComplete:r,onError:a,theme:s="light",className:n})=>{const{progress:o,currentStep:c,steps:d,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:f,isLoading:T,error:b,moveBack:E,refreshProgress:A}=Cr(t),[v,S]=i.useState(!1),M=i.useRef(null);if(i.useEffect(()=>{b&&a&&a(b)},[b,a]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{s==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[s]),i.useEffect(()=>{f&&S(!1)},[f]),T||!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(b)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:b.message})]})})})});if(f&&!v)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Te.Finished||o.status===Te.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Te.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const Y=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=d.filter(q=>q.visibility!==!1),Z=U.findIndex(q=>q.order===c.order),R=Z>=0?Z+1:1,h=U.length,z=h>1?Z/(h-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px",backgroundColor:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",borderRadius:"0.75rem",border:"1px solid var(--metakyc-border, #e5e7eb)",padding:"1rem 1.5rem",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(nt,{}),e.jsxs(wt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",h]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${z}%`,transition:"width 0.4s ease"}})})}),e.jsx($a,{ref:M,visibleSteps:U,currentVisibleStepIndex:Z,getStepFallbackName:Y})]})},B=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Or,{...U});case oe.UploadDocument:return e.jsx($r,{...U});case oe.Overview:return e.jsx(Br,{...U});case oe.IdentitySdk:return e.jsx(Ur,{...U});case oe.RiskScoring:return e.jsx(_r,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx(Hr,{...U});case oe.AppropriatenessTest:return e.jsx(Wr,{...U});case oe.ManualReview:return e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[L(),B()]})},$a=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:a},s)=>{const n=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(s,()=>n.current),i.useEffect(()=>{if(o.current&&n.current){const c=n.current,d=o.current,y=d.offsetLeft-c.offsetWidth/2+d.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:n,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",width:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,d)=>{const y=d<r,p=d===r,f=y||p,T=c.displayName||c.name||a(c.action)||`Step ${d+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...f?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):d+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:T})]}),d<t.length-1&&e.jsx("div",{style:{flex:"1 1 0%",minWidth:"16px",height:"2px",margin:"0 8px",borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Ba(t){return Ue.z.object({questionResults:Ue.z.any()}).passthrough()}function _a(t){let r=Ue.z.array(Ue.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(a=>!a||a.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(a=>!a||a.every(s=>s.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const a=t.allowedTypes.split(",").map(s=>s.trim());r=r.refine(s=>s?s.every(n=>a.some(o=>o.endsWith("/*")?n.type.startsWith(o.slice(0,-2)):n.type===o)):!0,{message:"Invalid file type"})}return r}function Ha(t){const r={};return t.uploadDocumentFiles.forEach(a=>{const s=`file_${a.id}`;r[s]=_a(a)}),Ue.z.object(r)}function Wa(t){return Ue.z.any()}function Ua(t){return Ue.z.string().min(1,"This question is required")}function Ka(t){const r={};return t.appropriatenessQuestions.forEach(a=>{const s=`question_${a.id}`;r[s]=Ua()}),Ue.z.object(r)}const qa=Ue.z.any();exports.ALLOWED_LANGUAGES=ht;exports.ApplicantProgressOnHoldReason=Ft;exports.ApplicantProgressStatus=Te;exports.ApplicantService=Yt;exports.ApplicantStatus=Lt;exports.AppropriatenessQuestionType=$t;exports.AppropriatenessTestService=Jt;exports.AppropriatenessTestStep=Wr;exports.Badge=wt;exports.BaseInformationService=tr;exports.Button=J;exports.COMPANY_FIELD_METADATA=Ze;exports.Card=ee;exports.CardContent=te;exports.CardFooter=fe;exports.CardHeader=he;exports.Checkbox=Fe;exports.CountriesType=We;exports.CreateApplicantForm=Ma;exports.CreateCompanyApplicantForm=za;exports.CriteriaBuiltInType=_t;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=Wt;exports.DEFAULT_VISIBLE_FIELDS=Ut;exports.DocumentReviewStatus=Ot;exports.EndpointBuilder=qt;exports.ErrorHandler=at;exports.EventEmitter=dr;exports.FIELD_METADATA=Ge;exports.FileType=zt;exports.FileUpload=Fr;exports.GenderType=lt;exports.Header=nt;exports.HttpClient=Vt;exports.IdentityProviderManager=He;exports.IdentityService=er;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=Ur;exports.Input=ye;exports.InvestorCategorizationService=rr;exports.InvestorCategorizationStep=Hr;exports.InvestorCategorizationType=we;exports.InvestorCategoryType=Ht;exports.KycProcessStatus=Dt;exports.KycStatus=Ye;exports.KycStatusDisplay=ft;exports.KycWorkflow=Oa;exports.Logo=Kr;exports.MetaKYCContext=bt;exports.MetaKYCError=De;exports.MetaKYCProvider=sa;exports.MultiSelect=Tr;exports.OnfidoProvider=xr;exports.OverviewService=Xt;exports.OverviewStep=Br;exports.PhoneInput=Pr;exports.QuestionnaireService=Qt;exports.QuestionnaireStep=Or;exports.ReviewStatus=Qe;exports.RiskCriteriaType=Bt;exports.RiskLevel=Pt;exports.RiskScoringService=Zt;exports.RiskScoringStep=_r;exports.SDK_VERSION=fr;exports.SardinAIProvider=gr;exports.SearchableSelect=ze;exports.Select=ut;exports.Spinner=Ee;exports.StepRouter=pr;exports.SumsubProvider=yr;exports.ThemeManager=hr;exports.ThemePreset=je;exports.ThemeService=cr;exports.UploadDocumentService=Gt;exports.UploadDocumentStep=$r;exports.UserType=Mt;exports.ValueDataType=Me;exports.WorkflowOrchestrator=ur;exports.WorkflowResultType=ot;exports.WorkflowState=mr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=qa;exports.clearAllStorage=ca;exports.clearApplicantId=wr;exports.clearWorkflowState=Sr;exports.cn=Se;exports.corporateTheme=ar;exports.defaultConfig=Kt;exports.defaultTheme=Re;exports.fileToBase64=kr;exports.fintechTheme=sr;exports.formatFileSize=mt;exports.generateAppropriatenessSchema=Ka;exports.generateQuestionnaireSchema=Ba;exports.generateRiskScoringSchema=Wa;exports.generateUploadDocumentSchema=Ha;exports.getAcceptString=oa;exports.getApplicantId=vr;exports.getThemePreset=st;exports.getWorkflowState=la;exports.healthcareTheme=nr;exports.isScriptLoaded=Jr;exports.loadScript=kt;exports.minimalTheme=or;exports.modernTheme=ir;exports.removeScript=Xr;exports.saveApplicantId=br;exports.saveWorkflowState=jr;exports.themePresets=lr;exports.useApplicant=vt;exports.useAppropriatenessTest=da;exports.useIdentityVerification=Er;exports.useKycWorkflow=Cr;exports.useMetaKYC=Ne;exports.useOverview=Ir;exports.useQuestionnaire=Nr;exports.useRiskScoring=Ar;exports.useUploadDocument=Rr;exports.validateFileSize=na;exports.validateFileType=ia;
|
|
124
|
+
*/const ba=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],zr=Dr("chevron-right",ba);function va(t,r){const a=!r||r.length===0||r.every(s=>!s||!s.trim());if(t.isRequired&&a)return t.errorMessage||"This field is required";if(!a){const s=r[0]??"";if(s&&t.regex)try{if(!new RegExp(t.regex).test(s))return t.errorMessage||"Invalid format"}catch{}if(s!==""){const n=Number(s);if(!isNaN(n)&&s.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&s.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&s.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function wa(t){const r=t.flatMap((s,n)=>(s.questions??[]).map((o,c)=>({question:o,groupIndex:n,qIdx:c}))),a=new Map;for(const s of r){const n=s.question.pageNumber!=null&&s.question.pageNumber>0?s.question.pageNumber:1;a.has(n)||a.set(n,[]),a.get(n).push(s)}return Array.from(a.entries()).sort(([s],[n])=>s-n).map(([,s])=>s)}const Or=({applicantId:t,onComplete:r,onBack:a})=>{const{questionnaire:s,initialAnswers:n,isLoading:o,isSubmitting:c,error:d,submit:y}=Nr(t),[p,f]=i.useState({}),[F,b]=i.useState({}),[E,A]=i.useState(0);i.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(p).length===0&&f(n)},[n]);const v=i.useMemo(()=>s?wa(s.questionGroups):[],[s]),S=E===v.length-1,M=v[E]??[],V=i.useCallback((R,h)=>{f(z=>({...z,[R]:h})),b(z=>{const q={...z};return delete q[R],q})},[]),L=i.useCallback(()=>{const R={};for(const{question:h}of M){const z=va(h,p[h.id]??[]);z&&(R[h.id]=z)}return b(h=>({...h,...R})),Object.keys(R).length===0},[M,p]),B=()=>{L()&&A(R=>R+1)},U=()=>{E>0?A(R=>R-1):a==null||a()},Z=async()=>{if(!(!L()||!s))try{const R=s.questionGroups.flatMap(z=>(z.questions??[]).map(q=>({questionId:q.id,values:p[q.id]??[]}))),h={applicantId:t,questionnarieId:s.id,questionResults:R};await y(h),r==null||r()}catch(R){console.error("Questionnaire submit error:",R)}};return o?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):d?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",d.message]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:s.displayName}),s.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s.subtitle}),v.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",E+1," of ",v.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:v.map((R,h)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:h===E?"20px":"6px",backgroundColor:h<=E?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},h))})]})]}),e.jsx(te,{className:"space-y-6",children:M.map(({question:R})=>e.jsx(ja,{question:R,value:p[R.id]??[],error:F[R.id],onChange:h=>V(R.id,h)},R.id))}),e.jsxs(fe,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:U,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Mr,{size:14}),E>0?"Previous":"Back"]}),S?e.jsx(J,{type:"button",isLoading:c,onClick:Z,children:"Continue"}):e.jsxs(J,{type:"button",onClick:B,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(zr,{size:14})]})]}),d&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:d.message})})]}):null},ja=({question:t,value:r,error:a,onChange:s})=>{var c;const o=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:d=>s([d.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:a,required:t.isRequired}),o==="single-select"&&e.jsx(ut,{value:r[0]??"",onChange:d=>s([d.target.value]),options:(t.defaultAnswers??[]).map(d=>({value:d,label:d})),placeholder:"Select an option…",error:a,required:t.isRequired}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===d,onChange:()=>s([d]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),(o==="checkbox"||o==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(d=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:r.includes(d),onChange:y=>{s(y?[...r,d]:r.filter(p=>p!==d))}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:d})]},d)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),a&&o==="text"&&null]})};function Sa(t){const r=new Map;for(const a of t){const s=a.pageNumber!=null&&a.pageNumber>0?a.pageNumber:1;r.has(s)||r.set(s,[]),r.get(s).push(a)}return Array.from(r.entries()).sort(([a],[s])=>a-s).map(([,a])=>a)}const $r=({applicantId:t,onComplete:r,onBack:a})=>{const{uploadDocument:s,isLoading:n,isSubmitting:o,error:c,submit:d}=Rr(t),[y,p]=i.useState({}),[f,F]=i.useState(null),[b,E]=i.useState(0),[A,v]=i.useState({}),S=i.useMemo(()=>s?Sa(s.uploadDocumentFiles):[],[s]),M=S[b]??[],V=b===S.length-1,L=S.length,B=i.useCallback(()=>{const h={};for(const z of M)z.isRequired&&(y[z.id]||[]).length===0&&(h[z.id]=`${z.displayName} is required`);return v(h),Object.keys(h).length===0},[M,y]),U=()=>{B()&&(E(h=>h+1),v({}))},Z=()=>{b>0?(E(h=>h-1),v({})):a==null||a()},R=async()=>{if(!(!B()||!s)){F(null);try{const h=await Promise.all(s.uploadDocumentFiles.map(async q=>{const Q=y[q.id]||[],$=await Promise.all(Q.map(async G=>({fileName:G.name,fileData:await kr(G)})));return{uploadDocumentFileId:q.id,valueList:$}})),z={applicantId:t,uploadDocumentId:s.id,uploadDocumentResults:h};await d(z),r==null||r()}catch(h){F((h==null?void 0:h.message)||"Failed to submit documents. Please try again.")}}};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:s.displayName||"Upload Documents"}),s.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:s.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",b+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:S.map((h,z)=>e.jsx("div",{style:{height:"6px",width:z===b?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:z<=b?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},z))})]})]}),s.description&&b===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:s.description})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:M.map(h=>e.jsx(Tr,{label:h.displayName,subtitle:h.subtitle,accept:h.allowedTypes,multiple:h.multipleFile,maxSize:h.maxEachFileSizeByte,required:h.isRequired,error:A[h.id],value:y[h.id]||[],onChange:z=>{F(null),v(q=>{const Q={...q};return delete Q[h.id],Q}),p(q=>({...q,[h.id]:z}))}},h.id))})}),f&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:Z,children:b>0?"Previous":"Back"}),V?e.jsx(J,{type:"button",isLoading:o,onClick:R,children:o?"Uploading...":"Continue"}):e.jsx(J,{type:"button",onClick:U,children:"Next"})]})})]}):null},Br=({applicantId:t,onComplete:r,onBack:a})=>{const{overview:s,isLoading:n,isSubmitting:o,error:c,passOverview:d}=Ir(t),y=async()=>{await d(),r==null||r()};return n?e.jsx(ee,{children:e.jsx(te,{children:e.jsx(Ee,{className:"my-8"})})}):c?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):s?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:s.title||"Overview"}),s.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s.description})]}),e.jsx(te,{className:"space-y-8",children:s.steps&&s.steps.length>0?s.steps.sort((p,f)=>p.order-f.order).map(p=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:p.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.description})]})]},p.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{onClick:y,isLoading:o,children:"Continue"})]})]}):null};function Ca(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function Na(t){return t.valueDataType===Me.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function Ra(t,r){const a=new Intl.NumberFormat(Ca(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,s=>{const n=parseFloat(s);return isNaN(n)?s:a.format(n)})}function Ia(t,r){const a=!r||r.length===0||r.every(s=>!s||!s.trim());if(t.isRequired&&a)return t.errorMessage||`${t.displayName} is required`;if(!a){const s=r[0]??"";if(s&&t.regex)try{if(!new RegExp(t.regex).test(s))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly;if(n&&s.trim()!==""){const o=Number(s);if(!isNaN(o)){if(t.min!==void 0&&t.min!==null&&o<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&o>t.max)return`Maximum value is ${t.max}`}}else if(!n&&s!==""){if(t.min!==void 0&&t.min!==null&&s.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&s.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function Ea(t){const r=new Map;return t.forEach((a,s)=>{const n=a.pageNumber!=null&&a.pageNumber>0?a.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:a,idx:s})}),Array.from(r.entries()).sort(([a],[s])=>a-s).map(([,a])=>a)}function Aa(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const _r=({applicantId:t,onComplete:r,onBack:a})=>{const{config:s}=Ne(),n=s.locale??"en",{criteria:o,initialAnswers:c,isLoading:d,isSubmitting:y,error:p,submit:f}=Ar(t),[F,b]=i.useState({}),[E,A]=i.useState({}),[v,S]=i.useState(0),[M,V]=i.useState(!1);i.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(F).length===0&&b(c)},[c]);const L=i.useMemo(()=>o&&o.length>0?Ea(o):[],[o]),B=v===L.length-1,U=L[v]??[];i.useEffect(()=>{!d&&o&&o.length===0&&!M&&!y&&(V(!0),f({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[d,o,M,y,f,t,r]);const Z=i.useCallback((Q,$)=>{b(G=>({...G,[Q]:$})),A(G=>{const ae={...G};return delete ae[Q],ae})},[]),R=i.useCallback(()=>{const Q={};for(const{criterion:$}of U){const G=Ia($,F[$.id]??[]);G&&(Q[$.id]=G)}return A($=>({...$,...Q})),Object.keys(Q).length===0},[U,F]),h=()=>{R()&&S(Q=>Q+1)},z=()=>{v>0?S(Q=>Q-1):a==null||a()},q=async()=>{if(!(!R()||!o))try{const Q=o.map(G=>{const ae=(F[G.id]??[]).filter(Y=>Y&&Y.trim());return ae.length>0?{riskCriteriaId:G.id,values:ae}:null}).filter(G=>G!==null);await f({applicantId:t,criteriaValueInputs:Q}),r==null||r()}catch(Q){console.error("Risk scoring submit error:",Q)}};return d?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!d&&o&&o.length===0?e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):p?e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",p.message]})})}):o?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",v+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((Q,$)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:$===v?"20px":"6px",backgroundColor:$<=v?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},$))})]})]}),e.jsx(te,{className:"space-y-6",children:U.map(({criterion:Q})=>e.jsx(Fa,{criterion:Q,value:F[Q.id]??[],error:E[Q.id],locale:n,onChange:$=>Z(Q.id,$)},Q.id))}),e.jsxs(fe,{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs(J,{type:"button",variant:"outline",onClick:z,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Mr,{size:14}),v>0?"Previous":"Back"]}),B?e.jsx(J,{type:"button",isLoading:y,onClick:q,children:"Continue"}):e.jsxs(J,{type:"button",onClick:h,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(zr,{size:14})]})]}),p&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:p.message})})]}):null},Fa=({criterion:t,value:r,error:a,locale:s,onChange:n})=>{const o=Aa(t),c=t.valueDataType===Me.Integer||t.valueDataType===Me.Money||t.valueDataType===Me.DigitOnly,d=Na(t),y=p=>d?Ra(p,s):p;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),o==="text"&&e.jsx(ye,{value:r[0]??"",onChange:p=>n([p.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:a,required:t.isRequired,min:t.min,max:t.max,onKeyDown:p=>{t.valueDataType===Me.DigitOnly&&["e","E","+","-","."].includes(p.key)&&p.preventDefault()}}),o==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===p,onChange:()=>n([p]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),o==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(p=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:r.includes(p),onChange:f=>{n(f?[...r,p]:r.filter(F=>F!==p))}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(p)})]},p)),a&&e.jsx("p",{className:"text-sm text-danger-500",children:a})]}),o==="country"&&e.jsx(ut,{value:r[0]??"",onChange:p=>n([p.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:a,required:t.isRequired})]})},Hr=({applicantId:t,onComplete:r,onBack:a})=>{const{investorCategorizationService:s}=Ne(),[n,o]=i.useState(null),[c,d]=i.useState(!1),[y,p]=i.useState(null),f=async F=>{if(F.preventDefault(),n===null){p("Please select an investor type");return}d(!0),p(null);try{const b={applicantId:t,investorType:n};console.log("Submitting investor categorization:",b);const E=await s.setInvestorCategorization(b);console.log("Investor categorization result:",E),r==null||r()}catch(b){console.error("Error submitting investor categorization:",b),p(b.message||"Failed to submit investor categorization")}finally{d(!1)}};return e.jsx("form",{onSubmit:f,children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(te,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.Individual,checked:n===we.Individual,onChange:()=>o(we.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.Sophisticated,checked:n===we.Sophisticated,onChange:()=>o(we.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===we.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===we.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:we.HighNetWorth,checked:n===we.HighNetWorth,onChange:()=>o(we.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:c,disabled:n===null,children:"Submit"})]})]})})};function Et(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function xt(t){const r=Math.floor(t/60),a=t%60;return`${r.toString().padStart(2,"0")}:${a.toString().padStart(2,"0")}`}const Wr=({applicantId:t,onComplete:r,onBack:a})=>{const{appropriatenessTestService:s}=Ne(),[n,o]=i.useState(null),[c,d]=i.useState(!0),[y,p]=i.useState(!1),[f,F]=i.useState(null),[b,E]=i.useState({}),[A,v]=i.useState(0),[S,M]=i.useState(!1),[V,L]=i.useState(!1),[B,U]=i.useState(0),[Z,R]=i.useState(0),[h,z]=i.useState(null);i.useEffect(()=>{(async()=>{try{d(!0),F(null);const O=await s.getAppropriatenessTest(t);if(o(O),O.waitTimeSpanForNextTry&&O.waitTimeSpanForNextTry!=="00:00:00"){const _=Et(O.waitTimeSpanForNextTry);_>0&&U(_)}}catch(O){F(O.message||"Failed to load appropriateness test")}finally{d(!1)}})()},[t,s]),i.useEffect(()=>{if(!S||A<=0)return;const O=setInterval(()=>{v(_=>_<=1?(L(!0),0):_-1)},1e3);return()=>clearInterval(O)},[S,A]),i.useEffect(()=>{if(B<=0)return;const O=setInterval(()=>{U(_=>_<=1?0:_-1)},1e3);return()=>clearInterval(O)},[B]),i.useEffect(()=>{V&&!y&&G()},[V]);const q=()=>{n&&(M(!0),v(n.testDurationSec),R(0),E({}),F(null))},Q=(O,_)=>{E(ue=>({...ue,[O]:_}))},$=i.useCallback(async()=>{try{const O=await s.getAppropriatenessTest(t);if(o(O),O.waitTimeSpanForNextTry&&O.waitTimeSpanForNextTry!=="00:00:00"){const _=Et(O.waitTimeSpanForNextTry);_>0&&U(_)}}catch{}},[t,s]),G=async O=>{if(n){if(!V){const _=n.appropriatenessQuestions.length-Object.keys(b).length;if(_>0){F(`Please answer all questions. ${_} remaining.`);return}}p(!0),F(null);try{const _=n.appropriatenessQuestions.map(N=>({appropriatenessQuestionId:N.id,value:b[N.id]||""})),ue={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:_};try{const N=await s.fillAppropriatenessTest(ue);N.isSuccess?z({success:!0,message:N.message||"Congratulations! You have passed the test."}):(z({success:!1,message:N.message||"You did not pass the test."}),setTimeout(()=>$(),1e3))}catch(N){if(N.code===400&&N.message)z({success:!1,message:N.message}),setTimeout(()=>$(),1500);else throw N}}catch(_){F(_.message||"Failed to submit test. Please try again."),ae()}finally{p(!1)}}},ae=()=>{M(!1),L(!1),E({}),R(0)};if(c)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!n)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),f&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:f})]})})});const Y=n.testAllowedMaxTry-n.totalFailedTries,ke=n.appropriatenessQuestions.length,ce=Object.keys(b).length;if(B>0)return e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName})}),e.jsx(te,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:xt(B)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),f&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})})]})})]});if(h){const O=()=>{z(null),ae(),F(null)};return e.jsxs(ee,{children:[e.jsx(te,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:h.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:h.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:h.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:h.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:h.message}),!h.success&&Y>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:Y})," attempt",Y!==1?"s":""," remaining"]})}),!h.success&&Y<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(fe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:h.success?e.jsx(J,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[Y>0&&B<=0&&e.jsx(J,{type:"button",onClick:O,children:"Retake Test"}),Y>0&&B>0&&e.jsx(J,{type:"button",onClick:O,children:"OK"}),Y<=0&&a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"})]})})})]})}if(!S)return e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle})]}),e.jsxs(te,{children:[n.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(ct,{icon:"questions",label:"Questions",value:String(n.totalQuestionCount)}),e.jsx(ct,{icon:"time",label:"Time Limit",value:xt(n.testDurationSec)}),e.jsx(ct,{icon:"target",label:"Pass Requirement",value:`${n.testCorrectAnswerPassLimit} correct`}),e.jsx(ct,{icon:"retry",label:"Attempts Left",value:String(Y),variant:Y<=1?"warning":"default"})]}),f&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",f]})]}),Y<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:a?"space-between":"flex-end",width:"100%"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"button",onClick:q,disabled:Y<=0,children:"Start Test"})]})})]});const de=n.appropriatenessQuestions[Z],ge=Z===ke-1,I=ce===ke,W=A<=60;return e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",Z+1," of ",ke]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:W?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:W?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:xt(A)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${ce/ke*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[ce," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[Y," attempt",Y!==1?"s":""," left"]})]})]})]}),e.jsxs(te,{children:[de&&e.jsx(Pa,{question:de,index:Z,selectedAnswer:b[de.id],onSelect:O=>Q(de.id,O),disabled:y}),ke>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:n.appropriatenessQuestions.map((O,_)=>e.jsx("button",{type:"button",onClick:()=>R(_),style:{width:"28px",height:"28px",borderRadius:"8px",border:_===Z?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:b[O.id]?_===Z?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":_===Z?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:b[O.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:_+1},O.id))}),V&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),f&&!V&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:f})})]}),e.jsx(fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(J,{type:"button",variant:"outline",onClick:()=>{Z>0?R(O=>O-1):a==null||a()},disabled:y,children:Z>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!ge&&e.jsx(J,{type:"button",onClick:()=>R(O=>O+1),children:"Next"}),(ge||I)&&e.jsx(J,{type:"button",isLoading:y,onClick:()=>G(),disabled:!I&&!V,style:{opacity:I||V?1:.5},children:V?"Submitting...":"Submit Test"})]})]})})]})},Ta={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},ct=({icon:t,label:r,value:a,variant:s="default"})=>{const n=s==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:n?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:n?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:n?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:Ta[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:n?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:a})]})]})},Pa=({question:t,selectedAnswer:r,onSelect:a,disabled:s})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((n,o)=>{const c=r===n;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:s?"default":"pointer",transition:"all 0.15s ease",opacity:s?.6:1},onMouseEnter:d=>{!s&&!c&&(d.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:d=>{c||(d.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:n,checked:c,onChange:()=>a(n),disabled:s,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:n})]},o)})})]}),Ur=({applicantId:t,onComplete:r,onBack:a})=>{var Je,$e,tt,Ke;const{applicantService:s,baseInformationService:n,identityService:o,config:c,currentTheme:d}=Ne(),{identityData:y,provider:p,token:f,isLoading:F,error:b,requestIdentity:E,restartIdentity:A}=Er(t),[v,S]=i.useState(null),[M,V]=i.useState(null),[L,B]=i.useState([]),[U,Z]=i.useState([]),[R,h]=i.useState(!0),[z,q]=i.useState(!1),[Q,$]=i.useState(null),[G,ae]=i.useState(!1),Y=i.useRef(!1),[ke,ce]=i.useState({}),[de,ge]=i.useState({}),I=d!=null&&d.reviewPageFields&&d.reviewPageFields.length>0?d.reviewPageFields[0]:null,W=!!(d!=null&&d.reviewPageDisabled),O=i.useRef(!1);O.current=W;const _=Ye.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});i.useEffect(()=>{if(W){Y.current||(Y.current=!0,E().then(()=>q(!0)).catch(D=>console.error("[Identity] Auto-request failed:",D)).finally(()=>h(!1)));return}(async()=>{try{const[D,K,H]=await Promise.all([s.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);V(D);const X=new Set,u=K.map(g=>({value:g.abbreviation3||g.abbreviation,label:g.name})).filter(g=>!g.value||X.has(g.value)?!1:(X.add(g.value),!0));B(u);const C=new Set,T=H.filter(g=>g.countryCode).map(g=>({value:g.countryCode,label:`${g.countryCode} – ${g.name}`})).filter(g=>C.has(g.value)?!1:(C.add(g.value),!0));Z(T);const m=D.applicantRequestData;if(ce({firstName:(m==null?void 0:m.firstName)||"",lastName:(m==null?void 0:m.lastName)||"",email:(m==null?void 0:m.email)||"",dateOfBirth:(m==null?void 0:m.dateOfBirth)||"",title:(m==null?void 0:m.title)||"",salutation:(m==null?void 0:m.salutation)||"",phonenumber:(m==null?void 0:m.phonenumber)||"",mobileCountryCode:(m==null?void 0:m.mobileCountryCode)||"",street:(m==null?void 0:m.street)||"",streetNumber:(m==null?void 0:m.streetNumber)||"",city:(m==null?void 0:m.city)||"",zip:(m==null?void 0:m.zip)||"",country:(m==null?void 0:m.country)||"",nationality:(m==null?void 0:m.nationality)||"",taxCountry:(m==null?void 0:m.taxCountry)||"",countryOfBirth:(m==null?void 0:m.countryOfBirth)||"",placeOfBirth:(m==null?void 0:m.placeOfBirth)||"",educationLevel:(m==null?void 0:m.educationLevel)||"",occupation:(m==null?void 0:m.occupation)||"",taxNumber:(m==null?void 0:m.taxNumber)||"",defaultLanguage:(m==null?void 0:m.defaultLanguage)||""}),_.reset({street:(m==null?void 0:m.street)||"",streetNumber:(m==null?void 0:m.streetNumber)||"",city:(m==null?void 0:m.city)||"",zip:(m==null?void 0:m.zip)||"",country:(m==null?void 0:m.country)||"",nationality:(m==null?void 0:m.nationality)||"",phonenumber:(m==null?void 0:m.phonenumber)||""}),D.kycRecords&&D.kycRecords.length>0&&D.kycRecords[0].providerTokenObject!==null&&!Y.current&&O.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),Y.current=!0;try{await E(),q(!0)}catch(g){console.error("[Identity] Auto-request failed:",g)}}}catch(D){console.error("Error loading applicant data:",D)}finally{h(!1)}})()},[t]),i.useEffect(()=>{y&&!z&&O.current&&(console.log("[Identity] Review page disabled — showing cached provider"),q(!0))},[y,z]),i.useEffect(()=>{if(f){if(f.expiresAt){const x=new Date(f.expiresAt).getTime();if(Date.now()>=x){console.warn("[Identity] Token has expired (expiresAt)"),ae(!0),$("Your verification session has expired. Please restart.");return}}if(f.url)try{const D=new URL(f.url).toString().toLowerCase();if(D.includes("expired")||D.includes("invalid")||D.includes("error")){console.warn("[Identity] Token URL indicates expiration"),ae(!0),$("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(f.status==="expired"||f.error==="expired"||f.expired===!0){console.warn("[Identity] Token object indicates expiration"),ae(!0),$("Your verification session has expired. Please restart.");return}}},[f]);const ue=p!==null&&p===Ae.Sumsub;i.useEffect(()=>{if(p!==null&&f&&!v&&z&&!G){const x=p;if(ue){console.log("[Sumsub] Fetching access token for Web SDK…"),$(null),(async()=>{try{const D=await o.refreshSumsubToken(t),K=He.parseProviderConfig(p,f,c);K.accessToken=D,K.onTokenRefresh=()=>o.refreshSumsubToken(t);const H=He.createProvider(p,K);H.onComplete(X=>{console.log("[Sumsub] Verification complete:",X),r==null||r()}),H.onError(X=>{console.error("[Sumsub] SDK error:",X),(typeof X=="string"?X:(X==null?void 0:X.message)||"Unknown error").toLowerCase().includes("expired")&&(ae(!0),$("Session expired. Please restart."))}),await H.initialize("sumsub-websdk-container"),console.log("[Sumsub] Web SDK launched"),S(H)}catch(D){console.error("[Sumsub] Initialization error:",D),$(`Failed to initialize: ${D.message||D}`),String(D.message||D).toLowerCase().includes("expired")&&ae(!0)}})();return}if(f.url){console.log("[Identity] Loading provider URL for user verification:",f.url),$(null);try{if(new URL(f.url),x===Ae.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const D=He.parseProviderConfig(p,f,c);He.createProvider(p,D).initialize().then(()=>console.log("[SardinAI] Risk SDK initialized in background")).catch(H=>console.warn("[SardinAI] Risk SDK init failed (non-blocking):",H))}catch(D){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",D)}}S({type:"url",url:f.url})}catch(D){console.error("[Identity] Invalid URL:",D),$("Invalid verification URL. Please restart."),ae(!0)}return}if(x===Ae.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),$(null);try{const D=He.parseProviderConfig(p,f,c),K=He.createProvider(p,D);K.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),S(K),setTimeout(()=>r==null?void 0:r(),2e3)}).catch(H=>{var u;console.error("[SardinAI] Failed to initialize:",H);const X=((u=H.message)==null?void 0:u.toLowerCase())||"";X.includes("expired")||X.includes("invalid")||X.includes("401")||X.includes("400")?(ae(!0),$("Session expired or invalid. Please restart verification.")):$(`Failed to initialize: ${H.message}`)})}catch(D){console.error("[SardinAI] Error creating provider:",D),$(`Configuration error: ${D.message}`)}return}try{$(null);const D=He.parseProviderConfig(p,f,c),K=He.createProvider(p,D);x===Ae.Onfido&&K.initialize("identity-container").catch(H=>{console.error("[Onfido] Initialization error:",H),$(`Failed to initialize: ${H.message}`)}),S(K)}catch(D){console.error("[Identity] Provider setup error:",D),$(`Setup error: ${D.message}`)}}return()=>{if(v&&v.destroy)try{v.destroy()}catch(x){console.error("[Identity] Error destroying provider:",x)}}},[p,f,v,z,r,G,ue,t,c,o]);const N=async()=>{try{$(null),ae(!1),await E(),q(!0)}catch(x){console.error("Error starting identity verification:",x)}},re=async()=>{try{$(null),ae(!1),S(null),console.log("[Identity] Restarting verification..."),await A(),q(!0)}catch(x){console.error("Error restarting identity verification:",x),$(x.message||"Failed to restart verification")}};if(R||F)return e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(b)return e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",b.message]})})});if(z&&(Q||G))return e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(te,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:G?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:Q||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"button",onClick:re,disabled:F,children:F?"Restarting...":"Restart Verification"})]})]});if(z&&y){const x=p;return ue?e.jsxs("div",{style:{background:"var(--metakyc-background, #ffffff)",borderRadius:"12px",border:"1px solid var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 24px",borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{margin:0,fontSize:"20px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)"},children:"Identity Verification"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please complete the identity verification process"})]}),e.jsx("button",{type:"button",onClick:re,disabled:F,style:{padding:"6px 14px",fontSize:"13px",fontWeight:500,borderRadius:"8px",border:"1px solid var(--metakyc-border, #d1d5db)",background:"var(--metakyc-background, #ffffff)",color:"var(--metakyc-text-primary, #111827)",cursor:F?"not-allowed":"pointer",opacity:F?.5:1},children:F?"Restarting…":"Restart"})]}),e.jsx("div",{id:"sumsub-websdk-container",style:{minHeight:"520px",width:"100%",padding:"16px 24px",background:"var(--metakyc-background, #ffffff)"}}),a&&e.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]}):f!=null&&f.url?e.jsxs(ee,{children:[e.jsx(he,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(J,{type:"button",variant:"outline",size:"sm",onClick:re,disabled:F,children:"Restart"})]})}),e.jsxs(te,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:f.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:D=>{var K,H,X;console.log("[Identity] Iframe loaded");try{const u=D.target,C=u.contentDocument||((K=u.contentWindow)==null?void 0:K.document);if(C){const T=((X=(H=C.body)==null?void 0:H.textContent)==null?void 0:X.toLowerCase())||"";(T.includes("expired")||T.includes("invalid")||T.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),ae(!0),$("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),a&&e.jsx(fe,{children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]}):x===Ae.SardinAI?e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(te,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ee,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(te,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),a&&e.jsx(fe,{children:e.jsx(J,{variant:"outline",onClick:a,children:"Back"})})]})}const me=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),se=(x=4)=>{const D=Math.min(4,Math.max(1,Number(x)||4));return{gridColumn:`span ${D} / span ${D}`}},be=(x,D)=>{if(!D&&D!==0)return"—";if(me.has(x)&&x!=="mobileCountryCode"){const K=L.find(H=>H.value===D);return K?K.label:String(D)}return String(D)},Pe=({helpText:x})=>{const[D,K]=i.useState(!1),H=i.useRef(null),[,X]=i.useState({top:0,left:0}),u=()=>{if(H.current){const C=H.current.getBoundingClientRect();X({top:C.bottom+window.scrollY+6,left:C.left+window.scrollX})}K(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:H,onClick:u,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),D&&pt.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>K(!1),children:e.jsxs("div",{onClick:C=>C.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:x},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>K(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},ve=(x,D)=>D?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:x}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Pe,{helpText:D})})]}):x,Oe=(x,D)=>{const K=`cf-${D}`,H=x.paramName??"",X=de[H];if(x.customType==="br")return e.jsx("div",{style:{...se(x.colSpan),minHeight:"0.5rem"}},K);if(x.customType==="paragraph")return e.jsx("div",{style:se(x.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:x.label||""}})},K);if(x.customType==="html")return e.jsx("div",{style:se(x.colSpan),dangerouslySetInnerHTML:{__html:x.label||""}},K);if(x.customType==="link")return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsx("a",{href:x.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:x.displayText||x.label||x.linkText||x.linkUrl}),x.helpText)},K);if(x.customType==="checkbox"||x.customType==="link_checkbox"){const u=X==="true"||X===!0;return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx(Te,{checked:!!u,onChange:C=>ge(T=>({...T,[H]:String(C)})),style:{marginTop:2}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.customType==="link_checkbox"&&x.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:x.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:x.linkText||x.label}),x.label&&x.linkText?` ${x.label}`:""]}):x.displayText||x.label})]}),x.helpText)},K)}if(x.customType==="group_checkbox"){const u=Array.isArray(X)?X:X?[X]:[],C=T=>{x.singleSelect?ge(m=>({...m,[H]:u[0]===T?[]:[T]})):ge(m=>({...m,[H]:u.includes(T)?u.filter(l=>l!==T):[...u,T]}))};return e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(T=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx(Te,{checked:u.includes(T.value),onChange:()=>C(T.value),style:{marginTop:2}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:T.label})]},T.value))]}),x.helpText)},K)}return x.customType==="radio_group"?e.jsx("div",{style:se(x.colSpan),children:ve(e.jsxs("div",{className:"space-y-1.5",children:[x.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:x.displayText||x.label}),(x.options||[]).map(u=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${H}`,value:u.value,checked:X===u.value,onChange:()=>ge(C=>({...C,[H]:u.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.label})]},u.value))]}),x.helpText)},K):e.jsx("div",{style:se(x.colSpan),children:ve(e.jsx(ye,{label:x.displayText||x.label||H,value:String(X??""),onChange:u=>ge(C=>({...C,[H]:u.target.value}))}),x.helpText)},K)},et=(x,D)=>{if(x.isCustom)return Oe(x,D);const K=x.name??"",H=Ge[K],X=x.displayText||(H==null?void 0:H.label)||K,u=ke[K]??"",C=K==="mobileCountryCode",T=!!(H!=null&&H.countriesType)&&!C;return x.editable?C?e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ze,{label:X,value:String(u),onChange:m=>ce(l=>({...l,[K]:m})),options:[{value:"",label:"Select country code…"},...U]}),x.helpText)},`epc-${D}`):T?e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ze,{label:X,value:String(u),onChange:m=>ce(l=>({...l,[K]:m})),options:[{value:"",label:`Select ${X.toLowerCase()}…`},...L]}),x.helpText)},`ec-${D}`):e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsx(ye,{label:X,type:(H==null?void 0:H.type)==="date"?"date":(H==null?void 0:H.type)==="email"?"email":"text",value:String(u),onChange:m=>ce(l=>({...l,[K]:m.target.value}))}),x.helpText)},`ei-${D}`):e.jsx("div",{style:se(x.colSpan??2),children:ve(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:X}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:be(K,u)})]}),x.helpText)},`ro-${D}`)};if(I){const x=I.title||"Review Your Information",D=I.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:K=>{K.preventDefault(),N()},children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:x}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:D})]}),e.jsx(te,{children:e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:I.fields.map((K,H)=>et(K,H))})}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:_.handleSubmit(N),children:e.jsxs(ee,{children:[e.jsxs(he,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(te,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Je=M==null?void 0:M.applicantRequestData)==null?void 0:Je.firstName)||""} ${(($e=M==null?void 0:M.applicantRequestData)==null?void 0:$e.lastName)||""}`.trim()},{label:"Email",value:(tt=M==null?void 0:M.applicantRequestData)==null?void 0:tt.email},{label:"Date of Birth",value:((Ke=M==null?void 0:M.applicantRequestData)==null?void 0:Ke.dateOfBirth)||"Not provided"}].map(({label:x,value:D})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:x}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:D})]},x))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ye.Controller,{control:_.control,name:"country",render:({field:x})=>e.jsx(ze,{label:"Country",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select country…"},...L]})}),e.jsx(Ye.Controller,{control:_.control,name:"nationality",render:({field:x})=>e.jsx(ze,{label:"Nationality",value:x.value,onChange:x.onChange,options:[{value:"",label:"Select nationality…"},...L]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ye.Controller,{control:_.control,name:"street",render:({field:x})=>e.jsx(ye,{...x,label:"Street"})}),e.jsx(Ye.Controller,{control:_.control,name:"streetNumber",render:({field:x})=>e.jsx(ye,{...x,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Ye.Controller,{control:_.control,name:"city",render:({field:x})=>e.jsx(ye,{...x,label:"City"})}),e.jsx(Ye.Controller,{control:_.control,name:"zip",render:({field:x})=>e.jsx(ye,{...x,label:"ZIP / Postal Code"})})]}),e.jsx(Ye.Controller,{control:_.control,name:"phonenumber",render:({field:x})=>e.jsx(ye,{...x,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[a&&e.jsx(J,{type:"button",variant:"outline",onClick:a,children:"Back"}),e.jsx(J,{type:"submit",isLoading:F,children:"Confirm and Start Verification"})]})]})})},ft=({kycStatus:t,reviewStatus:r,workflowResult:a,customMessage:s,onContinue:n,onContactSupport:o})=>{const d=t===Ve.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Ve.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Ve.Pending||t===Ve.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===Qe.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===Qe.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===Qe.UnderReview||r===Qe.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:a===ot.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:a===ot.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:a===ot.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(ee,{children:[e.jsxs(te,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${d.iconBg}`,children:e.jsx("span",{className:`text-5xl ${d.iconColor}`,children:d.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:d.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(wt,{variant:d.type==="success"?"success":d.type==="error"?"danger":d.type==="pending"?"warning":"info",children:t!=null?Ve[t]:Qe[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:s||d.message}),d.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),d.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),d.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Ve[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:Qe[r]})]})]})})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"center",gap:"1rem"},children:[d.type==="success"&&n&&e.jsx(J,{onClick:n,size:"lg",children:"Continue"}),d.type==="error"&&e.jsxs(e.Fragment,{children:[o&&e.jsx(J,{variant:"outline",onClick:o,children:"Contact Support"}),n&&e.jsx(J,{onClick:n,children:"Try Again"})]}),d.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Kr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:a=>{console.warn("[Logo] Failed to load logo:",t.url),a.target.style.display="none"}})}),nt=({title:t,subtitle:r,className:a=""})=>{const{currentTheme:s}=Ne(),n=t||(s==null?void 0:s.title)||"",o=!!(s!=null&&s.logo&&s.logo.visible&&s.logo.url),c=!!n;return!o&&!c?null:e.jsxs("div",{className:`metakyc-header ${a}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[o&&e.jsx(Kr,{config:s.logo}),o&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},dt=["firstName","lastName","email","phonenumber","dateOfBirth"];function rt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const La={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},At=({helpText:t,children:r})=>{const[a,s]=i.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=a?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>s(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:o=>o.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>s(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>s(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:o=>{o.currentTarget.style.background="var(--metakyc-primary, #2563eb)",o.currentTarget.style.color="#ffffff"},onMouseLeave:o=>{o.currentTarget.style.background="transparent",o.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?pt.createPortal(n,document.body):null]})},Da=({workflowKey:t,externalRefId:r,onSuccess:a,onCancel:s})=>{var K,H,X,u,C,T,m;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createApplicant:d,isLoading:y}=vt(),p=t||((K=n.applicantForm)==null?void 0:K.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const f=r||((H=n.applicantForm)==null?void 0:H.externalRefId)||"",F=((X=n.applicantForm)==null?void 0:X.email)||"",b=((u=n.applicantForm)==null?void 0:u.hiddenValues)||{},E=((C=n.applicantForm)==null?void 0:C.initialValues)||{},v=(((T=n.applicantForm)==null?void 0:T.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",S=i.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),M=i.useMemo(()=>{const l=new Set(dt),g=c==null?void 0:c.applicantFormRequiredFields;if(g)for(const P of g)l.add(P);if(S)for(const P of S)for(const k of P.fields)!k.isCustom&&k.name&&k.required&&l.add(k.name);return Array.from(l)},[c==null?void 0:c.applicantFormRequiredFields,S]),V=i.useMemo(()=>{var P;if(S){const k=S.flatMap(w=>w.fields).filter(w=>!w.isCustom&&w.name).map(w=>w.name),j=new Set(k);for(const w of dt)j.add(w);return Array.from(j)}let l;(P=n.applicantForm)!=null&&P.visibleFields?l=n.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?l=c.applicantFormVisibleFields:l=Ut;const g=new Set(l);for(const k of dt)g.add(k);return Array.from(g)},[(m=n.applicantForm)==null?void 0:m.visibleFields,c==null?void 0:c.applicantFormVisibleFields,S]),L=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),B=i.useMemo(()=>{var g,P;const l=new Set;if(S)for(const k of S)for(const j of k.fields)!j.isCustom&&j.name&&L.has(j.name)&&l.add(j.countriesType??((g=Ge[j.name])==null?void 0:g.countriesType));else for(const k of V)L.has(k)&&l.add((P=Ge[k])==null?void 0:P.countriesType);return l.size===0&&l.add(void 0),Array.from(l)},[V,S]),[U,Z]=i.useState({}),[R,h]=i.useState(!0),z=i.useRef(new Set),q=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const l=B.filter(k=>{const j=k!=null?String(k):"all";return!q.current.has(j)&&!z.current.has(j)});if(l.length===0){B.every(j=>{const w=j!=null?String(j):"all";return q.current.has(w)})&&h(!1);return}h(!0);const g=l.map(k=>k!=null?String(k):"all");g.forEach(k=>z.current.add(k)),(async()=>{try{const k=await Promise.all(l.map(async j=>{const w=j!=null?String(j):"all",le=await o.getCountries("",n.locale||"en",j),ne=j===40,xe=new Set,Ie=le.map(ie=>ne&&ie.countryCode?{value:ie.countryCode,label:`${ie.countryCode} – ${ie.name}`}:{value:ie.abbreviation3||ie.abbreviation,label:ie.name}).filter(ie=>!ie.value||xe.has(ie.value)?!1:(xe.add(ie.value),!0));return q.current.add(w),z.current.delete(w),[w,Ie]}));Z(j=>({...j,...Object.fromEntries(k)}))}catch(k){g.forEach(j=>z.current.delete(j)),console.error("Failed to load countries:",k)}finally{B.every(j=>{const w=j!=null?String(j):"all";return q.current.has(w)})&&h(!1)}})()},[B,c]);const Q=(l,g)=>{var j;const P=g??((j=Ge[l])==null?void 0:j.countriesType),k=P!=null?String(P):"all";return U[k]||[]},$={firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1},G=Object.fromEntries(Object.entries(b).filter(([l])=>l in $)),ae=Object.fromEntries(Object.entries(E).filter(([l])=>l in $)),[Y,ke]=i.useState({workflowKey:p,firstName:"",lastName:"",title:"",email:F,dateOfBirth:"",phonenumber:"",externalRefId:f,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...G,...ae}),ce=Object.fromEntries(Object.entries(b).filter(([l])=>!(l in G)&&l!=="externalRefId"&&l!=="workflowKey")),[de,ge]=i.useState({...ce}),[I,W]=i.useState(0),[O,_]=i.useState({}),[ue,N]=i.useState(null),[re,me]=i.useState(!1),se=(l,g)=>ke(P=>({...P,[l]:g})),be=(l,g)=>ge(P=>({...P,[l]:g})),Pe=l=>!l.conditionalOn||de[l.conditionalOn]==="true",ve=S&&I<S.length-1?I+1:-1,Oe=S&&I>0?I-1:-1,et=l=>{var P;const g={};for(const k of l.fields)if(k.isCustom){if(k.customType==="paragraph"||k.customType==="html"||k.customType==="br"||k.customType==="link")continue;if(k.required&&k.paramName){const j=de[k.paramName],w=k.displayText||k.label||k.paramName;k.customType==="checkbox"||k.customType==="link_checkbox"?j!=="true"&&(g[k.paramName]=`${w} is required.`):(!j||j.trim()==="")&&(g[k.paramName]=`${w} is required.`)}}else if(k.name){const j=k.name;if(M.includes(j)&&rt(Y[j])){const w=k.displayText||((P=Ge[j])==null?void 0:P.label)||j;g[j]=`${w} is required.`}}return g},Je=async()=>{if(!S)return;const l=S[I];if(l.conditionalOn&&!Pe(l)){_({}),ve>=0?W(ve):await $e();return}const g=et(l);if(Object.keys(g).length>0){_(g);return}_({}),ve>=0?W(ve):await $e()},$e=async()=>{if(S){let l={};for(const g of S)Pe(g)&&(l={...l,...et(g)});if(Object.keys(l).length>0){_(l);return}}me(!0),N(null);try{if(!Y.externalRefId||Y.externalRefId.trim()===""){N("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const l={workflowKey:Y.workflowKey,externalRefId:Y.externalRefId.trim()};if(S){for(const j of S)if(Pe(j)){for(const w of j.fields)if(!w.isCustom&&w.name){const le=w.name,ne=Y[le];rt(ne)||(l[le]=ne)}}for(const j of dt)if(l[j]===void 0){const w=Y[j];rt(w)||(l[j]=w)}}else V.forEach(j=>{if(j==="externalRefId")return;const w=Y[j];rt(w)||(l[j]=w)});const g=[];if(S){for(const j of S)if(Pe(j))for(const w of j.fields){if(!w.isCustom||!w.paramName||w.customType==="paragraph"||w.customType==="html"||w.customType==="br"||w.customType==="link")continue;const le=de[w.paramName]??"";let ne;if(w.customType==="checkbox"||w.customType==="link_checkbox")ne=le==="true"?"yes":"no";else if(ne=le,!ne&&!w.required)continue;g.push({paramName:w.paramName,value:ne})}}for(const[j,w]of Object.entries(G))l[j]===void 0&&!rt(w)&&(l[j]=w);const P=new Set(g.map(j=>j.paramName));for(const[j,w]of Object.entries(ce))!P.has(j)&&w&&g.push({paramName:j,value:w});g.length>0&&(l.applicantAdditionalDatas=g);const k=await d(l);a(k.applicantId)}catch(l){console.error("Error creating applicant:",l),N(l.message||"Failed to create applicant")}finally{me(!1)}},tt=async l=>{var g;l.preventDefault();for(const P of M)if(rt(Y[P])){const k=((g=Ge[P])==null?void 0:g.label)||P;N(`${k} is required.`);return}await $e()},Ke=(l,g,P,k,j)=>{var jt;const w=Ge[l];if(!w)return null;const le=M.includes(l),ne=O[l],xe=P||w.label,Ie=l in ae,ie=g??l,Le={required:le},Be=j?j!=="placeholder":v,qe=Be?xe:void 0,qr=Be?"...":xe;switch(w.type){case"select":if(l==="country"||l==="nationality"||l==="taxCountry"||l==="countryOfBirth"||l==="mobileCountryCode"){const Ce=Q(l,k);return e.jsx(ze,{...Le,label:qe,value:Y[l]||"",onChange:Xe=>se(l,Xe),options:[{value:"",label:`Select ${qr.toLowerCase()}`},...Ce],disabled:R,readOnly:Ie,error:ne},ie)}if(l==="salutation")return e.jsx(ze,{...Le,label:qe,value:((jt=Y[l])==null?void 0:jt.toString())||"",onChange:Ce=>se(l,Ce?Number(Ce):null),options:[{value:"",label:Be?"Select salutation...":xe},{value:lt.Male.toString(),label:"Male"},{value:lt.Female.toString(),label:"Female"},{value:lt.Other.toString(),label:"Other"}],readOnly:Ie,error:ne},ie);if(l==="defaultLanguage"){const Ce=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?ht.filter(Xe=>c.allowedLanguages.includes(Xe.value)):ht;return e.jsx(ze,{...Le,label:qe,value:Y[l]||"",onChange:Xe=>se(l,Xe),options:[{value:"",label:Be?"Select language...":xe},...Ce],readOnly:Ie,error:ne},ie)}return null;case"multiselect":if(l==="otherNationality"){const Ce=Q(l,k);return e.jsx(Fr,{...Le,label:qe,value:Y[l]||[],onChange:Xe=>se(l,Xe),options:Ce,placeholder:Be?"Select other nationalities...":xe,disabled:R,readOnly:Ie},ie)}return null;case"date":return e.jsx(ye,{...Le,type:"date",label:qe,placeholder:Be?void 0:xe,value:Y[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);case"email":return e.jsx(ye,{...Le,type:"email",label:qe,placeholder:Be?void 0:xe,value:Y[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);case"tel":return e.jsx(ye,{...Le,type:"tel",label:qe,placeholder:Be?void 0:xe,value:Y[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie);default:return e.jsx(ye,{...Le,type:"text",label:qe,placeholder:Be?void 0:xe,value:Y[l]||"",onChange:Ce=>se(l,Ce.target.value),readOnly:Ie,error:ne},ie)}},x=(l,g)=>{const P=l.labelMode?l.labelMode!=="placeholder":v;if(l.customType==="paragraph"){const w=l.displayText||l.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:w}},`custom-${g}`)}if(l.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:l.label||""}},`custom-${g}`);if(l.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${g}`);if(l.customType==="link"){const w=l.displayText||l.label||l.linkText||l.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:l.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[w,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${g}`)}if(!l.paramName)return null;const k=O[l.paramName],j=l.displayText||l.label||l.paramName;if(l.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:de[l.paramName]==="true",onChange:w=>be(l.paramName,w?"true":"false")}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),k&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:k})]},`custom-${g}`);if(l.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:de[l.paramName]==="true",onChange:w=>be(l.paramName,w?"true":"false")}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[j," ",l.linkUrl&&e.jsx("a",{href:l.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:w=>w.stopPropagation(),children:l.linkText||l.linkUrl}),l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),k&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:k})]},`custom-${g}`);if(l.customType==="group_checkbox"){const w=(de[l.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(le=>{const ne=l.singleSelect?de[l.paramName]===le.value:w.includes(le.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:ne,onChange:xe=>{if(l.singleSelect)be(l.paramName,xe?le.value:"");else{const Ie=xe?[...w,le.value]:w.filter(ie=>ie!==le.value);be(l.paramName,Ie.join(","))}}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:le.label})]},le.value)})}),k&&e.jsx("p",{className:"text-red-500 text-xs",children:k})]},`custom-${g}`)}return l.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[P&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[j,l.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(l.options||[]).map(w=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:de[l.paramName]===w.value,onChange:()=>be(l.paramName,w.value),name:`radio-group-${l.paramName}-${g}`,className:"metakyc-option-input",style:La}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:w.label})]},w.value))}),k&&e.jsx("p",{className:"text-red-500 text-xs",children:k})]},`custom-${g}`):e.jsx(ye,{type:"text",label:P?`${j}${l.required?" *":""}`:void 0,placeholder:P?void 0:j,value:de[l.paramName]||"",onChange:w=>be(l.paramName,w.target.value),required:l.required,error:k},`custom-${g}`)},D=(l,g)=>{const P=Pe(l);return e.jsxs("div",{className:"space-y-4",children:[l.conditionalOn&&e.jsx(At,{helpText:l.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx(Te,{checked:P,onChange:k=>be(l.conditionalOn,k?"true":"false")}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:l.conditionalOn})]})}),P&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:l.fields.map((k,j)=>{const w=Math.min(4,Math.max(1,Number(k.colSpan)||4)),le=k.isCustom?`custom-${j}-${k.paramName}`:`builtin-${k.name}-${j}`;return e.jsx("div",{style:{gridColumn:`span ${w} / span ${w}`},children:e.jsx(At,{helpText:k.helpText,children:k.isCustom?x(k,j):Ke(k.name,le,k.displayText,k.countriesType,k.labelMode)})},le)})})]})};if(!c||R)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(S){const l=S[I]??S[0],g=Oe===-1,P=ve===-1,k=S.length,j=Pe(l),w=Object.values(O);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[(l.title||l.subtitle||l.description)&&e.jsxs("div",{className:"mb-4",children:[l.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:l.title}),l.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.subtitle}),l.description&&l.description!==l.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.description})]}),(ue||w.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[ue&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",ue]}),w.map((le,ne)=>e.jsx("p",{className:"text-red-600 text-sm",children:le},ne))]}),k>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[S.map((le,ne)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...ne===I?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:ne<I?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},ne)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[I+1," / ",k]})]}),D(l)]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!g&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{W(Oe),_({})},disabled:re||y,children:"Previous"}),g&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:re||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:re||y,onClick:P?$e:Je,children:P?l.conditionalOn&&!j?"Skip & Submit":"Submit":l.conditionalOn&&!j?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:tt,children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(te,{children:[ue&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",ue]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:V.map(l=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Ke(l)},l))})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:re||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:re||y,children:"Create Applicant"})]})]})})})},Ft=["companyName","email"];function gt(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const Ma=({workflowKey:t,externalRefId:r,onSuccess:a,onCancel:s})=>{var Ke,x,D,K,H,X;const{config:n,baseInformationService:o,currentTheme:c}=Ne(),{createCompanyApplicant:d,isLoading:y}=vt(),p=t||((Ke=n.applicantForm)==null?void 0:Ke.workflowKey);if(!p)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const f=r||((x=n.applicantForm)==null?void 0:x.externalRefId)||"",F=((D=n.applicantForm)==null?void 0:D.email)||"",b=((K=n.applicantForm)==null?void 0:K.initialValues)||{},A=(((H=n.applicantForm)==null?void 0:H.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",v=i.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),S=i.useMemo(()=>{const u=new Set(Ft),C=c==null?void 0:c.companyFormRequiredFields;if(C)for(const T of C)u.add(T);if(v)for(const T of v)for(const m of T.fields)!m.isCustom&&m.name&&m.required&&u.add(m.name);return Array.from(u)},[c==null?void 0:c.companyFormRequiredFields,v]),M=i.useMemo(()=>{var u;if(v){const C=v.flatMap(m=>m.fields).filter(m=>!m.isCustom&&m.name).map(m=>m.name),T=new Set(C);for(const m of Ft)T.add(m);return Array.from(T)}return(u=n.applicantForm)!=null&&u.visibleFields?n.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:Wt},[(X=n.applicantForm)==null?void 0:X.visibleFields,c==null?void 0:c.companyFormVisibleFields,v]),V=new Set(["countryResidence","addressCountry"]),L=i.useMemo(()=>{var C,T;const u=new Set;if(v)for(const m of v)for(const l of m.fields)!l.isCustom&&l.name&&V.has(l.name)&&u.add(l.countriesType??((C=Ze[l.name])==null?void 0:C.countriesType));else for(const m of M)V.has(m)&&u.add((T=Ze[m])==null?void 0:T.countriesType);return u.size===0&&u.add(void 0),Array.from(u)},[M,v]),[B,U]=i.useState({}),[Z,R]=i.useState(!0),h=i.useRef(new Set),z=i.useRef(new Set);i.useEffect(()=>{if(!c)return;const u=L.filter(m=>{const l=m!=null?String(m):"all";return!z.current.has(l)&&!h.current.has(l)});if(u.length===0){L.every(l=>z.current.has(l!=null?String(l):"all"))&&R(!1);return}R(!0);const C=u.map(m=>m!=null?String(m):"all");C.forEach(m=>h.current.add(m)),(async()=>{try{const m=await Promise.all(u.map(async l=>{const g=l!=null?String(l):"all",P=await o.getCountries("",n.locale||"en",l),k=new Set,j=P.map(w=>({value:w.abbreviation3||w.abbreviation,label:w.name})).filter(w=>!w.value||k.has(w.value)?!1:(k.add(w.value),!0));return z.current.add(g),h.current.delete(g),[g,j]}));U(l=>({...l,...Object.fromEntries(m)}))}catch(m){C.forEach(l=>h.current.delete(l)),console.error("Failed to load countries:",m)}finally{L.every(l=>z.current.has(l!=null?String(l):"all"))&&R(!1)}})()},[L,c]);const q=(u,C)=>{var l;const T=C??((l=Ze[u])==null?void 0:l.countriesType),m=T!=null?String(T):"all";return B[m]||[]},Q={companyName:1,registrationNumber:1,email:1,phone:1,countryResidence:1,legalAddress:1,incorporatedOn:1,controlScheme:1,taxId:1,registrationLocation:1,website:1,postalAddress:1,street:1,streetNumber:1,city:1,state:1,postalCode:1,addressCountry:1,lei:1},$=Object.fromEntries(Object.entries(b).filter(([u])=>u in Q)),[G,ae]=i.useState({workflowKey:p,companyName:"",email:F,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:f,...$}),[Y,ke]=i.useState({}),[ce,de]=i.useState(0),[ge,I]=i.useState({}),[W,O]=i.useState(null),[_,ue]=i.useState(!1),N=(u,C)=>ae(T=>({...T,[u]:C})),re=(u,C)=>ke(T=>({...T,[u]:C})),me=u=>!u.conditionalOn||Y[u.conditionalOn]==="true",se=v&&ce<v.length-1?ce+1:-1,be=v&&ce>0?ce-1:-1,Pe=u=>{var T;const C={};for(const m of u.fields)if(m.isCustom){if(m.customType==="paragraph"||m.customType==="html"||m.customType==="br"||m.customType==="link")continue;if(m.required&&m.paramName){const l=Y[m.paramName],g=m.displayText||m.label||m.paramName;m.customType==="checkbox"||m.customType==="link_checkbox"?l!=="true"&&(C[m.paramName]=`${g} is required.`):(!l||l.trim()==="")&&(C[m.paramName]=`${g} is required.`)}}else if(m.name){const l=m.name;if(S.includes(l)&>(G[l])){const g=m.displayText||((T=Ze[l])==null?void 0:T.label)||l;C[l]=`${g} is required.`}}return C},ve=async()=>{if(!v)return;const u=v[ce];if(u.conditionalOn&&!me(u)){I({}),se>=0?de(se):await Oe();return}const C=Pe(u);if(Object.keys(C).length>0){I(C);return}I({}),se>=0?de(se):await Oe()},Oe=async()=>{var u;if(v){let C={};for(const T of v)me(T)&&(C={...C,...Pe(T)});if(Object.keys(C).length>0){I(C);return}}ue(!0),O(null);try{const C={workflowKey:G.workflowKey,externalRefId:((u=G.externalRefId)==null?void 0:u.trim())||void 0},T=v?v.filter(g=>me(g)).flatMap(g=>g.fields).filter(g=>!g.isCustom&&g.name).map(g=>g.name):M;for(const g of T){const P=G[g];if(!gt(P))switch(g){case"companyName":C.companyName=P;break;case"email":C.companyEmail=P;break;case"phone":C.companyPhone=P;break;case"registrationNumber":C.companyRegistrationNumber=P;break;case"countryResidence":C.companyCountry=P;break;case"city":C.companyCity=P;break;case"street":C.companyStreet=P;break;case"postalCode":C.companyZip=P;break;default:C[g]=P;break}}const m=[];if(v){for(const g of v)if(me(g))for(const P of g.fields){if(!P.isCustom||!P.paramName||P.customType==="paragraph"||P.customType==="html"||P.customType==="br"||P.customType==="link")continue;const k=Y[P.paramName]??"";let j;if(P.customType==="checkbox"||P.customType==="link_checkbox")j=k==="true"?"yes":"no";else if(j=k,!j&&!P.required)continue;m.push({paramName:P.paramName,value:j})}}m.length>0&&(C.applicantAdditionalDatas=m);const l=await d(C);a(l.applicantId)}catch(C){console.error("Error creating company applicant:",C),O(C.message||"Failed to create company applicant")}finally{ue(!1)}},et=async u=>{var C;u.preventDefault();for(const T of S)if(gt(G[T])){const m=((C=Ze[T])==null?void 0:C.label)||T;O(`${m} is required.`);return}await Oe()},Je=(u,C,T,m,l)=>{const g=Ze[u];if(!g)return null;const P=S.includes(u),k=ge[u],j=T||g.label,w=u in $,le=C??u,ne=l?l!=="placeholder":A,xe=ne?j:void 0,Ie=ne?"...":j;switch(g.type){case"select":if(u==="countryResidence"||u==="addressCountry"){const ie=q(u,m);return e.jsx(ze,{required:P,label:xe,value:G[u]||"",onChange:Le=>N(u,Le),options:[{value:"",label:`Select ${Ie.toLowerCase()}`},...ie],disabled:Z,readOnly:w,error:k},le)}return null;case"date":return e.jsx(ye,{required:P,type:"date",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);case"email":return e.jsx(ye,{required:P,type:"email",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);case"tel":return e.jsx(ye,{required:P,type:"tel",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le);default:return e.jsx(ye,{required:P,type:"text",label:xe,placeholder:ne?void 0:j,value:G[u]||"",onChange:ie=>N(u,ie.target.value),readOnly:w,error:k},le)}},$e=(u,C)=>{if(u.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:u.displayText||u.label||""}},`custom-${C}`);if(u.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:u.label||""}},`custom-${C}`);if(u.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${C}`);if(u.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:u.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:u.displayText||u.label||u.linkText||u.linkUrl||""})},`custom-${C}`);if(!u.paramName)return null;const T=ge[u.paramName],m=u.displayText||u.label||u.paramName,l=u.labelMode?u.labelMode!=="placeholder":A;return u.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx(Te,{checked:Y[u.paramName]==="true",onChange:g=>re(u.paramName,g?"true":"false")}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[m,u.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),T&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:T})]},`custom-${C}`):e.jsx(ye,{type:"text",label:l?`${m}${u.required?" *":""}`:void 0,placeholder:l?void 0:m,value:Y[u.paramName]||"",onChange:g=>re(u.paramName,g.target.value),required:u.required,error:T},`custom-${C}`)},tt=u=>{const C=me(u);return e.jsxs("div",{className:"space-y-4",children:[u.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx(Te,{checked:C,onChange:T=>re(u.conditionalOn,T?"true":"false")}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:u.conditionalOn})]}),C&&e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:u.fields.map((T,m)=>{const l=Math.min(4,Math.max(1,Number(T.colSpan)||4)),g=T.isCustom?`custom-${m}-${T.paramName}`:`builtin-${T.name}-${m}`;return e.jsx("div",{style:{gridColumn:`span ${l} / span ${l}`},children:T.isCustom?$e(T,m):Je(T.name,g,T.displayText,T.countriesType,T.labelMode)},g)})})]})};if(!c||Z)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(v){const u=v[ce]??v[0],C=be===-1,T=se===-1,m=v.length,l=me(u),g=Object.values(ge);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[(u.title||u.subtitle)&&e.jsxs("div",{className:"mb-4",children:[u.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),u.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:u.subtitle})]}),(W||g.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[W&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]}),g.map((P,k)=>e.jsx("p",{className:"text-red-600 text-sm",children:P},k))]}),m>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"0.5rem",marginBottom:"1rem"},children:[v.map((P,k)=>e.jsx("div",{style:{height:"0.375rem",borderRadius:"9999px",transition:"all 150ms",...k===ce?{flex:"1 1 0%",backgroundColor:"var(--metakyc-primary, #2563eb)"}:k<ce?{width:"2rem",backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{width:"2rem",backgroundColor:"#e5e7eb"}}},k)),e.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--metakyc-text-muted, #9ca3af)",flexShrink:0},children:[ce+1," / ",m]})]}),tt(u)]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{children:[!C&&e.jsx(J,{type:"button",variant:"outline",onClick:()=>{de(be),I({})},disabled:_||y,children:"Previous"}),C&&s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:_||y,children:"Cancel"})]}),e.jsx(J,{type:"button",isLoading:_||y,onClick:T?Oe:ve,children:T?u.conditionalOn&&!l?"Skip & Submit":"Submit":u.conditionalOn&&!l?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:et,children:e.jsxs(ee,{children:[e.jsx(he,{children:e.jsx(nt,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(te,{children:[W&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",W]})}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:"1rem"},children:M.map(u=>e.jsx("div",{style:{gridColumn:"span 4 / span 4"},children:Je(u)},u))})]}),e.jsxs(fe,{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[s&&e.jsx(J,{type:"button",variant:"outline",onClick:s,disabled:_||y,children:"Cancel"}),e.jsx(J,{type:"submit",isLoading:_||y,children:"Register Company"})]})]})})})},za=({applicantId:t,onComplete:r,onError:a,theme:s="light",className:n})=>{const{progress:o,currentStep:c,steps:d,workflowKey:y,nextWorkflowKey:p,hasWorkflowChanged:f,isLoading:F,error:b,moveBack:E,refreshProgress:A}=Cr(t),[v,S]=i.useState(!1),M=i.useRef(null);if(i.useEffect(()=>{b&&a&&a(b)},[b,a]),i.useEffect(()=>{o!=null&&o.workflowResult&&r&&r(o.workflowResult)},[o==null?void 0:o.workflowResult,r]),i.useEffect(()=>{s==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[s]),i.useEffect(()=>{f&&S(!1)},[f]),F||!o)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(b)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:b.message})]})})})});if(f&&!v)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsx(te,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:p})]})]}),o.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.nextWorkflowName})]}),e.jsx("button",{onClick:()=>S(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(o.status===Fe.Finished||o.status===Fe.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage,onContinue:r&&o.workflowResult?()=>r(o.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ee,{children:e.jsxs(te,{children:[e.jsx(Ee,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:o.status===Fe.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const V=U=>{switch(U){case oe.Overview:return"Overview";case oe.Questionaries:return"Questionnaire";case oe.UploadDocument:return"Documents";case oe.IdentitySdk:return"Identity";case oe.RiskScoring:return"Risk Assessment";case oe.InvestorCategorization:return"Investor Categorization";case oe.AppropriatenessTest:return"Appropriateness Test";case oe.AdditionalData:return"Additional Data";case oe.ManualReview:return"Review";default:return""}},L=()=>{const U=d.filter(q=>q.visibility!==!1),Z=U.findIndex(q=>q.order===c.order),R=Z>=0?Z+1:1,h=U.length,z=h>1?Z/(h-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px",backgroundColor:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",borderRadius:"0.75rem",border:"1px solid var(--metakyc-border, #e5e7eb)",padding:"1rem 1.5rem",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(nt,{}),e.jsxs(wt,{variant:o.status===1?"info":"success",children:["Step ",R," of ",h]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${z}%`,transition:"width 0.4s ease"}})})}),e.jsx(Oa,{ref:M,visibleSteps:U,currentVisibleStepIndex:Z,getStepFallbackName:V})]})},B=()=>{const U={applicantId:t,onComplete:async()=>{await A()},onBack:c.order>0?E:void 0};switch(c.action){case oe.Questionaries:return e.jsx(Or,{...U});case oe.UploadDocument:return e.jsx($r,{...U});case oe.Overview:return e.jsx(Br,{...U});case oe.IdentitySdk:return e.jsx(Ur,{...U});case oe.RiskScoring:return e.jsx(_r,{...U});case oe.AdditionalData:case oe.InvestorCategorization:return e.jsx(Hr,{...U});case oe.AppropriatenessTest:return e.jsx(Wr,{...U});case oe.ManualReview:return e.jsx(ft,{kycStatus:o.kycStatus,reviewStatus:o.reviewStatus,workflowResult:o.workflowResult,customMessage:o.customMessage});default:return e.jsx(ee,{children:e.jsxs(te,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ee,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",oe[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[L(),B()]})},Oa=i.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:a},s)=>{const n=i.useRef(null),o=i.useRef(null);return i.useImperativeHandle(s,()=>n.current),i.useEffect(()=>{if(o.current&&n.current){const c=n.current,d=o.current,y=d.offsetLeft-c.offsetWidth/2+d.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:n,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",width:"100%",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,d)=>{const y=d<r,p=d===r,f=y||p,F=c.displayName||c.name||a(c.action)||`Step ${d+1}`;return e.jsxs(i.Fragment,{children:[e.jsxs("div",{ref:p?o:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...f?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):d+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:p?600:400,color:p?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:F})]}),d<t.length-1&&e.jsx("div",{style:{flex:"1 1 0%",minWidth:"16px",height:"2px",margin:"0 8px",borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function $a(t){return Ue.z.object({questionResults:Ue.z.any()}).passthrough()}function Ba(t){let r=Ue.z.array(Ue.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(a=>!a||a.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(a=>!a||a.every(s=>s.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const a=t.allowedTypes.split(",").map(s=>s.trim());r=r.refine(s=>s?s.every(n=>a.some(o=>o.endsWith("/*")?n.type.startsWith(o.slice(0,-2)):n.type===o)):!0,{message:"Invalid file type"})}return r}function _a(t){const r={};return t.uploadDocumentFiles.forEach(a=>{const s=`file_${a.id}`;r[s]=Ba(a)}),Ue.z.object(r)}function Ha(t){return Ue.z.any()}function Wa(t){return Ue.z.string().min(1,"This question is required")}function Ua(t){const r={};return t.appropriatenessQuestions.forEach(a=>{const s=`question_${a.id}`;r[s]=Wa()}),Ue.z.object(r)}const Ka=Ue.z.any();exports.ALLOWED_LANGUAGES=ht;exports.ApplicantProgressOnHoldReason=Tt;exports.ApplicantProgressStatus=Fe;exports.ApplicantService=Vt;exports.ApplicantStatus=Lt;exports.AppropriatenessQuestionType=$t;exports.AppropriatenessTestService=Jt;exports.AppropriatenessTestStep=Wr;exports.Badge=wt;exports.BaseInformationService=tr;exports.Button=J;exports.COMPANY_FIELD_METADATA=Ze;exports.Card=ee;exports.CardContent=te;exports.CardFooter=fe;exports.CardHeader=he;exports.Checkbox=Te;exports.CountriesType=We;exports.CreateApplicantForm=Da;exports.CreateCompanyApplicantForm=Ma;exports.CriteriaBuiltInType=_t;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=Wt;exports.DEFAULT_VISIBLE_FIELDS=Ut;exports.DocumentReviewStatus=Ot;exports.EndpointBuilder=qt;exports.ErrorHandler=at;exports.EventEmitter=dr;exports.FIELD_METADATA=Ge;exports.FileType=zt;exports.FileUpload=Tr;exports.GenderType=lt;exports.Header=nt;exports.HttpClient=Yt;exports.IdentityProviderManager=He;exports.IdentityService=er;exports.IdentityVerificationProvider=Ae;exports.IdentityVerificationStep=Ur;exports.Input=ye;exports.InvestorCategorizationService=rr;exports.InvestorCategorizationStep=Hr;exports.InvestorCategorizationType=we;exports.InvestorCategoryType=Ht;exports.KycProcessStatus=Dt;exports.KycStatus=Ve;exports.KycStatusDisplay=ft;exports.KycWorkflow=za;exports.Logo=Kr;exports.MetaKYCContext=bt;exports.MetaKYCError=De;exports.MetaKYCProvider=aa;exports.MultiSelect=Fr;exports.OnfidoProvider=xr;exports.OverviewService=Xt;exports.OverviewStep=Br;exports.PhoneInput=Pr;exports.QuestionnaireService=Qt;exports.QuestionnaireStep=Or;exports.ReviewStatus=Qe;exports.RiskCriteriaType=Bt;exports.RiskLevel=Pt;exports.RiskScoringService=Zt;exports.RiskScoringStep=_r;exports.SDK_VERSION=fr;exports.SardinAIProvider=gr;exports.SearchableSelect=ze;exports.Select=ut;exports.Spinner=Ee;exports.StepRouter=pr;exports.SumsubProvider=yr;exports.ThemeManager=hr;exports.ThemePreset=je;exports.ThemeService=cr;exports.UploadDocumentService=Gt;exports.UploadDocumentStep=$r;exports.UserType=Mt;exports.ValueDataType=Me;exports.WorkflowOrchestrator=ur;exports.WorkflowResultType=ot;exports.WorkflowState=mr;exports.WorkflowStepAction=oe;exports.appropriatenessTestSchema=Ka;exports.clearAllStorage=la;exports.clearApplicantId=wr;exports.clearWorkflowState=Sr;exports.cn=Se;exports.corporateTheme=ar;exports.defaultConfig=Kt;exports.defaultTheme=Re;exports.fileToBase64=kr;exports.fintechTheme=sr;exports.formatFileSize=mt;exports.generateAppropriatenessSchema=Ua;exports.generateQuestionnaireSchema=$a;exports.generateRiskScoringSchema=Ha;exports.generateUploadDocumentSchema=_a;exports.getAcceptString=ia;exports.getApplicantId=vr;exports.getThemePreset=st;exports.getWorkflowState=oa;exports.healthcareTheme=nr;exports.isScriptLoaded=Jr;exports.loadScript=kt;exports.minimalTheme=or;exports.modernTheme=ir;exports.removeScript=Xr;exports.saveApplicantId=br;exports.saveWorkflowState=jr;exports.themePresets=lr;exports.useApplicant=vt;exports.useAppropriatenessTest=ca;exports.useIdentityVerification=Er;exports.useKycWorkflow=Cr;exports.useMetaKYC=Ne;exports.useOverview=Ir;exports.useQuestionnaire=Nr;exports.useRiskScoring=Ar;exports.useUploadDocument=Rr;exports.validateFileSize=sa;exports.validateFileType=na;
|
|
103
125
|
//# sourceMappingURL=index.cjs.map
|