@vpdev2/metakyc-sdk 1.0.38 → 1.0.39

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.
@@ -1 +1 @@
1
- {"version":3,"file":"useRiskScoring.d.ts","sourceRoot":"","sources":["../../src/hooks/useRiskScoring.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpF,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE/C;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM;;;;;;;;oBA+DjC,oBAAoB,KAAG,OAAO,CAAC,iBAAiB,CAAC;EA4BlE"}
1
+ {"version":3,"file":"useRiskScoring.d.ts","sourceRoot":"","sources":["../../src/hooks/useRiskScoring.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpF,KAAK,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AAE/C;;GAEG;AACH,wBAAgB,cAAc,CAAC,WAAW,CAAC,EAAE,MAAM;;;;;;;;oBAqEjC,oBAAoB,KAAG,OAAO,CAAC,iBAAiB,CAAC;EA4BlE"}
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var qt=Object.defineProperty;var Ht=(e,t,s)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var _=(e,t,s)=>Ht(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("axios"),o=require("react"),r=require("react/jsx-runtime"),ue=require("react-hook-form"),ce=require("zod");function Yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Re=Yt(o);var T=(e=>(e[e.IdentitySdk=0]="IdentitySdk",e[e.RiskScoring=1]="RiskScoring",e[e.Questionaries=2]="Questionaries",e[e.AdditionalData=3]="AdditionalData",e[e.AppropriatenessTest=4]="AppropriatenessTest",e[e.UploadDocument=5]="UploadDocument",e[e.ManualReview=6]="ManualReview",e[e.Overview=7]="Overview",e[e.InvestorCategorization=8]="InvestorCategorization",e))(T||{}),ye=(e=>(e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Success=2]="Success",e[e.PartialSuccess=3]="PartialSuccess",e[e.Failed=4]="Failed",e[e.Skipped=5]="Skipped",e[e.AdminReview=6]="AdminReview",e[e.SkippedAndAdminReview=7]="SkippedAndAdminReview",e))(ye||{}),se=(e=>(e[e.None=0]="None",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.OnHold=3]="OnHold",e[e.IdentityPending=4]="IdentityPending",e))(se||{}),De=(e=>(e[e.None=0]="None",e[e.RepresentativeKYC=1]="RepresentativeKYC",e[e.ManualRiskCriteria=2]="ManualRiskCriteria",e[e.UploadDocumentReview=3]="UploadDocumentReview",e[e.AdminReview=4]="AdminReview",e))(De||{}),Fe=(e=>(e[e.LowRisk=0]="LowRisk",e[e.MediumRisk=1]="MediumRisk",e[e.HighRisk=2]="HighRisk",e[e.Alert=3]="Alert",e))(Fe||{}),me=(e=>(e[e.None=0]="None",e[e.Pending=1]="Pending",e[e.Approved=2]="Approved",e[e.Rejected=3]="Rejected",e[e.ResendRequested=4]="ResendRequested",e[e.Unknown=5]="Unknown",e[e.InProgress=6]="InProgress",e))(me||{}),pe=(e=>(e[e.Approved=0]="Approved",e[e.Reject=1]="Reject",e[e.UnderReview=2]="UnderReview",e[e.Closed=3]="Closed",e[e.AdminReview=4]="AdminReview",e[e.New=5]="New",e[e.InProgress=6]="InProgress",e))(pe||{}),Pe=(e=>(e[e.ProviderResultPending=0]="ProviderResultPending",e[e.ProviderResultReceived=1]="ProviderResultReceived",e[e.Canceled=2]="Canceled",e[e.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",e))(Pe||{}),Le=(e=>(e[e.None=0]="None",e[e.ProviderResultPending=1]="ProviderResultPending",e[e.ProviderResultReceived=2]="ProviderResultReceived",e[e.Canceled=3]="Canceled",e))(Le||{}),re=(e=>(e[e.Onfido=0]="Onfido",e[e.Sumsub=2]="Sumsub",e[e.SardinAI=3]="SardinAI",e))(re||{}),Te=(e=>(e[e.Individual=0]="Individual",e[e.Company=1]="Company",e))(Te||{}),be=(e=>(e[e.Male=0]="Male",e[e.Female=1]="Female",e[e.Other=2]="Other",e))(be||{}),Me=(e=>(e[e.Image=0]="Image",e[e.Video=1]="Video",e[e.PDF=2]="PDF",e[e.OfficePDF=3]="OfficePDF",e[e.Custom=4]="Custom",e))(Me||{}),Oe=(e=>(e[e.Pending=0]="Pending",e[e.Approved=1]="Approved",e[e.Rejected=2]="Rejected",e[e.RequiresRevision=3]="RequiresRevision",e))(Oe||{}),ze=(e=>(e[e.SingleChoice=0]="SingleChoice",e[e.MultipleChoice=1]="MultipleChoice",e[e.Text=2]="Text",e))(ze||{}),oe=(e=>(e[e.String=0]="String",e[e.Integer=1]="Integer",e[e.Decimal=2]="Decimal",e[e.Boolean=3]="Boolean",e[e.Date=4]="Date",e[e.Country=5]="Country",e[e.DigitOnly=6]="DigitOnly",e))(oe||{}),Be=(e=>(e[e.Text=0]="Text",e[e.Radio=1]="Radio",e[e.Checkbox=2]="Checkbox",e[e.Dropdown=3]="Dropdown",e[e.Country=4]="Country",e))(Be||{}),Ke=(e=>(e[e.None=0]="None",e[e.Country=1]="Country",e))(Ke||{}),J=(e=>(e[e.Individual=0]="Individual",e[e.Sophisticated=1]="Sophisticated",e[e.HighNetWorth=2]="HighNetWorth",e[e.Business=3]="Business",e))(J||{}),Ue=(e=>(e[e.Retail=0]="Retail",e[e.Professional=1]="Professional",e[e.EligibleCounterparty=2]="EligibleCounterparty",e))(Ue||{});const je=[{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"}],_e=["firstName","lastName","email","phonenumber","dateOfBirth","street","streetNumber","zip","city","country","nationality","taxCountry","taxNumber"],Qt=["firstName","lastName","title","email","dateOfBirth","phonenumber","mobileCountryCode","street","streetNumber","zip","city","country","nationality","otherNationality","defaultLanguage","taxCountry","placeOfBirth","countryOfBirth","salutation","educationLevel","occupation","taxNumber","externalRefId"],Se={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},title:{label:"Title",type:"text"},email:{label:"Email",type:"email"},dateOfBirth:{label:"Date of Birth",type:"date"},phonenumber:{label:"Phone Number",type:"tel"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP/Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},defaultLanguage:{label:"Default Language",type:"select"},taxCountry:{label:"Tax Country",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},countryOfBirth:{label:"Country of Birth",type:"select"},salutation:{label:"Salutation",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"},taxNumber:{label:"Tax Number",type:"text"},externalRefId:{label:"External Reference ID",type:"text"}};var Y=(e=>(e.Default="default",e.Corporate="corporate",e.Fintech="fintech",e.Healthcare="healthcare",e.Modern="modern",e.Minimal="minimal",e))(Y||{});const $e={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class qe{constructor(t){this.config=t}build(t,s){const a=`${t}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${t}/${s}`;case"application-service":return`/services/app/${this.getServiceName(t)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(t){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[t]||t}}class ne extends Error{constructor(s,a,n,i,l){super(s);_(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=l,Object.setPrototypeOf(this,ne.prototype)}}class ge{static handleApiError(t){return new ne(t.message||"An unknown error occurred",t.code,t.details||void 0,t.validationErrors||void 0)}static handleAxiosError(t){if(t.response){const s=t.response.data;return s&&s.error?new ne(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,t.response):s&&s.result&&s.result.message?new ne(s.result.message,t.response.status,`HTTP ${t.response.status}: ${t.response.statusText}`,void 0,t.response):new ne((s==null?void 0:s.message)||t.message||"Request failed",t.response.status,`HTTP ${t.response.status}: ${t.response.statusText}`,void 0,t.response)}else return t.request?new ne("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ne(t.message||"An unexpected error occurred",0,t.toString())}static isMetaKYCError(t){return t instanceof ne}}class He{constructor(t){_(this,"axiosInstance");_(this,"endpointBuilder");_(this,"config");this.config={...$e,...t},this.endpointBuilder=new qe(this.config.endpoints),this.axiosInstance=Wt.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(t,s){return this.endpointBuilder.build(t,s)}async get(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async post(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async put(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async delete(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}handleResponse(t){const s=t.data;if(!s.success&&s.error)throw ge.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class We{constructor(t){this.httpClient=t}async createApplicant(t){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",t)).result}async createCompanyApplicant(t){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",t)).result}async duplicateApplicant(t){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",t)).result}async getProgress(t){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:t})).result}async getProgressStatus(t){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:t})).result}async getApplicantData(t){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:t})).result}async getApplicantStatus(t){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:t})).result}async stopProgress(t){await this.httpClient.get("Applicant","StopProgress",{applicantId:t})}async progressStepBack(t){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:t})}async setLanguage(t,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:t,language:s})}async activateApplicant(t){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:t})}async deleteApplicant(t){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:t})}async checkApplicantExists(t){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:t})).result}}class Ye{constructor(t){this.httpClient=t}async getQuestionnaire(t){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:t})).result}async fillQuestionnaire(t){return(await this.httpClient.post("Applicant","FillQuestionnarie",t)).result}}class Qe{constructor(t){this.httpClient=t}async getUploadDocument(t){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:t})).result}async fillUploadDocument(t){await this.httpClient.post("Applicant","FillUploadDocument",t)}async reviewUploadDocument(t){await this.httpClient.post("UploadDocument","ReviewUploadDocument",t)}}class Ve{constructor(t){this.httpClient=t}async getAppropriatenessTest(t){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:t})).result}async fillAppropriatenessTest(t){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",t)).result}}class Ge{constructor(t){this.httpClient=t}async getOverviewData(t){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:t})).result}async passOverview(t){await this.httpClient.get("Applicant","PassOverview",{applicantId:t})}}class Ze{constructor(t){this.httpClient=t}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(t){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:t})).result}async submitRiskScoring(t){return(await this.httpClient.post("Applicant","RiskScoringRequest",t)).result}}class Je{constructor(t){this.httpClient=t}async identityRequest(t){console.log("[IdentityService] Calling IdentityRequest with input:",t);const s=await this.httpClient.post("Applicant","IdentityRequest",t);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(t){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",t)).result}async restartIdentityRequest(t){const s={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(t){const s={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class Xe{constructor(t){this.httpClient=t}async getCountries(t,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:t||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class et{constructor(t){this.httpClient=t}async setInvestorCategorization(t){return(await this.httpClient.post("Applicant","SetInvestorCategorization",t)).result}async getInvestorCategorization(t){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:t})).result}}const V={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"}}},tt={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"}},rt={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"}},st={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"}}},at={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"}},nt={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"}},it={[Y.Default]:V,[Y.Corporate]:tt,[Y.Fintech]:rt,[Y.Healthcare]:st,[Y.Modern]:at,[Y.Minimal]:nt};function xe(e){return it[e]||V}class ot{constructor(t){this.httpClient=t}async getThemeConfiguration(){var t;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return xe(Y.Default);let a=s.result.preset?xe(s.result.preset):xe(Y.Default);return s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(t=a.darkMode)==null?void 0:t.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),xe(Y.Default)}}async saveThemeConfiguration(t){await this.httpClient.post("Tenant","SaveThemeConfiguration",t)}getAvailablePresets(){return[{id:Y.Default,name:"Default"},{id:Y.Corporate,name:"Corporate"},{id:Y.Fintech,name:"Fintech"},{id:Y.Healthcare,name:"Healthcare"},{id:Y.Modern,name:"Modern"},{id:Y.Minimal,name:"Minimal"}]}getPreviewTheme(t,s){const a=xe(t);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class lt{constructor(){_(this,"listeners",new Map)}on(t,s){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(s),()=>{this.off(t,s)}}off(t,s){const a=this.listeners.get(t);a&&a.delete(s)}emit(t,s){const a=this.listeners.get(t);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${t}":`,i)}})}clear(){this.listeners.clear()}clearEvent(t){this.listeners.delete(t)}}class ct{constructor(){_(this,"events",new lt);_(this,"_applicantId",null);_(this,"_progress",null);_(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var t;return((t=this._progress)==null?void 0:t.currentStep)||null}get steps(){var t;return((t=this._progress)==null?void 0:t.stepInfoList)||[]}get status(){var t;return((t=this._progress)==null?void 0:t.status)||se.None}get workflowResult(){var t;return((t=this._progress)==null?void 0:t.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===se.Finished}get isOnHold(){return this.status===se.OnHold}get isInProgress(){return this.status===se.InProgress}setApplicantId(t){this._applicantId=t}updateProgress(t){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=t,this._applicantId=t.applicantId,this._error=null,this.events.emit("progressUpdated",t),(s==null?void 0:s.order)!==((n=t.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",t.currentStep),this.events.emit("statusChanged",t.status),t.status===se.Finished&&t.workflowResult&&this.events.emit("completed",t.workflowResult)}setError(t){this._error=t,this.events.emit("error",t)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(t){return this.events.on("progressUpdated",t)}onStepChanged(t){return this.events.on("stepChanged",t)}onStatusChanged(t){return this.events.on("statusChanged",t)}onError(t){return this.events.on("error",t)}onCompleted(t){return this.events.on("completed",t)}clearListeners(){this.events.clear()}}class dt{constructor(){_(this,"handlers",new Map)}registerHandler(t,s){this.handlers.set(t,s)}getHandler(t){return this.handlers.get(t)}hasHandler(t){return this.handlers.has(t)}async loadStepData(t,s){const a=this.getHandler(t);if(!a)throw new Error(`No handler registered for step action: ${T[t]}`);return a.loadData(s)}async submitStepData(t,s){const a=this.getHandler(t);if(!a)throw new Error(`No handler registered for step action: ${T[t]}`);return a.submitData(s)}}class ut{constructor(t,s,a,n,i,l,c,d){_(this,"state");_(this,"stepRouter");this.applicantService=t,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=l,this.investorCategorizationService=d,this.state=new ct,this.stepRouter=new dt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(T.Questionaries,{loadData:t=>this.questionnaireService.getQuestionnaire(t),submitData:async t=>{await this.questionnaireService.fillQuestionnaire(t)}}),this.stepRouter.registerHandler(T.UploadDocument,{loadData:t=>this.uploadDocumentService.getUploadDocument(t),submitData:t=>this.uploadDocumentService.fillUploadDocument(t)}),this.stepRouter.registerHandler(T.AppropriatenessTest,{loadData:t=>this.appropriatenessTestService.getAppropriatenessTest(t),submitData:async t=>{await this.appropriatenessTestService.fillAppropriatenessTest(t)}}),this.stepRouter.registerHandler(T.Overview,{loadData:t=>this.overviewService.getOverviewData(t),submitData:t=>this.overviewService.passOverview(t.applicantId)}),this.stepRouter.registerHandler(T.RiskScoring,{loadData:t=>this.riskScoringService.getRiskCriterias(t),submitData:async t=>{await this.riskScoringService.submitRiskScoring(t)}}),this.stepRouter.registerHandler(T.IdentitySdk,{loadData:async t=>({applicantId:t,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(T.InvestorCategorization,{loadData:t=>this.investorCategorizationService.getInvestorCategorization(t),submitData:async t=>{await this.investorCategorizationService.setInvestorCategorization(t)}}),this.stepRouter.registerHandler(T.ManualReview,{loadData:async t=>({applicantId:t,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(T.AdditionalData,{loadData:async t=>({applicantId:t,message:"Additional data required"}),submitData:async()=>{}})}async initialize(t){try{this.state.setApplicantId(t);const s=await this.applicantService.getProgress(t);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const t=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(t),t}catch(t){throw this.state.setError(t),t}}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(t){throw this.state.setError(t),t}}async submitCurrentStep(t){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,t),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(t){throw this.state.setError(t),t}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function Ce(e,t){return new Promise((s,a)=>{if(t&&document.getElementById(t)){s();return}const n=document.createElement("script");n.src=e,t&&(n.id=t),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${e}`)),document.head.appendChild(n)})}function Vt(e){return!!document.getElementById(e)}function Gt(e){const t=document.getElementById(e);t&&t.remove()}class mt{constructor(t){_(this,"sdk",null);_(this,"config");this.config=t}async loadSDK(){await Ce("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(t){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${t}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(t){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&t(s)})}onError(t){this.sdk&&this.sdk.on("idCheck.onError",t)}}class pt{constructor(t){_(this,"sdk",null);_(this,"config");this.config=t}async loadSDK(){await Ce("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(t){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:t,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class ht{constructor(t){_(this,"sardineContext",null);_(this,"config");_(this,"sessionKey");this.config=t,this.sessionKey=t.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:t,region:s}=this.config;if(t==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((t,s)=>{if(window._Sardine){t();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),t()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const t=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:l}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:l===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,u)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",u);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(t),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(t){throw console.error("[SardinAI] Initialization failed:",t),t}}addNoScriptFallback(t){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${t}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(t){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}t.sessionKey&&(this.sessionKey=t.sessionKey),this.sardineContext.updateConfig({...t,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class he{static createProvider(t,s){switch(t){case re.Sumsub:return new mt(s);case re.Onfido:return new pt(s);case re.SardinAI:return new ht(s);default:throw new Error(`Unsupported identity provider: ${t}`)}}static parseProviderConfig(t,s,a){var n;switch(t){case re.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case re.Onfido:return{token:s.token||s.sdkToken};case re.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${t}`)}}}class gt{constructor(t){_(this,"currentTheme",V);_(this,"customStyleElement",null);_(this,"container");this.container=t||document.documentElement}applyTheme(t){this.currentTheme=this.mergeWithDefault(t),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(t){var a;const s={primary:t.primary,"primary-hover":t.primaryHover,"primary-light":t.primaryLight,"primary-dark":t.primaryDark,secondary:t.secondary,"secondary-hover":t.secondaryHover,success:t.success,warning:t.warning,danger:t.danger,info:t.info,background:t.background,surface:t.surface,border:t.border,"text-primary":t.textPrimary,"text-secondary":t.textSecondary,"text-muted":t.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(t){Object.entries(t).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(t){t&&(t.fontFamily&&this.container.style.setProperty("--metakyc-font-family",t.fontFamily),t.headingFont&&this.container.style.setProperty("--metakyc-heading-font",t.headingFont),t.fontSize&&Object.entries(t.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),t.fontWeight&&Object.entries(t.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(t){t&&Object.entries(t).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(t){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=t,document.head.appendChild(this.customStyleElement)}mergeWithDefault(t){var s;return{name:t.name||V.name,title:t.title||V.title,logo:{...V.logo,...t.logo},colors:{...V.colors,...t.colors},typography:t.typography?{...V.typography,...t.typography}:V.typography,spacing:t.spacing?{...V.spacing,...t.spacing}:V.spacing,customCSS:t.customCSS,darkMode:t.darkMode?{colors:{...(s=V.darkMode)==null?void 0:s.colors,...t.darkMode.colors}}:V.darkMode,applicantFormVisibleFields:t.applicantFormVisibleFields,applicantFormRequiredFields:t.applicantFormRequiredFields,allowedLanguages:t.allowedLanguages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(V)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ae=o.createContext(null),Zt=({config:e,children:t})=>{const[s,a]=o.useState(null),n=o.useRef(!1),i=o.useRef(!1),l=o.useMemo(()=>{const d=new He(e),u=new We(d),v=new Ye(d),w=new Qe(d),g=new Ve(d),m=new Ge(d),p=new Ze(d),k=new Je(d),f=new Xe(d),x=new et(d),A=new ot(d),j=new gt;return{httpClient:d,applicantService:u,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:g,overviewService:m,riskScoringService:p,identityService:k,baseInformationService:f,investorCategorizationService:x,themeService:A,themeManager:j}},[e]),c=o.useMemo(()=>({config:e,...l,currentTheme:s,createOrchestrator:()=>new ut(l.applicantService,l.questionnaireService,l.uploadDocumentService,l.appropriatenessTestService,l.overviewService,l.riskScoringService,l.identityService,l.investorCategorizationService)}),[e,l,s]);return o.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(e.theme){console.log("[MetaKYC] Applying static theme from config"),l.themeManager.applyTheme(e.theme),a(l.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const u=await l.themeService.getThemeConfiguration();l.themeManager.applyTheme(u),a(l.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",u)}catch(u){console.warn("[MetaKYC] Failed to load theme, using default:",u),a(l.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{l.themeManager.cleanup()}),[]),r.jsx(Ae.Provider,{value:c,children:t})};function te(){const e=o.useContext(Ae);if(!e)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return e}async function xt(e){return new Promise((t,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const i=a.result.split(",")[1];t(i)},a.onerror=n=>s(n)})}function Jt(e,t){return e.size<=t}function Xt(e,t){return t.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return e.type.startsWith(n)}return e.type===a})}function ve(e){if(e===0)return"0 Bytes";const t=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,a)*100)/100+" "+s[a]}function er(e){return e}function Q(...e){return e.filter(Boolean).join(" ")}const fe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function ft(e){try{localStorage.setItem(fe.APPLICANT_ID,e.toString())}catch(t){console.warn("Failed to save applicant ID to storage:",t)}}function yt(){try{const e=localStorage.getItem(fe.APPLICANT_ID);return e?parseInt(e,10):null}catch(e){return console.warn("Failed to retrieve applicant ID from storage:",e),null}}function bt(){try{localStorage.removeItem(fe.APPLICANT_ID)}catch(e){console.warn("Failed to clear applicant ID from storage:",e)}}function vt(e){try{localStorage.setItem(fe.WORKFLOW_STATE,JSON.stringify(e))}catch(t){console.warn("Failed to save workflow state to storage:",t)}}function tr(){try{const e=localStorage.getItem(fe.WORKFLOW_STATE);return e?JSON.parse(e):null}catch(e){return console.warn("Failed to retrieve workflow state from storage:",e),null}}function wt(){try{localStorage.removeItem(fe.WORKFLOW_STATE)}catch(e){console.warn("Failed to clear workflow state from storage:",e)}}function rr(){bt(),wt()}function kt(e){const{createOrchestrator:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(null),d=o.useRef(null),u=e||yt();o.useEffect(()=>{d.current||(d.current=t())},[t]),o.useEffect(()=>{var j;s&&u&&(ft(u),vt({applicantId:u,currentStepOrder:(j=s.currentStep)==null?void 0:j.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,u]);const v=o.useRef(!1),w=o.useRef(!1),g=o.useCallback(async()=>{if(!(!u||!d.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await d.current.initialize(u);a(j),w.current=!0}catch(j){c(j)}finally{i(!1),v.current=!1}}},[u]);o.useEffect(()=>{u&&!w.current&&g()},[u,g]);const m=o.useCallback(async()=>{if(d.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await d.current.refreshProgress();a(j)}catch(j){c(j)}finally{i(!1),v.current=!1}}},[]),p=o.useCallback(async()=>{if(d.current){i(!0),c(null);try{const j=await d.current.moveToNextStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),k=o.useCallback(async()=>{if(d.current){i(!0),c(null);try{const j=await d.current.moveToPreviousStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),f=o.useCallback(async j=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(j);const S=await d.current.refreshProgress();a(S)}catch(S){throw c(S),S}finally{i(!1)}}},[]),x=Re.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((j,S)=>j.order-S.order):[],[s==null?void 0:s.stepInfoList]),A=Re.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:u,currentStep:(s==null?void 0:s.currentStep)||null,steps:x,status:(s==null?void 0:s.status)||se.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:A,isLoading:n,error:l,isComplete:(s==null?void 0:s.status)===se.Finished,isOnHold:(s==null?void 0:s.status)===se.OnHold,refreshProgress:m,moveToNext:p,moveBack:k,submitCurrentStep:f,orchestrator:d.current}}function jt(e){const{questionnaireService:t,applicantService:s}=te(),[a,n]=o.useState(null),[i,l]=o.useState({}),[c,d]=o.useState(!1),[u,v]=o.useState(!1),[w,g]=o.useState(null),m=o.useRef(!1),p=o.useRef(null),k=o.useCallback(async()=>{var x,A;if(e){if(m.current){console.log("[Questionnaire] Load already in progress, skipping...");return}m.current=!0,d(!0),g(null);try{const[j,S]=await Promise.all([t.getQuestionnaire(e),s.getApplicantData(e).catch(()=>null)]);if(n(j),(x=S==null?void 0:S.questionnaireResults)!=null&&x.length&&j){const M=new Map;for(const h of S.questionnaireResults)h.question&&((A=h.answers)!=null&&A.length)&&M.set(h.question.trim().toLowerCase(),h.answers);const H={},I=j.questionGroups.flatMap(h=>h.questions??[]);for(const h of I){const N=h.text.trim().toLowerCase();M.has(N)&&(H[h.id]=M.get(N))}l(H)}p.current=e}catch(j){g(j)}finally{d(!1),m.current=!1}}},[e,t,s]);o.useEffect(()=>{e&&p.current!==e&&k()},[e]);const f=o.useCallback(async x=>{v(!0),g(null);try{return await t.fillQuestionnaire(x)}catch(A){throw g(A),A}finally{v(!1)}},[t]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:u,error:w,load:k,submit:f}}function St(e){const{uploadDocumentService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(0),[v,w]=o.useState(null),g=o.useRef(!1),m=o.useRef(null),p=o.useCallback(async()=>{if(e){if(g.current){console.log("[UploadDocument] Load already in progress, skipping...");return}g.current=!0,i(!0),w(null);try{const f=await t.getUploadDocument(e);a(f),m.current=e}catch(f){w(f)}finally{i(!1),g.current=!1}}},[e,t]);o.useEffect(()=>{e&&m.current!==e&&p()},[e]);const k=o.useCallback(async f=>{c(!0),u(0),w(null);try{await t.fillUploadDocument(f),u(100)}catch(x){throw w(x),x}finally{c(!1)}},[t]);return{uploadDocument:s,isLoading:n,isSubmitting:l,uploadProgress:d,error:v,load:p,submit:k}}function sr(e){const{appropriatenessTestService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(null),[v,w]=o.useState(null),g=o.useRef(!1),m=o.useRef(null),p=o.useCallback(async()=>{if(e){if(g.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const f=await t.getAppropriatenessTest(e);a(f),m.current=e}catch(f){u(f)}finally{i(!1),g.current=!1}}},[e,t]);o.useEffect(()=>{e&&m.current!==e&&p()},[e]);const k=o.useCallback(async f=>{c(!0),u(null);try{const x=await t.fillAppropriatenessTest(f);return w(x),x}catch(x){throw u(x),x}finally{c(!1)}},[t]);return{test:s,result:v,isLoading:n,isSubmitting:l,error:d,load:p,submit:k}}function Nt(e){const{overviewService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(null),v=o.useRef(!1),w=o.useRef(null),g=o.useCallback(async()=>{if(e){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),u(null);try{const p=await t.getOverviewData(e);a(p),w.current=e}catch(p){u(p)}finally{i(!1),v.current=!1}}},[e,t]);o.useEffect(()=>{e&&w.current!==e&&g()},[e]);const m=o.useCallback(async()=>{if(e){c(!0),u(null);try{await t.passOverview(e)}catch(p){throw u(p),p}finally{c(!1)}}},[e,t]);return{overview:s,isLoading:n,isSubmitting:l,error:d,load:g,passOverview:m}}function Ct(e){const{identityService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(null),d=o.useRef(!1),u=o.useCallback(async(g,m)=>{if(e){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const p={applicantId:e,restart:!1,redirectUrl:g||"",ttl:m||604800};console.log("Identity request input:",p);const k=await t.identityRequest(p);return console.log("Identity request result:",k),a(k),k}catch(p){throw c(p),p}finally{i(!1),d.current=!1}}},[e,t]),v=o.useCallback(async(g,m)=>{if(e){i(!0),c(null);try{const p={applicantId:e,restart:!1,redirectUrl:g,ttl:m},k=await t.identityCompanyRequest(p);return a(k),k}catch(p){throw c(p),p}finally{i(!1)}}},[e,t]),w=o.useCallback(async()=>{if(e){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",g);const m=await t.identityRequest(g);return console.log("Restart identity result:",m),a(m),m}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[e,t]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:l,requestIdentity:u,requestCompanyIdentity:v,restartIdentity:w}}function At(e){const{riskScoringService:t,applicantService:s}=te(),[a,n]=o.useState(null),[i,l]=o.useState({}),[c,d]=o.useState(!1),[u,v]=o.useState(!1),[w,g]=o.useState(null),[m,p]=o.useState(null),k=o.useRef(!1),f=o.useRef(null),x=o.useCallback(async()=>{var j;if(e){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,d(!0),g(null);try{const[S,M]=await Promise.all([t.getRiskCriterias(e),s.getApplicantData(e).catch(()=>null)]);if(n(S),(j=M==null?void 0:M.riskScoringResults)!=null&&j.length){const H=M.riskScoringResults[0],I={};for(const h of H.riskCriteriaResults??[])h.riskCriteriaId!=null&&h.answer!=null&&h.answer!==""&&(I[h.riskCriteriaId]=[h.answer]);l(I)}f.current=e}catch(S){g(S)}finally{d(!1),k.current=!1}}},[e,t,s]);o.useEffect(()=>{e&&f.current!==e&&x()},[e]);const A=o.useCallback(async j=>{v(!0),g(null);try{const S=await t.submitRiskScoring(j);return p(S),S}catch(S){throw g(S),S}finally{v(!1)}},[t]);return{criteria:a,initialAnswers:i,result:m,isLoading:c,isSubmitting:u,error:w,load:x,submit:A}}function Et(){const{applicantService:e,config:t}=te(),[s,a]=o.useState(!1),[n,i]=o.useState(null),l=o.useRef(!1),c=o.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){const p=Math.random()*16|0;return(m==="x"?p:p&3|8).toString(16)}),u=o.useCallback(async m=>{var p;if(l.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");l.current=!0,a(!0),i(null);try{if(m.applicantAdditionalDatas||(m.applicantAdditionalDatas=[]),(p=t.identityProviders)!=null&&p.sardinai){const f=d();console.log("[SardinAI] Generated session key:",f),m.applicantAdditionalDatas.push({paramName:"sessionKey",value:f})}return await e.createApplicant(m)}catch(k){throw i(k),k}finally{a(!1),l.current=!1}},[e,t]),v=o.useCallback(async m=>{a(!0),i(null);try{return await e.createCompanyApplicant(m)}catch(p){throw i(p),p}finally{a(!1)}},[e]),w=o.useCallback(async m=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await e.getApplicantData(m)}catch(p){throw i(p),p}finally{a(!1),c.current=!1}},[e]),g=o.useCallback(async m=>{a(!0),i(null);try{await e.stopProgress(m)}catch(p){throw i(p),p}finally{a(!1)}},[e]);return{isLoading:s,error:n,createApplicant:u,createCompanyApplicant:v,getApplicantData:w,stopProgress:g}}const z=({children:e,variant:t="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...l})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},u={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return r.jsxs("button",{className:Q(c,d[t],u[s],i),disabled:n||a,...l,children:[a&&r.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e]})},X=o.forwardRef(({label:e,error:t,helperText:s,leftIcon:a,rightIcon:n,className:i,...l},c)=>r.jsxs("div",{className:"w-full",children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[a&&r.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),r.jsx("input",{ref:c,className:Q("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",t?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...l}),n&&r.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t}),!t&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));X.displayName="Input";const P=({children:e,className:t,...s})=>r.jsx("div",{className:Q("metakyc-card rounded-xl shadow-sm border",t),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),G=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4 border-b",t),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),L=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4",t),...s,children:e}),ee=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4 border-t",t),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),ie=({children:e,variant:t="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return r.jsx("span",{className:Q("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[t],s),...a,children:e})},ae=({size:e="md",className:t,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return r.jsx("div",{className:Q("flex items-center justify-center",t),...s,children:r.jsxs("svg",{className:Q("animate-spin text-primary-500",a[e]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},le=o.forwardRef(({label:e,error:t,helperText:s,options:a,placeholder:n,className:i,...l},c)=>r.jsxs("div",{className:"w-full",children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("select",{ref:c,className:Q("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",t?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...l,children:[n&&r.jsx("option",{value:"",disabled:!0,children:n},"__placeholder__"),a.map((d,u)=>r.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${u}`))]}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t}),!t&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));le.displayName="Select";const Rt=({label:e,value:t,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:l=!1})=>{const[c,d]=o.useState(!1),[u,v]=o.useState(""),w=o.useRef(null);o.useEffect(()=>{const f=x=>{w.current&&!w.current.contains(x.target)&&(d(!1),v(""))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const g=a.filter(f=>f.label.toLowerCase().includes(u.toLowerCase())),m=f=>{i||(t.includes(f)?s(t.filter(x=>x!==f)):s([...t,f]))},p=(f,x)=>{x.stopPropagation(),i||s(t.filter(A=>A!==f))},k=f=>{var x;return((x=a.find(A=>A.value===f))==null?void 0:x.label)||f};return r.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l&&r.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[r.jsxs("div",{onClick:()=>!i&&d(!c),className:Q("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[t.length===0?r.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):r.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:t.map(f=>r.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(f),!i&&r.jsx("button",{type:"button",onClick:x=>p(f,x),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:"×"})]},f))}),r.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&r.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[r.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:r.jsx("input",{type:"text",value:u,onChange:f=>v(f.target.value),placeholder:"Search...",autoFocus:!0,onClick:f=>f.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),r.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:g.length===0?r.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):g.map(f=>r.jsxs("li",{onClick:()=>m(f.value),className:Q("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",t.includes(f.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[r.jsx("input",{type:"checkbox",checked:t.includes(f.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),r.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:f.label})]},f.value))}),t.length>0&&r.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:r.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",t.length," selected)"]})})]})]})]})},It=({label:e,error:t,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:l=[],className:c})=>{const[d,u]=o.useState(!1),v=o.useRef(null),w=x=>{if(!x)return;const A=Array.from(x);if(n&&A.filter(S=>S.size>n).length>0){const S=ve(n);alert(`Some files exceed the maximum size of ${S}`);return}i==null||i(a?[...l,...A]:[A[0]])},g=x=>{x.preventDefault(),u(!0)},m=()=>{u(!1)},p=x=>{x.preventDefault(),u(!1),w(x.dataTransfer.files)},k=()=>{var x;(x=v.current)==null||x.click()},f=x=>{const A=l.filter((j,S)=>S!==x);i==null||i(A)};return r.jsxs("div",{className:Q("w-full",c),children:[e&&r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e}),r.jsxs("div",{className:Q("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",t&&"border-danger-500"),onDragOver:g,onDragLeave:m,onDrop:p,onClick:k,children:[r.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:x=>w(x.target.files)}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:r.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&r.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",ve(n)]})]})]}),l.length>0&&r.jsx("div",{className:"mt-3 space-y-2",children:l.map((x,A)=>r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[r.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),r.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:x.name}),r.jsxs("span",{className:"text-xs text-gray-500",children:["(",ve(x.size),")"]})]}),r.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),f(A)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:r.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},A))}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t})]})},Dt=o.forwardRef(({countryCode:e="+1",onCountryCodeChange:t,className:s,...a},n)=>r.jsxs("div",{className:"w-full",children:[a.label&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),className:Q("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),r.jsx(X,{ref:n,type:"tel",className:Q("flex-1",s),...a,label:""})]}),a.error&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Dt.displayName="PhoneInput";/**
1
+ "use strict";var qt=Object.defineProperty;var Ht=(e,t,s)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var _=(e,t,s)=>Ht(e,typeof t!="symbol"?t+"":t,s);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Wt=require("axios"),o=require("react"),r=require("react/jsx-runtime"),ue=require("react-hook-form"),ce=require("zod");function Yt(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const s in e)if(s!=="default"){const a=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,a.get?a:{enumerable:!0,get:()=>e[s]})}}return t.default=e,Object.freeze(t)}const Re=Yt(o);var T=(e=>(e[e.IdentitySdk=0]="IdentitySdk",e[e.RiskScoring=1]="RiskScoring",e[e.Questionaries=2]="Questionaries",e[e.AdditionalData=3]="AdditionalData",e[e.AppropriatenessTest=4]="AppropriatenessTest",e[e.UploadDocument=5]="UploadDocument",e[e.ManualReview=6]="ManualReview",e[e.Overview=7]="Overview",e[e.InvestorCategorization=8]="InvestorCategorization",e))(T||{}),ye=(e=>(e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Success=2]="Success",e[e.PartialSuccess=3]="PartialSuccess",e[e.Failed=4]="Failed",e[e.Skipped=5]="Skipped",e[e.AdminReview=6]="AdminReview",e[e.SkippedAndAdminReview=7]="SkippedAndAdminReview",e))(ye||{}),se=(e=>(e[e.None=0]="None",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.OnHold=3]="OnHold",e[e.IdentityPending=4]="IdentityPending",e))(se||{}),De=(e=>(e[e.None=0]="None",e[e.RepresentativeKYC=1]="RepresentativeKYC",e[e.ManualRiskCriteria=2]="ManualRiskCriteria",e[e.UploadDocumentReview=3]="UploadDocumentReview",e[e.AdminReview=4]="AdminReview",e))(De||{}),Fe=(e=>(e[e.LowRisk=0]="LowRisk",e[e.MediumRisk=1]="MediumRisk",e[e.HighRisk=2]="HighRisk",e[e.Alert=3]="Alert",e))(Fe||{}),me=(e=>(e[e.None=0]="None",e[e.Pending=1]="Pending",e[e.Approved=2]="Approved",e[e.Rejected=3]="Rejected",e[e.ResendRequested=4]="ResendRequested",e[e.Unknown=5]="Unknown",e[e.InProgress=6]="InProgress",e))(me||{}),pe=(e=>(e[e.Approved=0]="Approved",e[e.Reject=1]="Reject",e[e.UnderReview=2]="UnderReview",e[e.Closed=3]="Closed",e[e.AdminReview=4]="AdminReview",e[e.New=5]="New",e[e.InProgress=6]="InProgress",e))(pe||{}),Pe=(e=>(e[e.ProviderResultPending=0]="ProviderResultPending",e[e.ProviderResultReceived=1]="ProviderResultReceived",e[e.Canceled=2]="Canceled",e[e.ExtendedToNewApplicant=3]="ExtendedToNewApplicant",e))(Pe||{}),Le=(e=>(e[e.None=0]="None",e[e.ProviderResultPending=1]="ProviderResultPending",e[e.ProviderResultReceived=2]="ProviderResultReceived",e[e.Canceled=3]="Canceled",e))(Le||{}),re=(e=>(e[e.Onfido=0]="Onfido",e[e.Sumsub=2]="Sumsub",e[e.SardinAI=3]="SardinAI",e))(re||{}),Te=(e=>(e[e.Individual=0]="Individual",e[e.Company=1]="Company",e))(Te||{}),be=(e=>(e[e.Male=0]="Male",e[e.Female=1]="Female",e[e.Other=2]="Other",e))(be||{}),Me=(e=>(e[e.Image=0]="Image",e[e.Video=1]="Video",e[e.PDF=2]="PDF",e[e.OfficePDF=3]="OfficePDF",e[e.Custom=4]="Custom",e))(Me||{}),Oe=(e=>(e[e.Pending=0]="Pending",e[e.Approved=1]="Approved",e[e.Rejected=2]="Rejected",e[e.RequiresRevision=3]="RequiresRevision",e))(Oe||{}),ze=(e=>(e[e.SingleChoice=0]="SingleChoice",e[e.MultipleChoice=1]="MultipleChoice",e[e.Text=2]="Text",e))(ze||{}),oe=(e=>(e[e.String=0]="String",e[e.Integer=1]="Integer",e[e.Decimal=2]="Decimal",e[e.Boolean=3]="Boolean",e[e.Date=4]="Date",e[e.Country=5]="Country",e[e.DigitOnly=6]="DigitOnly",e))(oe||{}),Be=(e=>(e[e.Text=0]="Text",e[e.Radio=1]="Radio",e[e.Checkbox=2]="Checkbox",e[e.Dropdown=3]="Dropdown",e[e.Country=4]="Country",e))(Be||{}),Ke=(e=>(e[e.None=0]="None",e[e.Country=1]="Country",e))(Ke||{}),J=(e=>(e[e.Individual=0]="Individual",e[e.Sophisticated=1]="Sophisticated",e[e.HighNetWorth=2]="HighNetWorth",e[e.Business=3]="Business",e))(J||{}),Ue=(e=>(e[e.Retail=0]="Retail",e[e.Professional=1]="Professional",e[e.EligibleCounterparty=2]="EligibleCounterparty",e))(Ue||{});const je=[{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"}],_e=["firstName","lastName","email","phonenumber","dateOfBirth","street","streetNumber","zip","city","country","nationality","taxCountry","taxNumber"],Qt=["firstName","lastName","title","email","dateOfBirth","phonenumber","mobileCountryCode","street","streetNumber","zip","city","country","nationality","otherNationality","defaultLanguage","taxCountry","placeOfBirth","countryOfBirth","salutation","educationLevel","occupation","taxNumber","externalRefId"],Se={firstName:{label:"First Name",type:"text"},lastName:{label:"Last Name",type:"text"},title:{label:"Title",type:"text"},email:{label:"Email",type:"email"},dateOfBirth:{label:"Date of Birth",type:"date"},phonenumber:{label:"Phone Number",type:"tel"},mobileCountryCode:{label:"Mobile Country Code",type:"text"},street:{label:"Street",type:"text"},streetNumber:{label:"Street Number",type:"text"},zip:{label:"ZIP/Postal Code",type:"text"},city:{label:"City",type:"text"},country:{label:"Country",type:"select"},nationality:{label:"Nationality",type:"select"},otherNationality:{label:"Other Nationalities",type:"multiselect"},defaultLanguage:{label:"Default Language",type:"select"},taxCountry:{label:"Tax Country",type:"select"},placeOfBirth:{label:"Place of Birth",type:"text"},countryOfBirth:{label:"Country of Birth",type:"select"},salutation:{label:"Salutation",type:"select"},educationLevel:{label:"Education Level",type:"text"},occupation:{label:"Occupation",type:"text"},taxNumber:{label:"Tax Number",type:"text"},externalRefId:{label:"External Reference ID",type:"text"}};var Y=(e=>(e.Default="default",e.Corporate="corporate",e.Fintech="fintech",e.Healthcare="healthcare",e.Modern="modern",e.Minimal="minimal",e))(Y||{});const $e={timeout:3e4,retries:3,locale:"en",endpoints:{pattern:"host-controller"}};class qe{constructor(t){this.config=t}build(t,s){const a=`${t}.${s}`;if(this.config.customPaths&&this.config.customPaths[a])return this.config.customPaths[a];switch(this.config.pattern){case"host-controller":return`/api/${t}/${s}`;case"application-service":return`/services/app/${this.getServiceName(t)}/${s}`;case"custom":throw new Error(`Custom endpoint path not found for ${a}. Please provide it in customPaths.`);default:throw new Error(`Unknown endpoint pattern: ${this.config.pattern}`)}}getServiceName(t){return{Applicant:"MetaKYCVerification",Questionnaire:"MetaKYCVerification",UploadDocument:"MetaKYCVerification",AppropriatenessTest:"MetaKYCVerification",BaseInformation:"MetaKYCVerification"}[t]||t}}class ne extends Error{constructor(s,a,n,i,l){super(s);_(this,"response");this.code=a,this.details=n,this.validationErrors=i,this.name="MetaKYCError",this.response=l,Object.setPrototypeOf(this,ne.prototype)}}class ge{static handleApiError(t){return new ne(t.message||"An unknown error occurred",t.code,t.details||void 0,t.validationErrors||void 0)}static handleAxiosError(t){if(t.response){const s=t.response.data;return s&&s.error?new ne(s.error.message||"An unknown error occurred",s.error.code,s.error.details||void 0,s.error.validationErrors||void 0,t.response):s&&s.result&&s.result.message?new ne(s.result.message,t.response.status,`HTTP ${t.response.status}: ${t.response.statusText}`,void 0,t.response):new ne((s==null?void 0:s.message)||t.message||"Request failed",t.response.status,`HTTP ${t.response.status}: ${t.response.statusText}`,void 0,t.response)}else return t.request?new ne("No response from server",0,"The request was made but no response was received. Please check your network connection."):new ne(t.message||"An unexpected error occurred",0,t.toString())}static isMetaKYCError(t){return t instanceof ne}}class He{constructor(t){_(this,"axiosInstance");_(this,"endpointBuilder");_(this,"config");this.config={...$e,...t},this.endpointBuilder=new qe(this.config.endpoints),this.axiosInstance=Wt.create({baseURL:this.config.baseUrl,timeout:this.config.timeout,headers:{"Content-Type":"application/json"}}),this.axiosInstance.interceptors.request.use(s=>(s.headers["Abp-TenantId"]=this.config.tenantId.toString(),s.headers.ApiKey=this.config.apiKey,s.headers["X-API-KEY"]=this.config.apiKey,this.config.locale&&(s.headers["Accept-Language"]=this.config.locale),s),s=>Promise.reject(s)),this.axiosInstance.interceptors.response.use(s=>s,async s=>{var n;const a=s.config;return((n=s.response)==null?void 0:n.status)>=500&&!a._retry&&(a._retry=!0,a._retryCount=(a._retryCount||0)+1,a._retryCount<(this.config.retries||3))?(await new Promise(i=>setTimeout(i,1e3*a._retryCount)),this.axiosInstance(a)):Promise.reject(s)})}buildEndpoint(t,s){return this.endpointBuilder.build(t,s)}async get(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.get(n,{params:a});return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async post(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.post(n,a);return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async put(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.put(n,a);return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}async delete(t,s,a){try{const n=this.buildEndpoint(t,s),i=await this.axiosInstance.delete(n,{params:a});return this.handleResponse(i)}catch(n){throw ge.handleAxiosError(n)}}handleResponse(t){const s=t.data;if(!s.success&&s.error)throw ge.handleApiError(s.error);return s}getAxiosInstance(){return this.axiosInstance}}class We{constructor(t){this.httpClient=t}async createApplicant(t){return(await this.httpClient.post("Applicant","ApplicantRegistrationRequest",t)).result}async createCompanyApplicant(t){return(await this.httpClient.post("Applicant","ApplicantCompanyRegistrationRequest",t)).result}async duplicateApplicant(t){return(await this.httpClient.post("Applicant","DuplicateApplicantRegistrationRequest",t)).result}async getProgress(t){return(await this.httpClient.get("Applicant","GetApplicantProgress",{applicantId:t})).result}async getProgressStatus(t){return(await this.httpClient.get("Applicant","GetApplicantProgressStaus",{applicantId:t})).result}async getApplicantData(t){return(await this.httpClient.get("Applicant","GetApplicantData",{applicantId:t})).result}async getApplicantStatus(t){return(await this.httpClient.get("Applicant","GetApplicantStatus",{applicantId:t})).result}async stopProgress(t){await this.httpClient.get("Applicant","StopProgress",{applicantId:t})}async progressStepBack(t){await this.httpClient.get("Applicant","ProgressStepBack",{applicantId:t})}async setLanguage(t,s){await this.httpClient.post("Applicant","SetApplicantLng",{applicantId:t,language:s})}async activateApplicant(t){await this.httpClient.get("Applicant","ActivateApplicant",{applicantId:t})}async deleteApplicant(t){await this.httpClient.delete("Applicant","DeleteApplicant",{applicantId:t})}async checkApplicantExists(t){return(await this.httpClient.get("Applicant","CheckApplicantIfExists",{externalRefId:t})).result}}class Ye{constructor(t){this.httpClient=t}async getQuestionnaire(t){return(await this.httpClient.get("Questionnaire","GetQuestionnaire",{applicantid:t})).result}async fillQuestionnaire(t){return(await this.httpClient.post("Applicant","FillQuestionnarie",t)).result}}class Qe{constructor(t){this.httpClient=t}async getUploadDocument(t){return(await this.httpClient.get("UploadDocument","GetUploadDocument",{applicantid:t})).result}async fillUploadDocument(t){await this.httpClient.post("Applicant","FillUploadDocument",t)}async reviewUploadDocument(t){await this.httpClient.post("UploadDocument","ReviewUploadDocument",t)}}class Ve{constructor(t){this.httpClient=t}async getAppropriatenessTest(t){return(await this.httpClient.get("AppropriatenessTest","GetAppropriatenessTest",{applicantid:t})).result}async fillAppropriatenessTest(t){return(await this.httpClient.post("Applicant","FillAppropriatenessTest",t)).result}}class Ge{constructor(t){this.httpClient=t}async getOverviewData(t){return(await this.httpClient.get("Applicant","GetOverviewData",{ApplicantId:t})).result}async passOverview(t){await this.httpClient.get("Applicant","PassOverview",{applicantId:t})}}class Ze{constructor(t){this.httpClient=t}async getRiskScoringPlan(){return(await this.httpClient.get("Applicant","GetRiskScoringPlanInfo")).result}async getRiskCriterias(t){return(await this.httpClient.get("Risk","GetCriterias",{applicantId:t})).result}async submitRiskScoring(t){return(await this.httpClient.post("Applicant","RiskScoringRequest",t)).result}}class Je{constructor(t){this.httpClient=t}async identityRequest(t){console.log("[IdentityService] Calling IdentityRequest with input:",t);const s=await this.httpClient.post("Applicant","IdentityRequest",t);return console.log("[IdentityService] IdentityRequest response:",s),s.result}async identityCompanyRequest(t){return(await this.httpClient.post("Applicant","IdentityCompanyRequest",t)).result}async restartIdentityRequest(t){const s={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};return console.log("[IdentityService] Restarting identity with restart=true:",s),this.identityRequest(s)}async restartIdentityCompanyRequest(t){const s={applicantId:t,restart:!0,redirectUrl:"",ttl:604800};return this.identityCompanyRequest(s)}}class Xe{constructor(t){this.httpClient=t}async getCountries(t,s,a){return(await this.httpClient.get("BaseInformation","GetAllCountries",{filter:t||"",lng:s||"en",type:a})).result}async getBranches(){return(await this.httpClient.get("BaseInformation","GetBranches")).result}async getLegalEntities(){return(await this.httpClient.get("BaseInformation","GetLegalEntities")).result}}class et{constructor(t){this.httpClient=t}async setInvestorCategorization(t){return(await this.httpClient.post("Applicant","SetInvestorCategorization",t)).result}async getInvestorCategorization(t){return(await this.httpClient.get("Applicant","GetInvestorCategorisation",{applicantId:t})).result}}const V={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"}}},tt={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"}},rt={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"}},st={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"}}},at={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"}},nt={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"}},it={[Y.Default]:V,[Y.Corporate]:tt,[Y.Fintech]:rt,[Y.Healthcare]:st,[Y.Modern]:at,[Y.Minimal]:nt};function xe(e){return it[e]||V}class ot{constructor(t){this.httpClient=t}async getThemeConfiguration(){var t;try{const s=await this.httpClient.get("Tenant","GetThemeConfiguration");if(!s.result.isEnabled)return xe(Y.Default);let a=s.result.preset?xe(s.result.preset):xe(Y.Default);return s.result.title&&(a.title=s.result.title),s.result.logo&&(a.logo={...a.logo,...s.result.logo}),s.result.colors&&(a.colors={...a.colors,...s.result.colors}),s.result.typography&&(a.typography={...a.typography,...s.result.typography}),s.result.spacing&&(a.spacing={...a.spacing,...s.result.spacing}),s.result.customCSS&&(a.customCSS=s.result.customCSS),s.result.darkMode&&(a.darkMode={colors:{...(t=a.darkMode)==null?void 0:t.colors,...s.result.darkMode.colors}}),s.result.applicantFormVisibleFields&&s.result.applicantFormVisibleFields.length>0&&(a.applicantFormVisibleFields=s.result.applicantFormVisibleFields),s.result.applicantFormRequiredFields&&s.result.applicantFormRequiredFields.length>0&&(a.applicantFormRequiredFields=s.result.applicantFormRequiredFields),s.result.allowedLanguages&&s.result.allowedLanguages.length>0&&(a.allowedLanguages=s.result.allowedLanguages),a}catch(s){return console.warn("[ThemeService] Failed to fetch theme configuration:",s),xe(Y.Default)}}async saveThemeConfiguration(t){await this.httpClient.post("Tenant","SaveThemeConfiguration",t)}getAvailablePresets(){return[{id:Y.Default,name:"Default"},{id:Y.Corporate,name:"Corporate"},{id:Y.Fintech,name:"Fintech"},{id:Y.Healthcare,name:"Healthcare"},{id:Y.Modern,name:"Modern"},{id:Y.Minimal,name:"Minimal"}]}getPreviewTheme(t,s){const a=xe(t);return s?{...a,...s,logo:{...a.logo,...s.logo},colors:{...a.colors,...s.colors},typography:s.typography?{...a.typography,...s.typography}:a.typography,spacing:s.spacing?{...a.spacing,...s.spacing}:a.spacing}:a}}class lt{constructor(){_(this,"listeners",new Map)}on(t,s){return this.listeners.has(t)||this.listeners.set(t,new Set),this.listeners.get(t).add(s),()=>{this.off(t,s)}}off(t,s){const a=this.listeners.get(t);a&&a.delete(s)}emit(t,s){const a=this.listeners.get(t);a&&a.forEach(n=>{try{n(s)}catch(i){console.error(`Error in event listener for "${t}":`,i)}})}clear(){this.listeners.clear()}clearEvent(t){this.listeners.delete(t)}}class ct{constructor(){_(this,"events",new lt);_(this,"_applicantId",null);_(this,"_progress",null);_(this,"_error",null)}get applicantId(){return this._applicantId}get progress(){return this._progress}get currentStep(){var t;return((t=this._progress)==null?void 0:t.currentStep)||null}get steps(){var t;return((t=this._progress)==null?void 0:t.stepInfoList)||[]}get status(){var t;return((t=this._progress)==null?void 0:t.status)||se.None}get workflowResult(){var t;return((t=this._progress)==null?void 0:t.workflowResult)||null}get error(){return this._error}get isComplete(){return this.status===se.Finished}get isOnHold(){return this.status===se.OnHold}get isInProgress(){return this.status===se.InProgress}setApplicantId(t){this._applicantId=t}updateProgress(t){var a,n;const s=(a=this._progress)==null?void 0:a.currentStep;this._progress=t,this._applicantId=t.applicantId,this._error=null,this.events.emit("progressUpdated",t),(s==null?void 0:s.order)!==((n=t.currentStep)==null?void 0:n.order)&&this.events.emit("stepChanged",t.currentStep),this.events.emit("statusChanged",t.status),t.status===se.Finished&&t.workflowResult&&this.events.emit("completed",t.workflowResult)}setError(t){this._error=t,this.events.emit("error",t)}clearError(){this._error=null}reset(){this._applicantId=null,this._progress=null,this._error=null}onProgressUpdated(t){return this.events.on("progressUpdated",t)}onStepChanged(t){return this.events.on("stepChanged",t)}onStatusChanged(t){return this.events.on("statusChanged",t)}onError(t){return this.events.on("error",t)}onCompleted(t){return this.events.on("completed",t)}clearListeners(){this.events.clear()}}class dt{constructor(){_(this,"handlers",new Map)}registerHandler(t,s){this.handlers.set(t,s)}getHandler(t){return this.handlers.get(t)}hasHandler(t){return this.handlers.has(t)}async loadStepData(t,s){const a=this.getHandler(t);if(!a)throw new Error(`No handler registered for step action: ${T[t]}`);return a.loadData(s)}async submitStepData(t,s){const a=this.getHandler(t);if(!a)throw new Error(`No handler registered for step action: ${T[t]}`);return a.submitData(s)}}class ut{constructor(t,s,a,n,i,l,c,d){_(this,"state");_(this,"stepRouter");this.applicantService=t,this.questionnaireService=s,this.uploadDocumentService=a,this.appropriatenessTestService=n,this.overviewService=i,this.riskScoringService=l,this.investorCategorizationService=d,this.state=new ct,this.stepRouter=new dt,this.registerStepHandlers()}registerStepHandlers(){this.stepRouter.registerHandler(T.Questionaries,{loadData:t=>this.questionnaireService.getQuestionnaire(t),submitData:async t=>{await this.questionnaireService.fillQuestionnaire(t)}}),this.stepRouter.registerHandler(T.UploadDocument,{loadData:t=>this.uploadDocumentService.getUploadDocument(t),submitData:t=>this.uploadDocumentService.fillUploadDocument(t)}),this.stepRouter.registerHandler(T.AppropriatenessTest,{loadData:t=>this.appropriatenessTestService.getAppropriatenessTest(t),submitData:async t=>{await this.appropriatenessTestService.fillAppropriatenessTest(t)}}),this.stepRouter.registerHandler(T.Overview,{loadData:t=>this.overviewService.getOverviewData(t),submitData:t=>this.overviewService.passOverview(t.applicantId)}),this.stepRouter.registerHandler(T.RiskScoring,{loadData:t=>this.riskScoringService.getRiskCriterias(t),submitData:async t=>{await this.riskScoringService.submitRiskScoring(t)}}),this.stepRouter.registerHandler(T.IdentitySdk,{loadData:async t=>({applicantId:t,message:"Identity verification required"}),submitData:async()=>{}}),this.stepRouter.registerHandler(T.InvestorCategorization,{loadData:t=>this.investorCategorizationService.getInvestorCategorization(t),submitData:async t=>{await this.investorCategorizationService.setInvestorCategorization(t)}}),this.stepRouter.registerHandler(T.ManualReview,{loadData:async t=>({applicantId:t,message:"Your application is under manual review"}),submitData:async()=>{}}),this.stepRouter.registerHandler(T.AdditionalData,{loadData:async t=>({applicantId:t,message:"Additional data required"}),submitData:async()=>{}})}async initialize(t){try{this.state.setApplicantId(t);const s=await this.applicantService.getProgress(t);return this.state.updateProgress(s),s}catch(s){throw this.state.setError(s),s}}async refreshProgress(){if(!this.state.applicantId)throw new Error("Workflow not initialized. Call initialize() first.");try{const t=await this.applicantService.getProgress(this.state.applicantId);return this.state.updateProgress(t),t}catch(t){throw this.state.setError(t),t}}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(t){throw this.state.setError(t),t}}async submitCurrentStep(t){if(!this.state.currentStep)throw new Error("No current step available");try{await this.stepRouter.submitStepData(this.state.currentStep.action,t),await this.refreshProgress()}catch(s){throw this.state.setError(s),s}}async moveToNextStep(){return this.refreshProgress()}async moveToPreviousStep(){if(!this.state.applicantId)throw new Error("Workflow not initialized");try{return await this.applicantService.progressStepBack(this.state.applicantId),await this.refreshProgress()}catch(t){throw this.state.setError(t),t}}getState(){return this.state}getStepRouter(){return this.stepRouter}}function Ce(e,t){return new Promise((s,a)=>{if(t&&document.getElementById(t)){s();return}const n=document.createElement("script");n.src=e,t&&(n.id=t),n.async=!0,n.onload=()=>s(),n.onerror=()=>a(new Error(`Failed to load script: ${e}`)),document.head.appendChild(n)})}function Vt(e){return!!document.getElementById(e)}function Gt(e){const t=document.getElementById(e);t&&t.remove()}class mt{constructor(t){_(this,"sdk",null);_(this,"config");this.config=t}async loadSDK(){await Ce("https://cdn.sumsub.com/websdk/v2/production/websdk.js","sumsub-sdk")}async initialize(t){if(window.snsWebSdk||await this.loadSDK(),!window.snsWebSdk)throw new Error("Sumsub SDK failed to load");this.sdk=window.snsWebSdk.init(this.config.accessToken,()=>this.config.accessToken).withConf({lang:this.config.lang||"en",email:this.config.applicantEmail,phone:this.config.applicantPhone,i18n:{}}).on("idCheck.onStepCompleted",s=>{console.log("Sumsub step completed:",s)}).on("idCheck.onError",s=>{console.error("Sumsub error:",s)}).build(),this.sdk.launch(`#${t}`)}destroy(){this.sdk&&(this.sdk.destroy(),this.sdk=null)}onComplete(t){this.sdk&&this.sdk.on("idCheck.applicantStatus",s=>{s.applicantStatus==="completed"&&t(s)})}onError(t){this.sdk&&this.sdk.on("idCheck.onError",t)}}class pt{constructor(t){_(this,"sdk",null);_(this,"config");this.config=t}async loadSDK(){await Ce("https://sdk.onfido.com/v12.0.0/onfido.min.js","onfido-sdk")}async initialize(t){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:t,steps:this.config.steps||[{type:"welcome",options:{title:"Identity Verification"}},{type:"document",options:{documentTypes:{passport:!0,driving_licence:!0,national_identity_card:!0}}},{type:"face",options:{requestedVariant:"standard"}},{type:"complete"}],onComplete:()=>{this.config.onComplete&&this.config.onComplete()},onError:s=>{this.config.onError&&this.config.onError(s)}})}destroy(){this.sdk&&(this.sdk.tearDown(),this.sdk=null)}}class ht{constructor(t){_(this,"sardineContext",null);_(this,"config");_(this,"sessionKey");this.config=t,this.sessionKey=t.sessionKey||this.generateSessionKey()}generateSessionKey(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){const s=Math.random()*16|0;return(t==="x"?s:s&3|8).toString(16)})}getSardineHost(){const{environment:t,region:s}=this.config;if(t==="sandbox")return"api.sandbox.sardine.ai";switch(s){case"eu":return"api.eu.sardine.ai";case"ca":return"api.ca.sardine.ai";case"au":return"api.au.sardine.ai";default:return"api.sardine.ai"}}async loadSDK(){return new Promise((t,s)=>{if(window._Sardine){t();return}const a=this.getSardineHost(),n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src=`https://${a}/assets/loader.min.js`,n.onload=()=>{console.log("[SardinAI] SDK loaded successfully"),t()},n.onerror=()=>{s(new Error("Failed to load SardinAI SDK"))};const i=document.getElementsByTagName("script")[0];i&&i.parentNode?i.parentNode.insertBefore(n,i):document.head.appendChild(n)})}async initialize(){try{if(await this.loadSDK(),!window._Sardine)throw new Error("SardinAI SDK not available after loading");const t=this.getSardineHost(),{clientId:s,environment:a,flow:n,enableBiometrics:i,enablePortScanning:l}=this.config;this.sardineContext=window._Sardine.createContext({clientId:s,sessionKey:this.sessionKey,userIdHash:void 0,flow:n||window.location.pathname,environment:a||"production",parentElement:document.body,enableBiometrics:i!==!1,enablePortScanning:l===!0,region:this.config.region,onDeviceResponse:c=>{console.log(`[SardinAI] Device ID: ${c.deviceId}`)},onConfigUpdate:(c,d,u)=>{switch(c){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Session update failed:",u);break;case"SESSION_UPDATED":console.log("[SardinAI] Session updated:",d);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No session update");break;default:console.warn("[SardinAI] Unknown event:",c)}}}),this.addNoScriptFallback(t),console.log("[SardinAI] SDK initialized with sessionKey:",this.sessionKey)}catch(t){throw console.error("[SardinAI] Initialization failed:",t),t}}addNoScriptFallback(t){const s=document.createElement("noscript"),a=document.createElement("img"),{clientId:n,flow:i}=this.config;a.src=`https://${t}/v1/a.png?clientId=${n}&sessionKey=${this.sessionKey}&flow=${i||"kyc"}&ns=1`,a.style.display="none",s.appendChild(a),document.body.appendChild(s)}updateConfig(t){if(!this.sardineContext){console.warn("[SardinAI] Cannot update config - SDK not initialized");return}t.sessionKey&&(this.sessionKey=t.sessionKey),this.sardineContext.updateConfig({...t,onConfigUpdate:(s,a,n)=>{switch(s){case"SESSION_UPDATE_FAILED":console.error("[SardinAI] Config update failed:",n);break;case"SESSION_UPDATED":console.log("[SardinAI] Config updated:",a);break;case"SESSION_NO_UPDATE":console.log("[SardinAI] No config update needed");break}}})}getSessionKey(){return this.sessionKey}destroy(){this.sardineContext&&(this.sardineContext=null)}}class he{static createProvider(t,s){switch(t){case re.Sumsub:return new mt(s);case re.Onfido:return new pt(s);case re.SardinAI:return new ht(s);default:throw new Error(`Unsupported identity provider: ${t}`)}}static parseProviderConfig(t,s,a){var n;switch(t){case re.Sumsub:return{accessToken:s.accessToken||s.token,applicantEmail:s.email,applicantPhone:s.phone,externalUserId:s.externalUserId,lang:s.lang||"en"};case re.Onfido:return{token:s.token||s.sdkToken};case re.SardinAI:const i=((n=a==null?void 0:a.identityProviders)==null?void 0:n.sardinai)||{};return{clientId:i.clientId||s.clientId,sessionKey:i.sessionKey||s.sessionKey,environment:i.environment||s.environment||"production",flow:i.flow||s.flow,region:i.region,enableBiometrics:i.enableBiometrics,enablePortScanning:i.enablePortScanning};default:throw new Error(`Unsupported identity provider: ${t}`)}}}class gt{constructor(t){_(this,"currentTheme",V);_(this,"customStyleElement",null);_(this,"container");this.container=t||document.documentElement}applyTheme(t){this.currentTheme=this.mergeWithDefault(t),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(t){var a;const s={primary:t.primary,"primary-hover":t.primaryHover,"primary-light":t.primaryLight,"primary-dark":t.primaryDark,secondary:t.secondary,"secondary-hover":t.secondaryHover,success:t.success,warning:t.warning,danger:t.danger,info:t.info,background:t.background,surface:t.surface,border:t.border,"text-primary":t.textPrimary,"text-secondary":t.textSecondary,"text-muted":t.textMuted};Object.entries(s).forEach(([n,i])=>{this.container.style.setProperty(`--metakyc-${n}`,i)}),(a=this.currentTheme.darkMode)!=null&&a.colors&&this.applyDarkModeColors(this.currentTheme.darkMode.colors)}applyDarkModeColors(t){Object.entries(t).forEach(([s,a])=>{if(a){const n=`--metakyc-dark-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)}})}applyTypography(t){t&&(t.fontFamily&&this.container.style.setProperty("--metakyc-font-family",t.fontFamily),t.headingFont&&this.container.style.setProperty("--metakyc-heading-font",t.headingFont),t.fontSize&&Object.entries(t.fontSize).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-size-${s}`,a)}),t.fontWeight&&Object.entries(t.fontWeight).forEach(([s,a])=>{this.container.style.setProperty(`--metakyc-font-weight-${s}`,a.toString())}))}applySpacing(t){t&&Object.entries(t).forEach(([s,a])=>{const n=`--metakyc-${this.kebabCase(s)}`;this.container.style.setProperty(n,a)})}injectCustomCSS(t){this.customStyleElement&&this.customStyleElement.remove(),this.customStyleElement=document.createElement("style"),this.customStyleElement.id="metakyc-custom-css",this.customStyleElement.textContent=t,document.head.appendChild(this.customStyleElement)}mergeWithDefault(t){var s;return{name:t.name||V.name,title:t.title||V.title,logo:{...V.logo,...t.logo},colors:{...V.colors,...t.colors},typography:t.typography?{...V.typography,...t.typography}:V.typography,spacing:t.spacing?{...V.spacing,...t.spacing}:V.spacing,customCSS:t.customCSS,darkMode:t.darkMode?{colors:{...(s=V.darkMode)==null?void 0:s.colors,...t.darkMode.colors}}:V.darkMode,applicantFormVisibleFields:t.applicantFormVisibleFields,applicantFormRequiredFields:t.applicantFormRequiredFields,allowedLanguages:t.allowedLanguages}}getCurrentTheme(){return this.currentTheme}resetTheme(){this.applyTheme(V)}cleanup(){this.customStyleElement&&(this.customStyleElement.remove(),this.customStyleElement=null)}kebabCase(t){return t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}}const Ae=o.createContext(null),Zt=({config:e,children:t})=>{const[s,a]=o.useState(null),n=o.useRef(!1),i=o.useRef(!1),l=o.useMemo(()=>{const d=new He(e),u=new We(d),v=new Ye(d),w=new Qe(d),g=new Ve(d),m=new Ge(d),p=new Ze(d),k=new Je(d),f=new Xe(d),x=new et(d),A=new ot(d),j=new gt;return{httpClient:d,applicantService:u,questionnaireService:v,uploadDocumentService:w,appropriatenessTestService:g,overviewService:m,riskScoringService:p,identityService:k,baseInformationService:f,investorCategorizationService:x,themeService:A,themeManager:j}},[e]),c=o.useMemo(()=>({config:e,...l,currentTheme:s,createOrchestrator:()=>new ut(l.applicantService,l.questionnaireService,l.uploadDocumentService,l.appropriatenessTestService,l.overviewService,l.riskScoringService,l.identityService,l.investorCategorizationService)}),[e,l,s]);return o.useEffect(()=>((async()=>{if(n.current||i.current){console.log("[MetaKYC] Theme already loading or loaded, skipping...");return}n.current=!0;try{if(e.theme){console.log("[MetaKYC] Applying static theme from config"),l.themeManager.applyTheme(e.theme),a(l.themeManager.getCurrentTheme()),i.current=!0;return}console.log("[MetaKYC] Fetching theme from backend...");const u=await l.themeService.getThemeConfiguration();l.themeManager.applyTheme(u),a(l.themeManager.getCurrentTheme()),i.current=!0,console.log("[MetaKYC] Theme loaded and applied",u)}catch(u){console.warn("[MetaKYC] Failed to load theme, using default:",u),a(l.themeManager.getCurrentTheme()),i.current=!0}finally{n.current=!1}})(),()=>{l.themeManager.cleanup()}),[]),r.jsx(Ae.Provider,{value:c,children:t})};function te(){const e=o.useContext(Ae);if(!e)throw new Error("useMetaKYC must be used within a MetaKYCProvider");return e}async function xt(e){return new Promise((t,s)=>{const a=new FileReader;a.readAsDataURL(e),a.onload=()=>{const i=a.result.split(",")[1];t(i)},a.onerror=n=>s(n)})}function Jt(e,t){return e.size<=t}function Xt(e,t){return t.split(",").map(a=>a.trim()).some(a=>{if(a.endsWith("/*")){const n=a.slice(0,-2);return e.type.startsWith(n)}return e.type===a})}function ve(e){if(e===0)return"0 Bytes";const t=1024,s=["Bytes","KB","MB","GB"],a=Math.floor(Math.log(e)/Math.log(t));return Math.round(e/Math.pow(t,a)*100)/100+" "+s[a]}function er(e){return e}function Q(...e){return e.filter(Boolean).join(" ")}const fe={APPLICANT_ID:"metakyc_applicant_id",WORKFLOW_STATE:"metakyc_workflow_state"};function ft(e){try{localStorage.setItem(fe.APPLICANT_ID,e.toString())}catch(t){console.warn("Failed to save applicant ID to storage:",t)}}function yt(){try{const e=localStorage.getItem(fe.APPLICANT_ID);return e?parseInt(e,10):null}catch(e){return console.warn("Failed to retrieve applicant ID from storage:",e),null}}function bt(){try{localStorage.removeItem(fe.APPLICANT_ID)}catch(e){console.warn("Failed to clear applicant ID from storage:",e)}}function vt(e){try{localStorage.setItem(fe.WORKFLOW_STATE,JSON.stringify(e))}catch(t){console.warn("Failed to save workflow state to storage:",t)}}function tr(){try{const e=localStorage.getItem(fe.WORKFLOW_STATE);return e?JSON.parse(e):null}catch(e){return console.warn("Failed to retrieve workflow state from storage:",e),null}}function wt(){try{localStorage.removeItem(fe.WORKFLOW_STATE)}catch(e){console.warn("Failed to clear workflow state from storage:",e)}}function rr(){bt(),wt()}function kt(e){const{createOrchestrator:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(null),d=o.useRef(null),u=e||yt();o.useEffect(()=>{d.current||(d.current=t())},[t]),o.useEffect(()=>{var j;s&&u&&(ft(u),vt({applicantId:u,currentStepOrder:(j=s.currentStep)==null?void 0:j.order,status:s.status,lastUpdated:new Date().toISOString(),workflowKey:s.workFlowKey,nextWorkflowKey:s.nextWorkflowKey}))},[s,u]);const v=o.useRef(!1),w=o.useRef(!1),g=o.useCallback(async()=>{if(!(!u||!d.current)){if(v.current){console.log("[Workflow] Load already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await d.current.initialize(u);a(j),w.current=!0}catch(j){c(j)}finally{i(!1),v.current=!1}}},[u]);o.useEffect(()=>{u&&!w.current&&g()},[u,g]);const m=o.useCallback(async()=>{if(d.current){if(v.current){console.log("[Workflow] Refresh already in progress, skipping...");return}v.current=!0,i(!0),c(null);try{const j=await d.current.refreshProgress();a(j)}catch(j){c(j)}finally{i(!1),v.current=!1}}},[]),p=o.useCallback(async()=>{if(d.current){i(!0),c(null);try{const j=await d.current.moveToNextStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),k=o.useCallback(async()=>{if(d.current){i(!0),c(null);try{const j=await d.current.moveToPreviousStep();a(j)}catch(j){c(j)}finally{i(!1)}}},[]),f=o.useCallback(async j=>{if(d.current){i(!0),c(null);try{await d.current.submitCurrentStep(j);const S=await d.current.refreshProgress();a(S)}catch(S){throw c(S),S}finally{i(!1)}}},[]),x=Re.useMemo(()=>s!=null&&s.stepInfoList?[...s.stepInfoList].sort((j,S)=>j.order-S.order):[],[s==null?void 0:s.stepInfoList]),A=Re.useMemo(()=>s?s.nextWorkflowKey&&s.nextWorkflowKey!==s.workFlowKey:!1,[s]);return{progress:s,applicantId:u,currentStep:(s==null?void 0:s.currentStep)||null,steps:x,status:(s==null?void 0:s.status)||se.None,workflowResult:(s==null?void 0:s.workflowResult)||null,workflowKey:s==null?void 0:s.workFlowKey,nextWorkflowKey:s==null?void 0:s.nextWorkflowKey,hasWorkflowChanged:A,isLoading:n,error:l,isComplete:(s==null?void 0:s.status)===se.Finished,isOnHold:(s==null?void 0:s.status)===se.OnHold,refreshProgress:m,moveToNext:p,moveBack:k,submitCurrentStep:f,orchestrator:d.current}}function jt(e){const{questionnaireService:t,applicantService:s}=te(),[a,n]=o.useState(null),[i,l]=o.useState({}),[c,d]=o.useState(!1),[u,v]=o.useState(!1),[w,g]=o.useState(null),m=o.useRef(!1),p=o.useRef(null),k=o.useCallback(async()=>{var x,A;if(e){if(m.current){console.log("[Questionnaire] Load already in progress, skipping...");return}m.current=!0,d(!0),g(null);try{const[j,S]=await Promise.all([t.getQuestionnaire(e),s.getApplicantData(e).catch(()=>null)]);if(n(j),(x=S==null?void 0:S.questionnaireResults)!=null&&x.length&&j){const M=new Map;for(const h of S.questionnaireResults)h.question&&((A=h.answers)!=null&&A.length)&&M.set(h.question.trim().toLowerCase(),h.answers);const H={},I=j.questionGroups.flatMap(h=>h.questions??[]);for(const h of I){const N=h.text.trim().toLowerCase();M.has(N)&&(H[h.id]=M.get(N))}l(H)}p.current=e}catch(j){g(j)}finally{d(!1),m.current=!1}}},[e,t,s]);o.useEffect(()=>{e&&p.current!==e&&k()},[e]);const f=o.useCallback(async x=>{v(!0),g(null);try{return await t.fillQuestionnaire(x)}catch(A){throw g(A),A}finally{v(!1)}},[t]);return{questionnaire:a,initialAnswers:i,isLoading:c,isSubmitting:u,error:w,load:k,submit:f}}function St(e){const{uploadDocumentService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(0),[v,w]=o.useState(null),g=o.useRef(!1),m=o.useRef(null),p=o.useCallback(async()=>{if(e){if(g.current){console.log("[UploadDocument] Load already in progress, skipping...");return}g.current=!0,i(!0),w(null);try{const f=await t.getUploadDocument(e);a(f),m.current=e}catch(f){w(f)}finally{i(!1),g.current=!1}}},[e,t]);o.useEffect(()=>{e&&m.current!==e&&p()},[e]);const k=o.useCallback(async f=>{c(!0),u(0),w(null);try{await t.fillUploadDocument(f),u(100)}catch(x){throw w(x),x}finally{c(!1)}},[t]);return{uploadDocument:s,isLoading:n,isSubmitting:l,uploadProgress:d,error:v,load:p,submit:k}}function sr(e){const{appropriatenessTestService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(null),[v,w]=o.useState(null),g=o.useRef(!1),m=o.useRef(null),p=o.useCallback(async()=>{if(e){if(g.current){console.log("[AppropriatenessTest] Load already in progress, skipping...");return}g.current=!0,i(!0),u(null);try{const f=await t.getAppropriatenessTest(e);a(f),m.current=e}catch(f){u(f)}finally{i(!1),g.current=!1}}},[e,t]);o.useEffect(()=>{e&&m.current!==e&&p()},[e]);const k=o.useCallback(async f=>{c(!0),u(null);try{const x=await t.fillAppropriatenessTest(f);return w(x),x}catch(x){throw u(x),x}finally{c(!1)}},[t]);return{test:s,result:v,isLoading:n,isSubmitting:l,error:d,load:p,submit:k}}function Nt(e){const{overviewService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(!1),[d,u]=o.useState(null),v=o.useRef(!1),w=o.useRef(null),g=o.useCallback(async()=>{if(e){if(v.current){console.log("[Overview] Load already in progress, skipping...");return}v.current=!0,i(!0),u(null);try{const p=await t.getOverviewData(e);a(p),w.current=e}catch(p){u(p)}finally{i(!1),v.current=!1}}},[e,t]);o.useEffect(()=>{e&&w.current!==e&&g()},[e]);const m=o.useCallback(async()=>{if(e){c(!0),u(null);try{await t.passOverview(e)}catch(p){throw u(p),p}finally{c(!1)}}},[e,t]);return{overview:s,isLoading:n,isSubmitting:l,error:d,load:g,passOverview:m}}function Ct(e){const{identityService:t}=te(),[s,a]=o.useState(null),[n,i]=o.useState(!1),[l,c]=o.useState(null),d=o.useRef(!1),u=o.useCallback(async(g,m)=>{if(e){if(d.current){console.log("[Identity] Request already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const p={applicantId:e,restart:!1,redirectUrl:g||"",ttl:m||604800};console.log("Identity request input:",p);const k=await t.identityRequest(p);return console.log("Identity request result:",k),a(k),k}catch(p){throw c(p),p}finally{i(!1),d.current=!1}}},[e,t]),v=o.useCallback(async(g,m)=>{if(e){i(!0),c(null);try{const p={applicantId:e,restart:!1,redirectUrl:g,ttl:m},k=await t.identityCompanyRequest(p);return a(k),k}catch(p){throw c(p),p}finally{i(!1)}}},[e,t]),w=o.useCallback(async()=>{if(e){if(d.current){console.log("[Identity] Restart already in progress, skipping...");return}d.current=!0,i(!0),c(null);try{const g={applicantId:e,restart:!0,redirectUrl:"",ttl:604800};console.log("Restarting identity with input:",g);const m=await t.identityRequest(g);return console.log("Restart identity result:",m),a(m),m}catch(g){throw c(g),g}finally{i(!1),d.current=!1}}},[e,t]);return{identityData:s,provider:(s==null?void 0:s.provider)||null,token:(s==null?void 0:s.publicProviderTokenObject)||null,isLoading:n,error:l,requestIdentity:u,requestCompanyIdentity:v,restartIdentity:w}}function At(e){const{riskScoringService:t,applicantService:s}=te(),[a,n]=o.useState(null),[i,l]=o.useState({}),[c,d]=o.useState(!1),[u,v]=o.useState(!1),[w,g]=o.useState(null),[m,p]=o.useState(null),k=o.useRef(!1),f=o.useRef(null),x=o.useCallback(async()=>{var j;if(e){if(k.current){console.log("[RiskScoring] Load already in progress, skipping...");return}k.current=!0,d(!0),g(null);try{const[S,M]=await Promise.all([t.getRiskCriterias(e),s.getApplicantData(e).catch(()=>null)]);if(n(S),(j=M==null?void 0:M.riskScoringResults)!=null&&j.length){const H=M.riskScoringResults[0],I={};for(const h of H.riskCriteriaResults??[])if(h.riskCriteriaId!=null&&h.answer!=null&&h.answer!==""){const N=[...new Set(h.answer.split(",").map(C=>C.trim()).filter(C=>C!==""))];N.length>0&&(I[h.riskCriteriaId]=N)}l(I)}f.current=e}catch(S){g(S)}finally{d(!1),k.current=!1}}},[e,t,s]);o.useEffect(()=>{e&&f.current!==e&&x()},[e]);const A=o.useCallback(async j=>{v(!0),g(null);try{const S=await t.submitRiskScoring(j);return p(S),S}catch(S){throw g(S),S}finally{v(!1)}},[t]);return{criteria:a,initialAnswers:i,result:m,isLoading:c,isSubmitting:u,error:w,load:x,submit:A}}function Et(){const{applicantService:e,config:t}=te(),[s,a]=o.useState(!1),[n,i]=o.useState(null),l=o.useRef(!1),c=o.useRef(!1),d=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(m){const p=Math.random()*16|0;return(m==="x"?p:p&3|8).toString(16)}),u=o.useCallback(async m=>{var p;if(l.current)throw console.log("[Applicant] Create already in progress, skipping..."),new Error("Creation already in progress");l.current=!0,a(!0),i(null);try{if(m.applicantAdditionalDatas||(m.applicantAdditionalDatas=[]),(p=t.identityProviders)!=null&&p.sardinai){const f=d();console.log("[SardinAI] Generated session key:",f),m.applicantAdditionalDatas.push({paramName:"sessionKey",value:f})}return await e.createApplicant(m)}catch(k){throw i(k),k}finally{a(!1),l.current=!1}},[e,t]),v=o.useCallback(async m=>{a(!0),i(null);try{return await e.createCompanyApplicant(m)}catch(p){throw i(p),p}finally{a(!1)}},[e]),w=o.useCallback(async m=>{if(c.current)throw console.log("[Applicant] Data load already in progress, skipping..."),new Error("Data load already in progress");c.current=!0,a(!0),i(null);try{return await e.getApplicantData(m)}catch(p){throw i(p),p}finally{a(!1),c.current=!1}},[e]),g=o.useCallback(async m=>{a(!0),i(null);try{await e.stopProgress(m)}catch(p){throw i(p),p}finally{a(!1)}},[e]);return{isLoading:s,error:n,createApplicant:u,createCompanyApplicant:v,getApplicantData:w,stopProgress:g}}const z=({children:e,variant:t="primary",size:s="md",isLoading:a=!1,disabled:n,className:i,...l})=>{const c="inline-flex items-center justify-center rounded-lg font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 disabled:opacity-50 disabled:cursor-not-allowed",d={primary:"bg-primary-500 text-white hover:bg-primary-600 focus:ring-primary-500",secondary:"bg-gray-200 text-gray-900 hover:bg-gray-300 focus:ring-gray-400",outline:"border-2 border-primary-500 text-primary-500 hover:bg-primary-50 focus:ring-primary-500",danger:"bg-danger-500 text-white hover:bg-danger-600 focus:ring-danger-500",ghost:"text-gray-700 hover:bg-gray-100 focus:ring-gray-400"},u={sm:"px-3 py-1.5 text-sm",md:"px-4 py-2 text-base",lg:"px-6 py-3 text-lg"};return r.jsxs("button",{className:Q(c,d[t],u[s],i),disabled:n||a,...l,children:[a&&r.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),e]})},X=o.forwardRef(({label:e,error:t,helperText:s,leftIcon:a,rightIcon:n,className:i,...l},c)=>r.jsxs("div",{className:"w-full",children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[a&&r.jsx("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:a}),r.jsx("input",{ref:c,className:Q("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",t?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",a?"pl-10":"",n?"pr-10":"",i),...l}),n&&r.jsx("div",{className:"absolute inset-y-0 right-0 pr-3 flex items-center pointer-events-none",children:n})]}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t}),!t&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));X.displayName="Input";const P=({children:e,className:t,...s})=>r.jsx("div",{className:Q("metakyc-card rounded-xl shadow-sm border",t),style:{backgroundColor:"var(--metakyc-surface, #ffffff)",borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),G=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4 border-b",t),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),L=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4",t),...s,children:e}),ee=({children:e,className:t,...s})=>r.jsx("div",{className:Q("px-6 py-4 border-t",t),style:{borderColor:"var(--metakyc-border, #e5e7eb)"},...s,children:e}),ie=({children:e,variant:t="default",className:s,...a})=>{const n={default:"bg-gray-100 text-gray-800 dark:bg-gray-700 dark:text-gray-300",success:"bg-success-100 text-success-800 dark:bg-success-900 dark:text-success-300",danger:"bg-danger-100 text-danger-800 dark:bg-danger-900 dark:text-danger-300",warning:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-300",info:"bg-primary-100 text-primary-800 dark:bg-primary-900 dark:text-primary-300"};return r.jsx("span",{className:Q("inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium",n[t],s),...a,children:e})},ae=({size:e="md",className:t,...s})=>{const a={sm:"h-4 w-4",md:"h-8 w-8",lg:"h-12 w-12"};return r.jsx("div",{className:Q("flex items-center justify-center",t),...s,children:r.jsxs("svg",{className:Q("animate-spin text-primary-500",a[e]),xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[r.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),r.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]})})},le=o.forwardRef(({label:e,error:t,helperText:s,options:a,placeholder:n,className:i,...l},c)=>r.jsxs("div",{className:"w-full",children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("select",{ref:c,className:Q("block w-full rounded-lg border px-3 py-2 text-sm transition-colors","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","disabled:bg-gray-100 disabled:cursor-not-allowed",t?"border-danger-500 focus:ring-danger-500":"border-gray-300 dark:border-gray-600","dark:bg-gray-800 dark:text-white",i),...l,children:[n&&r.jsx("option",{value:"",disabled:!0,children:n},"__placeholder__"),a.map((d,u)=>r.jsx("option",{value:d.value,disabled:d.disabled,children:d.label},d.value||`option-${u}`))]}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t}),!t&&s&&r.jsx("p",{className:"mt-1 text-sm text-gray-500",children:s})]}));le.displayName="Select";const Rt=({label:e,value:t,onChange:s,options:a,placeholder:n="Select...",disabled:i=!1,required:l=!1})=>{const[c,d]=o.useState(!1),[u,v]=o.useState(""),w=o.useRef(null);o.useEffect(()=>{const f=x=>{w.current&&!w.current.contains(x.target)&&(d(!1),v(""))};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[]);const g=a.filter(f=>f.label.toLowerCase().includes(u.toLowerCase())),m=f=>{i||(t.includes(f)?s(t.filter(x=>x!==f)):s([...t,f]))},p=(f,x)=>{x.stopPropagation(),i||s(t.filter(A=>A!==f))},k=f=>{var x;return((x=a.find(A=>A.value===f))==null?void 0:x.label)||f};return r.jsxs("div",{className:"w-full metakyc-multiselect",ref:w,children:[e&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[e,l&&r.jsx("span",{className:"text-red-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"relative",children:[r.jsxs("div",{onClick:()=>!i&&d(!c),className:Q("metakyc-multiselect-trigger","min-h-[42px] w-full px-3 py-2 rounded-lg border text-sm transition-colors","bg-white dark:bg-gray-800","border-gray-300 dark:border-gray-600",c&&"ring-2 ring-blue-500 border-transparent",i?"opacity-50 cursor-not-allowed":"cursor-pointer"),children:[t.length===0?r.jsx("span",{className:"metakyc-multiselect-placeholder text-gray-400 dark:text-gray-500 leading-6",children:n}):r.jsx("div",{className:"flex flex-wrap gap-1 pr-6",children:t.map(f=>r.jsxs("span",{className:"metakyc-multiselect-chip inline-flex items-center gap-1 px-2 py-0.5 rounded bg-blue-100 dark:bg-blue-900/40 text-blue-800 dark:text-blue-300 text-xs font-medium",children:[k(f),!i&&r.jsx("button",{type:"button",onClick:x=>p(f,x),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:"×"})]},f))}),r.jsx("span",{className:"metakyc-multiselect-arrow absolute right-3 top-1/2 -translate-y-1/2 text-gray-400 pointer-events-none text-xs",children:c?"▲":"▼"})]}),c&&r.jsxs("div",{className:"metakyc-multiselect-dropdown absolute z-50 w-full mt-1 rounded-lg shadow-lg",style:{background:"inherit",border:"1px solid #d1d5db"},children:[r.jsx("div",{className:"metakyc-multiselect-search-wrapper p-2",style:{borderBottom:"1px solid #e5e7eb"},children:r.jsx("input",{type:"text",value:u,onChange:f=>v(f.target.value),placeholder:"Search...",autoFocus:!0,onClick:f=>f.stopPropagation(),className:"metakyc-multiselect-search w-full px-2 py-1.5 text-sm rounded focus:outline-none focus:ring-1 focus:ring-blue-500",style:{border:"1px solid #d1d5db"}})}),r.jsx("ul",{className:"max-h-48 overflow-y-auto py-1",children:g.length===0?r.jsx("li",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No results"}):g.map(f=>r.jsxs("li",{onClick:()=>m(f.value),className:Q("metakyc-multiselect-option","flex items-center gap-2 px-3 py-2 text-sm cursor-pointer","hover:bg-gray-50 dark:hover:bg-gray-700",t.includes(f.value)&&"metakyc-multiselect-option-selected bg-blue-50 dark:bg-blue-900/20"),children:[r.jsx("input",{type:"checkbox",checked:t.includes(f.value),readOnly:!0,className:"rounded border-gray-300 text-blue-600 pointer-events-none"}),r.jsx("span",{className:"text-gray-900 dark:text-gray-100",children:f.label})]},f.value))}),t.length>0&&r.jsx("div",{className:"metakyc-multiselect-clear p-2 border-t border-gray-100 dark:border-gray-700",children:r.jsxs("button",{type:"button",onClick:()=>{s([]),v("")},className:"text-xs text-red-500 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300",children:["Clear all (",t.length," selected)"]})})]})]})]})},It=({label:e,error:t,accept:s,multiple:a=!1,maxSize:n,onChange:i,value:l=[],className:c})=>{const[d,u]=o.useState(!1),v=o.useRef(null),w=x=>{if(!x)return;const A=Array.from(x);if(n&&A.filter(S=>S.size>n).length>0){const S=ve(n);alert(`Some files exceed the maximum size of ${S}`);return}i==null||i(a?[...l,...A]:[A[0]])},g=x=>{x.preventDefault(),u(!0)},m=()=>{u(!1)},p=x=>{x.preventDefault(),u(!1),w(x.dataTransfer.files)},k=()=>{var x;(x=v.current)==null||x.click()},f=x=>{const A=l.filter((j,S)=>S!==x);i==null||i(A)};return r.jsxs("div",{className:Q("w-full",c),children:[e&&r.jsx("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:e}),r.jsxs("div",{className:Q("border-2 border-dashed rounded-lg p-6 text-center cursor-pointer transition-colors",d?"border-primary-500 bg-primary-50 dark:bg-primary-900/20":"border-gray-300 dark:border-gray-600 hover:border-primary-500",t&&"border-danger-500"),onDragOver:g,onDragLeave:m,onDrop:p,onClick:k,children:[r.jsx("input",{ref:v,type:"file",className:"hidden",accept:s,multiple:a,onChange:x=>w(x.target.files)}),r.jsxs("div",{className:"space-y-2",children:[r.jsx("svg",{className:"mx-auto h-12 w-12 text-gray-400",stroke:"currentColor",fill:"none",viewBox:"0 0 48 48",children:r.jsx("path",{d:"M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})}),r.jsxs("div",{className:"text-sm text-gray-600 dark:text-gray-400",children:[r.jsx("span",{className:"font-medium text-primary-500",children:"Click to upload"})," or drag and drop"]}),n&&r.jsxs("p",{className:"text-xs text-gray-500",children:["Maximum file size: ",ve(n)]})]})]}),l.length>0&&r.jsx("div",{className:"mt-3 space-y-2",children:l.map((x,A)=>r.jsxs("div",{className:"flex items-center justify-between px-3 py-2 bg-gray-50 dark:bg-gray-700 rounded-lg",children:[r.jsxs("div",{className:"flex items-center space-x-2 flex-1 min-w-0",children:[r.jsx("svg",{className:"h-5 w-5 text-gray-400 flex-shrink-0",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4 4a2 2 0 012-2h4.586A2 2 0 0112 2.586L15.414 6A2 2 0 0116 7.414V16a2 2 0 01-2 2H6a2 2 0 01-2-2V4z",clipRule:"evenodd"})}),r.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300 truncate",children:x.name}),r.jsxs("span",{className:"text-xs text-gray-500",children:["(",ve(x.size),")"]})]}),r.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),f(A)},className:"ml-2 text-danger-500 hover:text-danger-700 focus:outline-none",children:r.jsx("svg",{className:"h-5 w-5",fill:"currentColor",viewBox:"0 0 20 20",children:r.jsx("path",{fillRule:"evenodd",d:"M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z",clipRule:"evenodd"})})})]},A))}),t&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:t})]})},Dt=o.forwardRef(({countryCode:e="+1",onCountryCodeChange:t,className:s,...a},n)=>r.jsxs("div",{className:"w-full",children:[a.label&&r.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[a.label,a.required&&r.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),r.jsxs("div",{className:"flex gap-2",children:[r.jsx("input",{type:"text",value:e,onChange:i=>t==null?void 0:t(i.target.value),className:Q("w-20 rounded-lg border px-3 py-2 text-sm","focus:outline-none focus:ring-2 focus:ring-primary-500 focus:border-transparent","border-gray-300 dark:border-gray-600 dark:bg-gray-800 dark:text-white"),placeholder:"+1"}),r.jsx(X,{ref:n,type:"tel",className:Q("flex-1",s),...a,label:""})]}),a.error&&r.jsx("p",{className:"mt-1 text-sm text-danger-500",children:a.error})]}));Dt.displayName="PhoneInput";/**
2
2
  * @license lucide-react v0.574.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.