let e;import{x as t,r as s,j as n,H as i,ag as l,c as r,af as a,ah as o,o as c,D as u,E as g,z as d,s as S,i as h,R as v}from"./chunk-5b723e6e.js";import{e as f,d as j,c as p,D as b,S as x}from"./chunk-4f4afcb4.js";let k=s.createContext({}),y={},C=({children:e,enableGetClientSettings:i,clientSettings:l,apiCredentials:r,flowId:a})=>{let{apiClient:o}=t.useApiClient({apiCredentials:r}),[c,u]=s.useState({}),[g,d]=s.useState(!1);s.useEffect(()=>{i?async function e(){try{if(!o||"function"!=typeof o.clientSettings)return;let e=await o.clientSettings({flow_id:a});u(e)}catch(e){console.error(e)}finally{d(!0)}}():d(!0)},[i,o,a]);let S=y;return(l&&Object.keys(l).length>0?S=l:i&&(S=c),g)?n.jsx(k.Provider,{value:S,children:e}):null},m=()=>s.useContext(k),_=({children:e,onError:t})=>{let s=m();return n.jsx(i.LicenseProvider,{clientSettings:s,onError:t,children:e})},E=({children:e,onError:t,type:s})=>{let i=m();return n.jsx(l.Provider,{clientSettings:i,type:s,onError:t,children:e})},D={},P=({children:e,customTexts:t=D})=>{let s=m(),{lang:i,uiSettings:l}=r.useSDKSettings(),c=a({customTexts:t,clientSettings:s,lang:i,uiSettings:l});return n.jsx(o.SDKLocaleProvider,{value:c,children:e})},L={},z=({children:e,customTheme:t=L})=>{let s=m(),{uiSettings:i,themeVersion:l}=r.useSDKSettings(),a=f({customTheme:t,clientSettings:s,themeVersion:l,uiSettings:i,defaultThemes:j});return n.jsx(c,{theme:a,children:e})},B=v.lazy(()=>import("./chunk-60817d1f.js")),w=v.lazy(()=>import("./chunk-6c73723a.js")),A=v.lazy(()=>import("./chunk-8412c433.js")),K=v.lazy(()=>import("./chunk-7421d1e1.js")),I=v.lazy(()=>import("./chunk-35f9e28b.js")),V=v.lazy(()=>import("./chunk-9ce8e4a8.js"));var T=(e=e=>{var t,i,l;let a,{logCredentials:o={enable:!1},livenessComponent:c,customTheme:v={},customTexts:f,...j}=e,{mode:k,flowId:y,onError:C,onClose:D,debug:L,onLivenessDetectionDone:T}=j,W=m(),{billingSettings:M,enableBilling:O,themeVersion:G}=r.useSDKSettings(),q=u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.billing_config"),{submitBilling:F}=g({enable:O,onError:C,billingSettings:M??{json:q??{}},billingUrl:u.getWebSetting(W,"data.settings.sdk_settings.billing_settings.url")}),H=d.buildBillingInput(e),R=p(),U="face_authen"===R?S.BillingService.faceAuth:S.BillingService.selfie,$=s.useCallback(async(...e)=>{if("face_authen"===R)return void await T(...e);try{if(!await F({service:U,input:H,output:{...d.buildBillingOutput(e?.[0]||{}),sdkStatus:S.BillingStatus.success}}))return}catch(e){console.error(e)}await T(...e)},[H,U,R,T,F]),J=s.useCallback(e=>{S.ErrorsWithoutBilling.includes(e.code)?C(e):(F({service:U,input:H,output:{error:e,sdkStatus:S.BillingStatus.fail}}),C&&C(e))},[F,U,H,C]),N=s.useCallback(()=>{F({service:U,input:H,output:{sdkStatus:S.BillingStatus.cancel}}),D&&D()},[F,U,H,D]),Q=(t=k,i=c,l=G,a=K,t===S.Mode.ACTIVE&&(a=i?.ActiveLiveness??("v1"===l?I:K)),t===S.Mode.PASSIVE_V2&&(a=i?.PassiveLivenessV2??A),t===S.Mode.PASSIVE&&(a=i?.PassiveLiveness??("v1"===l?V:w)),"string"==typeof t&&t.startsWith("flash")&&(a=i?.FlashLiveness??B),a);return n.jsx(b,{debug:L,children:n.jsx(x,{onDone:T,onError:J,onClose:N,children:n.jsx(P,{customTexts:f,children:n.jsx(E,{onError:J,type:"face_authen"===y?"face_auth":"liveness",children:n.jsx(_,{onError:C,children:n.jsx(z,{customTheme:v,children:n.jsx(h.SDKTrackingProvider,{value:{tracking:{...o}},children:n.jsx(s.Suspense,{fallback:null,children:n.jsx(Q,{...j,onLivenessDetectionDone:$})})})})})})})})})},function(t){let{apiCheck:s,apiCredentials:i,serviceSettings:l,flowId:r,clientSettings:a}=t,o=s&&(l?.enableGetClientSettings??!0);return n.jsx(C,{enableGetClientSettings:o,clientSettings:a,apiCredentials:i,flowId:r,children:n.jsx(e,{...t})})}),W=Object.freeze({__proto__:null,default:T});export{C as C,T as L,P as S,W as i,m as u};
