@vpdev2/metakyc-sdk 1.0.100 → 1.0.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -79,5 +79,5 @@
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const os=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ir=Nr("chevron-right",os);function ls(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const n=Number(a);if(!isNaN(n)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function cs(t){const r=t.flatMap((a,n)=>(a.questions??[]).map((l,c)=>({question:l,groupIndex:n,qIdx:c}))),s=new Map;for(const a of r){const n=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(n)||s.set(n,[]),s.get(n).push(a)}return Array.from(s.entries()).sort(([a],[n])=>a-n).map(([,a])=>a)}const Er=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:n,isLoading:l,isSubmitting:c,error:u,submit:y}=fr(t),[m,w]=o.useState({}),[T,N]=o.useState({}),[F,f]=o.useState(0);o.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(m).length===0&&w(n)},[n]);const j=o.useMemo(()=>a?cs(a.questionGroups):[],[a]),P=F===j.length-1,_=j[F]??[],H=o.useCallback((I,g)=>{w(z=>({...z,[I]:g})),N(z=>{const $={...z};return delete $[I],$})},[]),L=o.useCallback(()=>{const I={};for(const{question:g}of _){const z=ls(g,m[g.id]??[]);z&&(I[g.id]=z)}return N(g=>({...g,...I})),Object.keys(I).length===0},[_,m]),K=()=>{L()&&f(I=>I+1)},W=()=>{F>0?f(I=>I-1):s==null||s()},Y=async()=>{if(!(!L()||!a))try{const I=a.questionGroups.flatMap(z=>(z.questions??[]).map($=>({questionId:$.id,values:m[$.id]??[]}))),g={applicantId:t,questionnarieId:a.id,questionResults:I};await y(g),r==null||r()}catch(I){console.error("Questionnaire submit error:",I)}};return l?e.jsx(J,{children:e.jsx(Z,{children:e.jsx(Ce,{className:"my-8"})})}):u?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",u.message]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),j.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",F+1," of ",j.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:j.map((I,g)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:g===F?"20px":"6px",backgroundColor:g<=F?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},g))})]})]}),e.jsx(Z,{className:"space-y-6",children:_.map(({question:I})=>e.jsx(ds,{question:I,value:m[I.id]??[],error:T[I.id],onChange:g=>H(I.id,g)},I.id))}),e.jsxs(xe,{className:"flex items-center justify-between",children:[e.jsxs(V,{type:"button",variant:"outline",onClick:W,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Rr,{size:14}),F>0?"Previous":"Back"]}),P?e.jsx(V,{type:"button",isLoading:c,onClick:Y,children:"Continue"}):e.jsxs(V,{type:"button",onClick:K,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Ir,{size:14})]})]}),u&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:u.message})})]}):null},ds=({question:t,value:r,error:s,onChange:a})=>{var c;const l=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),l==="text"&&e.jsx(me,{value:r[0]??"",onChange:u=>a([u.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),l==="single-select"&&e.jsx(ot,{value:r[0]??"",onChange:u=>a([u.target.value]),options:(t.defaultAnswers??[]).map(u=>({value:u,label:u})),placeholder:"Select an option…",error:s,required:t.isRequired}),l==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===u,onChange:()=>a([u]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(l==="checkbox"||l==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(u),onChange:y=>{y.target.checked?a([...r,u]):a(r.filter(m=>m!==u))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&l==="text"&&null]})};function us(t){const r=new Map;for(const s of t){const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push(s)}return Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}const Ar=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:n,isSubmitting:l,error:c,submit:u}=gr(t),[y,m]=o.useState({}),[w,T]=o.useState(null),[N,F]=o.useState(0),[f,j]=o.useState({}),P=o.useMemo(()=>a?us(a.uploadDocumentFiles):[],[a]),_=P[N]??[],H=N===P.length-1,L=P.length,K=o.useCallback(()=>{const g={};for(const z of _)z.isRequired&&(y[z.id]||[]).length===0&&(g[z.id]=`${z.displayName} is required`);return j(g),Object.keys(g).length===0},[_,y]),W=()=>{K()&&(F(g=>g+1),j({}))},Y=()=>{N>0?(F(g=>g-1),j({})):s==null||s()},I=async()=>{if(!(!K()||!a)){T(null);try{const g=await Promise.all(a.uploadDocumentFiles.map(async $=>{const D=y[$.id]||[],M=await Promise.all(D.map(async te=>({fileName:te.name,fileData:await dr(te)})));return{uploadDocumentFileId:$.id,valueList:M}})),z={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:g};await u(z),r==null||r()}catch(g){T((g==null?void 0:g.message)||"Failed to submit documents. Please try again.")}}};return n?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName||"Upload Documents"}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",N+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:P.map((g,z)=>e.jsx("div",{style:{height:"6px",width:z===N?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:z<=N?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},z))})]})]}),a.description&&N===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsx(Z,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:_.map(g=>e.jsx(wr,{label:g.displayName,subtitle:g.subtitle,accept:g.allowedTypes,multiple:g.multipleFile,maxSize:g.maxEachFileSizeByte,required:g.isRequired,error:f[g.id],value:y[g.id]||[],onChange:z=>{T(null),j($=>{const D={...$};return delete D[g.id],D}),m($=>({...$,[g.id]:z}))}},g.id))})}),w&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(V,{type:"button",variant:"outline",onClick:Y,children:N>0?"Previous":"Back"}),H?e.jsx(V,{type:"button",isLoading:l,onClick:I,children:l?"Uploading...":"Continue"}):e.jsx(V,{type:"button",onClick:W,children:"Next"})]})})]}):null},Fr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:n,isSubmitting:l,error:c,passOverview:u}=br(t),y=async()=>{await u(),r==null||r()};return n?e.jsx(J,{children:e.jsx(Z,{children:e.jsx(Ce,{className:"my-8"})})}):c?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.description})]}),e.jsx(Z,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((m,w)=>m.order-w.order).map(m=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:m.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.description})]})]},m.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{onClick:y,isLoading:l,children:"Continue"})]})]}):null};function ps(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function ms(t){return t.valueDataType===Ee.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function ys(t,r){const s=new Intl.NumberFormat(ps(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,a=>{const n=parseFloat(a);return isNaN(n)?a:s.format(n)})}function xs(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===Ee.Integer||t.valueDataType===Ee.Money||t.valueDataType===Ee.DigitOnly;if(n&&a.trim()!==""){const l=Number(a);if(!isNaN(l)){if(t.min!==void 0&&t.min!==null&&l<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&l>t.max)return`Maximum value is ${t.max}`}}else if(!n&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function hs(t){const r=new Map;return t.forEach((s,a)=>{const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function fs(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const Tr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:a}=we(),n=a.locale??"en",{criteria:l,initialAnswers:c,isLoading:u,isSubmitting:y,error:m,submit:w}=kr(t),[T,N]=o.useState({}),[F,f]=o.useState({}),[j,P]=o.useState(0),[_,H]=o.useState(!1);o.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(T).length===0&&N(c)},[c]);const L=o.useMemo(()=>l&&l.length>0?hs(l):[],[l]),K=j===L.length-1,W=L[j]??[];o.useEffect(()=>{!u&&l&&l.length===0&&!_&&!y&&(H(!0),w({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[u,l,_,y,w,t,r]);const Y=o.useCallback((D,M)=>{N(te=>({...te,[D]:M})),f(te=>{const re={...te};return delete re[D],re})},[]),I=o.useCallback(()=>{const D={};for(const{criterion:M}of W){const te=xs(M,T[M.id]??[]);te&&(D[M.id]=te)}return f(M=>({...M,...D})),Object.keys(D).length===0},[W,T]),g=()=>{I()&&P(D=>D+1)},z=()=>{j>0?P(D=>D-1):s==null||s()},$=async()=>{if(!(!I()||!l))try{const D=l.map(te=>{const re=(T[te.id]??[]).filter(ee=>ee&&ee.trim());return re.length>0?{riskCriteriaId:te.id,values:re}:null}).filter(te=>te!==null);await w({applicantId:t,criteriaValueInputs:D}),r==null||r()}catch(D){console.error("Risk scoring submit error:",D)}};return u?e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!u&&l&&l.length===0?e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):m?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",m.message]})})}):l?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",j+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((D,M)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:M===j?"20px":"6px",backgroundColor:M<=j?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},M))})]})]}),e.jsx(Z,{className:"space-y-6",children:W.map(({criterion:D})=>e.jsx(gs,{criterion:D,value:T[D.id]??[],error:F[D.id],locale:n,onChange:M=>Y(D.id,M)},D.id))}),e.jsxs(xe,{className:"flex items-center justify-between",children:[e.jsxs(V,{type:"button",variant:"outline",onClick:z,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Rr,{size:14}),j>0?"Previous":"Back"]}),K?e.jsx(V,{type:"button",isLoading:y,onClick:$,children:"Continue"}):e.jsxs(V,{type:"button",onClick:g,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Ir,{size:14})]})]}),m&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:m.message})})]}):null},gs=({criterion:t,value:r,error:s,locale:a,onChange:n})=>{const l=fs(t),c=t.valueDataType===Ee.Integer||t.valueDataType===Ee.Money||t.valueDataType===Ee.DigitOnly,u=ms(t),y=m=>u?ys(m,a):m;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),l==="text"&&e.jsx(me,{value:r[0]??"",onChange:m=>n([m.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:m=>{t.valueDataType===Ee.DigitOnly&&["e","E","+","-","."].includes(m.key)&&m.preventDefault()}}),l==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(m=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===m,onChange:()=>n([m]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(m)})]},m)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),l==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(m=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(m),onChange:w=>{w.target.checked?n([...r,m]):n(r.filter(T=>T!==m))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(m)})]},m)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),l==="country"&&e.jsx(ot,{value:r[0]??"",onChange:m=>n([m.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},Pr=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=we(),[n,l]=o.useState(null),[c,u]=o.useState(!1),[y,m]=o.useState(null),w=async T=>{if(T.preventDefault(),n===null){m("Please select an investor type");return}u(!0),m(null);try{const N={applicantId:t,investorType:n};console.log("Submitting investor categorization:",N);const F=await a.setInvestorCategorization(N);console.log("Investor categorization result:",F),r==null||r()}catch(N){console.error("Error submitting investor categorization:",N),m(N.message||"Failed to submit investor categorization")}finally{u(!1)}};return e.jsx("form",{onSubmit:w,children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.Individual,checked:n===ge.Individual,onChange:()=>l(ge.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.Sophisticated,checked:n===ge.Sophisticated,onChange:()=>l(ge.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.HighNetWorth,checked:n===ge.HighNetWorth,onChange:()=>l(ge.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:c,disabled:n===null,children:"Submit"})]})]})})};function kt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function lt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Lr=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=we(),[n,l]=o.useState(null),[c,u]=o.useState(!0),[y,m]=o.useState(!1),[w,T]=o.useState(null),[N,F]=o.useState({}),[f,j]=o.useState(0),[P,_]=o.useState(!1),[H,L]=o.useState(!1),[K,W]=o.useState(0),[Y,I]=o.useState(0),[g,z]=o.useState(null);o.useEffect(()=>{(async()=>{try{u(!0),T(null);const B=await a.getAppropriatenessTest(t);if(l(B),B.waitTimeSpanForNextTry&&B.waitTimeSpanForNextTry!=="00:00:00"){const b=kt(B.waitTimeSpanForNextTry);b>0&&W(b)}}catch(B){T(B.message||"Failed to load appropriateness test")}finally{u(!1)}})()},[t,a]),o.useEffect(()=>{if(!P||f<=0)return;const B=setInterval(()=>{j(b=>b<=1?(L(!0),0):b-1)},1e3);return()=>clearInterval(B)},[P,f]),o.useEffect(()=>{if(K<=0)return;const B=setInterval(()=>{W(b=>b<=1?0:b-1)},1e3);return()=>clearInterval(B)},[K]),o.useEffect(()=>{H&&!y&&te()},[H]);const $=()=>{n&&(_(!0),j(n.testDurationSec),I(0),F({}),T(null))},D=(B,b)=>{F(G=>({...G,[B]:b}))},M=o.useCallback(async()=>{try{const B=await a.getAppropriatenessTest(t);if(l(B),B.waitTimeSpanForNextTry&&B.waitTimeSpanForNextTry!=="00:00:00"){const b=kt(B.waitTimeSpanForNextTry);b>0&&W(b)}}catch{}},[t,a]),te=async B=>{if(n){if(!H){const b=n.appropriatenessQuestions.length-Object.keys(N).length;if(b>0){T(`Please answer all questions. ${b} remaining.`);return}}m(!0),T(null);try{const b=n.appropriatenessQuestions.map(Q=>({appropriatenessQuestionId:Q.id,value:N[Q.id]||""})),G={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:b};try{const Q=await a.fillAppropriatenessTest(G);Q.isSuccess?z({success:!0,message:Q.message||"Congratulations! You have passed the test."}):(z({success:!1,message:Q.message||"You did not pass the test."}),setTimeout(()=>M(),1e3))}catch(Q){if(Q.code===400&&Q.message)z({success:!1,message:Q.message}),setTimeout(()=>M(),1500);else throw Q}}catch(b){T(b.message||"Failed to submit test. Please try again."),re()}finally{m(!1)}}},re=()=>{_(!1),L(!1),F({}),I(0)};if(c)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!n)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),w&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:w})]})})});const ee=n.testAllowedMaxTry-n.totalFailedTries,ue=n.appropriatenessQuestions.length,oe=Object.keys(N).length;if(K>0)return e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName})}),e.jsx(Z,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:lt(K)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),w&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})})]})})]});if(g){const B=()=>{z(null),re(),T(null)};return e.jsxs(J,{children:[e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:g.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:g.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:g.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:g.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:g.message}),!g.success&&ee>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:ee})," attempt",ee!==1?"s":""," remaining"]})}),!g.success&&ee<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(xe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:g.success?e.jsx(V,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[ee>0&&K<=0&&e.jsx(V,{type:"button",onClick:B,children:"Retake Test"}),ee>0&&K>0&&e.jsx(V,{type:"button",onClick:B,children:"OK"}),ee<=0&&s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!P)return e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle})]}),e.jsxs(Z,{children:[n.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(st,{icon:"questions",label:"Questions",value:String(n.totalQuestionCount)}),e.jsx(st,{icon:"time",label:"Time Limit",value:lt(n.testDurationSec)}),e.jsx(st,{icon:"target",label:"Pass Requirement",value:`${n.testCorrectAnswerPassLimit} correct`}),e.jsx(st,{icon:"retry",label:"Attempts Left",value:String(ee),variant:ee<=1?"warning":"default"})]}),w&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",w]})]}),ee<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:$,disabled:ee<=0,children:"Start Test"})]})})]});const A=n.appropriatenessQuestions[Y],U=Y===ue-1,X=oe===ue,le=f<=60;return e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",Y+1," of ",ue]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:le?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:le?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:le?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:lt(f)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${oe/ue*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[oe," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[ee," attempt",ee!==1?"s":""," left"]})]})]})]}),e.jsxs(Z,{children:[A&&e.jsx(vs,{question:A,index:Y,selectedAnswer:N[A.id],onSelect:B=>D(A.id,B),disabled:y}),ue>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:n.appropriatenessQuestions.map((B,b)=>e.jsx("button",{type:"button",onClick:()=>I(b),style:{width:"28px",height:"28px",borderRadius:"8px",border:b===Y?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:N[B.id]?b===Y?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":b===Y?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:N[B.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b+1},B.id))}),H&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),w&&!H&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(V,{type:"button",variant:"outline",onClick:()=>{Y>0?I(B=>B-1):s==null||s()},disabled:y,children:Y>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!U&&e.jsx(V,{type:"button",onClick:()=>I(B=>B+1),children:"Next"}),(U||X)&&e.jsx(V,{type:"button",isLoading:y,onClick:()=>te(),disabled:!X&&!H,style:{opacity:X||H?1:.5},children:H?"Submitting...":"Submit Test"})]})]})})]})},bs={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},st=({icon:t,label:r,value:s,variant:a="default"})=>{const n=a==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:n?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:n?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:n?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:bs[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:n?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},vs=({question:t,selectedAnswer:r,onSelect:s,disabled:a})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((n,l)=>{const c=r===n;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:a?"default":"pointer",transition:"all 0.15s ease",opacity:a?.6:1},onMouseEnter:u=>{!a&&!c&&(u.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:u=>{c||(u.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:n,checked:c,onChange:()=>s(n),disabled:a,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:n})]},l)})})]}),Dr=({applicantId:t,onComplete:r,onBack:s})=>{var Te,Ve,Me,He;const{applicantService:a,baseInformationService:n,config:l,currentTheme:c}=we(),{identityData:u,provider:y,token:m,isLoading:w,error:T,requestIdentity:N,restartIdentity:F}=vr(t),[f,j]=o.useState(null),[P,_]=o.useState(null),[H,L]=o.useState([]),[K,W]=o.useState([]),[Y,I]=o.useState(!0),[g,z]=o.useState(!1),[$,D]=o.useState(null),[M,te]=o.useState(!1),re=o.useRef(!1),[ee,ue]=o.useState({}),[oe,A]=o.useState({}),U=c!=null&&c.reviewPageFields&&c.reviewPageFields.length>0?c.reviewPageFields[0]:null,X=!!(c!=null&&c.reviewPageDisabled),le=o.useRef(!1);le.current=X;const B=Oe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});o.useEffect(()=>{if(X){re.current||(re.current=!0,N().then(()=>z(!0)).catch(O=>console.error("[Identity] Auto-request failed:",O)).finally(()=>I(!1)));return}(async()=>{try{const[O,q,p]=await Promise.all([a.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);_(O);const k=new Set,R=q.map(x=>({value:x.abbreviation3||x.abbreviation,label:x.name})).filter(x=>!x.value||k.has(x.value)?!1:(k.add(x.value),!0));L(R);const v=new Set,i=p.filter(x=>x.countryCode).map(x=>({value:x.countryCode,label:`${x.countryCode} – ${x.name}`})).filter(x=>v.has(x.value)?!1:(v.add(x.value),!0));W(i);const d=O.applicantRequestData;if(ue({firstName:(d==null?void 0:d.firstName)||"",lastName:(d==null?void 0:d.lastName)||"",email:(d==null?void 0:d.email)||"",dateOfBirth:(d==null?void 0:d.dateOfBirth)||"",title:(d==null?void 0:d.title)||"",salutation:(d==null?void 0:d.salutation)||"",phonenumber:(d==null?void 0:d.phonenumber)||"",mobileCountryCode:(d==null?void 0:d.mobileCountryCode)||"",street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",taxCountry:(d==null?void 0:d.taxCountry)||"",countryOfBirth:(d==null?void 0:d.countryOfBirth)||"",placeOfBirth:(d==null?void 0:d.placeOfBirth)||"",educationLevel:(d==null?void 0:d.educationLevel)||"",occupation:(d==null?void 0:d.occupation)||"",taxNumber:(d==null?void 0:d.taxNumber)||"",defaultLanguage:(d==null?void 0:d.defaultLanguage)||""}),B.reset({street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",phonenumber:(d==null?void 0:d.phonenumber)||""}),O.kycRecords&&O.kycRecords.length>0&&O.kycRecords[0].providerTokenObject!==null&&!re.current&&le.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),re.current=!0;try{await N(),z(!0)}catch(x){console.error("[Identity] Auto-request failed:",x)}}}catch(O){console.error("Error loading applicant data:",O)}finally{I(!1)}})()},[t]),o.useEffect(()=>{u&&!g&&le.current&&(console.log("[Identity] Review page disabled — showing cached provider"),z(!0))},[u,g]),o.useEffect(()=>{if(m){if(m.expiresAt){const h=new Date(m.expiresAt).getTime();if(Date.now()>=h){console.warn("[Identity] Token has expired (expiresAt)"),te(!0),D("Your verification session has expired. Please restart.");return}}if(m.url)try{const O=new URL(m.url).toString().toLowerCase();if(O.includes("expired")||O.includes("invalid")||O.includes("error")){console.warn("[Identity] Token URL indicates expiration"),te(!0),D("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(m.status==="expired"||m.error==="expired"||m.expired===!0){console.warn("[Identity] Token object indicates expiration"),te(!0),D("Your verification session has expired. Please restart.");return}}},[m]),o.useEffect(()=>{if(y!==null&&m&&!f&&g&&!M){const h=y;if(m.url){console.log("[Identity] Loading provider URL for user verification:",m.url),D(null);try{if(new URL(m.url),h===Ne.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const O=Ke.parseProviderConfig(y,m,l);Ke.createProvider(y,O).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(p=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",p)})}catch(O){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",O)}}j({type:"url",url:m.url})}catch(O){console.error("[Identity] Invalid URL:",O),D("Invalid verification URL. Please restart."),te(!0)}return}if(h===Ne.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),D(null);try{const O=Ke.parseProviderConfig(y,m,l),q=Ke.createProvider(y,O);q.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),j(q),setTimeout(()=>{r==null||r()},2e3)}).catch(p=>{var R;console.error("[SardinAI] Failed to initialize:",p);const k=((R=p.message)==null?void 0:R.toLowerCase())||"";k.includes("expired")||k.includes("invalid")||k.includes("401")||k.includes("400")?(te(!0),D("Session expired or invalid. Please restart verification.")):D(`Failed to initialize: ${p.message}`)})}catch(O){console.error("[SardinAI] Error creating provider:",O),D(`Configuration error: ${O.message}`)}return}try{D(null);const O=Ke.parseProviderConfig(y,m,l),q=Ke.createProvider(y,O);h===Ne.Sumsub?(q.initialize("identity-container").catch(p=>{var k;console.error("[Sumsub] Initialization error:",p),D(`Failed to initialize: ${p.message}`),(k=p.message)!=null&&k.toLowerCase().includes("expired")&&te(!0)}),q.onComplete&&q.onComplete(()=>{r==null||r()})):h===Ne.Onfido&&q.initialize("identity-container").catch(p=>{console.error("[Onfido] Initialization error:",p),D(`Failed to initialize: ${p.message}`)}),j(q)}catch(O){console.error("[Identity] Provider setup error:",O),D(`Setup error: ${O.message}`)}}return()=>{if(f&&f.destroy)try{f.destroy()}catch(h){console.error("[Identity] Error destroying provider:",h)}}},[y,m,f,g,r,M]);const b=async()=>{try{D(null),te(!1),await N(),z(!0)}catch(h){console.error("Error starting identity verification:",h)}},G=async()=>{try{D(null),te(!1),j(null),console.log("[Identity] Restarting verification..."),await F(),z(!0)}catch(h){console.error("Error restarting identity verification:",h),D(h.message||"Failed to restart verification")}};if(Y||w)return e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(T)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",T.message]})})});if(g&&($||M))return e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:M?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:$||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:G,disabled:w,children:w?"Restarting...":"Restart Verification"})]})]});if(g&&u){const h=y;return m!=null&&m.url?e.jsxs(J,{children:[e.jsx(ye,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(V,{type:"button",variant:"outline",size:"sm",onClick:G,disabled:w,children:"Restart"})]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:m.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:O=>{var q,p,k;console.log("[Identity] Iframe loaded");try{const R=O.target,v=R.contentDocument||((q=R.contentWindow)==null?void 0:q.document);if(v){const i=((k=(p=v.body)==null?void 0:p.textContent)==null?void 0:k.toLowerCase())||"";(i.includes("expired")||i.includes("invalid")||i.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),te(!0),D("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(xe,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]}):h===Ne.SardinAI?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ce,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(Z,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(xe,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]})}const Q=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ie=(h=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[h]||"col-span-4",ke=(h,O)=>{if(!O&&O!==0)return"—";if(Q.has(h)&&h!=="mobileCountryCode"){const q=H.find(p=>p.value===O);return q?q.label:String(O)}return String(O)},Fe=({helpText:h})=>{const[O,q]=o.useState(!1),p=o.useRef(null),[,k]=o.useState({top:0,left:0}),R=()=>{if(p.current){const v=p.current.getBoundingClientRect();k({top:v.bottom+window.scrollY+6,left:v.left+window.scrollX})}q(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:p,onClick:R,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),O&&it.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>q(!1),children:e.jsxs("div",{onClick:v=>v.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:h},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>q(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},he=(h,O)=>O?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:h}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Fe,{helpText:O})})]}):h,qe=(h,O)=>{const q=`cf-${O}`,p=h.paramName??"",k=oe[p];if(h.customType==="br")return e.jsx("div",{className:ie(h.colSpan),style:{minHeight:"0.5rem"}},q);if(h.customType==="paragraph")return e.jsx("div",{className:ie(h.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:h.label||""}})},q);if(h.customType==="html")return e.jsx("div",{className:ie(h.colSpan),dangerouslySetInnerHTML:{__html:h.label||""}},q);if(h.customType==="link")return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsx("a",{href:h.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:h.displayText||h.label||h.linkText||h.linkUrl}),h.helpText)},q);if(h.customType==="checkbox"||h.customType==="link_checkbox"){const R=k==="true"||k===!0;return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!R,onChange:v=>A(i=>({...i,[p]:String(v.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.customType==="link_checkbox"&&h.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:h.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:h.linkText||h.label}),h.label&&h.linkText?` ${h.label}`:""]}):h.displayText||h.label})]}),h.helpText)},q)}if(h.customType==="group_checkbox"){const R=Array.isArray(k)?k:k?[k]:[],v=i=>{h.singleSelect?A(d=>({...d,[p]:R[0]===i?[]:[i]})):A(d=>({...d,[p]:R.includes(i)?R.filter(E=>E!==i):[...R,i]}))};return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("div",{className:"space-y-1.5",children:[h.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.displayText||h.label}),(h.options||[]).map(i=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:R.includes(i.value),onChange:()=>v(i.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:i.label})]},i.value))]}),h.helpText)},q)}return h.customType==="radio_group"?e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("div",{className:"space-y-1.5",children:[h.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.displayText||h.label}),(h.options||[]).map(R=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${p}`,value:R.value,checked:k===R.value,onChange:()=>A(v=>({...v,[p]:R.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:R.label})]},R.value))]}),h.helpText)},q):e.jsx("div",{className:ie(h.colSpan),children:he(e.jsx(me,{label:h.displayText||h.label||p,value:String(k??""),onChange:R=>A(v=>({...v,[p]:R.target.value}))}),h.helpText)},q)},Ye=(h,O)=>{if(h.isCustom)return qe(h,O);const q=h.name??"",p=_e[q],k=h.displayText||(p==null?void 0:p.label)||q,R=ee[q]??"",v=q==="mobileCountryCode",i=!!(p!=null&&p.countriesType)&&!v;return h.editable?v?e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(Ae,{label:k,value:String(R),onChange:d=>ue(E=>({...E,[q]:d})),options:[{value:"",label:"Select country code…"},...K]}),h.helpText)},`epc-${O}`):i?e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(Ae,{label:k,value:String(R),onChange:d=>ue(E=>({...E,[q]:d})),options:[{value:"",label:`Select ${k.toLowerCase()}…`},...H]}),h.helpText)},`ec-${O}`):e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(me,{label:k,type:(p==null?void 0:p.type)==="date"?"date":(p==null?void 0:p.type)==="email"?"email":"text",value:String(R),onChange:d=>ue(E=>({...E,[q]:d.target.value}))}),h.helpText)},`ei-${O}`):e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:k}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ke(q,R)})]}),h.helpText)},`ro-${O}`)};if(U){const h=U.title||"Review Your Information",O=U.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:q=>{q.preventDefault(),b()},children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:h}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:O})]}),e.jsx(Z,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:U.fields.map((q,p)=>Ye(q,p))})}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:w,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:B.handleSubmit(b),children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(Z,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Te=P==null?void 0:P.applicantRequestData)==null?void 0:Te.firstName)||""} ${((Ve=P==null?void 0:P.applicantRequestData)==null?void 0:Ve.lastName)||""}`.trim()},{label:"Email",value:(Me=P==null?void 0:P.applicantRequestData)==null?void 0:Me.email},{label:"Date of Birth",value:((He=P==null?void 0:P.applicantRequestData)==null?void 0:He.dateOfBirth)||"Not provided"}].map(({label:h,value:O})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:h}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:O})]},h))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"country",render:({field:h})=>e.jsx(Ae,{label:"Country",value:h.value,onChange:h.onChange,options:[{value:"",label:"Select country…"},...H]})}),e.jsx(Oe.Controller,{control:B.control,name:"nationality",render:({field:h})=>e.jsx(Ae,{label:"Nationality",value:h.value,onChange:h.onChange,options:[{value:"",label:"Select nationality…"},...H]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"street",render:({field:h})=>e.jsx(me,{...h,label:"Street"})}),e.jsx(Oe.Controller,{control:B.control,name:"streetNumber",render:({field:h})=>e.jsx(me,{...h,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"city",render:({field:h})=>e.jsx(me,{...h,label:"City"})}),e.jsx(Oe.Controller,{control:B.control,name:"zip",render:({field:h})=>e.jsx(me,{...h,label:"ZIP / Postal Code"})})]}),e.jsx(Oe.Controller,{control:B.control,name:"phonenumber",render:({field:h})=>e.jsx(me,{...h,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:w,children:"Confirm and Start Verification"})]})]})})},ut=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:l})=>{const u=t===Be.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Be.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Be.Pending||t===Be.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===$e.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===$e.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===$e.UnderReview||r===$e.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===tt.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===tt.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===tt.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(J,{children:[e.jsxs(Z,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${u.iconBg}`,children:e.jsx("span",{className:`text-5xl ${u.iconColor}`,children:u.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(xt,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Be[t]:$e[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a||u.message}),u.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),u.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),u.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Be[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:$e[r]})]})]})})]}),e.jsxs(xe,{className:"flex justify-center gap-4",children:[u.type==="success"&&n&&e.jsx(V,{onClick:n,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[l&&e.jsx(V,{variant:"outline",onClick:l,children:"Contact Support"}),n&&e.jsx(V,{onClick:n,children:"Try Again"})]}),u.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Mr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Ze=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=we(),n=t||(a==null?void 0:a.title)||"",l=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),c=!!n;return!l&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[l&&e.jsx(Mr,{config:a.logo}),l&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},at=["firstName","lastName","email","phonenumber","dateOfBirth"];function Qe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const et={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},jt=({helpText:t,children:r})=>{const[s,a]=o.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>a(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:l=>l.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>a(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:l=>{l.currentTarget.style.background="var(--metakyc-primary, #2563eb)",l.currentTarget.style.color="#ffffff"},onMouseLeave:l=>{l.currentTarget.style.background="transparent",l.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?it.createPortal(n,document.body):null]})},ks=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var O,q,p,k,R,v;const{config:n,baseInformationService:l,currentTheme:c}=we(),{createApplicant:u,isLoading:y}=yt(),m=t||((O=n.applicantForm)==null?void 0:O.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const w=r||((q=n.applicantForm)==null?void 0:q.externalRefId)||"",T=((p=n.applicantForm)==null?void 0:p.email)||"",N=((k=n.applicantForm)==null?void 0:k.hiddenValues)||{},f=(((R=n.applicantForm)==null?void 0:R.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",j=o.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),P=o.useMemo(()=>{const i=new Set(at),d=c==null?void 0:c.applicantFormRequiredFields;if(d)for(const E of d)i.add(E);if(j)for(const E of j)for(const x of E.fields)!x.isCustom&&x.name&&x.required&&i.add(x.name);return Array.from(i)},[c==null?void 0:c.applicantFormRequiredFields,j]),_=o.useMemo(()=>{var E;if(j){const x=j.flatMap(S=>S.fields).filter(S=>!S.isCustom&&S.name).map(S=>S.name),C=new Set(x);for(const S of at)C.add(S);return Array.from(C)}let i;(E=n.applicantForm)!=null&&E.visibleFields?i=n.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?i=c.applicantFormVisibleFields:i=Mt;const d=new Set(i);for(const x of at)d.add(x);return Array.from(d)},[(v=n.applicantForm)==null?void 0:v.visibleFields,c==null?void 0:c.applicantFormVisibleFields,j]),H=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),L=o.useMemo(()=>{var d,E;const i=new Set;if(j)for(const x of j)for(const C of x.fields)!C.isCustom&&C.name&&H.has(C.name)&&i.add(C.countriesType??((d=_e[C.name])==null?void 0:d.countriesType));else for(const x of _)H.has(x)&&i.add((E=_e[x])==null?void 0:E.countriesType);return i.size===0&&i.add(void 0),Array.from(i)},[_,j]),[K,W]=o.useState({}),[Y,I]=o.useState(!0),g=o.useRef(new Set),z=o.useRef(new Set);o.useEffect(()=>{if(!c)return;const i=L.filter(x=>{const C=x!=null?String(x):"all";return!z.current.has(C)&&!g.current.has(C)});if(i.length===0){L.every(C=>{const S=C!=null?String(C):"all";return z.current.has(S)})&&I(!1);return}I(!0);const d=i.map(x=>x!=null?String(x):"all");d.forEach(x=>g.current.add(x)),(async()=>{try{const x=await Promise.all(i.map(async C=>{const S=C!=null?String(C):"all",ne=await l.getCountries("",n.locale||"en",C),se=C===40,fe=new Set,pe=ne.map(ce=>se&&ce.countryCode?{value:ce.countryCode,label:`${ce.countryCode} – ${ce.name}`}:{value:ce.abbreviation3||ce.abbreviation,label:ce.name}).filter(ce=>!ce.value||fe.has(ce.value)?!1:(fe.add(ce.value),!0));return z.current.add(S),g.current.delete(S),[S,pe]}));W(C=>({...C,...Object.fromEntries(x)}))}catch(x){d.forEach(C=>g.current.delete(C)),console.error("Failed to load countries:",x)}finally{L.every(C=>{const S=C!=null?String(C):"all";return z.current.has(S)})&&I(!1)}})()},[L,c]);const $=(i,d)=>{var C;const E=d??((C=_e[i])==null?void 0:C.countriesType),x=E!=null?String(E):"all";return K[x]||[]},D=Object.fromEntries(Object.entries(N).filter(([i])=>i in{firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1})),[M,te]=o.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:T,dateOfBirth:"",phonenumber:"",externalRefId:w,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...D}),re=Object.fromEntries(Object.entries(N).filter(([i])=>!(i in D)&&i!=="externalRefId"&&i!=="workflowKey")),[ee,ue]=o.useState({...re}),[oe,A]=o.useState(0),[U,X]=o.useState({}),[le,B]=o.useState(null),[b,G]=o.useState(!1),Q=(i,d)=>te(E=>({...E,[i]:d})),ie=(i,d)=>ue(E=>({...E,[i]:d})),ke=i=>!i.conditionalOn||ee[i.conditionalOn]==="true",Fe=j&&oe<j.length-1?oe+1:-1,he=j&&oe>0?oe-1:-1,qe=i=>{var E;const d={};for(const x of i.fields)if(x.isCustom){if(x.customType==="paragraph"||x.customType==="html"||x.customType==="br"||x.customType==="link")continue;if(x.required&&x.paramName){const C=ee[x.paramName],S=x.displayText||x.label||x.paramName;x.customType==="checkbox"||x.customType==="link_checkbox"?C!=="true"&&(d[x.paramName]=`${S} is required.`):(!C||C.trim()==="")&&(d[x.paramName]=`${S} is required.`)}}else if(x.name){const C=x.name;if(P.includes(C)&&Qe(M[C])){const S=x.displayText||((E=_e[C])==null?void 0:E.label)||C;d[C]=`${S} is required.`}}return d},Ye=async()=>{if(!j)return;const i=j[oe];if(i.conditionalOn&&!ke(i)){X({}),Fe>=0?A(Fe):await Te();return}const d=qe(i);if(Object.keys(d).length>0){X(d);return}X({}),Fe>=0?A(Fe):await Te()},Te=async()=>{if(j){let i={};for(const d of j)ke(d)&&(i={...i,...qe(d)});if(Object.keys(i).length>0){X(i);return}}G(!0),B(null);try{if(!M.externalRefId||M.externalRefId.trim()===""){B("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const i={workflowKey:M.workflowKey,externalRefId:M.externalRefId.trim()};if(j){for(const C of j)if(ke(C)){for(const S of C.fields)if(!S.isCustom&&S.name){const ne=S.name,se=M[ne];Qe(se)||(i[ne]=se)}}for(const C of at)if(i[C]===void 0){const S=M[C];Qe(S)||(i[C]=S)}}else _.forEach(C=>{if(C==="externalRefId")return;const S=M[C];Qe(S)||(i[C]=S)});const d=[];if(j){for(const C of j)if(ke(C))for(const S of C.fields){if(!S.isCustom||!S.paramName||S.customType==="paragraph"||S.customType==="html"||S.customType==="br"||S.customType==="link")continue;const ne=ee[S.paramName]??"";let se;if(S.customType==="checkbox"||S.customType==="link_checkbox")se=ne==="true"?"yes":"no";else if(se=ne,!se&&!S.required)continue;d.push({paramName:S.paramName,value:se})}}for(const[C,S]of Object.entries(D))i[C]===void 0&&!Qe(S)&&(i[C]=S);const E=new Set(d.map(C=>C.paramName));for(const[C,S]of Object.entries(re))!E.has(C)&&S&&d.push({paramName:C,value:S});d.length>0&&(i.applicantAdditionalDatas=d);const x=await u(i);s(x.applicantId)}catch(i){console.error("Error creating applicant:",i),B(i.message||"Failed to create applicant")}finally{G(!1)}},Ve=async i=>{var d;i.preventDefault();for(const E of P)if(Qe(M[E])){const x=((d=_e[E])==null?void 0:d.label)||E;B(`${x} is required.`);return}await Te()},Me=(i,d,E,x,C)=>{var ht;const S=_e[i];if(!S)return null;const ne=P.includes(i),se=U[i],fe=E||S.label,pe=d??i,ce={required:ne},Pe=C?C!=="placeholder":f,ze=Pe?fe:void 0,zr=Pe?"...":fe;switch(S.type){case"select":if(i==="country"||i==="nationality"||i==="taxCountry"||i==="countryOfBirth"||i==="mobileCountryCode"){const je=$(i,x);return e.jsx(Ae,{...ce,label:ze,value:M[i]||"",onChange:We=>Q(i,We),options:[{value:"",label:`Select ${zr.toLowerCase()}`},...je],disabled:Y,error:se},pe)}if(i==="salutation")return e.jsx(Ae,{...ce,label:ze,value:((ht=M[i])==null?void 0:ht.toString())||"",onChange:je=>Q(i,je?Number(je):null),options:[{value:"",label:Pe?"Select salutation...":fe},{value:rt.Male.toString(),label:"Male"},{value:rt.Female.toString(),label:"Female"},{value:rt.Other.toString(),label:"Other"}],error:se},pe);if(i==="defaultLanguage"){const je=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?dt.filter(We=>c.allowedLanguages.includes(We.value)):dt;return e.jsx(Ae,{...ce,label:ze,value:M[i]||"",onChange:We=>Q(i,We),options:[{value:"",label:Pe?"Select language...":fe},...je],error:se},pe)}return null;case"multiselect":if(i==="otherNationality"){const je=$(i,x);return e.jsx(jr,{...ce,label:ze,value:M[i]||[],onChange:We=>Q(i,We),options:je,placeholder:Pe?"Select other nationalities...":fe,disabled:Y},pe)}return null;case"date":return e.jsx(me,{...ce,type:"date",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);case"email":return e.jsx(me,{...ce,type:"email",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);case"tel":return e.jsx(me,{...ce,type:"tel",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);default:return e.jsx(me,{...ce,type:"text",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe)}},He=(i,d)=>{const E=i.labelMode?i.labelMode!=="placeholder":f;if(i.customType==="paragraph"){const S=i.displayText||i.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:S}},`custom-${d}`)}if(i.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:i.label||""}},`custom-${d}`);if(i.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${d}`);if(i.customType==="link"){const S=i.displayText||i.label||i.linkText||i.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:i.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[S,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${d}`)}if(!i.paramName)return null;const x=U[i.paramName],C=i.displayText||i.label||i.paramName;if(i.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:ee[i.paramName]==="true",onChange:S=>ie(i.paramName,S.target.checked?"true":"false"),className:"metakyc-option-input",style:et}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),x&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:x})]},`custom-${d}`);if(i.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:ee[i.paramName]==="true",onChange:S=>ie(i.paramName,S.target.checked?"true":"false"),className:"metakyc-option-input",style:{...et,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[C," ",i.linkUrl&&e.jsx("a",{href:i.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:S=>S.stopPropagation(),children:i.linkText||i.linkUrl}),i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),x&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:x})]},`custom-${d}`);if(i.customType==="group_checkbox"){const S=(ee[i.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[E&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(i.options||[]).map(ne=>{const se=i.singleSelect?ee[i.paramName]===ne.value:S.includes(ne.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:se,onChange:fe=>{if(i.singleSelect)ie(i.paramName,fe.target.checked?ne.value:"");else{const pe=fe.target.checked?[...S,ne.value]:S.filter(ce=>ce!==ne.value);ie(i.paramName,pe.join(","))}},className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:ne.label})]},ne.value)})}),x&&e.jsx("p",{className:"text-red-500 text-xs",children:x})]},`custom-${d}`)}return i.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[E&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(i.options||[]).map(S=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:ee[i.paramName]===S.value,onChange:()=>ie(i.paramName,S.value),name:`radio-group-${i.paramName}-${d}`,className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:S.label})]},S.value))}),x&&e.jsx("p",{className:"text-red-500 text-xs",children:x})]},`custom-${d}`):e.jsx(me,{type:"text",label:E?`${C}${i.required?" *":""}`:void 0,placeholder:E?void 0:C,value:ee[i.paramName]||"",onChange:S=>ie(i.paramName,S.target.value),required:i.required,error:x},`custom-${d}`)},h=(i,d)=>{const E=ke(i);return e.jsxs("div",{className:"space-y-4",children:[i.conditionalOn&&e.jsx(jt,{helpText:i.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:E,onChange:x=>ie(i.conditionalOn,x.target.checked?"true":"false"),className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:i.conditionalOn})]})}),E&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:i.fields.map((x,C)=>{const S=x.colSpan===1?"col-span-1":x.colSpan===2?"col-span-2":x.colSpan===3?"col-span-3":"col-span-4",ne=x.isCustom?`custom-${C}-${x.paramName}`:`builtin-${x.name}-${C}`;return e.jsx("div",{className:S,children:e.jsx(jt,{helpText:x.helpText,children:x.isCustom?He(x,C):Me(x.name,ne,x.displayText,x.countriesType,x.labelMode)})},ne)})})]})};if(!c||Y)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(j){const i=j[oe]??j[0],d=he===-1,E=Fe===-1,x=j.length,C=ke(i),S=Object.values(U);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(Z,{children:[(i.title||i.subtitle||i.description)&&e.jsxs("div",{className:"mb-4",children:[i.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:i.title}),i.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:i.subtitle}),i.description&&i.description!==i.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:i.description})]}),(le||S.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[le&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",le]}),S.map((ne,se)=>e.jsx("p",{className:"text-red-600 text-sm",children:ne},se))]}),x>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[j.map((ne,se)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${se===oe?"flex-1":"w-8"}`,style:se===oe?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:se<oe?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},se)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[oe+1," / ",x]})]}),h(i)]}),e.jsxs(xe,{className:"flex justify-between",children:[e.jsxs("div",{children:[!d&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{A(he),X({})},disabled:b||y,children:"Previous"}),d&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:b||y,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:b||y,onClick:E?Te:Ye,children:E?i.conditionalOn&&!C?"Skip & Submit":"Submit":i.conditionalOn&&!C?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Ve,children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(Z,{children:[le&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",le]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:_.map(i=>e.jsx("div",{className:"col-span-4",children:Me(i)},i))})]}),e.jsxs(xe,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:b||y,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:b||y,children:"Create Applicant"})]})]})})})},wt=["companyName","email"];function ct(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const js=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var Me,He,h,O,q;const{config:n,baseInformationService:l,currentTheme:c}=we(),{createCompanyApplicant:u,isLoading:y}=yt(),m=t||((Me=n.applicantForm)==null?void 0:Me.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const w=r||((He=n.applicantForm)==null?void 0:He.externalRefId)||"",T=((h=n.applicantForm)==null?void 0:h.email)||"",F=(((O=n.applicantForm)==null?void 0:O.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",f=o.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),j=o.useMemo(()=>{const p=new Set(wt),k=c==null?void 0:c.companyFormRequiredFields;if(k)for(const R of k)p.add(R);if(f)for(const R of f)for(const v of R.fields)!v.isCustom&&v.name&&v.required&&p.add(v.name);return Array.from(p)},[c==null?void 0:c.companyFormRequiredFields,f]),P=o.useMemo(()=>{var p;if(f){const k=f.flatMap(v=>v.fields).filter(v=>!v.isCustom&&v.name).map(v=>v.name),R=new Set(k);for(const v of wt)R.add(v);return Array.from(R)}return(p=n.applicantForm)!=null&&p.visibleFields?n.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:Dt},[(q=n.applicantForm)==null?void 0:q.visibleFields,c==null?void 0:c.companyFormVisibleFields,f]),_=new Set(["countryResidence","addressCountry"]),H=o.useMemo(()=>{var k,R;const p=new Set;if(f)for(const v of f)for(const i of v.fields)!i.isCustom&&i.name&&_.has(i.name)&&p.add(i.countriesType??((k=Ue[i.name])==null?void 0:k.countriesType));else for(const v of P)_.has(v)&&p.add((R=Ue[v])==null?void 0:R.countriesType);return p.size===0&&p.add(void 0),Array.from(p)},[P,f]),[L,K]=o.useState({}),[W,Y]=o.useState(!0),I=o.useRef(new Set),g=o.useRef(new Set);o.useEffect(()=>{if(!c)return;const p=H.filter(v=>{const i=v!=null?String(v):"all";return!g.current.has(i)&&!I.current.has(i)});if(p.length===0){H.every(i=>g.current.has(i!=null?String(i):"all"))&&Y(!1);return}Y(!0);const k=p.map(v=>v!=null?String(v):"all");k.forEach(v=>I.current.add(v)),(async()=>{try{const v=await Promise.all(p.map(async i=>{const d=i!=null?String(i):"all",E=await l.getCountries("",n.locale||"en",i),x=new Set,C=E.map(S=>({value:S.abbreviation3||S.abbreviation,label:S.name})).filter(S=>!S.value||x.has(S.value)?!1:(x.add(S.value),!0));return g.current.add(d),I.current.delete(d),[d,C]}));K(i=>({...i,...Object.fromEntries(v)}))}catch(v){k.forEach(i=>I.current.delete(i)),console.error("Failed to load countries:",v)}finally{H.every(i=>g.current.has(i!=null?String(i):"all"))&&Y(!1)}})()},[H,c]);const z=(p,k)=>{var i;const R=k??((i=Ue[p])==null?void 0:i.countriesType),v=R!=null?String(R):"all";return L[v]||[]},[$,D]=o.useState({workflowKey:m,companyName:"",email:T,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:w}),[M,te]=o.useState({}),[re,ee]=o.useState(0),[ue,oe]=o.useState({}),[A,U]=o.useState(null),[X,le]=o.useState(!1),B=(p,k)=>D(R=>({...R,[p]:k})),b=(p,k)=>te(R=>({...R,[p]:k})),G=p=>!p.conditionalOn||M[p.conditionalOn]==="true",Q=f&&re<f.length-1?re+1:-1,ie=f&&re>0?re-1:-1,ke=p=>{var R;const k={};for(const v of p.fields)if(v.isCustom){if(v.customType==="paragraph"||v.customType==="html"||v.customType==="br"||v.customType==="link")continue;if(v.required&&v.paramName){const i=M[v.paramName],d=v.displayText||v.label||v.paramName;v.customType==="checkbox"||v.customType==="link_checkbox"?i!=="true"&&(k[v.paramName]=`${d} is required.`):(!i||i.trim()==="")&&(k[v.paramName]=`${d} is required.`)}}else if(v.name){const i=v.name;if(j.includes(i)&&ct($[i])){const d=v.displayText||((R=Ue[i])==null?void 0:R.label)||i;k[i]=`${d} is required.`}}return k},Fe=async()=>{if(!f)return;const p=f[re];if(p.conditionalOn&&!G(p)){oe({}),Q>=0?ee(Q):await he();return}const k=ke(p);if(Object.keys(k).length>0){oe(k);return}oe({}),Q>=0?ee(Q):await he()},he=async()=>{var p;if(f){let k={};for(const R of f)G(R)&&(k={...k,...ke(R)});if(Object.keys(k).length>0){oe(k);return}}le(!0),U(null);try{const k={workflowKey:$.workflowKey,externalRefId:((p=$.externalRefId)==null?void 0:p.trim())||void 0},R=f?f.filter(d=>G(d)).flatMap(d=>d.fields).filter(d=>!d.isCustom&&d.name).map(d=>d.name):P;for(const d of R){const E=$[d];if(!ct(E))switch(d){case"companyName":k.companyName=E;break;case"email":k.companyEmail=E;break;case"phone":k.companyPhone=E;break;case"registrationNumber":k.companyRegistrationNumber=E;break;case"countryResidence":k.companyCountry=E;break;case"city":k.companyCity=E;break;case"street":k.companyStreet=E;break;case"postalCode":k.companyZip=E;break;default:k[d]=E;break}}const v=[];if(f){for(const d of f)if(G(d))for(const E of d.fields){if(!E.isCustom||!E.paramName||E.customType==="paragraph"||E.customType==="html"||E.customType==="br"||E.customType==="link")continue;const x=M[E.paramName]??"";let C;if(E.customType==="checkbox"||E.customType==="link_checkbox")C=x==="true"?"yes":"no";else if(C=x,!C&&!E.required)continue;v.push({paramName:E.paramName,value:C})}}v.length>0&&(k.applicantAdditionalDatas=v);const i=await u(k);s(i.applicantId)}catch(k){console.error("Error creating company applicant:",k),U(k.message||"Failed to create company applicant")}finally{le(!1)}},qe=async p=>{var k;p.preventDefault();for(const R of j)if(ct($[R])){const v=((k=Ue[R])==null?void 0:k.label)||R;U(`${v} is required.`);return}await he()},Ye=(p,k,R,v,i)=>{const d=Ue[p];if(!d)return null;const E=j.includes(p),x=ue[p],C=R||d.label,S=k??p,ne=i?i!=="placeholder":F,se=ne?C:void 0,fe=ne?"...":C;switch(d.type){case"select":if(p==="countryResidence"||p==="addressCountry"){const pe=z(p,v);return e.jsx(Ae,{required:E,label:se,value:$[p]||"",onChange:ce=>B(p,ce),options:[{value:"",label:`Select ${fe.toLowerCase()}`},...pe],disabled:W,error:x},S)}return null;case"date":return e.jsx(me,{required:E,type:"date",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);case"email":return e.jsx(me,{required:E,type:"email",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);case"tel":return e.jsx(me,{required:E,type:"tel",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);default:return e.jsx(me,{required:E,type:"text",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S)}},Te=(p,k)=>{if(p.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:p.displayText||p.label||""}},`custom-${k}`);if(p.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:p.label||""}},`custom-${k}`);if(p.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${k}`);if(p.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:p.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:p.displayText||p.label||p.linkText||p.linkUrl||""})},`custom-${k}`);if(!p.paramName)return null;const R=ue[p.paramName],v=p.displayText||p.label||p.paramName,i=p.labelMode?p.labelMode!=="placeholder":F;return p.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:M[p.paramName]==="true",onChange:d=>b(p.paramName,d.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[v,p.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),R&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:R})]},`custom-${k}`):e.jsx(me,{type:"text",label:i?`${v}${p.required?" *":""}`:void 0,placeholder:i?void 0:v,value:M[p.paramName]||"",onChange:d=>b(p.paramName,d.target.value),required:p.required,error:R},`custom-${k}`)},Ve=p=>{const k=G(p);return e.jsxs("div",{className:"space-y-4",children:[p.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:k,onChange:R=>b(p.conditionalOn,R.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:p.conditionalOn})]}),k&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:p.fields.map((R,v)=>{const i=R.colSpan===1?"col-span-1":R.colSpan===2?"col-span-2":R.colSpan===3?"col-span-3":"col-span-4",d=R.isCustom?`custom-${v}-${R.paramName}`:`builtin-${R.name}-${v}`;return e.jsx("div",{className:i,children:R.isCustom?Te(R,v):Ye(R.name,d,R.displayText,R.countriesType,R.labelMode)},d)})})]})};if(!c||W)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(f){const p=f[re]??f[0],k=ie===-1,R=Q===-1,v=f.length,i=G(p),d=Object.values(ue);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(Z,{children:[(p.title||p.subtitle)&&e.jsxs("div",{className:"mb-4",children:[p.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.subtitle})]}),(A||d.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[A&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",A]}),d.map((E,x)=>e.jsx("p",{className:"text-red-600 text-sm",children:E},x))]}),v>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[f.map((E,x)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${x===re?"flex-1":"w-8"}`,style:x===re?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:x<re?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},x)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[re+1," / ",v]})]}),Ve(p)]}),e.jsxs(xe,{className:"flex justify-between",children:[e.jsxs("div",{children:[!k&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{ee(ie),oe({})},disabled:X||y,children:"Previous"}),k&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:X||y,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:X||y,onClick:R?he:Fe,children:R?p.conditionalOn&&!i?"Skip & Submit":"Submit":p.conditionalOn&&!i?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:qe,children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(Z,{children:[A&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",A]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:P.map(p=>e.jsx("div",{className:"col-span-4",children:Ye(p)},p))})]}),e.jsxs(xe,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:X||y,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:X||y,children:"Register Company"})]})]})})})},ws=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:l,currentStep:c,steps:u,workflowKey:y,nextWorkflowKey:m,hasWorkflowChanged:w,isLoading:T,error:N,moveBack:F,refreshProgress:f}=hr(t),[j,P]=o.useState(!1);if(o.useEffect(()=>{N&&s&&s(N)},[N,s]),o.useEffect(()=>{l!=null&&l.workflowResult&&r&&r(l.workflowResult)},[l==null?void 0:l.workflowResult,r]),o.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),o.useEffect(()=>{w&&P(!1)},[w]),T||!l)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(N)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:N.message})]})})})});if(w&&!j)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:m})]})]}),l.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.nextWorkflowName})]}),e.jsx("button",{onClick:()=>P(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(l.status===Re.Finished||l.status===Re.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ut,{kycStatus:l.kycStatus,reviewStatus:l.reviewStatus,workflowResult:l.workflowResult,customMessage:l.customMessage,onContinue:r&&l.workflowResult?()=>r(l.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.status===Re.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const _=W=>{switch(W){case ae.Overview:return"Overview";case ae.Questionaries:return"Questionnaire";case ae.UploadDocument:return"Documents";case ae.IdentitySdk:return"Identity";case ae.RiskScoring:return"Risk Assessment";case ae.InvestorCategorization:return"Investor Categorization";case ae.AppropriatenessTest:return"Appropriateness Test";case ae.AdditionalData:return"Additional Data";case ae.ManualReview:return"Review";default:return""}},H=o.useRef(null),L=()=>{const W=u.filter($=>$.visibility!==!1),Y=W.findIndex($=>$.order===c.order),I=Y>=0?Y+1:1,g=W.length,z=g>1?Y/(g-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(Ze,{}),e.jsxs(xt,{variant:l.status===1?"info":"success",children:["Step ",I," of ",g]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${z}%`,transition:"width 0.4s ease"}})})}),e.jsx(Ss,{ref:H,visibleSteps:W,currentVisibleStepIndex:Y,getStepFallbackName:_})]})},K=()=>{const W={applicantId:t,onComplete:async()=>{await f()},onBack:c.order>0?F:void 0};switch(c.action){case ae.Questionaries:return e.jsx(Er,{...W});case ae.UploadDocument:return e.jsx(Ar,{...W});case ae.Overview:return e.jsx(Fr,{...W});case ae.IdentitySdk:return e.jsx(Dr,{...W});case ae.RiskScoring:return e.jsx(Tr,{...W});case ae.AdditionalData:case ae.InvestorCategorization:return e.jsx(Pr,{...W});case ae.AppropriatenessTest:return e.jsx(Lr,{...W});case ae.ManualReview:return e.jsx(ut,{kycStatus:l.kycStatus,reviewStatus:l.reviewStatus,workflowResult:l.workflowResult,customMessage:l.customMessage});default:return e.jsx(J,{children:e.jsxs(Z,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ce,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",ae[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[L(),K()]})},Ss=o.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},a)=>{const n=o.useRef(null),l=o.useRef(null);return o.useImperativeHandle(a,()=>n.current),o.useEffect(()=>{if(l.current&&n.current){const c=n.current,u=l.current,y=u.offsetLeft-c.offsetWidth/2+u.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:n,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,u)=>{const y=u<r,m=u===r,w=y||m,T=c.displayName||c.name||s(c.action)||`Step ${u+1}`;return e.jsxs(o.Fragment,{children:[e.jsxs("div",{ref:m?l:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...w?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):u+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:m?600:400,color:m?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:T})]}),u<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Cs(t){return De.z.object({questionResults:De.z.any()}).passthrough()}function Ns(t){let r=De.z.array(De.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(a=>a.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(a=>a.trim());r=r.refine(a=>a?a.every(n=>s.some(l=>l.endsWith("/*")?n.type.startsWith(l.slice(0,-2)):n.type===l)):!0,{message:"Invalid file type"})}return r}function Rs(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=Ns(s)}),De.z.object(r)}function Is(t){return De.z.any()}function Es(t){return De.z.string().min(1,"This question is required")}function As(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=Es()}),De.z.object(r)}const Fs=De.z.any();exports.ALLOWED_LANGUAGES=dt;exports.ApplicantProgressOnHoldReason=St;exports.ApplicantProgressStatus=Re;exports.ApplicantService=$t;exports.ApplicantStatus=Nt;exports.AppropriatenessQuestionType=Ft;exports.AppropriatenessTestService=Wt;exports.AppropriatenessTestStep=Lr;exports.Badge=xt;exports.BaseInformationService=Yt;exports.Button=V;exports.COMPANY_FIELD_METADATA=Ue;exports.Card=J;exports.CardContent=Z;exports.CardFooter=xe;exports.CardHeader=ye;exports.CountriesType=Le;exports.CreateApplicantForm=ks;exports.CreateCompanyApplicantForm=js;exports.CriteriaBuiltInType=Pt;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=Dt;exports.DEFAULT_VISIBLE_FIELDS=Mt;exports.DocumentReviewStatus=At;exports.EndpointBuilder=Ot;exports.ErrorHandler=Ge;exports.EventEmitter=rr;exports.FIELD_METADATA=_e;exports.FileType=Et;exports.FileUpload=wr;exports.GenderType=rt;exports.Header=Ze;exports.HttpClient=Bt;exports.IdentityProviderManager=Ke;exports.IdentityService=qt;exports.IdentityVerificationProvider=Ne;exports.IdentityVerificationStep=Dr;exports.Input=me;exports.InvestorCategorizationService=Vt;exports.InvestorCategorizationStep=Pr;exports.InvestorCategorizationType=ge;exports.InvestorCategoryType=Lt;exports.KycProcessStatus=Rt;exports.KycStatus=Be;exports.KycStatusDisplay=ut;exports.KycWorkflow=ws;exports.Logo=Mr;exports.MetaKYCContext=mt;exports.MetaKYCError=Ie;exports.MetaKYCProvider=Kr;exports.MultiSelect=jr;exports.OnfidoProvider=or;exports.OverviewService=Ut;exports.OverviewStep=Fr;exports.PhoneInput=Sr;exports.QuestionnaireService=_t;exports.QuestionnaireStep=Er;exports.ReviewStatus=$e;exports.RiskCriteriaType=Tt;exports.RiskLevel=Ct;exports.RiskScoringService=Kt;exports.RiskScoringStep=Tr;exports.SardinAIProvider=lr;exports.SearchableSelect=Ae;exports.Select=ot;exports.Spinner=Ce;exports.StepRouter=ar;exports.SumsubProvider=ir;exports.ThemeManager=cr;exports.ThemePreset=be;exports.ThemeService=tr;exports.UploadDocumentService=Ht;exports.UploadDocumentStep=Ar;exports.UserType=It;exports.ValueDataType=Ee;exports.WorkflowOrchestrator=nr;exports.WorkflowResultType=tt;exports.WorkflowState=sr;exports.WorkflowStepAction=ae;exports.appropriatenessTestSchema=Fs;exports.clearAllStorage=Gr;exports.clearApplicantId=mr;exports.clearWorkflowState=xr;exports.cn=ve;exports.corporateTheme=Qt;exports.defaultConfig=zt;exports.defaultTheme=Se;exports.fileToBase64=dr;exports.fintechTheme=Gt;exports.formatFileSize=nt;exports.generateAppropriatenessSchema=As;exports.generateQuestionnaireSchema=Cs;exports.generateRiskScoringSchema=Is;exports.generateUploadDocumentSchema=Rs;exports.getAcceptString=Vr;exports.getApplicantId=pr;exports.getThemePreset=Je;exports.getWorkflowState=Qr;exports.healthcareTheme=Jt;exports.isScriptLoaded=Hr;exports.loadScript=pt;exports.minimalTheme=Xt;exports.modernTheme=Zt;exports.removeScript=Wr;exports.saveApplicantId=ur;exports.saveWorkflowState=yr;exports.themePresets=er;exports.useApplicant=yt;exports.useAppropriatenessTest=Jr;exports.useIdentityVerification=vr;exports.useKycWorkflow=hr;exports.useMetaKYC=we;exports.useOverview=br;exports.useQuestionnaire=fr;exports.useRiskScoring=kr;exports.useUploadDocument=gr;exports.validateFileSize=qr;exports.validateFileType=Yr;
82
+ */const os=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Ir=Nr("chevron-right",os);function ls(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||"This field is required";if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}if(a!==""){const n=Number(a);if(!isNaN(n)&&a.trim()!==""){if(t.min!==void 0&&t.min!==null&&n<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&n>t.max)return`Maximum value is ${t.max}`}else{if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}}return null}function cs(t){const r=t.flatMap((a,n)=>(a.questions??[]).map((l,c)=>({question:l,groupIndex:n,qIdx:c}))),s=new Map;for(const a of r){const n=a.question.pageNumber!=null&&a.question.pageNumber>0?a.question.pageNumber:1;s.has(n)||s.set(n,[]),s.get(n).push(a)}return Array.from(s.entries()).sort(([a],[n])=>a-n).map(([,a])=>a)}const Er=({applicantId:t,onComplete:r,onBack:s})=>{const{questionnaire:a,initialAnswers:n,isLoading:l,isSubmitting:c,error:u,submit:y}=fr(t),[m,w]=o.useState({}),[T,N]=o.useState({}),[F,f]=o.useState(0);o.useEffect(()=>{n&&Object.keys(n).length>0&&Object.keys(m).length===0&&w(n)},[n]);const j=o.useMemo(()=>a?cs(a.questionGroups):[],[a]),P=F===j.length-1,_=j[F]??[],H=o.useCallback((I,g)=>{w(z=>({...z,[I]:g})),N(z=>{const $={...z};return delete $[I],$})},[]),L=o.useCallback(()=>{const I={};for(const{question:g}of _){const z=ls(g,m[g.id]??[]);z&&(I[g.id]=z)}return N(g=>({...g,...I})),Object.keys(I).length===0},[_,m]),K=()=>{L()&&f(I=>I+1)},W=()=>{F>0?f(I=>I-1):s==null||s()},Y=async()=>{if(!(!L()||!a))try{const I=a.questionGroups.flatMap(z=>(z.questions??[]).map($=>({questionId:$.id,values:m[$.id]??[]}))),g={applicantId:t,questionnarieId:a.id,questionResults:I};await y(g),r==null||r()}catch(I){console.error("Questionnaire submit error:",I)}};return l?e.jsx(J,{children:e.jsx(Z,{children:e.jsx(Ce,{className:"my-8"})})}):u?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading questionnaire: ",u.message]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.displayName}),a.subtitle&&e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.subtitle}),j.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",F+1," of ",j.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:j.map((I,g)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:g===F?"20px":"6px",backgroundColor:g<=F?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},g))})]})]}),e.jsx(Z,{className:"space-y-6",children:_.map(({question:I})=>e.jsx(ds,{question:I,value:m[I.id]??[],error:T[I.id],onChange:g=>H(I.id,g)},I.id))}),e.jsxs(xe,{className:"flex items-center justify-between",children:[e.jsxs(V,{type:"button",variant:"outline",onClick:W,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Rr,{size:14}),F>0?"Previous":"Back"]}),P?e.jsx(V,{type:"button",isLoading:c,onClick:Y,children:"Continue"}):e.jsxs(V,{type:"button",onClick:K,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Ir,{size:14})]})]}),u&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:u.message})})]}):null},ds=({question:t,value:r,error:s,onChange:a})=>{var c;const l=(((c=t.defaultAnswers)==null?void 0:c.length)??0)>0?t.showAsDropdown?t.canMultipleAnswer?"multi-select":"single-select":t.canMultipleAnswer?"checkbox":"radio":"text";return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.text,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.subtitle&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.subtitle}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.description}),l==="text"&&e.jsx(me,{value:r[0]??"",onChange:u=>a([u.target.value]),placeholder:t.subtitle?void 0:"Enter your answer…",error:s,required:t.isRequired}),l==="single-select"&&e.jsx(ot,{value:r[0]??"",onChange:u=>a([u.target.value]),options:(t.defaultAnswers??[]).map(u=>({value:u,label:u})),placeholder:"Select an option…",error:s,required:t.isRequired}),l==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===u,onChange:()=>a([u]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),(l==="checkbox"||l==="multi-select")&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultAnswers??[]).map(u=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(u),onChange:y=>{y.target.checked?a([...r,u]):a(r.filter(m=>m!==u))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:u})]},u)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),s&&l==="text"&&null]})};function us(t){const r=new Map;for(const s of t){const a=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(a)||r.set(a,[]),r.get(a).push(s)}return Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}const Ar=({applicantId:t,onComplete:r,onBack:s})=>{const{uploadDocument:a,isLoading:n,isSubmitting:l,error:c,submit:u}=gr(t),[y,m]=o.useState({}),[w,T]=o.useState(null),[N,F]=o.useState(0),[f,j]=o.useState({}),P=o.useMemo(()=>a?us(a.uploadDocumentFiles):[],[a]),_=P[N]??[],H=N===P.length-1,L=P.length,K=o.useCallback(()=>{const g={};for(const z of _)z.isRequired&&(y[z.id]||[]).length===0&&(g[z.id]=`${z.displayName} is required`);return j(g),Object.keys(g).length===0},[_,y]),W=()=>{K()&&(F(g=>g+1),j({}))},Y=()=>{N>0?(F(g=>g-1),j({})):s==null||s()},I=async()=>{if(!(!K()||!a)){T(null);try{const g=await Promise.all(a.uploadDocumentFiles.map(async $=>{const D=y[$.id]||[],M=await Promise.all(D.map(async te=>({fileName:te.name,fileData:await dr(te)})));return{uploadDocumentFileId:$.id,valueList:M}})),z={applicantId:t,uploadDocumentId:a.id,uploadDocumentResults:g};await u(z),r==null||r()}catch(g){T((g==null?void 0:g.message)||"Failed to submit documents. Please try again.")}}};return n?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading document requirements..."})]})})}):c?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"32px 0",gap:"12px",textAlign:"center"},children:[e.jsx("div",{style:{width:"48px",height:"48px",borderRadius:"50%",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-danger, #ef4444)",fontWeight:500},children:"Error loading document requirements"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)"},children:c.message})]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:a.displayName||"Upload Documents"}),a.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:a.subtitle}),L>1&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"12px"},children:[e.jsxs("span",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",N+1," of ",L]}),e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:P.map((g,z)=>e.jsx("div",{style:{height:"6px",width:z===N?"20px":"6px",borderRadius:"999px",transition:"all 0.2s ease",backgroundColor:z<=N?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},z))})]})]}),a.description&&N===0&&e.jsxs("div",{style:{margin:"0 24px",marginTop:"4px",display:"flex",gap:"10px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:a.description})]}),e.jsx(Z,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:_.map(g=>e.jsx(wr,{label:g.displayName,subtitle:g.subtitle,accept:g.allowedTypes,multiple:g.multipleFile,maxSize:g.maxEachFileSizeByte,required:g.isRequired,error:f[g.id],value:y[g.id]||[],onChange:z=>{T(null),j($=>{const D={...$};return delete D[g.id],D}),m($=>({...$,[g.id]:z}))}},g.id))})}),w&&e.jsxs("div",{style:{margin:"0 24px",padding:"10px 14px",borderRadius:"8px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(V,{type:"button",variant:"outline",onClick:Y,children:N>0?"Previous":"Back"}),H?e.jsx(V,{type:"button",isLoading:l,onClick:I,children:l?"Uploading...":"Continue"}):e.jsx(V,{type:"button",onClick:W,children:"Next"})]})})]}):null},Fr=({applicantId:t,onComplete:r,onBack:s})=>{const{overview:a,isLoading:n,isSubmitting:l,error:c,passOverview:u}=br(t),y=async()=>{await u(),r==null||r()};return n?e.jsx(J,{children:e.jsx(Z,{children:e.jsx(Ce,{className:"my-8"})})}):c?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading overview: ",c.message]})})}):a?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:a.title||"Overview"}),a.description&&e.jsx("p",{className:"mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a.description})]}),e.jsx(Z,{className:"space-y-8",children:a.steps&&a.steps.length>0?a.steps.sort((m,w)=>m.order-w.order).map(m=>e.jsxs("div",{className:"metakyc-overview-step-item flex items-center space-x-3",children:[e.jsx("div",{className:"metakyc-step-icon flex-shrink-0",children:e.jsx("div",{className:"w-8 h-8 rounded-full flex items-center justify-center font-medium text-sm",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:m.order+1})}),e.jsxs("div",{className:"metakyc-step-content",style:{flex:1,border:"none",height:"auto",background:"transparent"},children:[e.jsx("span",{className:"metakyc-step-title text-sm font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:m.title}),m.description&&e.jsx("p",{className:"metakyc-step-description text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:m.description})]})]},m.order)):e.jsx("div",{className:"text-center py-8",children:e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading overview data..."})})}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{onClick:y,isLoading:l,children:"Continue"})]})]}):null};function ps(t){const r=(t??"en").toLowerCase().replace("_","-");try{return Intl.NumberFormat.supportedLocalesOf([r]),r}catch{return"en"}}function ms(t){return t.valueDataType===Ee.Money&&Array.isArray(t.defaultValues)&&t.defaultValues.length>0}function ys(t,r){const s=new Intl.NumberFormat(ps(r),{minimumFractionDigits:0,maximumFractionDigits:2});return t.replace(/([\d]+(?:\.\d+)?)/g,a=>{const n=parseFloat(a);return isNaN(n)?a:s.format(n)})}function xs(t,r){const s=!r||r.length===0||r.every(a=>!a||!a.trim());if(t.isRequired&&s)return t.errorMessage||`${t.displayName} is required`;if(!s){const a=r[0]??"";if(a&&t.regex)try{if(!new RegExp(t.regex).test(a))return t.errorMessage||"Invalid format"}catch{}const n=t.valueDataType===Ee.Integer||t.valueDataType===Ee.Money||t.valueDataType===Ee.DigitOnly;if(n&&a.trim()!==""){const l=Number(a);if(!isNaN(l)){if(t.min!==void 0&&t.min!==null&&l<t.min)return`Minimum value is ${t.min}`;if(t.max!==void 0&&t.max!==null&&l>t.max)return`Maximum value is ${t.max}`}}else if(!n&&a!==""){if(t.min!==void 0&&t.min!==null&&a.length<t.min)return`Minimum length is ${t.min} characters`;if(t.max!==void 0&&t.max!==null&&a.length>t.max)return`Maximum length is ${t.max} characters`}}return null}function hs(t){const r=new Map;return t.forEach((s,a)=>{const n=s.pageNumber!=null&&s.pageNumber>0?s.pageNumber:1;r.has(n)||r.set(n,[]),r.get(n).push({criterion:s,idx:a})}),Array.from(r.entries()).sort(([s],[a])=>s-a).map(([,s])=>s)}function fs(t){return t.builtInType===1?"country":!t.defaultValues||t.defaultValues.length===0?"text":t.multipleValue?"checkbox":"radio"}const Tr=({applicantId:t,onComplete:r,onBack:s})=>{const{config:a}=we(),n=a.locale??"en",{criteria:l,initialAnswers:c,isLoading:u,isSubmitting:y,error:m,submit:w}=kr(t),[T,N]=o.useState({}),[F,f]=o.useState({}),[j,P]=o.useState(0),[_,H]=o.useState(!1);o.useEffect(()=>{c&&Object.keys(c).length>0&&Object.keys(T).length===0&&N(c)},[c]);const L=o.useMemo(()=>l&&l.length>0?hs(l):[],[l]),K=j===L.length-1,W=L[j]??[];o.useEffect(()=>{!u&&l&&l.length===0&&!_&&!y&&(H(!0),w({applicantId:t,criteriaValueInputs:[]}).then(()=>r==null?void 0:r()).catch(console.error))},[u,l,_,y,w,t,r]);const Y=o.useCallback((D,M)=>{N(te=>({...te,[D]:M})),f(te=>{const re={...te};return delete re[D],re})},[]),I=o.useCallback(()=>{const D={};for(const{criterion:M}of W){const te=xs(M,T[M.id]??[]);te&&(D[M.id]=te)}return f(M=>({...M,...D})),Object.keys(D).length===0},[W,T]),g=()=>{I()&&P(D=>D+1)},z=()=>{j>0?P(D=>D-1):s==null||s()},$=async()=>{if(!(!I()||!l))try{const D=l.map(te=>{const re=(T[te.id]??[]).filter(ee=>ee&&ee.trim());return re.length>0?{riskCriteriaId:te.id,values:re}:null}).filter(te=>te!==null);await w({applicantId:t,criteriaValueInputs:D}),r==null||r()}catch(D){console.error("Risk scoring submit error:",D)}};return u?e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading risk scoring criteria…"})]})}):!u&&l&&l.length===0?e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-sm mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"No criteria required. Moving to next step…"})]})}):m?e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error loading criteria: ",m.message]})})}):l?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",children:"Risk Assessment"}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please answer the following questions for risk evaluation"}),L.length>1&&e.jsxs("div",{className:"flex items-center justify-between mt-3",children:[e.jsxs("span",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:["Page ",j+1," of ",L.length]}),e.jsx("div",{className:"flex items-center gap-1.5",children:L.map((D,M)=>e.jsx("div",{className:"rounded-full transition-all duration-200",style:{height:"6px",width:M===j?"20px":"6px",backgroundColor:M<=j?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}},M))})]})]}),e.jsx(Z,{className:"space-y-6",children:W.map(({criterion:D})=>e.jsx(gs,{criterion:D,value:T[D.id]??[],error:F[D.id],locale:n,onChange:M=>Y(D.id,M)},D.id))}),e.jsxs(xe,{className:"flex items-center justify-between",children:[e.jsxs(V,{type:"button",variant:"outline",onClick:z,style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Rr,{size:14}),j>0?"Previous":"Back"]}),K?e.jsx(V,{type:"button",isLoading:y,onClick:$,children:"Continue"}):e.jsxs(V,{type:"button",onClick:g,style:{display:"flex",alignItems:"center",gap:"4px"},children:["Next",e.jsx(Ir,{size:14})]})]}),m&&e.jsx("div",{className:"mx-6 mb-4 p-3 bg-red-50 border border-red-200 rounded",children:e.jsx("p",{className:"text-red-600 text-sm",children:m.message})})]}):null},gs=({criterion:t,value:r,error:s,locale:a,onChange:n})=>{const l=fs(t),c=t.valueDataType===Ee.Integer||t.valueDataType===Ee.Money||t.valueDataType===Ee.DigitOnly,u=ms(t),y=m=>u?ys(m,a):m;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[t.displayName,t.isRequired&&e.jsx("span",{className:"text-danger-500 ml-1",children:"*"})]}),t.description&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:t.description}),c&&(t.min!==void 0||t.max!==void 0)&&e.jsx("p",{className:"text-xs",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:t.min!==void 0&&t.max!==void 0?`Range: ${t.min} – ${t.max}`:t.min!==void 0?`Minimum: ${t.min}`:`Maximum: ${t.max}`}),l==="text"&&e.jsx(me,{value:r[0]??"",onChange:m=>n([m.target.value]),type:c?"number":"text",placeholder:"Enter your answer…",error:s,required:t.isRequired,min:t.min,max:t.max,onKeyDown:m=>{t.valueDataType===Ee.DigitOnly&&["e","E","+","-","."].includes(m.key)&&m.preventDefault()}}),l==="radio"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(m=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:r[0]===m,onChange:()=>n([m]),className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(m)})]},m)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),l==="checkbox"&&e.jsxs("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:[(t.defaultValues??[]).map(m=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:r.includes(m),onChange:w=>{w.target.checked?n([...r,m]):n(r.filter(T=>T!==m))},className:"metakyc-option-input",style:{width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"}}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",marginLeft:0},children:y(m)})]},m)),s&&e.jsx("p",{className:"text-sm text-danger-500",children:s})]}),l==="country"&&e.jsx(ot,{value:r[0]??"",onChange:m=>n([m.target.value]),options:[{value:"US",label:"United States"},{value:"GB",label:"United Kingdom"},{value:"DE",label:"Germany"},{value:"FR",label:"France"},{value:"AE",label:"United Arab Emirates"}],placeholder:"Select a country…",error:s,required:t.isRequired})]})},Pr=({applicantId:t,onComplete:r,onBack:s})=>{const{investorCategorizationService:a}=we(),[n,l]=o.useState(null),[c,u]=o.useState(!1),[y,m]=o.useState(null),w=async T=>{if(T.preventDefault(),n===null){m("Please select an investor type");return}u(!0),m(null);try{const N={applicantId:t,investorType:n};console.log("Submitting investor categorization:",N);const F=await a.setInvestorCategorization(N);console.log("Investor categorization result:",F),r==null||r()}catch(N){console.error("Error submitting investor categorization:",N),m(N.message||"Failed to submit investor categorization")}finally{u(!1)}};return e.jsx("form",{onSubmit:w,children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Which statement best describes you?"}),e.jsx("p",{className:"mt-2",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"All Tokenise clients are treated as Retail Investors under EU regulation, which gives you the highest level of investor protection. For our internal purposes, we ask you to select the description that best matches your situation"})]}),e.jsxs(Z,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm font-medium mb-3",style:{color:"var(--metakyc-text-secondary, #374151)"},children:"Choose one"}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.Individual?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.Individual?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.Individual,checked:n===ge.Individual,onChange:()=>l(ge.Individual),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Individual investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"(Recommended) Most of our clients choose this option. Provides the strongest protection and aligns with our mission to make investing accessible to everyone."})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.Sophisticated?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.Sophisticated?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.Sophisticated,checked:n===ge.Sophisticated,onChange:()=>l(ge.Sophisticated),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Sophisticated investor"}),e.jsx("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"In the last 2 years, I have done one or more of the following:"}),e.jsxs("ul",{className:"text-sm mt-2 space-y-1 list-none",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:[e.jsx("li",{children:"Worked in private equity or provided capital to small and medium enterprises, and/or"}),e.jsx("li",{children:"Been the director of a company with an annual turnover of at least (USD) $2m million, and/or"}),e.jsx("li",{children:"Invested directly in at least 2 private (not listed) companies."})]})]})]})}),e.jsx("label",{className:"block p-4 border-2 rounded-lg cursor-pointer transition-all",style:{borderColor:n===ge.HighNetWorth?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",backgroundColor:n===ge.HighNetWorth?"var(--metakyc-primary-light, #dbeafe)":"transparent"},children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("input",{type:"radio",name:"investorType",value:ge.HighNetWorth,checked:n===ge.HighNetWorth,onChange:()=>l(ge.HighNetWorth),className:"mt-1"}),e.jsxs("div",{className:"ml-3",children:[e.jsx("div",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"High networth investor"}),e.jsxs("div",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:["I earn more than (USD/EUR) $150,000 per year, and/or",e.jsx("br",{}),"I have net assets (excluding my main property) of at least $/EUR 300,000"]})]})]})}),y&&e.jsx("div",{className:"p-4 rounded-lg",style:{backgroundColor:"#fee2e2",border:"1px solid #fca5a5"},children:e.jsxs("p",{className:"text-sm",style:{color:"#991b1b"},children:[e.jsx("strong",{children:"Error:"})," ",y]})})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:c,disabled:n===null,children:"Submit"})]})]})})};function kt(t){const r=t.split(":").map(Number);return r.length===3?r[0]*3600+r[1]*60+r[2]:0}function lt(t){const r=Math.floor(t/60),s=t%60;return`${r.toString().padStart(2,"0")}:${s.toString().padStart(2,"0")}`}const Lr=({applicantId:t,onComplete:r,onBack:s})=>{const{appropriatenessTestService:a}=we(),[n,l]=o.useState(null),[c,u]=o.useState(!0),[y,m]=o.useState(!1),[w,T]=o.useState(null),[N,F]=o.useState({}),[f,j]=o.useState(0),[P,_]=o.useState(!1),[H,L]=o.useState(!1),[K,W]=o.useState(0),[Y,I]=o.useState(0),[g,z]=o.useState(null);o.useEffect(()=>{(async()=>{try{u(!0),T(null);const B=await a.getAppropriatenessTest(t);if(l(B),B.waitTimeSpanForNextTry&&B.waitTimeSpanForNextTry!=="00:00:00"){const b=kt(B.waitTimeSpanForNextTry);b>0&&W(b)}}catch(B){T(B.message||"Failed to load appropriateness test")}finally{u(!1)}})()},[t,a]),o.useEffect(()=>{if(!P||f<=0)return;const B=setInterval(()=>{j(b=>b<=1?(L(!0),0):b-1)},1e3);return()=>clearInterval(B)},[P,f]),o.useEffect(()=>{if(K<=0)return;const B=setInterval(()=>{W(b=>b<=1?0:b-1)},1e3);return()=>clearInterval(B)},[K]),o.useEffect(()=>{H&&!y&&te()},[H]);const $=()=>{n&&(_(!0),j(n.testDurationSec),I(0),F({}),T(null))},D=(B,b)=>{F(G=>({...G,[B]:b}))},M=o.useCallback(async()=>{try{const B=await a.getAppropriatenessTest(t);if(l(B),B.waitTimeSpanForNextTry&&B.waitTimeSpanForNextTry!=="00:00:00"){const b=kt(B.waitTimeSpanForNextTry);b>0&&W(b)}}catch{}},[t,a]),te=async B=>{if(n){if(!H){const b=n.appropriatenessQuestions.length-Object.keys(N).length;if(b>0){T(`Please answer all questions. ${b} remaining.`);return}}m(!0),T(null);try{const b=n.appropriatenessQuestions.map(Q=>({appropriatenessQuestionId:Q.id,value:N[Q.id]||""})),G={applicantId:t,appropriatenessTestId:n.id,appropriatenessQuestionResults:b};try{const Q=await a.fillAppropriatenessTest(G);Q.isSuccess?z({success:!0,message:Q.message||"Congratulations! You have passed the test."}):(z({success:!1,message:Q.message||"You did not pass the test."}),setTimeout(()=>M(),1e3))}catch(Q){if(Q.code===400&&Q.message)z({success:!1,message:Q.message}),setTimeout(()=>M(),1500);else throw Q}}catch(b){T(b.message||"Failed to submit test. Please try again."),re()}finally{m(!1)}}},re=()=>{_(!1),L(!1),F({}),I(0)};if(c)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",padding:"48px 0",gap:"16px"},children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)"},children:"Loading test..."})]})})});if(!n)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 0"},children:[e.jsx("p",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-danger, #ef4444)"},children:"No test data available"}),w&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"8px"},children:w})]})})});const ee=n.testAllowedMaxTry-n.totalFailedTries,ue=n.appropriatenessQuestions.length,oe=Object.keys(N).length;if(K>0)return e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName})}),e.jsx(Z,{children:e.jsxs("div",{style:{textAlign:"center",padding:"32px 0"},children:[e.jsx("div",{style:{width:"100px",height:"100px",borderRadius:"50%",margin:"0 auto 20px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)"},children:e.jsx("span",{style:{fontSize:"28px",fontWeight:700,color:"var(--metakyc-primary, #2563eb)",fontVariantNumeric:"tabular-nums"},children:lt(K)})}),e.jsx("p",{style:{fontSize:"15px",fontWeight:500,color:"var(--metakyc-text-primary, #111827)"},children:"Please wait before retrying"}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"4px"},children:"You can attempt the test again once the timer expires"}),w&&e.jsx("div",{style:{marginTop:"20px",padding:"12px 16px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})})]})})]});if(g){const B=()=>{z(null),re(),T(null)};return e.jsxs(J,{children:[e.jsx(Z,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",textAlign:"center",padding:"40px 16px",gap:"16px"},children:[e.jsx("div",{style:{width:"72px",height:"72px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:g.success?"color-mix(in srgb, var(--metakyc-success, #10b981) 12%, transparent)":"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)"},children:g.success?e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-success, #10b981)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}):e.jsxs("svg",{width:"36",height:"36",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),e.jsx("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}),e.jsx("h2",{style:{fontSize:"20px",fontWeight:700,color:g.success?"var(--metakyc-success, #10b981)":"var(--metakyc-danger, #ef4444)",margin:0},children:g.success?"Test Passed":"Test Failed"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",margin:0,lineHeight:1.6,maxWidth:"400px",whiteSpace:"pre-line"},children:g.message}),!g.success&&ee>0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"var(--metakyc-surface, #f9fafb)",border:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:["You have ",e.jsx("strong",{style:{color:"var(--metakyc-text-primary, #111827)"},children:ee})," attempt",ee!==1?"s":""," remaining"]})}),!g.success&&ee<=0&&e.jsx("div",{style:{marginTop:"4px",padding:"10px 20px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"No attempts remaining. Please contact support for assistance."})})]})}),e.jsx(xe,{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",width:"100%",gap:"12px"},children:g.success?e.jsx(V,{type:"button",onClick:()=>r==null?void 0:r(),children:"Continue"}):e.jsxs(e.Fragment,{children:[ee>0&&K<=0&&e.jsx(V,{type:"button",onClick:B,children:"Retake Test"}),ee>0&&K>0&&e.jsx(V,{type:"button",onClick:B,children:"OK"}),ee<=0&&s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"})]})})})]})}if(!P)return e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),n.subtitle&&e.jsx("p",{style:{fontSize:"14px",color:"var(--metakyc-text-secondary, #6b7280)",marginTop:"4px"},children:n.subtitle})]}),e.jsxs(Z,{children:[n.description&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))",border:"1px solid color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-primary, #2563eb)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),e.jsx("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]}),e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-text-secondary, #374151)",margin:0,lineHeight:1.5},children:n.description})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginBottom:"20px"},children:[e.jsx(st,{icon:"questions",label:"Questions",value:String(n.totalQuestionCount)}),e.jsx(st,{icon:"time",label:"Time Limit",value:lt(n.testDurationSec)}),e.jsx(st,{icon:"target",label:"Pass Requirement",value:`${n.testCorrectAnswerPassLimit} correct`}),e.jsx(st,{icon:"retry",label:"Attempts Left",value:String(ee),variant:ee<=1?"warning":"default"})]}),w&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)",display:"flex",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"var(--metakyc-danger, #ef4444)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0,marginTop:"1px"},children:[e.jsx("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),e.jsx("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),e.jsx("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]}),e.jsxs("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0,lineHeight:1.5},children:[e.jsx("strong",{children:"Previous attempt:"})," ",w]})]}),ee<=0&&e.jsx("div",{style:{padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:"You have used all your attempts. Please contact support for assistance."})})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:s?"space-between":"flex-end",width:"100%"},children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:$,disabled:ee<=0,children:"Start Test"})]})})]});const A=n.appropriatenessQuestions[Y],U=Y===ue-1,X=oe===ue,le=f<=60;return e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("h2",{style:{fontSize:"18px",fontWeight:700,color:"var(--metakyc-text-primary, #111827)",margin:0},children:n.displayName}),e.jsxs("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",marginTop:"2px"},children:["Question ",Y+1," of ",ue]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 14px",borderRadius:"999px",backgroundColor:le?"color-mix(in srgb, var(--metakyc-danger, #ef4444) 10%, transparent)":"var(--metakyc-surface, #f3f4f6)",transition:"all 0.3s ease"},children:[e.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:le?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-muted, #9ca3af)",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("span",{style:{fontSize:"16px",fontWeight:700,fontVariantNumeric:"tabular-nums",color:le?"var(--metakyc-danger, #ef4444)":"var(--metakyc-text-primary, #111827)",transition:"color 0.3s ease"},children:lt(f)})]})]}),e.jsxs("div",{style:{marginTop:"12px"},children:[e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${oe/ue*100}%`,transition:"width 0.3s ease"}})}),e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"4px"},children:[e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[oe," answered"]}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--metakyc-text-muted, #9ca3af)"},children:[ee," attempt",ee!==1?"s":""," left"]})]})]})]}),e.jsxs(Z,{children:[A&&e.jsx(vs,{question:A,index:Y,selectedAnswer:N[A.id],onSelect:B=>D(A.id,B),disabled:y}),ue>1&&e.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"6px",marginTop:"20px",flexWrap:"wrap"},children:n.appropriatenessQuestions.map((B,b)=>e.jsx("button",{type:"button",onClick:()=>I(b),style:{width:"28px",height:"28px",borderRadius:"8px",border:b===Y?"2px solid var(--metakyc-primary, #2563eb)":"1px solid var(--metakyc-border, #e5e7eb)",backgroundColor:N[B.id]?b===Y?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 15%, transparent)":"color-mix(in srgb, var(--metakyc-primary, #2563eb) 8%, transparent)":b===Y?"var(--metakyc-surface, #f9fafb)":"var(--metakyc-background, #ffffff)",color:N[B.id]?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",fontSize:"12px",fontWeight:600,cursor:"pointer",transition:"all 0.15s ease",padding:0,display:"flex",alignItems:"center",justifyContent:"center"},children:b+1},B.id))}),H&&e.jsxs("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, #f59e0b 10%, transparent)",border:"1px solid color-mix(in srgb, #f59e0b 25%, transparent)",display:"flex",alignItems:"center",gap:"10px"},children:[e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"#f59e0b",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("p",{style:{fontSize:"13px",color:"#b45309",margin:0,fontWeight:500},children:"Time's up! Your answers are being submitted."})]}),w&&!H&&e.jsx("div",{style:{marginTop:"16px",padding:"12px 14px",borderRadius:"10px",backgroundColor:"color-mix(in srgb, var(--metakyc-danger, #ef4444) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--metakyc-danger, #ef4444) 20%, transparent)"},children:e.jsx("p",{style:{fontSize:"13px",color:"var(--metakyc-danger, #ef4444)",margin:0},children:w})})]}),e.jsx(xe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"},children:[e.jsx(V,{type:"button",variant:"outline",onClick:()=>{Y>0?I(B=>B-1):s==null||s()},disabled:y,children:Y>0?"Previous":"Cancel"}),e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[!U&&e.jsx(V,{type:"button",onClick:()=>I(B=>B+1),children:"Next"}),(U||X)&&e.jsx(V,{type:"button",isLoading:y,onClick:()=>te(),disabled:!X&&!H,style:{opacity:X||H?1:.5},children:H?"Submitting...":"Submit Test"})]})]})})]})},bs={questions:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M9 11l3 3L22 4"}),e.jsx("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]}),time:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),target:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("circle",{cx:"12",cy:"12",r:"6"}),e.jsx("circle",{cx:"12",cy:"12",r:"2"})]}),retry:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})},st=({icon:t,label:r,value:s,variant:a="default"})=>{const n=a==="warning";return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px",borderRadius:"10px",backgroundColor:n?"color-mix(in srgb, #f59e0b 8%, transparent)":"var(--metakyc-surface, #f9fafb)",border:n?"1px solid color-mix(in srgb, #f59e0b 20%, transparent)":"1px solid var(--metakyc-border, #e5e7eb)"},children:[e.jsx("div",{style:{color:n?"#f59e0b":"var(--metakyc-primary, #2563eb)",flexShrink:0},children:bs[t]}),e.jsxs("div",{children:[e.jsx("p",{style:{fontSize:"12px",color:"var(--metakyc-text-muted, #9ca3af)",margin:0},children:r}),e.jsx("p",{style:{fontSize:"15px",fontWeight:600,color:n?"#b45309":"var(--metakyc-text-primary, #111827)",margin:0,marginTop:"1px"},children:s})]})]})},vs=({question:t,selectedAnswer:r,onSelect:s,disabled:a})=>e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[t.groupName&&e.jsx("span",{style:{display:"inline-block",fontSize:"11px",fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",color:"var(--metakyc-primary, #2563eb)",marginBottom:"8px"},children:t.groupName}),e.jsx("h3",{style:{fontSize:"16px",fontWeight:600,color:"var(--metakyc-text-primary, #111827)",margin:0,lineHeight:1.5},children:t.question})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:t.answers.map((n,l)=>{const c=r===n;return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"14px 16px",borderRadius:"10px",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)"}`,backgroundColor:c?"color-mix(in srgb, var(--metakyc-primary, #2563eb) 5%, var(--metakyc-background, #ffffff))":"var(--metakyc-background, #ffffff)",cursor:a?"default":"pointer",transition:"all 0.15s ease",opacity:a?.6:1},onMouseEnter:u=>{!a&&!c&&(u.currentTarget.style.borderColor="color-mix(in srgb, var(--metakyc-primary, #2563eb) 50%, var(--metakyc-border, #e5e7eb))")},onMouseLeave:u=>{c||(u.currentTarget.style.borderColor="var(--metakyc-border, #e5e7eb)")},children:[e.jsx("div",{style:{width:"20px",height:"20px",borderRadius:"50%",border:`2px solid ${c?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #d1d5db)"}`,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"border-color 0.15s ease"},children:c&&e.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",backgroundColor:"var(--metakyc-primary, #2563eb)"}})}),e.jsx("input",{type:"radio",name:`q-${t.id}`,value:n,checked:c,onChange:()=>s(n),disabled:a,style:{position:"absolute",opacity:0,width:0,height:0}}),e.jsx("span",{style:{fontSize:"14px",color:c?"var(--metakyc-text-primary, #111827)":"var(--metakyc-text-secondary, #6b7280)",fontWeight:c?500:400,transition:"color 0.15s ease"},children:n})]},l)})})]}),Dr=({applicantId:t,onComplete:r,onBack:s})=>{var Te,Ve,Me,He;const{applicantService:a,baseInformationService:n,config:l,currentTheme:c}=we(),{identityData:u,provider:y,token:m,isLoading:w,error:T,requestIdentity:N,restartIdentity:F}=vr(t),[f,j]=o.useState(null),[P,_]=o.useState(null),[H,L]=o.useState([]),[K,W]=o.useState([]),[Y,I]=o.useState(!0),[g,z]=o.useState(!1),[$,D]=o.useState(null),[M,te]=o.useState(!1),re=o.useRef(!1),[ee,ue]=o.useState({}),[oe,A]=o.useState({}),U=c!=null&&c.reviewPageFields&&c.reviewPageFields.length>0?c.reviewPageFields[0]:null,X=!!(c!=null&&c.reviewPageDisabled),le=o.useRef(!1);le.current=X;const B=Oe.useForm({defaultValues:{street:"",streetNumber:"",city:"",zip:"",country:"",nationality:"",phonenumber:""}});o.useEffect(()=>{if(X){re.current||(re.current=!0,N().then(()=>z(!0)).catch(O=>console.error("[Identity] Auto-request failed:",O)).finally(()=>I(!1)));return}(async()=>{try{const[O,q,p]=await Promise.all([a.getApplicantData(t),n.getCountries("","en"),n.getCountries("","en",40)]);_(O);const k=new Set,R=q.map(x=>({value:x.abbreviation3||x.abbreviation,label:x.name})).filter(x=>!x.value||k.has(x.value)?!1:(k.add(x.value),!0));L(R);const v=new Set,i=p.filter(x=>x.countryCode).map(x=>({value:x.countryCode,label:`${x.countryCode} – ${x.name}`})).filter(x=>v.has(x.value)?!1:(v.add(x.value),!0));W(i);const d=O.applicantRequestData;if(ue({firstName:(d==null?void 0:d.firstName)||"",lastName:(d==null?void 0:d.lastName)||"",email:(d==null?void 0:d.email)||"",dateOfBirth:(d==null?void 0:d.dateOfBirth)||"",title:(d==null?void 0:d.title)||"",salutation:(d==null?void 0:d.salutation)||"",phonenumber:(d==null?void 0:d.phonenumber)||"",mobileCountryCode:(d==null?void 0:d.mobileCountryCode)||"",street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",taxCountry:(d==null?void 0:d.taxCountry)||"",countryOfBirth:(d==null?void 0:d.countryOfBirth)||"",placeOfBirth:(d==null?void 0:d.placeOfBirth)||"",educationLevel:(d==null?void 0:d.educationLevel)||"",occupation:(d==null?void 0:d.occupation)||"",taxNumber:(d==null?void 0:d.taxNumber)||"",defaultLanguage:(d==null?void 0:d.defaultLanguage)||""}),B.reset({street:(d==null?void 0:d.street)||"",streetNumber:(d==null?void 0:d.streetNumber)||"",city:(d==null?void 0:d.city)||"",zip:(d==null?void 0:d.zip)||"",country:(d==null?void 0:d.country)||"",nationality:(d==null?void 0:d.nationality)||"",phonenumber:(d==null?void 0:d.phonenumber)||""}),O.kycRecords&&O.kycRecords.length>0&&O.kycRecords[0].providerTokenObject!==null&&!re.current&&le.current){console.log("[Identity] Review page disabled + existing identity — auto-requesting..."),re.current=!0;try{await N(),z(!0)}catch(x){console.error("[Identity] Auto-request failed:",x)}}}catch(O){console.error("Error loading applicant data:",O)}finally{I(!1)}})()},[t]),o.useEffect(()=>{u&&!g&&le.current&&(console.log("[Identity] Review page disabled — showing cached provider"),z(!0))},[u,g]),o.useEffect(()=>{if(m){if(m.expiresAt){const h=new Date(m.expiresAt).getTime();if(Date.now()>=h){console.warn("[Identity] Token has expired (expiresAt)"),te(!0),D("Your verification session has expired. Please restart.");return}}if(m.url)try{const O=new URL(m.url).toString().toLowerCase();if(O.includes("expired")||O.includes("invalid")||O.includes("error")){console.warn("[Identity] Token URL indicates expiration"),te(!0),D("Your verification link has expired. Please restart.");return}}catch{console.error("[Identity] Invalid token URL")}if(m.status==="expired"||m.error==="expired"||m.expired===!0){console.warn("[Identity] Token object indicates expiration"),te(!0),D("Your verification session has expired. Please restart.");return}}},[m]),o.useEffect(()=>{if(y!==null&&m&&!f&&g&&!M){const h=y;if(m.url){console.log("[Identity] Loading provider URL for user verification:",m.url),D(null);try{if(new URL(m.url),h===Ne.SardinAI){console.log("[SardinAI] Initializing Risk SDK in background...");try{const O=Ke.parseProviderConfig(y,m,l);Ke.createProvider(y,O).initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully in background")}).catch(p=>{console.warn("[SardinAI] Risk SDK initialization failed (non-blocking):",p)})}catch(O){console.warn("[SardinAI] Risk SDK setup failed (non-blocking):",O)}}j({type:"url",url:m.url})}catch(O){console.error("[Identity] Invalid URL:",O),D("Invalid verification URL. Please restart."),te(!0)}return}if(h===Ne.SardinAI){console.log("[SardinAI] No URL provided - initializing Risk SDK only..."),D(null);try{const O=Ke.parseProviderConfig(y,m,l),q=Ke.createProvider(y,O);q.initialize().then(()=>{console.log("[SardinAI] Risk SDK initialized successfully"),j(q),setTimeout(()=>{r==null||r()},2e3)}).catch(p=>{var R;console.error("[SardinAI] Failed to initialize:",p);const k=((R=p.message)==null?void 0:R.toLowerCase())||"";k.includes("expired")||k.includes("invalid")||k.includes("401")||k.includes("400")?(te(!0),D("Session expired or invalid. Please restart verification.")):D(`Failed to initialize: ${p.message}`)})}catch(O){console.error("[SardinAI] Error creating provider:",O),D(`Configuration error: ${O.message}`)}return}try{D(null);const O=Ke.parseProviderConfig(y,m,l),q=Ke.createProvider(y,O);h===Ne.Sumsub?(q.initialize("identity-container").catch(p=>{var k;console.error("[Sumsub] Initialization error:",p),D(`Failed to initialize: ${p.message}`),(k=p.message)!=null&&k.toLowerCase().includes("expired")&&te(!0)}),q.onComplete&&q.onComplete(()=>{r==null||r()})):h===Ne.Onfido&&q.initialize("identity-container").catch(p=>{console.error("[Onfido] Initialization error:",p),D(`Failed to initialize: ${p.message}`)}),j(q)}catch(O){console.error("[Identity] Provider setup error:",O),D(`Setup error: ${O.message}`)}}return()=>{if(f&&f.destroy)try{f.destroy()}catch(h){console.error("[Identity] Error destroying provider:",h)}}},[y,m,f,g,r,M]);const b=async()=>{try{D(null),te(!1),await N(),z(!0)}catch(h){console.error("Error starting identity verification:",h)}},G=async()=>{try{D(null),te(!1),j(null),console.log("[Identity] Restarting verification..."),await F(),z(!0)}catch(h){console.error("Error restarting identity verification:",h),D(h.message||"Failed to restart verification")}};if(Y||w)return e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center text-gray-600 dark:text-gray-400 mt-4",children:"Loading identity verification..."})]})});if(T)return e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("p",{className:"text-danger-500",children:["Error: ",T.message]})})});if(g&&($||M))return e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx("h2",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:"Verification Session Issue"})}),e.jsxs(Z,{children:[e.jsx("div",{className:"p-4 bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg mb-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx("svg",{className:"h-6 w-6 text-red-600 dark:text-red-400 mr-3 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-1",children:M?"Session Expired":"Verification Error"}),e.jsx("p",{className:"text-red-800 dark:text-red-200 text-sm",children:$||"Your verification session has expired and needs to be restarted."})]})]})}),e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What to do next:"}),e.jsxs("ul",{className:"text-blue-800 dark:text-blue-200 text-sm space-y-1 list-disc list-inside",children:[e.jsx("li",{children:'Click "Restart Verification" below to generate a new session'}),e.jsx("li",{children:"Complete the verification process without delays"}),e.jsx("li",{children:"If issues persist, contact support"})]})]})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"button",onClick:G,disabled:w,children:w?"Restarting...":"Restart Verification"})]})]});if(g&&u){const h=y;return m!=null&&m.url?e.jsxs(J,{children:[e.jsx(ye,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(V,{type:"button",variant:"outline",size:"sm",onClick:G,disabled:w,children:"Restart"})]})}),e.jsxs(Z,{children:[e.jsx("div",{className:"mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 border border-yellow-200 dark:border-yellow-800 rounded-lg",children:e.jsxs("p",{className:"text-yellow-800 dark:text-yellow-200 text-sm",children:[e.jsx("strong",{children:"Important:"}),' If you see an "expired" or "invalid link" message below, click the "Restart" button above to generate a new verification session.']})}),e.jsx("div",{className:"w-full",style:{height:"600px"},children:e.jsx("iframe",{src:m.url,className:"w-full h-full border-0 rounded-lg",allow:"camera; microphone; geolocation",title:"Identity Verification",onLoad:O=>{var q,p,k;console.log("[Identity] Iframe loaded");try{const R=O.target,v=R.contentDocument||((q=R.contentWindow)==null?void 0:q.document);if(v){const i=((k=(p=v.body)==null?void 0:p.textContent)==null?void 0:k.toLowerCase())||"";(i.includes("expired")||i.includes("invalid")||i.includes("error"))&&(console.warn("[Identity] Iframe shows expiration message"),te(!0),D("Your verification link has expired."))}}catch{console.log("[Identity] Cannot check iframe content (CORS)")}}})})]}),s&&e.jsx(xe,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]}):h===Ne.SardinAI?e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Device Risk Assessment"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Analyzing device security and behavioral patterns..."})]}),e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-12",children:[e.jsx(Ce,{className:"mb-4"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400",children:"Please wait while we verify your device security"}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-500 mt-2",children:"This process is automatic and will complete in a few seconds"})]})})]}):e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"Identity Verification"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-400 mt-1",children:"Please complete the identity verification process"})]}),e.jsx(Z,{children:e.jsx("div",{id:"identity-container",className:"min-h-[400px]"})}),s&&e.jsx(xe,{children:e.jsx(V,{variant:"outline",onClick:s,children:"Back"})})]})}const Q=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),ie=(h=4)=>({1:"col-span-1",2:"col-span-2",3:"col-span-3",4:"col-span-4"})[h]||"col-span-4",ke=(h,O)=>{if(!O&&O!==0)return"—";if(Q.has(h)&&h!=="mobileCountryCode"){const q=H.find(p=>p.value===O);return q?q.label:String(O)}return String(O)},Fe=({helpText:h})=>{const[O,q]=o.useState(!1),p=o.useRef(null),[,k]=o.useState({top:0,left:0}),R=()=>{if(p.current){const v=p.current.getBoundingClientRect();k({top:v.bottom+window.scrollY+6,left:v.left+window.scrollX})}q(!0)};return e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"metakyc-help-btn",ref:p,onClick:R,style:{width:18,height:18,borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:11,fontWeight:700,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,lineHeight:1,position:"relative",zIndex:2},children:"?"}),O&&it.createPortal(e.jsx("div",{style:{position:"fixed",inset:0,zIndex:99999,background:"rgba(0,0,0,0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>q(!1),children:e.jsxs("div",{onClick:v=>v.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 8px)",padding:"20px 24px",maxWidth:400,width:"90%",boxShadow:"0 24px 64px rgba(0,0,0,0.4)"},children:[e.jsx("div",{dangerouslySetInnerHTML:{__html:h},style:{fontSize:13,color:"var(--metakyc-text-primary, #111827)",lineHeight:1.6}}),e.jsx("button",{type:"button",onClick:()=>q(!1),style:{marginTop:12,padding:"4px 12px",fontSize:12,border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"var(--metakyc-border-radius, 6px)",background:"transparent",cursor:"pointer",color:"var(--metakyc-text-secondary, #6b7280)"},children:"Close"})]})}),document.body)]})},he=(h,O)=>O?e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:5,flexWrap:"nowrap"},children:[e.jsx("div",{style:{flex:1,minWidth:0},children:h}),e.jsx("div",{style:{paddingTop:24},children:e.jsx(Fe,{helpText:O})})]}):h,qe=(h,O)=>{const q=`cf-${O}`,p=h.paramName??"",k=oe[p];if(h.customType==="br")return e.jsx("div",{className:ie(h.colSpan),style:{minHeight:"0.5rem"}},q);if(h.customType==="paragraph")return e.jsx("div",{className:ie(h.colSpan),children:e.jsx("div",{className:"text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:h.label||""}})},q);if(h.customType==="html")return e.jsx("div",{className:ie(h.colSpan),dangerouslySetInnerHTML:{__html:h.label||""}},q);if(h.customType==="link")return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsx("a",{href:h.linkUrl??"#",target:"_blank",rel:"noopener noreferrer",className:"text-sm underline",style:{color:"var(--metakyc-primary, #6366f1)"},children:h.displayText||h.label||h.linkText||h.linkUrl}),h.helpText)},q);if(h.customType==="checkbox"||h.customType==="link_checkbox"){const R=k==="true"||k===!0;return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:!!R,onChange:v=>A(i=>({...i,[p]:String(v.target.checked)})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.customType==="link_checkbox"&&h.linkUrl?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:h.linkUrl,target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #6366f1)",textDecoration:"underline"},children:h.linkText||h.label}),h.label&&h.linkText?` ${h.label}`:""]}):h.displayText||h.label})]}),h.helpText)},q)}if(h.customType==="group_checkbox"){const R=Array.isArray(k)?k:k?[k]:[],v=i=>{h.singleSelect?A(d=>({...d,[p]:R[0]===i?[]:[i]})):A(d=>({...d,[p]:R.includes(i)?R.filter(E=>E!==i):[...R,i]}))};return e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("div",{className:"space-y-1.5",children:[h.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.displayText||h.label}),(h.options||[]).map(i=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:R.includes(i.value),onChange:()=>v(i.value),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:i.label})]},i.value))]}),h.helpText)},q)}return h.customType==="radio_group"?e.jsx("div",{className:ie(h.colSpan),children:he(e.jsxs("div",{className:"space-y-1.5",children:[h.label&&e.jsx("p",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:h.displayText||h.label}),(h.options||[]).map(R=>e.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:8,cursor:"pointer"},children:[e.jsx("input",{type:"radio",name:`rg-${p}`,value:R.value,checked:k===R.value,onChange:()=>A(v=>({...v,[p]:R.value})),style:{width:16,height:16,flexShrink:0,marginTop:2,accentColor:"var(--metakyc-primary, #6366f1)"}}),e.jsx("span",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)"},children:R.label})]},R.value))]}),h.helpText)},q):e.jsx("div",{className:ie(h.colSpan),children:he(e.jsx(me,{label:h.displayText||h.label||p,value:String(k??""),onChange:R=>A(v=>({...v,[p]:R.target.value}))}),h.helpText)},q)},Ye=(h,O)=>{if(h.isCustom)return qe(h,O);const q=h.name??"",p=_e[q],k=h.displayText||(p==null?void 0:p.label)||q,R=ee[q]??"",v=q==="mobileCountryCode",i=!!(p!=null&&p.countriesType)&&!v;return h.editable?v?e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(Ae,{label:k,value:String(R),onChange:d=>ue(E=>({...E,[q]:d})),options:[{value:"",label:"Select country code…"},...K]}),h.helpText)},`epc-${O}`):i?e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(Ae,{label:k,value:String(R),onChange:d=>ue(E=>({...E,[q]:d})),options:[{value:"",label:`Select ${k.toLowerCase()}…`},...H]}),h.helpText)},`ec-${O}`):e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsx(me,{label:k,type:(p==null?void 0:p.type)==="date"?"date":(p==null?void 0:p.type)==="email"?"email":"text",value:String(R),onChange:d=>ue(E=>({...E,[q]:d.target.value}))}),h.helpText)},`ei-${O}`):e.jsx("div",{className:ie(h.colSpan??2),children:he(e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-sm font-medium mb-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:k}),e.jsx("p",{className:"text-sm",style:{color:"var(--metakyc-text-primary, #111827)",minHeight:"1.5rem"},children:ke(q,R)})]}),h.helpText)},`ro-${O}`)};if(U){const h=U.title||"Review Your Information",O=U.subtitle||"Please review and confirm your information before starting identity verification";return e.jsx("form",{onSubmit:q=>{q.preventDefault(),b()},children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:h}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:O})]}),e.jsx(Z,{children:e.jsx("div",{className:"grid grid-cols-4 gap-4",children:U.fields.map((q,p)=>Ye(q,p))})}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:w,children:"Confirm and Start Verification"})]})]})})}return e.jsx("form",{onSubmit:B.handleSubmit(b),children:e.jsxs(J,{children:[e.jsxs(ye,{children:[e.jsx("h2",{className:"text-lg font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Review Your Information"}),e.jsx("p",{className:"mt-1 text-sm",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Please review and confirm your information before starting identity verification"})]}),e.jsxs(Z,{className:"space-y-6",children:[e.jsx("div",{className:"space-y-4 pb-4",style:{borderBottom:"1px solid var(--metakyc-border, #e5e7eb)"},children:[{label:"Name",value:`${((Te=P==null?void 0:P.applicantRequestData)==null?void 0:Te.firstName)||""} ${((Ve=P==null?void 0:P.applicantRequestData)==null?void 0:Ve.lastName)||""}`.trim()},{label:"Email",value:(Me=P==null?void 0:P.applicantRequestData)==null?void 0:Me.email},{label:"Date of Birth",value:((He=P==null?void 0:P.applicantRequestData)==null?void 0:He.dateOfBirth)||"Not provided"}].map(({label:h,value:O})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:h}),e.jsx("p",{className:"mt-1 text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:O})]},h))}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"text-base font-semibold",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Address Information"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"country",render:({field:h})=>e.jsx(Ae,{label:"Country",value:h.value,onChange:h.onChange,options:[{value:"",label:"Select country…"},...H]})}),e.jsx(Oe.Controller,{control:B.control,name:"nationality",render:({field:h})=>e.jsx(Ae,{label:"Nationality",value:h.value,onChange:h.onChange,options:[{value:"",label:"Select nationality…"},...H]})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"street",render:({field:h})=>e.jsx(me,{...h,label:"Street"})}),e.jsx(Oe.Controller,{control:B.control,name:"streetNumber",render:({field:h})=>e.jsx(me,{...h,label:"Street Number"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsx(Oe.Controller,{control:B.control,name:"city",render:({field:h})=>e.jsx(me,{...h,label:"City"})}),e.jsx(Oe.Controller,{control:B.control,name:"zip",render:({field:h})=>e.jsx(me,{...h,label:"ZIP / Postal Code"})})]}),e.jsx(Oe.Controller,{control:B.control,name:"phonenumber",render:({field:h})=>e.jsx(me,{...h,label:"Phone Number",type:"tel"})})]})]}),e.jsxs(xe,{className:"flex justify-between",children:[s&&e.jsx(V,{type:"button",variant:"outline",onClick:s,children:"Back"}),e.jsx(V,{type:"submit",isLoading:w,children:"Confirm and Start Verification"})]})]})})},ut=({kycStatus:t,reviewStatus:r,workflowResult:s,customMessage:a,onContinue:n,onContactSupport:l})=>{const u=t===Be.Approved?{type:"success",title:"Verification Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your identity verification has been successfully approved."}:t===Be.Rejected?{type:"error",title:"Verification Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Unfortunately, your identity verification was not approved."}:t===Be.Pending||t===Be.InProgress?{type:"pending",title:"Verification Pending",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your identity verification is currently being processed."}:r===$e.Approved?{type:"success",title:"Application Approved",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your application has been approved."}:r===$e.Reject?{type:"error",title:"Application Rejected",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"Your application has been rejected."}:r===$e.UnderReview||r===$e.AdminReview?{type:"pending",title:"Under Review",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application is currently under manual review."}:s===tt.Success?{type:"success",title:"Process Complete",icon:"✓",iconBg:"bg-green-100 dark:bg-green-900/30",iconColor:"text-green-600 dark:text-green-400",message:"Your verification process has been completed successfully."}:s===tt.Failed?{type:"error",title:"Process Failed",icon:"✕",iconBg:"bg-red-100 dark:bg-red-900/30",iconColor:"text-red-600 dark:text-red-400",message:"The verification process could not be completed."}:s===tt.AdminReview?{type:"pending",title:"Admin Review Required",icon:"📋",iconBg:"bg-yellow-100 dark:bg-yellow-900/30",iconColor:"text-yellow-700 dark:text-yellow-400",message:"Your application requires administrator review."}:{type:"pending",title:"Processing",icon:"⏱",iconBg:"bg-blue-100 dark:bg-blue-900/30",iconColor:"text-blue-600 dark:text-blue-400",message:"Your application is being reviewed."};return e.jsxs(J,{children:[e.jsxs(Z,{className:"py-12",children:[e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx("div",{className:`w-24 h-24 rounded-full flex items-center justify-center ${u.iconBg}`,children:e.jsx("span",{className:`text-5xl ${u.iconColor}`,children:u.icon})})}),e.jsx("h2",{className:"text-3xl font-bold text-center mb-4",style:{color:"var(--metakyc-text-primary, #111827)"},children:u.title}),e.jsx("div",{className:"flex justify-center mb-6",children:e.jsx(xt,{variant:u.type==="success"?"success":u.type==="error"?"danger":u.type==="pending"?"warning":"info",children:t!=null?Be[t]:$e[r]})}),e.jsx("p",{className:"text-center mb-6 max-w-md mx-auto",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:a||u.message}),u.type==="success"&&e.jsxs("div",{className:"bg-green-50 dark:bg-green-900/20 border border-green-200 dark:border-green-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-green-900 dark:text-green-100 mb-2",children:"What's Next?"}),e.jsxs("ul",{className:"text-sm text-green-800 dark:text-green-200 space-y-1",children:[e.jsx("li",{children:"✓ Your identity has been verified"}),e.jsx("li",{children:"✓ You can now proceed with your application"}),e.jsx("li",{children:"✓ All features are now accessible"})]})]}),u.type==="error"&&e.jsxs("div",{className:"bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-red-900 dark:text-red-100 mb-2",children:"What Can You Do?"}),e.jsxs("ul",{className:"text-sm text-red-800 dark:text-red-200 space-y-2",children:[e.jsx("li",{children:"• Review the requirements and ensure all information is correct"}),e.jsx("li",{children:"• Contact our support team for assistance"}),e.jsx("li",{children:"• You may be able to resubmit your application"})]})]}),u.type==="pending"&&e.jsxs("div",{className:"bg-blue-50 dark:bg-blue-900/20 border border-blue-200 dark:border-blue-800 rounded-lg p-4 mb-6",children:[e.jsx("h3",{className:"font-semibold text-blue-900 dark:text-blue-100 mb-2",children:"What Happens Next?"}),e.jsxs("ul",{className:"text-sm text-blue-800 dark:text-blue-200 space-y-2",children:[e.jsx("li",{children:"• Our team is reviewing your information"}),e.jsx("li",{children:"• You will be notified via email once the review is complete"}),e.jsx("li",{children:"• This typically takes 24-48 hours"}),e.jsx("li",{children:"• No action is required from you at this time"})]})]}),e.jsx("div",{className:"mt-6 pt-6",style:{borderTop:"1px solid var(--metakyc-border, #e5e7eb)"},children:e.jsxs("div",{className:"grid grid-cols-2 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"KYC Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:t!=null?Be[t]:"Not Available"})]}),e.jsxs("div",{children:[e.jsx("span",{style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Review Status:"}),e.jsx("div",{className:"font-medium mt-1",style:{color:"var(--metakyc-text-primary, #111827)"},children:$e[r]})]})]})})]}),e.jsxs(xe,{className:"flex justify-center gap-4",children:[u.type==="success"&&n&&e.jsx(V,{onClick:n,size:"lg",children:"Continue"}),u.type==="error"&&e.jsxs(e.Fragment,{children:[l&&e.jsx(V,{variant:"outline",onClick:l,children:"Contact Support"}),n&&e.jsx(V,{onClick:n,children:"Try Again"})]}),u.type==="pending"&&e.jsx("div",{className:"text-center",children:e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:"Please check back later or wait for our email notification"})})]})]})},Mr=({config:t,className:r=""})=>!(t!=null&&t.visible)||!(t!=null&&t.url)?null:e.jsx("div",{className:`metakyc-logo ${r}`,children:e.jsx("img",{src:t.url,alt:t.alt||"Company Logo",style:{width:t.width||"auto",height:t.height||"40px",maxWidth:"100%",objectFit:"contain"},onError:s=>{console.warn("[Logo] Failed to load logo:",t.url),s.target.style.display="none"}})}),Ze=({title:t,subtitle:r,className:s=""})=>{const{currentTheme:a}=we(),n=t||(a==null?void 0:a.title)||"",l=!!(a!=null&&a.logo&&a.logo.visible&&a.logo.url),c=!!n;return!l&&!c?null:e.jsxs("div",{className:`metakyc-header ${s}`,children:[e.jsxs("div",{className:"metakyc-header-title flex items-center text-xl font-bold",style:{color:"var(--metakyc-text-primary, #111827)"},children:[l&&e.jsx(Mr,{config:a.logo}),l&&c&&e.jsx("span",{style:{fontSize:"1.5rem",fontWeight:300,color:"var(--metakyc-text-muted, #9ca3af)",margin:"0 12px"},children:"|"}),c&&e.jsx("span",{style:{color:"var(--metakyc-text-primary, #111827)"},children:n})]}),r&&e.jsx("p",{className:"text-sm mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:r})]})},at=["firstName","lastName","email","phonenumber","dateOfBirth"];function Qe(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const et={width:"16px",height:"16px",minWidth:"16px",flexShrink:0,flexGrow:0,accentColor:"var(--metakyc-primary, #2563eb)",cursor:"pointer",margin:0,padding:0,display:"inline-block",verticalAlign:"middle"},jt=({helpText:t,children:r})=>{const[s,a]=o.useState(!1);if(!t)return e.jsx(e.Fragment,{children:r});const n=s?e.jsx("div",{role:"dialog","aria-modal":"true",onClick:()=>a(!1),style:{position:"fixed",inset:0,zIndex:999999,background:"rgba(0, 0, 0, 0.55)",backdropFilter:"blur(6px)",WebkitBackdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:"16px"},children:e.jsxs("div",{onClick:l=>l.stopPropagation(),style:{background:"var(--metakyc-surface, var(--metakyc-background, #ffffff))",border:"1px solid var(--metakyc-border, #e5e7eb)",borderRadius:"12px",padding:"28px 24px 24px",maxWidth:"480px",width:"100%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 24px 64px rgba(0,0,0,0.4)",position:"relative"},children:[e.jsx("button",{type:"button",onClick:()=>a(!1),"aria-label":"Close",style:{position:"absolute",top:"12px",right:"12px",width:"28px",height:"28px",borderRadius:"50%",border:"1px solid var(--metakyc-border, #e5e7eb)",background:"var(--metakyc-input-bg, #f3f4f6)",color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1},children:"×"}),e.jsx("div",{style:{color:"var(--metakyc-text-primary, #111827)",fontSize:"14px",lineHeight:1.75},dangerouslySetInnerHTML:{__html:t}})]})}):null;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",flexWrap:"nowrap"},children:[r,e.jsx("button",{type:"button",className:"metakyc-help-btn",onClick:()=>a(!0),"aria-label":"Help",style:{flexShrink:0,marginTop:"2px",width:"18px",height:"18px",borderRadius:"50%",border:"1.5px solid var(--metakyc-primary, #2563eb)",background:"transparent",color:"var(--metakyc-primary, #2563eb)",fontSize:"10px",fontWeight:"700",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",lineHeight:1,padding:0,position:"relative",zIndex:2,transition:"background 0.15s, color 0.15s"},onMouseEnter:l=>{l.currentTarget.style.background="var(--metakyc-primary, #2563eb)",l.currentTarget.style.color="#ffffff"},onMouseLeave:l=>{l.currentTarget.style.background="transparent",l.currentTarget.style.color="var(--metakyc-primary, #2563eb)"},children:"?"}),typeof document<"u"&&n?it.createPortal(n,document.body):null]})},ks=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var O,q,p,k,R,v;const{config:n,baseInformationService:l,currentTheme:c}=we(),{createApplicant:u,isLoading:y}=yt(),m=t||((O=n.applicantForm)==null?void 0:O.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateApplicantForm or set it in config.applicantForm.workflowKey");const w=r||((q=n.applicantForm)==null?void 0:q.externalRefId)||"",T=((p=n.applicantForm)==null?void 0:p.email)||"",N=((k=n.applicantForm)==null?void 0:k.hiddenValues)||{},f=(((R=n.applicantForm)==null?void 0:R.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",j=o.useMemo(()=>c!=null&&c.applicantFormPages&&c.applicantFormPages.length>0?c.applicantFormPages:null,[c==null?void 0:c.applicantFormPages]),P=o.useMemo(()=>{const i=new Set(at),d=c==null?void 0:c.applicantFormRequiredFields;if(d)for(const E of d)i.add(E);if(j)for(const E of j)for(const x of E.fields)!x.isCustom&&x.name&&x.required&&i.add(x.name);return Array.from(i)},[c==null?void 0:c.applicantFormRequiredFields,j]),_=o.useMemo(()=>{var E;if(j){const x=j.flatMap(S=>S.fields).filter(S=>!S.isCustom&&S.name).map(S=>S.name),C=new Set(x);for(const S of at)C.add(S);return Array.from(C)}let i;(E=n.applicantForm)!=null&&E.visibleFields?i=n.applicantForm.visibleFields:c!=null&&c.applicantFormVisibleFields&&c.applicantFormVisibleFields.length>0?i=c.applicantFormVisibleFields:i=Mt;const d=new Set(i);for(const x of at)d.add(x);return Array.from(d)},[(v=n.applicantForm)==null?void 0:v.visibleFields,c==null?void 0:c.applicantFormVisibleFields,j]),H=new Set(["country","nationality","taxCountry","countryOfBirth","mobileCountryCode","otherNationality"]),L=o.useMemo(()=>{var d,E;const i=new Set;if(j)for(const x of j)for(const C of x.fields)!C.isCustom&&C.name&&H.has(C.name)&&i.add(C.countriesType??((d=_e[C.name])==null?void 0:d.countriesType));else for(const x of _)H.has(x)&&i.add((E=_e[x])==null?void 0:E.countriesType);return i.size===0&&i.add(void 0),Array.from(i)},[_,j]),[K,W]=o.useState({}),[Y,I]=o.useState(!0),g=o.useRef(new Set),z=o.useRef(new Set);o.useEffect(()=>{if(!c)return;const i=L.filter(x=>{const C=x!=null?String(x):"all";return!z.current.has(C)&&!g.current.has(C)});if(i.length===0){L.every(C=>{const S=C!=null?String(C):"all";return z.current.has(S)})&&I(!1);return}I(!0);const d=i.map(x=>x!=null?String(x):"all");d.forEach(x=>g.current.add(x)),(async()=>{try{const x=await Promise.all(i.map(async C=>{const S=C!=null?String(C):"all",ne=await l.getCountries("",n.locale||"en",C),se=C===40,fe=new Set,pe=ne.map(ce=>se&&ce.countryCode?{value:ce.countryCode,label:`${ce.countryCode} – ${ce.name}`}:{value:ce.abbreviation3||ce.abbreviation,label:ce.name}).filter(ce=>!ce.value||fe.has(ce.value)?!1:(fe.add(ce.value),!0));return z.current.add(S),g.current.delete(S),[S,pe]}));W(C=>({...C,...Object.fromEntries(x)}))}catch(x){d.forEach(C=>g.current.delete(C)),console.error("Failed to load countries:",x)}finally{L.every(C=>{const S=C!=null?String(C):"all";return z.current.has(S)})&&I(!1)}})()},[L,c]);const $=(i,d)=>{var C;const E=d??((C=_e[i])==null?void 0:C.countriesType),x=E!=null?String(E):"all";return K[x]||[]},D=Object.fromEntries(Object.entries(N).filter(([i])=>i in{firstName:1,lastName:1,title:1,email:1,dateOfBirth:1,phonenumber:1,mobileCountryCode:1,street:1,streetNumber:1,zip:1,city:1,country:1,nationality:1,otherNationality:1,defaultLanguage:1,taxCountry:1,placeOfBirth:1,countryOfBirth:1,salutation:1,educationLevel:1,occupation:1,taxNumber:1})),[M,te]=o.useState({workflowKey:m,firstName:"",lastName:"",title:"",email:T,dateOfBirth:"",phonenumber:"",externalRefId:w,mobileCountryCode:"",street:"",streetNumber:"",zip:"",city:"",country:"",nationality:"",otherNationality:[],defaultLanguage:"EN",taxCountry:"",placeOfBirth:"",countryOfBirth:"",salutation:null,educationLevel:"",occupation:"",taxNumber:"",...D}),re=Object.fromEntries(Object.entries(N).filter(([i])=>!(i in D)&&i!=="externalRefId"&&i!=="workflowKey")),[ee,ue]=o.useState({...re}),[oe,A]=o.useState(0),[U,X]=o.useState({}),[le,B]=o.useState(null),[b,G]=o.useState(!1),Q=(i,d)=>te(E=>({...E,[i]:d})),ie=(i,d)=>ue(E=>({...E,[i]:d})),ke=i=>!i.conditionalOn||ee[i.conditionalOn]==="true",Fe=j&&oe<j.length-1?oe+1:-1,he=j&&oe>0?oe-1:-1,qe=i=>{var E;const d={};for(const x of i.fields)if(x.isCustom){if(x.customType==="paragraph"||x.customType==="html"||x.customType==="br"||x.customType==="link")continue;if(x.required&&x.paramName){const C=ee[x.paramName],S=x.displayText||x.label||x.paramName;x.customType==="checkbox"||x.customType==="link_checkbox"?C!=="true"&&(d[x.paramName]=`${S} is required.`):(!C||C.trim()==="")&&(d[x.paramName]=`${S} is required.`)}}else if(x.name){const C=x.name;if(P.includes(C)&&Qe(M[C])){const S=x.displayText||((E=_e[C])==null?void 0:E.label)||C;d[C]=`${S} is required.`}}return d},Ye=async()=>{if(!j)return;const i=j[oe];if(i.conditionalOn&&!ke(i)){X({}),Fe>=0?A(Fe):await Te();return}const d=qe(i);if(Object.keys(d).length>0){X(d);return}X({}),Fe>=0?A(Fe):await Te()},Te=async()=>{if(j){let i={};for(const d of j)ke(d)&&(i={...i,...qe(d)});if(Object.keys(i).length>0){X(i);return}}G(!0),B(null);try{if(!M.externalRefId||M.externalRefId.trim()===""){B("External Reference ID is required. Please pass it via config.applicantForm.externalRefId.");return}const i={workflowKey:M.workflowKey,externalRefId:M.externalRefId.trim()};if(j){for(const C of j)if(ke(C)){for(const S of C.fields)if(!S.isCustom&&S.name){const ne=S.name,se=M[ne];Qe(se)||(i[ne]=se)}}for(const C of at)if(i[C]===void 0){const S=M[C];Qe(S)||(i[C]=S)}}else _.forEach(C=>{if(C==="externalRefId")return;const S=M[C];Qe(S)||(i[C]=S)});const d=[];if(j){for(const C of j)if(ke(C))for(const S of C.fields){if(!S.isCustom||!S.paramName||S.customType==="paragraph"||S.customType==="html"||S.customType==="br"||S.customType==="link")continue;const ne=ee[S.paramName]??"";let se;if(S.customType==="checkbox"||S.customType==="link_checkbox")se=ne==="true"?"yes":"no";else if(se=ne,!se&&!S.required)continue;d.push({paramName:S.paramName,value:se})}}for(const[C,S]of Object.entries(D))i[C]===void 0&&!Qe(S)&&(i[C]=S);const E=new Set(d.map(C=>C.paramName));for(const[C,S]of Object.entries(re))!E.has(C)&&S&&d.push({paramName:C,value:S});d.length>0&&(i.applicantAdditionalDatas=d);const x=await u(i);s(x.applicantId)}catch(i){console.error("Error creating applicant:",i),B(i.message||"Failed to create applicant")}finally{G(!1)}},Ve=async i=>{var d;i.preventDefault();for(const E of P)if(Qe(M[E])){const x=((d=_e[E])==null?void 0:d.label)||E;B(`${x} is required.`);return}await Te()},Me=(i,d,E,x,C)=>{var ht;const S=_e[i];if(!S)return null;const ne=P.includes(i),se=U[i],fe=E||S.label,pe=d??i,ce={required:ne},Pe=C?C!=="placeholder":f,ze=Pe?fe:void 0,zr=Pe?"...":fe;switch(S.type){case"select":if(i==="country"||i==="nationality"||i==="taxCountry"||i==="countryOfBirth"||i==="mobileCountryCode"){const je=$(i,x);return e.jsx(Ae,{...ce,label:ze,value:M[i]||"",onChange:We=>Q(i,We),options:[{value:"",label:`Select ${zr.toLowerCase()}`},...je],disabled:Y,error:se},pe)}if(i==="salutation")return e.jsx(Ae,{...ce,label:ze,value:((ht=M[i])==null?void 0:ht.toString())||"",onChange:je=>Q(i,je?Number(je):null),options:[{value:"",label:Pe?"Select salutation...":fe},{value:rt.Male.toString(),label:"Male"},{value:rt.Female.toString(),label:"Female"},{value:rt.Other.toString(),label:"Other"}],error:se},pe);if(i==="defaultLanguage"){const je=c!=null&&c.allowedLanguages&&c.allowedLanguages.length>0?dt.filter(We=>c.allowedLanguages.includes(We.value)):dt;return e.jsx(Ae,{...ce,label:ze,value:M[i]||"",onChange:We=>Q(i,We),options:[{value:"",label:Pe?"Select language...":fe},...je],error:se},pe)}return null;case"multiselect":if(i==="otherNationality"){const je=$(i,x);return e.jsx(jr,{...ce,label:ze,value:M[i]||[],onChange:We=>Q(i,We),options:je,placeholder:Pe?"Select other nationalities...":fe,disabled:Y},pe)}return null;case"date":return e.jsx(me,{...ce,type:"date",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);case"email":return e.jsx(me,{...ce,type:"email",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);case"tel":return e.jsx(me,{...ce,type:"tel",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe);default:return e.jsx(me,{...ce,type:"text",label:ze,placeholder:Pe?void 0:fe,value:M[i]||"",onChange:je=>Q(i,je.target.value),error:se},pe)}},He=(i,d)=>{const E=i.labelMode?i.labelMode!=="placeholder":f;if(i.customType==="paragraph"){const S=i.displayText||i.label||"";return e.jsx("p",{className:"metakyc-paragraph",style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:S}},`custom-${d}`)}if(i.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:i.label||""}},`custom-${d}`);if(i.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${d}`);if(i.customType==="link"){const S=i.displayText||i.label||i.linkText||i.linkUrl||"";return e.jsx("div",{className:"metakyc-link-field",children:e.jsxs("a",{href:i.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:"4px",color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline",cursor:"pointer"},children:[S,e.jsx("span",{style:{fontSize:"10px",opacity:.7},children:"↗"})]})},`custom-${d}`)}if(!i.paramName)return null;const x=U[i.paramName],C=i.displayText||i.label||i.paramName;if(i.customType==="checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:ee[i.paramName]==="true",onChange:S=>ie(i.paramName,S.target.checked?"true":"false"),className:"metakyc-option-input",style:et}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),x&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:x})]},`custom-${d}`);if(i.customType==="link_checkbox")return e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:ee[i.paramName]==="true",onChange:S=>ie(i.paramName,S.target.checked?"true":"false"),className:"metakyc-option-input",style:{...et,alignSelf:"flex-start",marginTop:"2px"}}),e.jsxs("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:[C," ",i.linkUrl&&e.jsx("a",{href:i.linkUrl,target:"_blank",rel:"noopener noreferrer",className:"underline",style:{color:"var(--metakyc-primary, #2563eb)"},onClick:S=>S.stopPropagation(),children:i.linkText||i.linkUrl}),i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),x&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:x})]},`custom-${d}`);if(i.customType==="group_checkbox"){const S=(ee[i.paramName]||"").split(",").filter(Boolean);return e.jsxs("div",{className:"flex flex-col gap-1.5",children:[E&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(i.options||[]).map(ne=>{const se=i.singleSelect?ee[i.paramName]===ne.value:S.includes(ne.value);return e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:se,onChange:fe=>{if(i.singleSelect)ie(i.paramName,fe.target.checked?ne.value:"");else{const pe=fe.target.checked?[...S,ne.value]:S.filter(ce=>ce!==ne.value);ie(i.paramName,pe.join(","))}},className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:ne.label})]},ne.value)})}),x&&e.jsx("p",{className:"text-red-500 text-xs",children:x})]},`custom-${d}`)}return i.customType==="radio_group"?e.jsxs("div",{className:"flex flex-col gap-1.5",children:[E&&e.jsxs("div",{className:"text-sm font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:[C,i.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]}),e.jsx("div",{className:"metakyc-options-group",style:{display:"flex",flexDirection:"column",gap:"8px"},children:(i.options||[]).map(S=>e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"radio",checked:ee[i.paramName]===S.value,onChange:()=>ie(i.paramName,S.value),name:`radio-group-${i.paramName}-${d}`,className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4"},children:S.label})]},S.value))}),x&&e.jsx("p",{className:"text-red-500 text-xs",children:x})]},`custom-${d}`):e.jsx(me,{type:"text",label:E?`${C}${i.required?" *":""}`:void 0,placeholder:E?void 0:C,value:ee[i.paramName]||"",onChange:S=>ie(i.paramName,S.target.value),required:i.required,error:x},`custom-${d}`)},h=(i,d)=>{const E=ke(i);return e.jsxs("div",{className:"space-y-4",children:[i.conditionalOn&&e.jsx(jt,{helpText:i.conditionalHelpText,children:e.jsxs("label",{className:"metakyc-option-label",style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer",margin:0,padding:0},children:[e.jsx("input",{type:"checkbox",checked:E,onChange:x=>ie(i.conditionalOn,x.target.checked?"true":"false"),className:"metakyc-option-input",style:et}),e.jsx("span",{className:"metakyc-option-text",style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)",lineHeight:"1.4",fontWeight:500},children:i.conditionalOn})]})}),E&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:i.fields.map((x,C)=>{const S=x.colSpan===1?"col-span-1":x.colSpan===2?"col-span-2":x.colSpan===3?"col-span-3":"col-span-4",ne=x.isCustom?`custom-${C}-${x.paramName}`:`builtin-${x.name}-${C}`;return e.jsx("div",{className:S,children:e.jsx(jt,{helpText:x.helpText,children:x.isCustom?He(x,C):Me(x.name,ne,x.displayText,x.countriesType,x.labelMode)})},ne)})})]})};if(!c||Y)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(j){const i=j[oe]??j[0],d=he===-1,E=Fe===-1,x=j.length,C=ke(i),S=Object.values(U);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(Z,{children:[(i.title||i.subtitle||i.description)&&e.jsxs("div",{className:"mb-4",children:[i.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:i.title}),i.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:i.subtitle}),i.description&&i.description!==i.subtitle&&e.jsx("p",{className:"text-xs mt-1",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:i.description})]}),(le||S.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[le&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",le]}),S.map((ne,se)=>e.jsx("p",{className:"text-red-600 text-sm",children:ne},se))]}),x>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[j.map((ne,se)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${se===oe?"flex-1":"w-8"}`,style:se===oe?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:se<oe?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},se)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[oe+1," / ",x]})]}),h(i)]}),e.jsxs(xe,{className:"flex justify-between",children:[e.jsxs("div",{children:[!d&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{A(he),X({})},disabled:b||y,children:"Previous"}),d&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:b||y,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:b||y,onClick:E?Te:Ye,children:E?i.conditionalOn&&!C?"Skip & Submit":"Submit":i.conditionalOn&&!C?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:Ve,children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Create Applicant"})}),e.jsxs(Z,{children:[le&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",le]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:_.map(i=>e.jsx("div",{className:"col-span-4",children:Me(i)},i))})]}),e.jsxs(xe,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:b||y,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:b||y,children:"Create Applicant"})]})]})})})},wt=["companyName","email"];function ct(t){return t==null||t===""||Array.isArray(t)&&t.length===0}const js=({workflowKey:t,externalRefId:r,onSuccess:s,onCancel:a})=>{var Me,He,h,O,q;const{config:n,baseInformationService:l,currentTheme:c}=we(),{createCompanyApplicant:u,isLoading:y}=yt(),m=t||((Me=n.applicantForm)==null?void 0:Me.workflowKey);if(!m)throw new Error("workflowKey is required. Provide it either as a prop to CreateCompanyApplicantForm or set it in config.applicantForm.workflowKey");const w=r||((He=n.applicantForm)==null?void 0:He.externalRefId)||"",T=((h=n.applicantForm)==null?void 0:h.email)||"",F=(((O=n.applicantForm)==null?void 0:O.fieldLabelMode)||(c==null?void 0:c.fieldLabelMode)||"label")!=="placeholder",f=o.useMemo(()=>c!=null&&c.companyFormPages&&c.companyFormPages.length>0?c.companyFormPages:null,[c==null?void 0:c.companyFormPages]),j=o.useMemo(()=>{const p=new Set(wt),k=c==null?void 0:c.companyFormRequiredFields;if(k)for(const R of k)p.add(R);if(f)for(const R of f)for(const v of R.fields)!v.isCustom&&v.name&&v.required&&p.add(v.name);return Array.from(p)},[c==null?void 0:c.companyFormRequiredFields,f]),P=o.useMemo(()=>{var p;if(f){const k=f.flatMap(v=>v.fields).filter(v=>!v.isCustom&&v.name).map(v=>v.name),R=new Set(k);for(const v of wt)R.add(v);return Array.from(R)}return(p=n.applicantForm)!=null&&p.visibleFields?n.applicantForm.visibleFields:c!=null&&c.companyFormVisibleFields&&c.companyFormVisibleFields.length>0?c.companyFormVisibleFields:Dt},[(q=n.applicantForm)==null?void 0:q.visibleFields,c==null?void 0:c.companyFormVisibleFields,f]),_=new Set(["countryResidence","addressCountry"]),H=o.useMemo(()=>{var k,R;const p=new Set;if(f)for(const v of f)for(const i of v.fields)!i.isCustom&&i.name&&_.has(i.name)&&p.add(i.countriesType??((k=Ue[i.name])==null?void 0:k.countriesType));else for(const v of P)_.has(v)&&p.add((R=Ue[v])==null?void 0:R.countriesType);return p.size===0&&p.add(void 0),Array.from(p)},[P,f]),[L,K]=o.useState({}),[W,Y]=o.useState(!0),I=o.useRef(new Set),g=o.useRef(new Set);o.useEffect(()=>{if(!c)return;const p=H.filter(v=>{const i=v!=null?String(v):"all";return!g.current.has(i)&&!I.current.has(i)});if(p.length===0){H.every(i=>g.current.has(i!=null?String(i):"all"))&&Y(!1);return}Y(!0);const k=p.map(v=>v!=null?String(v):"all");k.forEach(v=>I.current.add(v)),(async()=>{try{const v=await Promise.all(p.map(async i=>{const d=i!=null?String(i):"all",E=await l.getCountries("",n.locale||"en",i),x=new Set,C=E.map(S=>({value:S.abbreviation3||S.abbreviation,label:S.name})).filter(S=>!S.value||x.has(S.value)?!1:(x.add(S.value),!0));return g.current.add(d),I.current.delete(d),[d,C]}));K(i=>({...i,...Object.fromEntries(v)}))}catch(v){k.forEach(i=>I.current.delete(i)),console.error("Failed to load countries:",v)}finally{H.every(i=>g.current.has(i!=null?String(i):"all"))&&Y(!1)}})()},[H,c]);const z=(p,k)=>{var i;const R=k??((i=Ue[p])==null?void 0:i.countriesType),v=R!=null?String(R):"all";return L[v]||[]},[$,D]=o.useState({workflowKey:m,companyName:"",email:T,phone:"",registrationNumber:"",countryResidence:"",legalAddress:"",incorporatedOn:"",controlScheme:"",taxId:"",registrationLocation:"",website:"",postalAddress:"",street:"",streetNumber:"",city:"",state:"",postalCode:"",addressCountry:"",lei:"",externalRefId:w}),[M,te]=o.useState({}),[re,ee]=o.useState(0),[ue,oe]=o.useState({}),[A,U]=o.useState(null),[X,le]=o.useState(!1),B=(p,k)=>D(R=>({...R,[p]:k})),b=(p,k)=>te(R=>({...R,[p]:k})),G=p=>!p.conditionalOn||M[p.conditionalOn]==="true",Q=f&&re<f.length-1?re+1:-1,ie=f&&re>0?re-1:-1,ke=p=>{var R;const k={};for(const v of p.fields)if(v.isCustom){if(v.customType==="paragraph"||v.customType==="html"||v.customType==="br"||v.customType==="link")continue;if(v.required&&v.paramName){const i=M[v.paramName],d=v.displayText||v.label||v.paramName;v.customType==="checkbox"||v.customType==="link_checkbox"?i!=="true"&&(k[v.paramName]=`${d} is required.`):(!i||i.trim()==="")&&(k[v.paramName]=`${d} is required.`)}}else if(v.name){const i=v.name;if(j.includes(i)&&ct($[i])){const d=v.displayText||((R=Ue[i])==null?void 0:R.label)||i;k[i]=`${d} is required.`}}return k},Fe=async()=>{if(!f)return;const p=f[re];if(p.conditionalOn&&!G(p)){oe({}),Q>=0?ee(Q):await he();return}const k=ke(p);if(Object.keys(k).length>0){oe(k);return}oe({}),Q>=0?ee(Q):await he()},he=async()=>{var p;if(f){let k={};for(const R of f)G(R)&&(k={...k,...ke(R)});if(Object.keys(k).length>0){oe(k);return}}le(!0),U(null);try{const k={workflowKey:$.workflowKey,externalRefId:((p=$.externalRefId)==null?void 0:p.trim())||void 0},R=f?f.filter(d=>G(d)).flatMap(d=>d.fields).filter(d=>!d.isCustom&&d.name).map(d=>d.name):P;for(const d of R){const E=$[d];if(!ct(E))switch(d){case"companyName":k.companyName=E;break;case"email":k.companyEmail=E;break;case"phone":k.companyPhone=E;break;case"registrationNumber":k.companyRegistrationNumber=E;break;case"countryResidence":k.companyCountry=E;break;case"city":k.companyCity=E;break;case"street":k.companyStreet=E;break;case"postalCode":k.companyZip=E;break;default:k[d]=E;break}}const v=[];if(f){for(const d of f)if(G(d))for(const E of d.fields){if(!E.isCustom||!E.paramName||E.customType==="paragraph"||E.customType==="html"||E.customType==="br"||E.customType==="link")continue;const x=M[E.paramName]??"";let C;if(E.customType==="checkbox"||E.customType==="link_checkbox")C=x==="true"?"yes":"no";else if(C=x,!C&&!E.required)continue;v.push({paramName:E.paramName,value:C})}}v.length>0&&(k.applicantAdditionalDatas=v);const i=await u(k);s(i.applicantId)}catch(k){console.error("Error creating company applicant:",k),U(k.message||"Failed to create company applicant")}finally{le(!1)}},qe=async p=>{var k;p.preventDefault();for(const R of j)if(ct($[R])){const v=((k=Ue[R])==null?void 0:k.label)||R;U(`${v} is required.`);return}await he()},Ye=(p,k,R,v,i)=>{const d=Ue[p];if(!d)return null;const E=j.includes(p),x=ue[p],C=R||d.label,S=k??p,ne=i?i!=="placeholder":F,se=ne?C:void 0,fe=ne?"...":C;switch(d.type){case"select":if(p==="countryResidence"||p==="addressCountry"){const pe=z(p,v);return e.jsx(Ae,{required:E,label:se,value:$[p]||"",onChange:ce=>B(p,ce),options:[{value:"",label:`Select ${fe.toLowerCase()}`},...pe],disabled:W,error:x},S)}return null;case"date":return e.jsx(me,{required:E,type:"date",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);case"email":return e.jsx(me,{required:E,type:"email",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);case"tel":return e.jsx(me,{required:E,type:"tel",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S);default:return e.jsx(me,{required:E,type:"text",label:se,placeholder:ne?void 0:C,value:$[p]||"",onChange:pe=>B(p,pe.target.value),error:x},S)}},Te=(p,k)=>{if(p.customType==="paragraph")return e.jsx("p",{style:{fontSize:"14px",lineHeight:"1.7",margin:0,color:"var(--metakyc-text-secondary, #6b7280)"},dangerouslySetInnerHTML:{__html:p.displayText||p.label||""}},`custom-${k}`);if(p.customType==="html")return e.jsx("div",{dangerouslySetInnerHTML:{__html:p.label||""}},`custom-${k}`);if(p.customType==="br")return e.jsx("div",{style:{height:"12px"}},`custom-${k}`);if(p.customType==="link")return e.jsx("div",{children:e.jsx("a",{href:p.linkUrl||"#",target:"_blank",rel:"noopener noreferrer",style:{color:"var(--metakyc-primary, #2563eb)",fontSize:"14px",textDecoration:"underline"},children:p.displayText||p.label||p.linkText||p.linkUrl||""})},`custom-${k}`);if(!p.paramName)return null;const R=ue[p.paramName],v=p.displayText||p.label||p.paramName,i=p.labelMode?p.labelMode!=="placeholder":F;return p.customType==="checkbox"?e.jsxs("div",{className:"flex flex-col gap-1",children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:M[p.paramName]==="true",onChange:d=>b(p.paramName,d.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsxs("span",{style:{fontSize:"14px",color:"var(--metakyc-text-primary, #111827)"},children:[v,p.required&&e.jsx("span",{className:"text-red-500 ml-0.5",children:"*"})]})]}),R&&e.jsx("p",{className:"text-red-500 text-xs mt-0.5",children:R})]},`custom-${k}`):e.jsx(me,{type:"text",label:i?`${v}${p.required?" *":""}`:void 0,placeholder:i?void 0:v,value:M[p.paramName]||"",onChange:d=>b(p.paramName,d.target.value),required:p.required,error:R},`custom-${k}`)},Ve=p=>{const k=G(p);return e.jsxs("div",{className:"space-y-4",children:[p.conditionalOn&&e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"10px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:k,onChange:R=>b(p.conditionalOn,R.target.checked?"true":"false"),style:{width:"16px",height:"16px",accentColor:"var(--metakyc-primary, #2563eb)"}}),e.jsx("span",{style:{fontSize:"14px",fontWeight:500},children:p.conditionalOn})]}),k&&e.jsx("div",{className:"grid grid-cols-4 gap-4",children:p.fields.map((R,v)=>{const i=R.colSpan===1?"col-span-1":R.colSpan===2?"col-span-2":R.colSpan===3?"col-span-3":"col-span-4",d=R.isCustom?`custom-${v}-${R.paramName}`:`builtin-${R.name}-${v}`;return e.jsx("div",{className:i,children:R.isCustom?Te(R,v):Ye(R.name,d,R.displayText,R.countriesType,R.labelMode)},d)})})]})};if(!c||W)return e.jsx("div",{className:"metakyc-sdk",children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)",fontSize:"0.875rem"},children:"Loading form…"})]})})});if(f){const p=f[re]??f[0],k=ie===-1,R=Q===-1,v=f.length,i=G(p),d=Object.values(ue);return e.jsx("div",{className:"metakyc-sdk",children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(Z,{children:[(p.title||p.subtitle)&&e.jsxs("div",{className:"mb-4",children:[p.title&&e.jsx("h3",{className:"font-semibold text-base",style:{color:"var(--metakyc-text-primary, #111827)"},children:p.title}),p.subtitle&&e.jsx("p",{className:"text-sm mt-0.5",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:p.subtitle})]}),(A||d.length>0)&&e.jsxs("div",{className:"mb-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[A&&e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",A]}),d.map((E,x)=>e.jsx("p",{className:"text-red-600 text-sm",children:E},x))]}),v>1&&e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[f.map((E,x)=>e.jsx("div",{className:`h-1.5 rounded-full transition-all ${x===re?"flex-1":"w-8"}`,style:x===re?{backgroundColor:"var(--metakyc-primary, #2563eb)"}:x<re?{backgroundColor:"var(--metakyc-primary-light, #93c5fd)",opacity:.7}:{backgroundColor:"#e5e7eb"}},x)),e.jsxs("span",{className:"text-xs text-gray-400 flex-shrink-0",children:[re+1," / ",v]})]}),Ve(p)]}),e.jsxs(xe,{className:"flex justify-between",children:[e.jsxs("div",{children:[!k&&e.jsx(V,{type:"button",variant:"outline",onClick:()=>{ee(ie),oe({})},disabled:X||y,children:"Previous"}),k&&a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:X||y,children:"Cancel"})]}),e.jsx(V,{type:"button",isLoading:X||y,onClick:R?he:Fe,children:R?p.conditionalOn&&!i?"Skip & Submit":"Submit":p.conditionalOn&&!i?"Skip":"Next"})]})]})})}return e.jsx("div",{className:"metakyc-sdk",children:e.jsx("form",{onSubmit:qe,children:e.jsxs(J,{children:[e.jsx(ye,{children:e.jsx(Ze,{title:(c==null?void 0:c.title)||"Company Registration"})}),e.jsxs(Z,{children:[A&&e.jsx("div",{className:"mb-6 p-4 bg-red-50 border border-red-200 rounded-lg",children:e.jsxs("p",{className:"text-red-600 text-sm",children:[e.jsx("strong",{children:"Error:"})," ",A]})}),e.jsx("div",{className:"grid grid-cols-4 gap-4",children:P.map(p=>e.jsx("div",{className:"col-span-4",children:Ye(p)},p))})]}),e.jsxs(xe,{className:"flex justify-between",children:[a&&e.jsx(V,{type:"button",variant:"outline",onClick:a,disabled:X||y,children:"Cancel"}),e.jsx(V,{type:"submit",isLoading:X||y,children:"Register Company"})]})]})})})},ws=({applicantId:t,onComplete:r,onError:s,theme:a="light",className:n})=>{const{progress:l,currentStep:c,steps:u,workflowKey:y,nextWorkflowKey:m,hasWorkflowChanged:w,isLoading:T,error:N,moveBack:F,refreshProgress:f}=hr(t),[j,P]=o.useState(!1),_=o.useRef(null);if(o.useEffect(()=>{N&&s&&s(N)},[N,s]),o.useEffect(()=>{l!=null&&l.workflowResult&&r&&r(l.workflowResult)},[l==null?void 0:l.workflowResult,r]),o.useEffect(()=>{a==="dark"?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")},[a]),o.useEffect(()=>{w&&P(!1)},[w]),T||!l)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Loading workflow..."})]})})});if(N)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("p",{className:"text-lg mb-4",style:{color:"var(--metakyc-danger, #ef4444)"},children:"An error occurred"}),e.jsx("p",{style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:N.message})]})})})});if(w&&!j)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsx(Z,{children:e.jsxs("div",{className:"text-center py-8",children:[e.jsx("div",{className:"mb-6",children:e.jsx("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full mb-4",style:{backgroundColor:"var(--metakyc-primary-light, #dbeafe)"},children:e.jsx("svg",{className:"w-8 h-8",style:{color:"var(--metakyc-primary, #2563eb)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})})}),e.jsx("h3",{className:"text-xl font-semibold mb-2",style:{color:"var(--metakyc-text-primary, #111827)"},children:"Workflow Transition"}),e.jsx("p",{className:"mb-6",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:"Your application workflow has been updated based on your progress."}),e.jsxs("div",{className:"rounded-lg p-4 mb-6 max-w-md mx-auto",style:{backgroundColor:"var(--metakyc-surface, #f9fafb)"},children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"text-left",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"Previous Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-text-primary, #111827)"},children:y})]}),e.jsx("svg",{className:"w-6 h-6 mx-4",style:{color:"var(--metakyc-text-muted, #9ca3af)"},fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 7l5 5m0 0l-5 5m5-5H6"})}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"mb-1",style:{color:"var(--metakyc-text-muted, #9ca3af)"},children:"New Workflow"}),e.jsx("p",{className:"font-medium",style:{color:"var(--metakyc-primary, #2563eb)"},children:m})]})]}),l.nextWorkflowName&&e.jsx("p",{className:"text-center mt-2 text-xs",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.nextWorkflowName})]}),e.jsx("button",{onClick:()=>P(!0),className:"px-6 py-3 font-medium rounded-lg transition-opacity hover:opacity-90",style:{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff"},children:"Continue with New Workflow"})]})})})});if(l.status===Re.Finished||l.status===Re.OnHold)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(ut,{kycStatus:l.kycStatus,reviewStatus:l.reviewStatus,workflowResult:l.workflowResult,customMessage:l.customMessage,onContinue:r&&l.workflowResult?()=>r(l.workflowResult):void 0,onContactSupport:()=>{typeof window<"u"&&(window.location.href="mailto:support@example.com")}})});if(!c)return e.jsx("div",{className:`metakyc-sdk ${n||""}`,children:e.jsx(J,{children:e.jsxs(Z,{children:[e.jsx(Ce,{className:"my-8"}),e.jsx("p",{className:"text-center mt-4",style:{color:"var(--metakyc-text-secondary, #6b7280)"},children:l.status===Re.IdentityPending?"Loading identity verification...":"Loading current step..."})]})})});const H=W=>{switch(W){case ae.Overview:return"Overview";case ae.Questionaries:return"Questionnaire";case ae.UploadDocument:return"Documents";case ae.IdentitySdk:return"Identity";case ae.RiskScoring:return"Risk Assessment";case ae.InvestorCategorization:return"Investor Categorization";case ae.AppropriatenessTest:return"Appropriateness Test";case ae.AdditionalData:return"Additional Data";case ae.ManualReview:return"Review";default:return""}},L=()=>{const W=u.filter($=>$.visibility!==!1),Y=W.findIndex($=>$.order===c.order),I=Y>=0?Y+1:1,g=W.length,z=g>1?Y/(g-1)*100:100;return e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",marginBottom:"16px"},children:[e.jsx(Ze,{}),e.jsxs(xt,{variant:l.status===1?"info":"success",children:["Step ",I," of ",g]})]}),e.jsx("div",{style:{marginBottom:"16px"},children:e.jsx("div",{style:{height:"4px",borderRadius:"999px",backgroundColor:"var(--metakyc-border, #e5e7eb)",overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",borderRadius:"999px",backgroundColor:"var(--metakyc-primary, #2563eb)",width:`${z}%`,transition:"width 0.4s ease"}})})}),e.jsx(Ss,{ref:_,visibleSteps:W,currentVisibleStepIndex:Y,getStepFallbackName:H})]})},K=()=>{const W={applicantId:t,onComplete:async()=>{await f()},onBack:c.order>0?F:void 0};switch(c.action){case ae.Questionaries:return e.jsx(Er,{...W});case ae.UploadDocument:return e.jsx(Ar,{...W});case ae.Overview:return e.jsx(Fr,{...W});case ae.IdentitySdk:return e.jsx(Dr,{...W});case ae.RiskScoring:return e.jsx(Tr,{...W});case ae.AdditionalData:case ae.InvestorCategorization:return e.jsx(Pr,{...W});case ae.AppropriatenessTest:return e.jsx(Lr,{...W});case ae.ManualReview:return e.jsx(ut,{kycStatus:l.kycStatus,reviewStatus:l.reviewStatus,workflowResult:l.workflowResult,customMessage:l.customMessage});default:return e.jsx(J,{children:e.jsxs(Z,{className:"py-12 text-center",children:[e.jsx("div",{className:"mb-4",children:e.jsx(Ce,{})}),e.jsxs("p",{className:"text-gray-600 dark:text-gray-400 mb-2",children:["Processing step: ",c.title||c.name]}),e.jsxs("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:["Action type: ",ae[c.action]]})]})})}};return e.jsxs("div",{className:`metakyc-sdk ${n||""}`,children:[L(),K()]})},Ss=o.forwardRef(({visibleSteps:t,currentVisibleStepIndex:r,getStepFallbackName:s},a)=>{const n=o.useRef(null),l=o.useRef(null);return o.useImperativeHandle(a,()=>n.current),o.useEffect(()=>{if(l.current&&n.current){const c=n.current,u=l.current,y=u.offsetLeft-c.offsetWidth/2+u.offsetWidth/2;c.scrollTo({left:Math.max(0,y),behavior:"smooth"})}},[r]),e.jsx("div",{ref:n,className:"metakyc-stepper-scroll",style:{display:"flex",alignItems:"center",overflowX:"auto",overflowY:"hidden",scrollbarWidth:"none",msOverflowStyle:"none",WebkitOverflowScrolling:"touch",padding:"4px 0",gap:"0"},children:t.map((c,u)=>{const y=u<r,m=u===r,w=y||m,T=c.displayName||c.name||s(c.action)||`Step ${u+1}`;return e.jsxs(o.Fragment,{children:[e.jsxs("div",{ref:m?l:void 0,style:{display:"flex",alignItems:"center",flexShrink:0},children:[e.jsx("div",{style:{width:"28px",height:"28px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:600,flexShrink:0,transition:"all 0.2s ease",...w?{backgroundColor:"var(--metakyc-primary, #2563eb)",color:"#ffffff",border:"none"}:{backgroundColor:"transparent",color:"var(--metakyc-text-muted, #9ca3af)",border:"2px solid var(--metakyc-border, #e5e7eb)"}},children:y?e.jsx("svg",{width:"14",height:"14",fill:"none",stroke:"currentColor",strokeWidth:2.5,viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 13l4 4L19 7"})}):u+1}),e.jsx("span",{style:{marginLeft:"6px",fontSize:"13px",whiteSpace:"nowrap",fontWeight:m?600:400,color:m?"var(--metakyc-text-primary, #111827)":y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-text-muted, #9ca3af)",transition:"color 0.2s ease"},children:T})]}),u<t.length-1&&e.jsx("div",{style:{width:"32px",minWidth:"16px",height:"2px",margin:"0 8px",flexShrink:0,borderRadius:"999px",backgroundColor:y?"var(--metakyc-primary, #2563eb)":"var(--metakyc-border, #e5e7eb)",transition:"background-color 0.2s ease"}})]},c.order)})})});function Cs(t){return De.z.object({questionResults:De.z.any()}).passthrough()}function Ns(t){let r=De.z.array(De.z.instanceof(File));if(t.isRequired?r=r.min(1,`${t.displayName} is required`):r=r.optional(),t.multipleFile||(r=r.refine(s=>!s||s.length<=1,{message:"Only one file is allowed"})),t.maxEachFileSizeByte>0&&(r=r.refine(s=>!s||s.every(a=>a.size<=t.maxEachFileSizeByte),{message:`File size must not exceed ${Math.round(t.maxEachFileSizeByte/1024/1024)}MB`})),t.allowedTypes){const s=t.allowedTypes.split(",").map(a=>a.trim());r=r.refine(a=>a?a.every(n=>s.some(l=>l.endsWith("/*")?n.type.startsWith(l.slice(0,-2)):n.type===l)):!0,{message:"Invalid file type"})}return r}function Rs(t){const r={};return t.uploadDocumentFiles.forEach(s=>{const a=`file_${s.id}`;r[a]=Ns(s)}),De.z.object(r)}function Is(t){return De.z.any()}function Es(t){return De.z.string().min(1,"This question is required")}function As(t){const r={};return t.appropriatenessQuestions.forEach(s=>{const a=`question_${s.id}`;r[a]=Es()}),De.z.object(r)}const Fs=De.z.any();exports.ALLOWED_LANGUAGES=dt;exports.ApplicantProgressOnHoldReason=St;exports.ApplicantProgressStatus=Re;exports.ApplicantService=$t;exports.ApplicantStatus=Nt;exports.AppropriatenessQuestionType=Ft;exports.AppropriatenessTestService=Wt;exports.AppropriatenessTestStep=Lr;exports.Badge=xt;exports.BaseInformationService=Yt;exports.Button=V;exports.COMPANY_FIELD_METADATA=Ue;exports.Card=J;exports.CardContent=Z;exports.CardFooter=xe;exports.CardHeader=ye;exports.CountriesType=Le;exports.CreateApplicantForm=ks;exports.CreateCompanyApplicantForm=js;exports.CriteriaBuiltInType=Pt;exports.DEFAULT_COMPANY_VISIBLE_FIELDS=Dt;exports.DEFAULT_VISIBLE_FIELDS=Mt;exports.DocumentReviewStatus=At;exports.EndpointBuilder=Ot;exports.ErrorHandler=Ge;exports.EventEmitter=rr;exports.FIELD_METADATA=_e;exports.FileType=Et;exports.FileUpload=wr;exports.GenderType=rt;exports.Header=Ze;exports.HttpClient=Bt;exports.IdentityProviderManager=Ke;exports.IdentityService=qt;exports.IdentityVerificationProvider=Ne;exports.IdentityVerificationStep=Dr;exports.Input=me;exports.InvestorCategorizationService=Vt;exports.InvestorCategorizationStep=Pr;exports.InvestorCategorizationType=ge;exports.InvestorCategoryType=Lt;exports.KycProcessStatus=Rt;exports.KycStatus=Be;exports.KycStatusDisplay=ut;exports.KycWorkflow=ws;exports.Logo=Mr;exports.MetaKYCContext=mt;exports.MetaKYCError=Ie;exports.MetaKYCProvider=Kr;exports.MultiSelect=jr;exports.OnfidoProvider=or;exports.OverviewService=Ut;exports.OverviewStep=Fr;exports.PhoneInput=Sr;exports.QuestionnaireService=_t;exports.QuestionnaireStep=Er;exports.ReviewStatus=$e;exports.RiskCriteriaType=Tt;exports.RiskLevel=Ct;exports.RiskScoringService=Kt;exports.RiskScoringStep=Tr;exports.SardinAIProvider=lr;exports.SearchableSelect=Ae;exports.Select=ot;exports.Spinner=Ce;exports.StepRouter=ar;exports.SumsubProvider=ir;exports.ThemeManager=cr;exports.ThemePreset=be;exports.ThemeService=tr;exports.UploadDocumentService=Ht;exports.UploadDocumentStep=Ar;exports.UserType=It;exports.ValueDataType=Ee;exports.WorkflowOrchestrator=nr;exports.WorkflowResultType=tt;exports.WorkflowState=sr;exports.WorkflowStepAction=ae;exports.appropriatenessTestSchema=Fs;exports.clearAllStorage=Gr;exports.clearApplicantId=mr;exports.clearWorkflowState=xr;exports.cn=ve;exports.corporateTheme=Qt;exports.defaultConfig=zt;exports.defaultTheme=Se;exports.fileToBase64=dr;exports.fintechTheme=Gt;exports.formatFileSize=nt;exports.generateAppropriatenessSchema=As;exports.generateQuestionnaireSchema=Cs;exports.generateRiskScoringSchema=Is;exports.generateUploadDocumentSchema=Rs;exports.getAcceptString=Vr;exports.getApplicantId=pr;exports.getThemePreset=Je;exports.getWorkflowState=Qr;exports.healthcareTheme=Jt;exports.isScriptLoaded=Hr;exports.loadScript=pt;exports.minimalTheme=Xt;exports.modernTheme=Zt;exports.removeScript=Wr;exports.saveApplicantId=ur;exports.saveWorkflowState=yr;exports.themePresets=er;exports.useApplicant=yt;exports.useAppropriatenessTest=Jr;exports.useIdentityVerification=vr;exports.useKycWorkflow=hr;exports.useMetaKYC=we;exports.useOverview=br;exports.useQuestionnaire=fr;exports.useRiskScoring=kr;exports.useUploadDocument=gr;exports.validateFileSize=qr;exports.validateFileType=Yr;
83
83
  //# sourceMappingURL=index.cjs.map