var ft=Object.defineProperty,ht=Object.defineProperties;var yt=Object.getOwnPropertyDescriptors;var Oe=Object.getOwnPropertySymbols;var gt=Object.prototype.hasOwnProperty,vt=Object.prototype.propertyIsEnumerable;var Me=Math.pow,He=(e,t,a)=>t in e?ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a,j=(e,t)=>{for(var a in t||(t={}))gt.call(t,a)&&He(e,a,t[a]);if(Oe)for(var a of Oe(t))vt.call(t,a)&&He(e,a,t[a]);return e},N=(e,t)=>ht(e,yt(t));var g=(e,t,a)=>new Promise((r,s)=>{var i=m=>{try{l(a.next(m))}catch(d){s(d)}},o=m=>{try{l(a.throw(m))}catch(d){s(d)}},l=m=>m.done?r(m.value):Promise.resolve(m.value).then(i,o);l((a=a.apply(e,t)).next())});import{r as c,j as n,H as z,b as ue,u as ie,c as pt,d as Ke,e as xt,f as Je,g as $e,h as bt,i as me,k as Ct,l as Xe,m as be,z as v,n as wt,o as Ye,p as fe,t as he,q as kt,F as jt,s as ye,v as qe,S as St,w as At,x as et,y as ze,Q as Et,E as $t,A as qt,B as Nt,D as Ft,G as It,I as Tt,J as Bt,K as Rt,L as Pt,M as Lt,N as Dt,O as Vt,P as Ot,U as Ht,V as Mt,W as zt,X as Gt}from"./vendor-J3KLBgF9.js";import{T as Ut,B as O,A as Wt,U as _t,a as Qt,P as Zt,D as tt,I as re,S as Kt,b as X,c as Jt,d as Xt,E as Yt,e as en,f as Ne,M as Fe,g as tn,C as nn,h as an,i as rn,j as sn,L as on,X as ln,k as cn,l as dn,m as un,n as mn,o as fn,p as hn}from"./vendor-ui-FZ_ikLaE.js";import{r as nt}from"./bank-info-ki7j66o-.js";(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&r(o)}).observe(document,{childList:!0,subtree:!0});function a(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=a(s);fetch(s.href,i)}})();class yn{constructor(t=""){this.keyPrefix=t}setItem(t,a){return g(this,null,function*(){window.localStorage.setItem(this.keyPrefix+t,a)})}getItem(t){return g(this,null,function*(){return Promise.resolve(window.localStorage.getItem(this.keyPrefix+t))})}removeItem(t){return g(this,null,function*(){window.localStorage.removeItem(this.keyPrefix+t)})}clear(){return g(this,null,function*(){window.localStorage.clear()})}}const gn=c.createContext(void 0),vn=({client:e,children:t})=>n.jsx(gn.Provider,{value:e,children:t});var G=(e=>(e.anonymousPayerUuid="anonymousPayerUuid",e.anonymousPayerAccessToken="anonymousPayerAccessToken",e.regularPayerAccessToken="regularPayerAccessToken",e))(G||{});class R extends Error{constructor(t,a=0,r={}){super(t),this.code=a,this.errors=r}isValidationError(){return this.code===z.UnprocessableEntity}isNetworkError(){return this.code===0}isUnauthorizedError(){return this.code===z.Unauthorized}isForbiddenError(){return this.code===z.Forbidden}isMethodNotAllowedError(){return this.code===z.MethodNotAllowed}isBadRequest(){return this.code===z.BadRequest}isServerError(){return this.code>=z.InternalServerError}isClientError(){return this.code>=z.BadRequest&&this.code<=z.UnavailableForLegalReasons}}function Ge(e){e?ue.defaults.headers.common.Authorization="Bearer ".concat(e):delete ue.defaults.headers.common.Authorization}function pn(e){ue.defaults.headers.common["Accept-Language"]=e}function B(e={}){var a;const t=ue.create(N(j({},e),{baseURL:"https://veryfy.ai/api/web/v1",headers:j(N(j({},ue.defaults.headers.common),{Accept:"application/json","Content-Type":"application/json"}),(a=e.headers)!=null?a:{})}));return t.interceptors.response.use(r=>{if(!r.data.success||r.data.errors&&typeof r.data.errors=="object"){const s=r.data.errors,i="message"in s&&Object.keys(s).length===1&&typeof s.message=="string"?new R(s.message):new R("ApiError occurred",0,s);return Promise.reject(i)}return Promise.resolve(r)},r=>{var l,m,d,u;const s=(m=(l=r.response)==null?void 0:l.status)!=null?m:0,i=(u=(d=r.response)==null?void 0:d.data.errors)!=null?u:{},o="message"in i&&Object.keys(i).length===1&&typeof i.message=="string"?new R(i.message,s):new R(r.message,s,i);return Promise.reject(o)}),t}function L(e,t={}){return ie(N(j({throwOnError:a=>a instanceof R?a.isServerError()||a.isNetworkError():!0},t),{mutationFn:e}))}function ee(e,t,a={}){return pt(N(j({throwOnError:r=>r instanceof R?r.isServerError()||r.isNetworkError():!0},a),{queryFn:e,queryKey:t}))}const ge="payers";var oe=(e=>(e.regular="payer",e.anonymous="anonymous_payer",e))(oe||{});const at=[ge,"me"];function xn(a){return g(this,arguments,function*(e,t={}){const r=B({signal:t.signal}),s=e?{uuid:e}:void 0;return(yield r.get("/".concat(ge,"/-/me"),{params:s})).data.data})}function bn(s,i,o){return g(this,arguments,function*(e,t,a,r={}){const l=B({signal:r.signal}),m={[t]:e,otpUuid:a};return(yield l.put("/".concat(ge,"/sign-in"),m)).data.data})}function Cn(){return g(this,arguments,function*(e={}){yield B({signal:e.signal}).put("/".concat(ge,"/-/sign-out"))})}function wn(r,s){return g(this,arguments,function*(e,t,a={}){const i=B({signal:a.signal}),o={phone:e,otpUuid:t};return(yield i.post("/".concat(ge),o)).data.data})}const rt=c.createContext(void 0),kn=({data:e,children:t})=>n.jsx(rt.Provider,{value:e,children:t});function I(){const e=c.useContext(rt);if(!e)throw new Error("GlobalData is empty, use GlobalDataContext context to set one");return e}function jn(e,t={}){return ee(a=>xn(e,{signal:a.signal}),at,t)}function Sn(e={}){const{abortController:t}=I();return L(({identity:a,identityType:r,otpUuid:s})=>bn(a,r,s,{signal:t.signal}),e)}function An(e={}){const{abortController:t}=I();return L(()=>Cn({signal:t.signal}),e)}function En(e={}){const{abortController:t}=I();return L(({phone:a,otpUuid:r})=>wn(a,r,{signal:t.signal}),e)}function $n(e,t){return Ke((a,r)=>({anonymousPayerUuid:void 0,anonymousPayerAccessToken:void 0,regularPayerAccessToken:void 0,isInitialStateLoaded:!1,isInitialPayerResolved:!1,actions:{init(){return g(this,null,function*(){if(r().isInitialStateLoaded)return;const[i,o,l]=yield Promise.all([e.getItem(G.anonymousPayerUuid),e.getItem(G.anonymousPayerAccessToken),e.getItem(G.regularPayerAccessToken)]);a(()=>({anonymousPayerUuid:o&&i!=null?i:void 0,anonymousPayerAccessToken:o!=null?o:void 0,regularPayerAccessToken:l!=null?l:void 0,isInitialStateLoaded:!0})),Ge(r().actions.getActualToken())})},getActualToken(){const{anonymousPayerAccessToken:i,regularPayerAccessToken:o}=r();return o!=null?o:i},setAnonymousPayerUuid(i){return g(this,null,function*(){a(()=>({anonymousPayerUuid:i})),yield i?e.setItem(G.anonymousPayerUuid,i):e.removeItem(G.anonymousPayerUuid)})},setPayerAccessToken(m,d){return g(this,arguments,function*(i,o,l={invalidateQuery:!0}){const u=i?G.regularPayerAccessToken:G.anonymousPayerAccessToken;yield o?e.setItem(u,o):e.removeItem(u),a(()=>({[i?"regularPayerAccessToken":"anonymousPayerAccessToken"]:o})),Ge(r().actions.getActualToken()),l.invalidateQuery&&(yield t.invalidateQueries({queryKey:at}))})},setInitialPayerAsResolved(){a(()=>({isInitialPayerResolved:!0}))}}}))}const st=c.createContext(void 0),qn=({storageClient:e,queryClient:t,children:a})=>n.jsx(st.Provider,{value:$n(e,t),children:a}),it=c.createContext(void 0),Nn=({children:e})=>{const t=c.useRef(void 0),a={showToastMessage(r){var s;(s=t.current)==null||s.show(r)},showToastMessages(r){var s;(s=t.current)==null||s.show(r)},removeToastMessage(r){var s;(s=t.current)==null||s.remove(r)},clearToastMessages(){var r;(r=t.current)==null||r.clear()}};return n.jsxs(it.Provider,{value:a,children:[n.jsx(Ut,{ref:r=>t.current=r!=null?r:void 0}),e]})};function Fn(){const e=c.useContext(it);if(!e)throw new Error("Toast is empty, use ToastContext context to set one");return e}function V(){const{showBoundary:e}=xt(),{showToastMessage:t}=Fn(),{t:a}=Je("common");return r=>{if(r instanceof R&&(r.isForbiddenError()||r.isMethodNotAllowedError())){t({severity:"warn",detail:a("error.operationNotPermitted.label"),life:5e3});return}e(r)}}function le(){const e=c.useContext(st);if(!e)throw new Error("AuthStore is empty, use AuthProvider to set one");const t=Sn(),a=En(),r=An(),s=V(),{anonymousPayerUuid:i,regularPayerAccessToken:o,isInitialStateLoaded:l,isInitialPayerResolved:m,actions:d}=$e(e);c.useEffect(()=>{d.init()},[]);const u=jn(i,{enabled:l,refetchOnMount:!1,refetchOnWindowFocus:!1,refetchOnReconnect:!1,throwOnError:!1});return c.useEffect(()=>{g(this,null,function*(){switch(u.status){case"success":const y=u.data;y.type===oe.anonymous&&(yield d.setAnonymousPayerUuid(y.uuid)),yield d.setPayerAccessToken(y.type===oe.regular,y.accessToken,{invalidateQuery:!1}),m||d.setInitialPayerAsResolved();case"error":if(!u.error)return;u.error instanceof R&&u.error.isUnauthorizedError()&&d.getActualToken()===o?(yield d.setPayerAccessToken(d.getActualToken()===o,void 0),yield u.refetch()):u.error instanceof R&&u.error.isServerError()&&i&&!d.getActualToken()?(yield d.setAnonymousPayerUuid(void 0),yield u.refetch()):s(u.error)}})},[u.status,u.data,u.error]),{anonymousPayerUuid:i,isInitialized:m,payer:u,signIn:ie({mutationFn:y=>g(this,null,function*(){const{accessToken:b}=yield t.mutateAsync(y);yield d.setPayerAccessToken(!0,b)})}),signUp:ie({mutationFn:y=>g(this,null,function*(){const{accessToken:b}=yield a.mutateAsync(y);yield d.setPayerAccessToken(!0,b)})}),signOut:ie({mutationFn:()=>g(this,null,function*(){yield r.mutateAsync(),yield d.setPayerAccessToken(!0,void 0)})})}}function H(e){var t,a;return n.jsx(O,N(j({},e),{className:"!p-0 ".concat((t=e.className)!=null?t:""),link:!0,type:(a=e.type)!=null?a:"button"}))}const ve="form-sessions";var ne=(e=>(e.phone="phone",e.email="email",e.billingAddress="billing_address",e.kyc="kyc",e))(ne||{});function In(s,i,o){return g(this,arguments,function*(e,t,a,r={}){const l=B(r),m=Object.keys(t).map(y=>y).reduce((y,b)=>t[b]===""||t[b]===null||t[b]===void 0?y:N(j({},y),{[b]:t[b]}),{}),d={initialData:e,browserData:m,useCase:a};return(yield l.post("/".concat(ve),d)).data.data})}function Tn(s,i,o){return g(this,arguments,function*(e,t,a,r={}){const l=B(r),m={paymentAccountTokenHash:t,paymentAccountHash:a};yield l.put("/".concat(ve,"/").concat(e,"/payer-account"),m)})}function Bn(a){return g(this,arguments,function*(e,t={}){const s=yield B(t).get("/".concat(ve,"/").concat(e,"/payer-detail-request")),i=Object.values(s.data.data.requestedPayerDetailGroups||{}).sort((o,l)=>l.priority-o.priority).map(o=>{const l=o.settings;if(!l)return o;const m={};for(const d of Object.keys(l)){const u=l[d];u==="true"?m[d]=!0:u==="false"?m[d]=!1:u==="null"?m[d]=null:isNaN(parseInt(u.toString(),10))?isNaN(parseFloat(u.toString()))?m[d]=u:m[d]=parseFloat(u.toString()):m[d]=parseInt(u.toString(),10)}return N(j({},o),{settings:m})});return{title:s.data.data.title,description:s.data.data.description,groups:i}})}function Rn(a){return g(this,arguments,function*(e,t={}){return(yield B(t).put("/".concat(ve,"/").concat(e,"/check-status"))).data.data.checkResult})}function Pn(r,s){return g(this,arguments,function*(e,t,a={}){const i=B(a),o={anonymousPayerUuid:t};yield i.put("/".concat(ve,"/").concat(e,"/migrate"),o)})}function Ln(e={}){const{abortController:t,useCase:a}=I();return L(({initialEncryptedData:r})=>In(r,N(j({},bt()),{referer:document.referrer,location:document.location.href}),a,{signal:t.signal}),N(j({},e),{throwOnError:!0}))}function Dn(e={}){const{abortController:t}=I();return L(({uuid:a,paymentAccountTokenHash:r,paymentAccountHash:s})=>Tn(a,r,s,{signal:t.signal}),e)}function Vn(e,t={}){return ee(a=>Bn(e,{signal:a.signal}),["formSession",e,"payerDetailsRequest"],t)}function On(e={}){const{abortController:t}=I();return L(({uuid:a})=>Rn(a,{signal:t.signal}),e)}function Hn(e={}){const{abortController:t}=I();return L(({uuid:a,anonymousPayerUuid:r})=>Pn(a,r,{signal:t.signal}),e)}var Ce=(e=>(e.payment="payment",e.payout="payout",e.data="data",e))(Ce||{});const ot=c.createContext(void 0),Mn=({children:e})=>{const t=Ke(()=>({uuid:void 0,paymentAccountTokenHash:void 0,paymentAccountHash:void 0,paymentAccountDetails:void 0}));return n.jsx(ot.Provider,{value:t,children:e})};function M(){const e=c.useContext(ot);if(!e)throw new Error("FormSessionStore is empty, use FormSessionProvider to set one");const t=$e(e,i=>i.uuid),a=$e(e,i=>i.paymentAccountDetails),r=Ln(),s=Dn();return{uuid:t,paymentAccountDetails:a,create:ie({mutationFn:i=>g(this,null,function*(){const{uuid:o}=yield r.mutateAsync(i);e.setState(()=>({uuid:o}))})}),savePaymentAccountToken:ie({mutationFn:i=>g(this,null,function*(){yield s.mutateAsync(i),e.setState(()=>({paymentAccountTokenHash:i.paymentAccountTokenHash,paymentAccountHash:i.paymentAccountHash}))})}),savePaymentAccountDetails:i=>e.setState(()=>({paymentAccountDetails:i})),reset:()=>e.setState(()=>({uuid:void 0,paymentAccountTokenHash:void 0,paymentAccountHash:void 0,paymentAccountDetails:void 0}))}}const zn={error:{operationNotPermitted:{label:"Operation not permitted"}}},Gn={common:zn},Un={error:{operationNotPermitted:{label:"Операция не разрешена"}}},Wn={common:Un};me.use(Ct).init({compatibilityJSON:"v3",fallbackLng:"en",supportedLngs:["en","ru"],cleanCode:!0,lng:"en",react:{useSuspense:!1},interpolation:{escapeValue:!1},resources:{en:Gn,ru:Wn}});function P(e,t="default"){const a=c.useRef(me.cloneInstance({forkResourceStore:!1,lng:me.language}));for(const r of Object.keys(e))a.current.addResourceBundle(r,t,e[r],!0,!0);return a.current.setDefaultNamespace(t),Je(["default","common"],{i18n:a.current})}const _n="Sign out",Qn={signOutButton:_n},Zn="Выйти",Kn={signOutButton:Zn},te="payer-accounts";var se=(e=>(e.mastercard="mastercard",e.mir="mir",e.nspkMir="nspk mir",e.visa="visa",e.unsupported="unsupported",e))(se||{});const Re=[te,"bank-cards"],Jn=e=>[te,"bank-cards","resolve-brand",e];function Xn(){var m;const{payer:e,signOut:t}=le(),{initialEncryptedData:a}=I(),{create:r}=M(),{t:s}=P({en:Qn,ru:Kn}),i=V(),o=Xe(),l=()=>g(this,null,function*(){try{yield t.mutateAsync(),yield r.mutateAsync({initialEncryptedData:a}),yield o.invalidateQueries({queryKey:Re})}catch(d){i(d)}});return n.jsxs("div",{className:"flex flex-row items-center justify-between space-x-2",children:[n.jsx("div",{className:"flex-1 truncate",children:n.jsxs("div",{className:"flex flex-row items-center space-x-2",children:[n.jsx("div",{children:n.jsx(Wt,{size:"normal",shape:"circle",icon:({iconProps:d})=>n.jsx(_t,N(j({},d),{className:"".concat(d.className," w-6 text-primary")}))})}),n.jsx("span",{className:"truncate text-primary",children:(m=e.data)==null?void 0:m.phone})]})}),n.jsx(H,{label:s("signOutButton"),icon:({iconProps:d})=>n.jsx(Qt,N(j({},d),{className:"".concat(d.className," w-5")})),loading:t.isPending,disabled:t.isPending,onClick:()=>l()})]})}function Yn(){return g(this,arguments,function*(e={}){return(yield B({signal:e.signal}).get("/".concat(te,"/bank-cards"))).data.data})}function ea(i,o,l){return g(this,arguments,function*(e,t,a,r=void 0,s={}){const m=B({signal:s.signal}),d={card:e,exp:t,cvc:a,cardholder:r};return(yield m.post("/".concat(te,"/bank-cards/tokens"),d)).data.data})}function ta(r,s){return g(this,arguments,function*(e,t,a={}){const i=B({signal:a.signal}),o={paymentAccountTokenHash:e,cvc:t};return(yield i.put("/".concat(te,"/bank-cards/tokens/-/refresh"),o)).data.data})}function na(a){return g(this,arguments,function*(e,t={}){const r=B({signal:t.signal}),s={pan:e};return(yield r.put("/".concat(te,"/bank-cards/-/resolve-brand"),s)).data.data.brand})}function aa(a){return g(this,arguments,function*(e,t={}){yield B({signal:t.signal}).delete("/".concat(te,"/").concat(e))})}function ra(e={}){return ee(t=>Yn({signal:t.signal}),Re,e)}function sa(e={}){const{abortController:t}=I();return L(({card:a,cvc:r,exp:s,cardholder:i})=>ea(a,s,r,i,{signal:t.signal}),e)}function ia(e={}){const{abortController:t}=I();return L(({paymentAccountTokenHash:a,cvc:r})=>ta(a,r,{signal:t.signal}),e)}function oa(e,t={}){return ee(a=>na(e,{signal:a.signal}),Jn(e),N(j({},t),{throwOnError:a=>!(a instanceof R)}))}function la(e={}){const{abortController:t}=I();return L(({hash:a})=>aa(a,{signal:t.signal}),e)}var Ie=(e=>(e.first="first",e.last="last",e))(Ie||{});const de={paymentAccountTokenHash:"-1",paymentAccountHash:"-1"},Ue={value:de,label:"newAccountSelectItem.label",icon:n.jsx(Zt,{}),isNewAccountSelectItem:!0},ca=e=>c.createElement("svg",j({width:69,height:20,viewBox:"0 0 69 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),c.createElement("g",{clipPath:"url(#clip0)"},c.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18.48 3.69338e-07V0.00847741C18.4715 0.00847741 15.8012 3.23373e-07 15.0891 2.55159C14.4364 4.89125 12.5969 11.3508 12.546 11.5288H12.0374C12.0374 11.5288 10.1555 4.92516 9.49429 2.54311C8.78222 -0.00847675 6.10347 3.69338e-07 6.10347 3.69338e-07H0V19.4124H6.10347V7.88365H6.35778H6.61209L10.1725 19.4124H14.411L17.9713 7.89213H18.48V19.4124H24.5834V3.69338e-07H18.48Z",fill:"#4DB45E"}),c.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M40.7741 0C40.7741 0 38.9854 0.161064 38.1462 2.03449L33.8229 11.5288H33.3143V0H27.2108V19.4124H32.9752C32.9752 19.4124 34.8486 19.2429 35.6878 17.3779L39.9264 7.88365H40.435V19.4124H46.5385V0H40.7741Z",fill:"#4DB45E"}),c.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M49.2516 8.81604V19.4123H55.355V13.2241H61.9671C64.8493 13.2241 67.2907 11.3846 68.1977 8.81604H49.2516Z",fill:"#4DB45E"}),c.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M61.9672 0H48.3954C49.0736 3.69599 51.8456 6.66296 55.4314 7.62934C56.2452 7.84974 57.1014 7.96842 57.983 7.96842H68.4437C68.5369 7.52761 68.5793 7.07833 68.5793 6.61209C68.5793 2.95849 65.6208 0 61.9672 0Z",fill:"url(#paint0_linear)"})),c.createElement("defs",null,c.createElement("linearGradient",{id:"paint0_linear",x1:48.3971,y1:3.98421,x2:68.5793,y2:3.98421,gradientUnits:"userSpaceOnUse"},c.createElement("stop",{offset:.3,stopColor:"#00B4E6"}),c.createElement("stop",{offset:1,stopColor:"#088CCB"})),c.createElement("clipPath",{id:"clip0"},c.createElement("rect",{width:68.5793,height:19.4124,fill:"white"})))),da=e=>c.createElement("svg",j({"xmlns:dc":"http://purl.org/dc/elements/1.1/","xmlns:cc":"http://creativecommons.org/ns#","xmlns:rdf":"http://www.w3.org/1999/02/22-rdf-syntax-ns#","xmlns:svg":"http://www.w3.org/2000/svg",xmlns:"http://www.w3.org/2000/svg","xmlns:sodipodi":"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd","xmlns:inkscape":"http://www.inkscape.org/namespaces/inkscape",id:"Layer_1",x:"0px",y:"0px",width:69.046,height:20.65302,viewBox:"0 0 1000.046 323.653",enableBackground:"new 0 0 258.381 161.154",xmlSpace:"preserve","inkscape:version":"0.91 r13725","sodipodi:docname":"Visa_2006.svg"},e),c.createElement("metadata",{id:"metadata23"},c.createElement("rdf:RDF",null,c.createElement("cc:Work",{"rdf:about":""},c.createElement("dc:format",null,"image/svg+xml"),c.createElement("dc:type",{"rdf:resource":"http://purl.org/dc/dcmitype/StillImage"}),c.createElement("dc:title",null)))),c.createElement("defs",{id:"defs21"}),c.createElement("sodipodi:namedview",{pagecolor:"#ffffff",bordercolor:"#666666",borderopacity:1,objecttolerance:10,gridtolerance:10,guidetolerance:10,"inkscape:pageopacity":0,"inkscape:pageshadow":2,"inkscape:window-width":1366,"inkscape:window-height":705,id:"namedview19",showgrid:"false","inkscape:zoom":.35355339,"inkscape:cx":34.690897,"inkscape:cy":131.15483,"inkscape:window-x":-8,"inkscape:window-y":-8,"inkscape:window-maximized":1,"inkscape:current-layer":"Layer_1"}),c.createElement("g",{id:"g4158",transform:"matrix(4.4299631,0,0,4.4299631,-81.165783,-105.04783)"},c.createElement("polygon",{points:"116.145,95.719 97.858,95.719 109.296,24.995 127.582,24.995 ",id:"polygon9",style:{fill:"#00579f"}}),c.createElement("path",{d:"m 182.437,26.724 c -3.607,-1.431 -9.328,-3.011 -16.402,-3.011 -18.059,0 -30.776,9.63 -30.854,23.398 -0.15,10.158 9.105,15.8 16.027,19.187 7.075,3.461 9.48,5.72 9.48,8.805 -0.072,4.738 -5.717,6.922 -10.982,6.922 -7.301,0 -11.213,-1.126 -17.158,-3.762 l -2.408,-1.13 -2.559,15.876 c 4.289,1.954 12.191,3.688 20.395,3.764 19.188,0 31.68,-9.481 31.828,-24.153 0.073,-8.051 -4.814,-14.22 -15.35,-19.261 -6.396,-3.236 -10.313,-5.418 -10.313,-8.729 0.075,-3.01 3.313,-6.093 10.533,-6.093 5.945,-0.151 10.313,1.278 13.622,2.708 l 1.654,0.751 2.487,-15.272 0,0 z",id:"path11","inkscape:connector-curvature":0,style:{fill:"#00579f"}}),c.createElement("path",{d:"m 206.742,70.664 c 1.506,-4.063 7.301,-19.788 7.301,-19.788 -0.076,0.151 1.503,-4.138 2.406,-6.771 l 1.278,6.094 c 0,0 3.463,16.929 4.215,20.465 -2.858,0 -11.588,0 -15.2,0 l 0,0 z m 22.573,-45.669 -14.145,0 c -4.362,0 -7.676,1.278 -9.558,5.868 l -27.163,64.855 19.188,0 c 0,0 3.159,-8.729 3.838,-10.609 2.105,0 20.771,0 23.479,0 0.525,2.483 2.182,10.609 2.182,10.609 l 16.932,0 -14.753,-70.723 0,0 z",id:"path13","inkscape:connector-curvature":0,style:{fill:"#00579f"}}),c.createElement("path",{d:"M 82.584,24.995 64.675,73.222 62.718,63.441 C 59.407,52.155 49.023,39.893 37.435,33.796 l 16.404,61.848 19.338,0 28.744,-70.649 -19.337,0 0,0 z",id:"path15","inkscape:connector-curvature":0,style:{fill:"#00579f"}}),c.createElement("path",{d:"m 48.045,24.995 -29.422,0 -0.301,1.429 c 22.951,5.869 38.151,20.016 44.396,37.02 L 56.322,30.94 c -1.053,-4.517 -4.289,-5.796 -8.277,-5.945 l 0,0 z",id:"path17","inkscape:connector-curvature":0,style:{fill:"#00579f"}}))),ua=e=>c.createElement("svg",j({width:33,height:20,viewBox:"0 0 33 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),c.createElement("rect",{x:11.4198,y:2.03369,width:9.34353,height:15.2538,fill:"#FC6020"}),c.createElement("path",{d:"M11.9257 9.6483C11.9257 6.5767 13.3549 3.85189 15.5724 2.08076C13.9339 0.780287 11.8641 0 9.60958 0C4.29967 0 0 4.32254 0 9.66069C0 14.9988 4.29967 19.3214 9.60958 19.3214C11.8641 19.3214 13.9339 18.5411 15.5724 17.2406C13.3549 15.4447 11.9257 12.7199 11.9257 9.6483Z",fill:"#E80B26"}),c.createElement("path",{d:"M21.9329 0C19.528 0 17.3202 0.781288 15.5724 2.08343C17.9379 3.85684 19.4623 6.58514 19.4623 9.66069C19.4623 12.7362 17.9379 15.4645 15.5724 17.2379C17.3202 18.5401 19.528 19.3214 21.9329 19.3214C27.5968 19.3214 32.1831 14.9933 32.1831 9.64829C32.1831 4.30329 27.5968 0 21.9329 0Z",fill:"#F59D31"}));function ce(e,t,a=!0){const r=t||{},s=Object.keys(e).sort();if(a){const i=Object.keys(r).sort();if(JSON.stringify(s)!==JSON.stringify(i))return!1}for(const i of s)if(e[i]!==r[i])return!1;return!0}function We(e,t){const a=[[1,3],[3,5],[5,7]],[r,s,i]=a.map(([o,l])=>parseInt(e.slice(o,l),16));return"".concat(t?"rgba":"rgb","(").concat(r,", ").concat(s,", ").concat(i).concat(t?", "+t:"",")")}function ma(e,t){return Object.keys(e).filter(s=>!t.includes(s)).reduce((s,i)=>N(j({},s),{[i]:e[i]}),{})}function Pe(e){const t=ma(e,["brand"]);switch(e.brand){case se.mir:case se.nspkMir:return n.jsx(ca,j({},t));case se.visa:return n.jsx(da,j({},t));case se.mastercard:return n.jsx(ua,j({},t))}}const fa=e=>c.createElement("svg",j({width:39,height:43,viewBox:"0 0 39 43",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),c.createElement("path",{d:"M10.2856 18.4286H4.1427V32.7619H10.2856V18.4286Z",fill:"currentColor"}),c.createElement("path",{d:"M38.9521 36.8572H0.0473633V43H38.9521V36.8572Z",fill:"currentColor"}),c.createElement("path",{d:"M22.5713 18.4286H16.4285V32.7619H22.5713V18.4286Z",fill:"currentColor"}),c.createElement("path",{d:"M19.5001 0L0.0477295 10.2381V14.3333H38.9526V10.2381L19.5001 0Z",fill:"currentColor"}),c.createElement("path",{d:"M34.857 18.4286H28.7142V32.7619H34.857V18.4286Z",fill:"currentColor"}));function ha(e){var r,s,i,o,l;const t=e.inverted?e.big?(r=e.bankInfo)==null?void 0:r.logoInvertedBig:(s=e.bankInfo)==null?void 0:s.logoInvertedSmall:e.big?(i=e.bankInfo)==null?void 0:i.logoOriginalBig:(o=e.bankInfo)==null?void 0:o.logoOriginalSmall;if(!t)return n.jsx(fa,{className:"text-secondary ".concat(e.className)});const a=c.useRef(null);return c.useEffect(()=>{a.current&&(a.current.shadowRoot||a.current.attachShadow({mode:"open"}),a.current.shadowRoot.innerHTML=t.replace("<svg ",'<svg width="100%" height="100%" '))},[t]),n.jsx("div",{className:(l=e.className)!=null?l:"",ref:m=>a.current=m})}const ya={label:"Add new account"},ga={newAccountSelectItem:ya},va={label:"Добавить новый аккаунт"},pa={newAccountSelectItem:va};function lt(e){const{t}=P({en:ga,ru:pa});return e.item?"isNewAccountSelectItem"in e.item?n.jsxs("div",{className:"flex flex-row items-center space-x-2",children:[n.jsx("div",{className:"w-5",children:e.item.icon}),n.jsx("div",{className:"text-primary truncate",children:t(e.item.label)})]}):n.jsxs("div",{className:"flex flex-row space-x-2 items-center w-full",children:[!e.hideBankLogo&&n.jsx(ha,{bankInfo:e.item.bankDetails,className:"w-5 h-5"}),n.jsx("div",{className:"text-primary",children:e.truncateCard?"**** "+e.item.label.substring(e.item.label.length-4):e.item.label}),!e.hidePaymentSystem&&n.jsx("div",{className:"!ml-auto",children:n.jsx(Pe,{brand:e.item.account.brand,className:"w-9 h-7"})})]}):""}function xa(e){var o;const t=l=>n.jsx(lt,{item:l}),a=l=>l?"isNewAccountSelectItem"in l?t(l):e.valueTemplate?e.valueTemplate(l,e):t(l):e.placeholder||"empty",r=(o=e.newAccountItemPosition)!=null?o:Ie.first,s=e.data.map(l=>{var m;return{account:l,bankDetails:l.bank?nt.get(l.bank):void 0,label:((m=l.title.match(/.{1,4}/g))!=null?m:[]).join(" "),value:{paymentAccountHash:l.paymentAccountHash,paymentAccountTokenHash:l.paymentAccountTokenHash}}}),i=r===Ie.first?[Ue,...s]:[...s,Ue];return n.jsx(tt,N(j({},e),{options:i,itemTemplate:l=>t(l),valueTemplate:l=>a(l)}))}function Le(e){var t,a;return n.jsxs("div",{className:"flex flex-col space-y-2 ".concat((t=e.containerClassName)!=null?t:""),children:[e.label&&n.jsx("label",{htmlFor:e.labelFor,className:"text-".concat(e.invalid?"error":"primary"," ").concat((a=e.labelClassName)!=null?a:""),children:e.label}),n.jsx("div",{className:"relative",children:e.children}),e.errors&&e.errors.map((r,s)=>n.jsx("div",{className:"text-error",children:r},"error-".concat(s)))]})}function D(e){var a;const t=(a=e.showError)!=null?a:!0;return n.jsx(be,{name:e.name,control:e.control,disabled:e.disabled,rules:e.rules,defaultValue:e.defaultValue,render:({field:r,fieldState:s,formState:i})=>{var o;return n.jsx(Le,{label:e.label,labelFor:r.name,labelClassName:e.labelClassName,containerClassName:e.containerClassName,invalid:s.invalid,errors:t&&((o=s.error)!=null&&o.message)?e.errorTranslateFn?[e.errorTranslateFn(s.error.message)]:[s.error.message]:void 0,children:e.render({field:r,fieldState:s,formState:i})})}})}const ba=6,Ca=v.object({card:v.string({required_error:"form.fields.card.validations.required"}).trim().min(1,"Card is required").regex(/^\d{4}\s?\d{4}\s?\d{4}\s?\d{4,7}$/,"form.fields.card.validations.invalidFormat"),exp:v.string({required_error:"form.fields.expirationDate.validations.required"}).trim().min(1,"form.fields.expirationDate.validations.required").regex(/^(0[1-9]|1[0-2])\/\d{2}$/,"form.fields.expirationDate.validations.invalidFormat"),cvc:v.string({required_error:"form.fields.cvc.validations.required"}).trim().min(1,"form.fields.cvc.validations.required").regex(/^\d{3}$/,"form.fields.cvc.validations.invalidFormat"),cardholder:v.string({required_error:"form.fields.cardHolder.validations.required"}).trim().min(1,"form.fields.cardHolder.validations.required").regex(/^((?:[a-z]+ ?){1,3})$/gi,"form.fields.cardHolder.validations.invalidFormat").toUpperCase(),brand:v.string().optional()});function W(e){const t=wt(e.imask);return n.jsx(re,N(j({},e),{ref:t.ref}))}const wa={fields:{card:{label:"Card",validations:{required:'"Card" is required',invalidFormat:'"Card" has incorrect format'}},expirationDate:{label:"Exp. Date",validations:{required:'"Exp. Date" is required',invalidFormat:'"Exp. Date" has incorrect format'}},cvc:{label:"CVC",validations:{required:'"CVC" is required',invalidFormat:'"CVC" has incorrect format'}},cardHolder:{label:"Card Holder",placeholder:"JOHN DOE",validations:{required:'"Card Holder" is required',invalidFormat:'"Card Holder" has incorrect format'}}}},ka={form:wa},ja={fields:{card:{label:"Номер карты",validations:{required:'"Номер карты" обязательное поле',invalidFormat:'"Номер карты" имеет неправильный формат'}},expirationDate:{label:"Дата окончания",validations:{required:'"Дата окончания" обязательное поле',invalidFormat:'"Дата окончания" имеет неправильный формат'}},cvc:{label:"CVC",validations:{required:'"CVC" обязательное поле',invalidFormat:'"CVC" имеет неправильный формат'}},cardHolder:{label:"Держатель карты",placeholder:"IVAN IVANOV",validations:{required:'"Держатель карты" обязательное поле',invalidFormat:'"Держатель карты" имеет неправильный формат'}}}},Sa={form:ja};function _e(e){var m,d;const{control:t,watch:a,setValue:r}=Ye(),{t:s}=P({en:ka,ru:Sa}),i=(m=e.minCardLengthForResolveBrand)!=null?m:ba,o=((d=a("".concat(e.group,".card")))!=null?d:"").substring(0,i),l=oa(o,{enabled:o.length===i});return c.useEffect(()=>{!l.isSuccess||!l.data||r("".concat(e.group,".brand"),l.data)},[l.isSuccess,l.data]),n.jsxs("div",{className:"flex flex-col space-y-4",children:[n.jsx(D,{name:"".concat(e.group,".card"),control:t,label:s("form.fields.card.label"),errorTranslateFn:s,render:({field:u,fieldState:y})=>{var b;return n.jsxs("div",{className:"p-input-icon-right w-full",children:[n.jsx(W,{id:u.name,className:"w-full ".concat(y.invalid?"p-invalid":""),value:(b=u.value)!=null?b:"",placeholder:"4200 0000 0000 0000",imask:{mask:"0000 0000 0000 0000000"},autoComplete:"cc-number",onBlur:()=>u.onBlur(),onInput:w=>u.onChange(w.currentTarget.value),onChange:w=>u.onChange(w.target.value)}),l.isFetching?n.jsx(Kt,{className:"p-icon-spin"}):l.data&&l.isSuccess&&n.jsx("div",{className:"absolute right-4 top-1/2 transform -translate-y-1/2 flex items-center space-x-4",children:n.jsx(Pe,{brand:l.data})})]})}}),n.jsxs("div",{className:"flex flex-row space-x-4",children:[n.jsx("div",{className:"flex-1",children:n.jsx(D,{name:"".concat(e.group,".exp"),label:s("form.fields.expirationDate.label"),errorTranslateFn:s,control:t,render:({field:u,fieldState:y})=>{var b;return n.jsx(W,{id:u.name,className:"w-full ".concat(y.invalid?"p-invalid":""),value:(b=u.value)!=null?b:"",placeholder:"00/00",imask:{mask:"00/00"},autoComplete:"cc-exp",onBlur:()=>u.onBlur(),onInput:w=>u.onChange(w.currentTarget.value),onChange:w=>u.onChange(w.target.value)})}})}),n.jsx("div",{className:"flex-1",children:n.jsx(D,{name:"".concat(e.group,".cvc"),label:s("form.fields.cvc.label"),errorTranslateFn:s,control:t,render:({field:u,fieldState:y})=>{var b;return n.jsx(W,{id:u.name,className:"w-full ".concat(y.invalid?"p-invalid":""),value:(b=u.value)!=null?b:"",type:"password",placeholder:"000",imask:{mask:"000"},autoComplete:"cc-csc",onBlur:()=>u.onBlur(),onInput:w=>u.onChange(w.currentTarget.value),onChange:w=>u.onChange(w.target.value)})}})})]}),n.jsx(D,{name:"".concat(e.group,".cardholder"),label:s("form.fields.cardHolder.label"),errorTranslateFn:s,control:t,render:({field:u,fieldState:y})=>{var b;return n.jsx(W,{id:u.name,className:"w-full ".concat(y.invalid?"p-invalid":""),value:(b=u.value)!=null?b:"",style:{textTransform:"uppercase"},placeholder:s("form.fields.cardHolder.placeholder"),imask:{mask:/[a-z ]/ig},autoComplete:"cc-name",onBlur:()=>u.onBlur(),onInput:w=>u.onChange(w.currentTarget.value),onChange:w=>u.onChange(w.target.value.trimStart())})}})]})}const Aa={fields:{cvc:{label:"CVC",validations:{required:'"CVC" is required',invalidFormat:'"CVC" has incorrect format'}}}},Ea={form:Aa},$a={fields:{cvc:{label:"CVC",validations:{required:'"CVC" обязательное поле',invalidFormat:'"CVC" имеет неправильный формат'}}}},qa={form:$a};function Na(e){const{control:t}=Ye(),{t:a}=P({en:Ea,ru:qa});return n.jsx("div",{className:"flex flex-col",children:n.jsx(D,{name:"".concat(e.group,".cvc"),label:a("form.fields.cvc.label"),errorTranslateFn:a,labelClassName:"!text-xs",containerClassName:"!space-y-0",control:t,showError:!1,render:({field:r})=>{var s;return n.jsx(W,{id:r.name,className:"!text-sm !w-8 !border-0 !p-0 !shadow-none",value:(s=r.value)!=null?s:"",type:"password",placeholder:"000",autoComplete:"cc-csc",imask:{mask:"000"},autoFocus:!0,onBlur:()=>r.onBlur(),onInput:i=>r.onChange(i.currentTarget.value),onChange:i=>r.onChange(i.target.value)})}})})}const Ae=v.object({paymentAccountHash:v.string(),paymentAccountTokenHash:v.string()},{required_error:"form.fields.selectedAccount.validations.required"}).required(),Fa=v.object({cvc:v.string({required_error:"form.fields.cvc.validations.required"}).trim().min(1,"form.fields.cvc.validations.required").regex(/^\d{3}$/,"form.fields.cvc.validations.invalidFormat")});function Ia(){const e=fe({defaultValues:{selectedAccount:void 0,data:void 0},resolver:(t,a,r)=>{let s;return t.selectedAccount?ce(de,t.selectedAccount)?s=v.object({selectedAccount:Ae,data:Ca}):s=v.object({selectedAccount:Ae,data:Fa}):s=v.object({selectedAccount:Ae}),he(s)(t,a,r)}});return c.useEffect(()=>{const t=e.watch((a,{name:r})=>{var s;if(r==="selectedAccount")for(const i of Object.keys((s=e.getValues("data"))!=null?s:{}))e.resetField("data.".concat(i),{keepError:!1,keepTouched:!1})});return()=>t.unsubscribe()},[e.watch]),{formMethods:e}}function Ta(e){const[t,a]=c.useState(0);return c.useEffect(()=>{const r=e;a(r.clientWidth);const s=new kt(i=>{if(i.length<=0)return;const o=i[0].contentRect.width;t!==o&&a(o)});return s.observe(r),()=>{s.unobserve(r),s.disconnect()}},[]),t}const Ba={title:"Removing payment account",message:"Are you sure want to remove bank card",buttons:{accept:{label:"Yes"},reject:{label:"No"}}},Ra={fields:{selectedAccount:{validations:{required:"Select one of available payment accounts"}},cvc:{label:"CVC",validations:{required:'"CVC" is required',invalidFormat:'"CVC" has incorrect format'}}},buttons:{submitOnCreation:{label:"Pay"},submitOnSelect:{label:"Pay"}}},Pa={removeConfirmationDialog:Ba,form:Ra},La={title:"Удаление платежного аккаунта",message:"Вы действительно хотите удалить банковскую карту",buttons:{accept:{label:"Да"},reject:{label:"Нет"}}},Da={fields:{selectedAccount:{validations:{required:"Выберите один из доступных платежных аккаунтов"}},cvc:{label:"CVC",validations:{required:'"CVC" обязательное поле',invalidFormat:'"CVC" имеет неправильный формат'}}},buttons:{submitOnCreation:{label:"Оплатить"},submitOnSelect:{label:"Оплатить"}}},Va={removeConfirmationDialog:La,form:Da};function Oa(e){var f;const{uuid:t,savePaymentAccountToken:a,savePaymentAccountDetails:r}=M(),{formMethods:s}=Ia(),i=ra(),o=sa(),l=ia(),m=la(),{t:d}=P({en:Pa,ru:Va}),u=V(),{containerElement:y}=I(),b=Ta(y),w=s.watch("selectedAccount");c.useEffect(()=>{i.isSuccess&&(e.onReady(),s.setValue("selectedAccount",i.data.length>0?{paymentAccountHash:i.data[0].paymentAccountHash,paymentAccountTokenHash:i.data[0].paymentAccountTokenHash}:j({},de)))},[i.isSuccess,i.data]);const S=ce(de,w),q=!!((f=i.data)!=null&&f.length),$=C=>g(this,null,function*(){var k,h;try{let x,p,A;if(ce(de,C.selectedAccount)){const{card:E,exp:_,cvc:pe,cardholder:Q,brand:je}=C.data;try{p=(yield o.mutateAsync({card:E,exp:_,cvc:pe,cardholder:Q})).paymentAccountTokenHash}catch(Z){if(Z instanceof R&&Z.isValidationError()){for(const Se of Object.keys(Z.errors))s.setError("data.".concat(Se),{type:"custom",message:((k=Z.errors[Se])==null?void 0:k[0])||"form.fields.".concat(Se,".validations.invalidFormat")});return}throw Z}A={card:E.substring(0,6)+"******"+E.substring(E.length-4),bankDetails:void 0,brand:je}}else{const E=C.selectedAccount.paymentAccountTokenHash,{cvc:_}=C.data,pe=yield l.mutateAsync({paymentAccountTokenHash:E,cvc:_});x=pe.paymentAccountHash,p=pe.paymentAccountTokenHash;const Q=(h=i.data)==null?void 0:h.find(({paymentAccountHash:je,paymentAccountTokenHash:Z})=>ce(C.selectedAccount,{paymentAccountHash:je,paymentAccountTokenHash:Z}));Q&&(A={card:Q.title,brand:Q.brand,bankDetails:Q.bank?nt.get(Q.bank):void 0})}yield a.mutateAsync({uuid:t,paymentAccountHash:x,paymentAccountTokenHash:p}),r(A),e.onSuccess()}catch(x){u(x)}}),T=()=>g(this,null,function*(){var k;if(!w)return;const C=(k=i.data)==null?void 0:k.find(({paymentAccountHash:h,paymentAccountTokenHash:x})=>ce(w,{paymentAccountHash:h,paymentAccountTokenHash:x}));C&&Xt({header:d("removeConfirmationDialog.title"),message:n.jsxs("div",{children:[d("removeConfirmationDialog.message")," ",n.jsx("b",{children:C.title}),"?"]}),icon:n.jsx(Yt,{className:"w-5 h-5"}),acceptLabel:d("removeConfirmationDialog.buttons.accept.label"),rejectLabel:d("removeConfirmationDialog.buttons.reject.label"),accept:()=>g(this,null,function*(){try{yield m.mutateAsync({hash:C.paymentAccountHash}),s.reset(),yield i.refetch()}catch(h){u(h)}})})});return n.jsxs("form",{className:"flex flex-col space-y-4",onSubmit:s.handleSubmit($),children:[i.isPending&&n.jsx("div",{className:"flex justify-center items-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})}),i.isSuccess&&n.jsx(jt,N(j({},s),{children:q?n.jsxs(n.Fragment,{children:[n.jsx(be,{name:"selectedAccount",control:s.control,render:({field:C,fieldState:k,formState:h})=>{var x,p,A;return n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsxs("div",{className:"flex flex-row space-x-2 items-center",children:[n.jsx(xa,{id:C.name,value:C.value,data:i.data,className:"w-full ".concat(k.invalid?"p-invalid":""),pt:{input:{style:{padding:"0.75rem 0 0.75rem 0.75rem"}}},valueTemplate:E=>n.jsxs("div",{className:"flex flex-row space-x-2 items-center",children:[n.jsx(lt,{item:E,truncateCard:b<=380,hideBankLogo:b<=300,hidePaymentSystem:b<=270}),n.jsx("span",{className:"text-secondary",children:"|"}),n.jsx(Na,{group:"data"})]}),onBlur:()=>C.onBlur(),onChange:E=>C.onChange(E.value)}),!S&&C.value&&n.jsx(O,{text:!0,type:"button",severity:"danger",className:"min-w-8",icon:({iconProps:E})=>n.jsx(Jt,N(j({},E),{className:"".concat(E.className," w-5")})),loading:m.isPending,disabled:m.isPending,onClick:()=>T()})]}),((x=k.error)==null?void 0:x.message)&&n.jsx("div",{className:"text-error",children:d(k.error.message)}),!S&&((A=(p=h.errors.data)==null?void 0:p.cvc)==null?void 0:A.message)&&n.jsx("div",{className:"text-error",children:d(h.errors.data.cvc.message)})]})}}),S&&n.jsx(_e,{group:"data"})]}):n.jsx(_e,{group:"data"})})),n.jsx(O,{type:"submit",disabled:i.isPending||m.isPending||s.formState.isSubmitting,loading:s.formState.isSubmitting,label:d("form.buttons.".concat(S||!q?"submitOnCreation":"submitOnSelect",".label"))})]})}const Ha="veryfy_checkout_";var we=(e=>(e[e.bankCard=1]="bankCard",e[e.qiwi=2]="qiwi",e[e.ruIndividualBank=3]="ruIndividualBank",e[e.usdt=4]="usdt",e[e.yooMoney=5]="yooMoney",e[e.webMoney=6]="webMoney",e[e.googlePay=7]="googlePay",e[e.applePay=8]="applePay",e[e.trx=10]="trx",e[e.eth=11]="eth",e[e.iban=15]="iban",e[e.bankCardP2p=16]="bankCardP2p",e[e.gameItems=17]="gameItems",e[e.sbp=40]="sbp",e[e.cardTransfer=50]="cardTransfer",e))(we||{}),Te=(e=>(e.cardlink="cardlink",e.centapp="centapp",e.defaultDark="default-dark",e.defaultLight="default-light",e.itpay="itpay",e.paypalych="paypalych",e.paysteam="paysteam",e))(Te||{});const Ee={theme:"default-light",language:window.navigator.language,useCase:Ce.payment},Ma=v.object({containerElement:v.instanceof(HTMLElement,{message:"'containerElement' element argument is required and should be instance of HTMLElement"}),initialEncryptedData:v.string({required_error:"'initialEncryptedData' element argument is required."}).trim().min(1,"'initialEncryptedData' element argument is required and cannot be empty."),paymentMethod:v.nativeEnum(we).or(v.literal(void 0)).optional(),useCase:v.nativeEnum(Ce),language:v.string({required_error:"'language' element is required and cannot be empty"}).trim().min(1,"'language' element is required and cannot be empty").optional(),theme:v.nativeEnum(Te,{invalid_type_error:"'theme' element argument has unallowed value. Allowed values are ".concat(Object.values(Te).join(", "),"."),required_error:"'theme' element argument is required."}),onStepReady:v.function().args(v.string()).or(v.literal(void 0)),onFinalize:v.function().args(v.string()),onReset:v.function(),onError:v.function().or(v.literal(void 0))}).required(),za="Select Payment Account",Ga={label:"Sign In / Sign Up"},Ua={title:za,signInButton:Ga},Wa="Выберите платежный аккаунт",_a={label:"Войти / Зарегистрироваться"},Qa={title:Wa,signInButton:_a};function Za(){var i,o;const e=ye(),{paymentMethod:t,onStepReady:a}=I(),{payer:r}=le(),{t:s}=P({en:Ua,ru:Qa});return t||e("/steps/fill-details"),n.jsxs("div",{className:"flex flex-col space-y-4",children:[((i=r.data)==null?void 0:i.type)!==oe.regular&&n.jsx("div",{children:n.jsx(H,{label:s("signInButton.label"),onClick:()=>e("/sign-in")})}),((o=r.data)==null?void 0:o.type)===oe.regular&&n.jsx(Xn,{}),n.jsx("div",{className:"text-primary font-semibold",children:s("title")}),we.bankCard===t&&n.jsx(Oa,{onSuccess:()=>e("/steps/fill-details"),onReady:()=>a==null?void 0:a(ke.selectPaymentAccount)})]})}const De="otp-codes";var xe=(e=>(e.process="process",e.success="success",e.fail="fail",e))(xe||{}),Y=(e=>(e.phone="phone",e.email="email",e))(Y||{});function Ka(r,s){return g(this,arguments,function*(e,t,a={}){const i=B({signal:a.signal}),o={[t]:e};return(yield i.post("/".concat(De),o)).data.data})}function Ja(a){return g(this,arguments,function*(e,t={}){return(yield B({signal:t.signal}).get("/".concat(De,"/").concat(e,"/delivery-status"))).data.data.status})}function Xa(r,s){return g(this,arguments,function*(e,t,a={}){const i=B({signal:a.signal}),o={code:t};return(yield i.put("/".concat(De,"/").concat(e,"/check"),o)).data.data.ok})}function Qe(e={}){const{abortController:t}=I();return L(a=>Ka(a.identity,a.identityType,{signal:t.signal}),e)}function Ya(e={}){const{abortController:t}=I();return L(({uuid:a,code:r})=>Xa(a,r,{signal:t.signal}),e)}function er(e,t){return ee(a=>Ja(e,{signal:a.signal}),["otpCodes",e,"deliveryStatus"],t)}const tr={identity:""};var K=(e=>(e.identity="identity",e.otp="otp",e))(K||{});const Ve="payer-details";var ae=(e=>(e.ignored="ignored",e.green="green",e.yellow="yellow",e.red="red",e.error="error",e.unknown="",e))(ae||{});function nr(i,o,l,m){return g(this,arguments,function*(e,t,a,r,s={}){const d=B(s),u={formSessionUuid:e,groupId:t,key:a,value:r};yield d.post("/".concat(Ve),u)})}function ar(a){return g(this,arguments,function*(e,t={}){return(yield B(t).get("".concat(Ve,"/sumsub/kyc-token/").concat(e))).data.data.token})}function rr(a){return g(this,arguments,function*(e,t={}){return(yield B(t).put("".concat(Ve,"/sumsub/check-status/").concat(e))).data.data.reviewAnswer.toLowerCase()})}function ct(e={}){const{abortController:t}=I();return L(({formSessionUuid:a,groupId:r,key:s,value:i})=>nr(a,r,s,i,{signal:t.signal}),e)}function sr(e,t={}){return ee(a=>ar(e,{signal:a.signal}),["payerDetailsSumsubAccessToken"],t)}function ir(e,t={}){return ee(a=>rr(e,{signal:a.signal}),["payerDetailsSumsubStatus"],t)}function or(e){const t=c.useRef([]),[a,r]=c.useState(Array(e.length).fill("")),s=m=>{var b,w;const d=m.clipboardData.getData("Text").slice(0,e.length).split(""),u=e.length-d.length;u>0&&d.push(...Array(u).fill(""));let y=d.findIndex(S=>S==="");y<0&&(y=e.length-1),(b=t.current[y])==null||b.focus(),(w=t.current[y])==null||w.select(),r(d.map(S=>S.trim()).map(S=>{var q,$;return($=(q=S.match(e.allowedCellChars))==null?void 0:q[0])!=null?$:""}))},i=(m,d)=>{var b,w,S,q;const u=(w=(b=m.target.value.charAt(0).match(e.allowedCellChars))==null?void 0:b[0])!=null?w:"";u!==""&&d+1<e.length&&((S=t.current[d+1])==null||S.focus(),(q=t.current[d+1])==null||q.select());const y=a.map(($,T)=>T===d?u:$);r(y),e.onChange&&e.onChange({value:y.join("")})},o=(m,d)=>{var u,y;m.key.toLowerCase()==="backspace"&&d-1>=0&&((u=t.current[d-1])==null||u.focus(),(y=t.current[d-1])==null||y.select())},l=m=>{e.onBlur&&e.onBlur()};return n.jsx("div",{className:"flex flex-row space-x-2 sm:space-x-4",children:a.map((m,d)=>{var u;return n.jsx(re,{ref:y=>t.current.push(y),autoComplete:d===0?"one-time-code":"off",autoFocus:d===0&&e.autoFocus?!0:void 0,maxLength:1,placeholder:e.placeholder,disabled:e.disabled,value:m,className:"w-8 flex-1 text-center ".concat((u=e.className)!=null?u:""),onPaste:y=>s(y),onChange:y=>i(y,d),onKeyUp:y=>o(y,d),onBlur:y=>l()},"otp-input-".concat(d))})})}function lr(e){const[t,a]=c.useState(e.seconds);c.useEffect(()=>{if(t===0){e.onTimedOut();return}const i=setTimeout(()=>a(t-1),1e3);return()=>clearTimeout(i)},[t]);const r=Math.floor(t/60),s=t%60;return n.jsxs("div",{className:e.className,children:[r.toString().padStart(2,"0"),":",s.toString().padStart(2,"0")]})}const cr={code:""},dr=6,ur=/\d/,mr=v.object({code:v.string({required_error:"form.fields.confirmationCode.validations.required"}).trim().min(1,"form.fields.confirmationCode.validations.required").regex(/\d{6}/,"form.fields.confirmationCode.validations.invalidFormat")}).required(),fr=15e3,hr="We've sent confirmation code to",yr={types:{email:"email",phone:"phone"},button:{label:"Change {{identityType}}"}},gr={timerText:{begin:"Didn't receive any code? You can send new code in",end:"seconds."},button:{label:"Resend"}},vr={fields:{confirmationCode:{label:"Confirmation code",validations:{required:'"Confirmation code" is required',invalidFormat:'"Confirmation code" has incorrect format, allowed only digits'}}},buttons:{submit:{label:"Submit"}}},pr={info:"Delivering of verification code may take up to 3 minutes",fail:"Cannot to delivery code on your specified method, please try another one"},xr={title:hr,changeIdentity:yr,resend:gr,form:vr,delivery:pr},br="Код подтверждения был отправлен на",Cr={types:{email:"эл.почту",phone:"телефон"},button:{label:"Сменить {{identityType}}"}},wr={timerText:{begin:"Не получали никакого кода? Вы можете отправить новый код через",end:"секунд."},button:{label:"Переотправить"}},kr={fields:{confirmationCode:{label:"Код подтверждения",validations:{required:'"Код подтверждения" обязательное поле',invalidFormat:'"Код подтверждения" имеет некорректный формат, разрешены только цифры'}}},buttons:{submit:{label:"Отправить"}}},jr={info:"Доставка кода подтверждения может занимать до 3-х минут",fail:"Невозможно доставить код на указанный метод, пожалуйста укажите другой"},Sr={title:br,changeIdentity:Cr,resend:wr,form:kr,delivery:jr};function dt(e){var h;const{t}=P({en:xr,ru:Sr}),[a,r]=c.useState(void 0),[s,i]=c.useState(0),[o,l]=c.useState(!1),m=(h=e.waitingTimeOnResendCodeByAttempt[s])!=null?h:e.maxWaitingTimeOnResendCode,{control:d,handleSubmit:u,formState:y,setError:b}=fe({defaultValues:cr,resolver:he(mr),mode:e.useAutoSubmit?"onChange":"onSubmit"}),w=Qe(),S=Qe(),q=Ya(),$=er(a!=null?a:"",{enabled:!!a,refetchInterval:x=>!x.state.data||x.state.data===xe.process?fr:void 0}),T=V();c.useEffect(()=>{g(this,null,function*(){try{const{uuid:x}=yield w.mutateAsync({identity:e.identity,identityType:e.identityType});r(x)}catch(x){e.onSendingConfirmationError(x)}})},[]);const f=()=>l(!0),C=()=>g(this,null,function*(){try{const{uuid:x}=yield S.mutateAsync({identity:e.identity,identityType:e.identityType});r(x);const p=s+1;i(p),l(!1)}catch(x){T(x)}}),k=x=>g(this,null,function*(){var p,A;try{return(yield q.mutateAsync({code:x.code,uuid:a}))?yield e.onConfirmed(a,e.identityType,e.identity):b("code",{message:"Incorrect code"})}catch(E){if(E instanceof R&&(E.isValidationError()||E.isBadRequest())){b("code",{type:"custom",message:((A=(p=E.errors)==null?void 0:p.code)==null?void 0:A[0])||E.message});return}T(E)}});return n.jsxs(n.Fragment,{children:[w.isPending&&n.jsx("div",{className:"flex justify-center items-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})}),w.isSuccess&&n.jsxs("form",{className:"flex flex-col space-y-4",onChange:e.useAutoSubmit?u(k):void 0,onSubmit:u(k),children:[n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsxs("span",{className:"text-primary",children:[t("title")," ",n.jsx("b",{children:e.identity})]}),e.canChangeIdentity&&e.onChangeIdentity&&n.jsx("div",{children:n.jsx(H,{label:t("changeIdentity.button.label",{identityType:t("changeIdentity.types.".concat(e.identityType))}),icon:({iconProps:x})=>n.jsx(en,N(j({},x),{className:"".concat(x.className," w-5")})),onClick:()=>e.onChangeIdentity()})})]}),$.data!==xe.fail&&n.jsxs(n.Fragment,{children:[n.jsx(be,{name:"code",control:d,render:({field:x,fieldState:p})=>{var A;return n.jsxs("div",{className:"flex flex-col space-y-2",children:[n.jsx(Le,{label:t("form.fields.confirmationCode.label"),labelFor:x.name,invalid:p.invalid,errors:(A=p.error)!=null&&A.message?[t(p.error.message)]:void 0,children:n.jsx(or,{autoFocus:!0,length:dr,className:p.invalid?"p-invalid":"",allowedCellChars:ur,disabled:x.disabled,onChange:E=>x.onChange(E.value),onBlur:()=>x.onBlur()})}),o&&n.jsx("div",{children:n.jsx(H,{label:t("resend.button.label"),icon:({iconProps:E})=>n.jsx(Ne,N(j({},E),{className:"".concat(E.className," w-5")})),loading:S.isPending,disabled:S.isPending,onClick:()=>C()})}),!o&&m&&n.jsxs("div",{className:"text-primary",children:[t("resend.timerText.begin"),n.jsx(lr,{className:"inline font-bold mx-1",seconds:m,onTimedOut:()=>f()}),t("resend.timerText.end")]})]})}}),n.jsx(Fe,{severity:"info",text:t("delivery.info")}),n.jsx(O,{label:t("form.buttons.submit.label"),type:"submit",loading:y.isSubmitting,disabled:y.isSubmitting})]}),$.data===xe.fail&&n.jsx(Fe,{severity:"error",text:t("delivery.fail")})]})]})}function ut(e){const[t,a]=c.useState(K.identity),r=V(),{uuid:s}=M(),{handleSubmit:i,control:o,getValues:l,setError:m,formState:{isSubmitting:d}}=fe({defaultValues:tr,resolver:e.formValidation?he(e.formValidation):void 0}),u=ct(),y=()=>{e.onSuccess(l())},b=()=>g(this,null,function*(){if(e.confirmable&&l().identity.length>0){a(K.otp);return}yield S()}),w=()=>a(K.identity),S=$=>g(this,null,function*(){const T=N(j({},l()),{otpUuid:$});try{T.identity&&(yield u.mutateAsync({formSessionUuid:s,groupId:e.requestGroupId,key:e.identityType,value:T.identity})),e.onSuccess(T)}catch(f){r(f)}}),q=$=>{if(a(K.identity),$ instanceof R&&$.isValidationError()){m("identity",{message:"form.fields.identity.validations.invalidFormat"});return}r($)};return n.jsxs(n.Fragment,{children:[t===K.identity&&n.jsxs("form",{className:"flex-col space-y-4 flex",onSubmit:i(b),children:[n.jsx(D,{name:"identity",errorTranslateFn:e.translateFn,render:e.render,control:o}),n.jsx(O,{type:"submit",label:e.translateFn("form.buttons.submit.label"),loading:d,disabled:d}),e.optional&&n.jsx(H,{label:e.translateFn("form.buttons.skip.label"),onClick:()=>y()})]}),t===K.otp&&n.jsx(dt,{identityType:e.identityType,identity:l().identity,onChangeIdentity:()=>w(),onConfirmed:$=>S($),onSendingConfirmationError:$=>q($),canChangeIdentity:!0,useAutoSubmit:!0,waitingTimeOnResendCodeByAttempt:[60,120,300],maxWaitingTimeOnResendCode:3600})]})}const Ar={fields:{email:{label:"Email",placeholder:"johndoe@mail.com",validations:{required:'"Email" is required',invalidFormat:'"Email" has incorrect format'}}},buttons:{submit:{label:"Submit"},skip:{label:"Skip"}}},Er={form:Ar},$r={fields:{email:{label:"Эл. почта",placeholder:"ivanivanov@mail.ru",validations:{required:'"Эл. почта" обязательное поле',invalidFormat:'"Эл. почта" имеет неправильный формат'}}},buttons:{submit:{label:"Отправить"},skip:{label:"Пропустить"}}},qr={form:$r};function Nr(e){var r,s,i;const{t}=P({en:Er,ru:qr}),a=v.object({identity:(r=e.requestGroupSettings)!=null&&r.required?v.string({required_error:"form.fields.email.validations.required"}).min(1,"form.fields.email.validations.required").email({message:"form.fields.email.validations.invalidFormat"}).trim():v.string({required_error:"form.fields.email.validations.required"}).email({message:"form.fields.email.validations.invalidFormat"}).trim().optional().or(v.literal(""))}).required();return n.jsx(ut,{identityType:Y.email,translateFn:t,onSuccess:({identity:o,otpUuid:l})=>e.onSuccess({email:o,otpUuid:l}),requestGroupId:e.requestGroupId,formValidation:a,confirmable:!!((s=e.requestGroupSettings)!=null&&s.confirmable),optional:!((i=e.requestGroupSettings)!=null&&i.required),render:({field:o,fieldState:l})=>n.jsx(W,{id:o.name,className:"w-full ".concat(l.invalid?"p-invalid":""),autoFocus:!0,value:o.value,imask:{mask:function(m){return!!(/^[a-z0-9_\.-]+$/.test(m)||/^[a-z0-9_\.-]+@$/.test(m)||/^[a-z0-9_\.-]+@[a-z0-9-]+$/.test(m)||/^[a-z0-9_\.-]+@[a-z0-9-]+\.$/.test(m)||/^[a-z0-9_\.-]+@[a-z0-9-]+\.[a-z]{1,4}$/.test(m)||/^[a-z0-9_\.-]+@[a-z0-9-]+\.[a-z]{1,4}\.$/.test(m)||/^[a-z0-9_\.-]+@[a-z0-9-]+\.[a-z]{1,4}\.[a-z]{1,4}$/.test(m))}},autoComplete:"email",placeholder:t("form.fields.email.placeholder"),onInput:m=>o.onChange(m.currentTarget.value),onChange:m=>o.onChange(m.target.value)})})}const Fr={fields:{phone:{label:"Phone",validations:{required:'"Phone" is required',invalidFormat:'"Phone" has incorrect format'}}},buttons:{submit:{label:"Submit"},skip:{label:"Skip"}}},Ir={form:Fr},Tr={fields:{phone:{label:"Телефон",validations:{required:'"Телефон" обязательное поле',invalidFormat:'"Телефон" имеет неправильный формат'}}},buttons:{submit:{label:"Отправить"},skip:{label:"Пропустить"}}},Br={form:Tr};function Rr(e){var r,s,i;const{t}=P({en:Ir,ru:Br}),a=v.object({identity:(r=e.requestGroupSettings)!=null&&r.required?v.string({required_error:"form.fields.phone.validations.required"}).min(1,"form.fields.phone.validations.required").regex(/\d{11,17}/i,"form.fields.phone.validations.invalidFormat").trim():v.string({required_error:"form.fields.phone.validations.required"}).regex(/\d{11,17}/i,"form.fields.phone.validations.invalidFormat").trim().optional().or(v.literal(""))}).required();return n.jsx(ut,{identityType:Y.phone,translateFn:t,onSuccess:({identity:o,otpUuid:l})=>e.onSuccess({phone:o,otpUuid:l}),requestGroupId:e.requestGroupId,formValidation:a,confirmable:!!((s=e.requestGroupSettings)!=null&&s.confirmable),optional:!((i=e.requestGroupSettings)!=null&&i.required),render:({field:o,fieldState:l})=>n.jsx(W,{id:o.name,className:"w-full ".concat(l.invalid?"p-invalid":""),autoFocus:!0,value:o.value,placeholder:"+79001112233",imask:{mask:"+000000000000000"},autoComplete:"tel",onInput:m=>o.onChange(m.currentTarget.value),onChange:m=>o.onChange(m.target.value)})})}const Pr={address:"",state:"",city:"",country:"",postalCode:""},Lr={fields:{address:{label:"Address",helpText:"Street number (building/house), street name, and any relevant apartment or unit number",validations:{required:'"Address" is required'}},city:{label:"City",validations:{required:'"City" is required'}},state:{label:"State / Province",validations:{required:'"State" is required'}},country:{label:"Country",placeholder:"",validations:{required:'"Country" is required'}},postalCode:{label:"Postal code",validations:{required:'"Postal code" is required'}}},buttons:{submit:{label:"Submit"},skip:{label:"Skip"}}},Dr={form:Lr},Vr={fields:{address:{label:"Адрес",helpText:"Название улицы, номер улицы (строение / дом), номер квартиры",validations:{required:'"Адрес" обязательное поле'}},city:{label:"Город",validations:{required:'"Город" обязательное поле'}},state:{label:"Область",validations:{required:'"Область" обязательное поле'}},country:{label:"Страна",placeholder:"",validations:{required:'"Страна" обязательное поле'}},postalCode:{label:"Индекс",validations:{required:'"Индекс" обязательное поле'}}},buttons:{submit:{label:"Отправить"},skip:{label:"Пропустить"}}},Or={form:Vr};function Hr(e){var q,$,T,f,C,k;const{t,i18n:a}=P({en:Dr,ru:Or}),r=V(),{uuid:s}=M(),[i,o]=c.useState([]);c.useEffect(()=>{const h=Object.entries(qe.getNames(a.language)).map(([x,p])=>{const A=x.toUpperCase().split("").map(_=>127397+_.charCodeAt(0));return{label:String.fromCodePoint(...A)+" "+p,value:p}});o(h)},[]);const l=v.object({address:(q=e.requestGroupSettings)!=null&&q.required?v.string({required_error:"form.fields.address.validations.required"}).trim().min(1,"form.fields.address.validations.required"):v.string({required_error:"form.fields.address.validations.required"}).trim().optional().or(v.literal("")),city:($=e.requestGroupSettings)!=null&&$.required?v.string({required_error:"form.fields.city.validations.required"}).trim().min(1,"form.fields.city.validations.required"):v.string({required_error:"form.fields.city.validations.required"}).trim().optional().or(v.literal("")),state:(T=e.requestGroupSettings)!=null&&T.required?v.string({required_error:"form.fields.state.validations.required"}).trim().min(1,"form.fields.state.validations.required"):v.string({required_error:"form.fields.state.validations.required"}).trim().optional().or(v.literal("")),country:(f=e.requestGroupSettings)!=null&&f.required?v.string({required_error:"form.fields.country.validations.required"}).trim().min(1,"form.fields.country.validations.required"):v.string({required_error:"form.fields.country.validations.required"}).trim().optional().or(v.literal("")),postalCode:(C=e.requestGroupSettings)!=null&&C.required?v.string({required_error:"form.fields.postalCode.validations.required"}).trim().min(1,"form.fields.postalCode.validations.required"):v.string({required_error:"form.fields.postalCode.validations.required"}).trim().optional().or(v.literal(""))}).required(),{handleSubmit:m,control:d,getValues:u,formState:{isSubmitting:y}}=fe({defaultValues:Pr,resolver:he(l)}),b=ct(),w=()=>{e.onSuccess(u())},S=()=>g(this,null,function*(){const h=u();try{yield Promise.all(Object.entries(h).filter(([x,p])=>!!p).map(([x,p])=>b.mutateAsync({formSessionUuid:s,key:x,value:p,groupId:e.requestGroupId}))),e.onSuccess(h)}catch(x){r(x)}});return n.jsxs("form",{className:"flex-col space-y-4 flex",onSubmit:m(S),children:[n.jsx(D,{name:"address",label:t("form.fields.address.label"),errorTranslateFn:t,control:d,render:({field:h,fieldState:x})=>n.jsxs(n.Fragment,{children:[n.jsx(re,{id:h.name,className:"w-full ".concat(x.invalid?"p-invalid":""),value:h.value,autoFocus:!0,type:"text",maxLength:1024,"aria-describedby":"".concat(h.name,"-help"),onBlur:()=>h.onBlur(),onChange:p=>h.onChange(p.target.value)}),n.jsx("small",{id:"".concat(h.name,"-help"),className:"text-secondary",children:t("form.fields.address.helpText")})]})}),n.jsx(D,{name:"city",label:t("form.fields.city.label"),errorTranslateFn:t,control:d,render:({field:h,fieldState:x})=>n.jsx(re,{id:h.name,className:"w-full ".concat(x.invalid?"p-invalid":""),value:h.value,type:"text",maxLength:255,onBlur:()=>h.onBlur(),onChange:p=>h.onChange(p.target.value)})}),n.jsx(D,{name:"state",label:t("form.fields.state.label"),errorTranslateFn:t,control:d,render:({field:h,fieldState:x})=>n.jsx(re,{id:h.name,className:"w-full ".concat(x.invalid?"p-invalid":""),value:h.value,type:"text",maxLength:255,onBlur:()=>h.onBlur(),onChange:p=>h.onChange(p.target.value)})}),n.jsx(D,{name:"country",label:t("form.fields.country.label"),errorTranslateFn:t,control:d,render:({field:h,fieldState:x})=>n.jsx(tt,{id:h.name,className:"w-full ".concat(x.invalid?"p-invalid":""),value:h.value,options:i,filter:!0,showClear:!!h.value,onBlur:()=>h.onBlur(),onChange:p=>h.onChange(p.value),pt:{item:{className:"max-w-80 whitespace-normal"},input:{className:"truncate"}}})}),n.jsx(D,{name:"postalCode",label:t("form.fields.postalCode.label"),errorTranslateFn:t,control:d,render:({field:h,fieldState:x})=>n.jsx(re,{id:h.name,className:"w-full ".concat(x.invalid?"p-invalid":""),value:h.value,type:"text",maxLength:10,onBlur:()=>h.onBlur(),onChange:p=>h.onChange(p.target.value)})}),n.jsx(O,{type:"submit",label:t("form.buttons.submit.label"),loading:y,disabled:y}),!((k=e.requestGroupSettings)!=null&&k.required)&&n.jsx(H,{label:t("form.buttons.skip.label"),onClick:()=>w()})]})}var U=(e=>(e.init="init",e.pending="pending",e.prechecked="prechecked",e.queued="queued",e.completed="completed",e.onHold="onHold",e))(U||{});const Mr=1e4,zr={buttons:{skip:{label:"Skip"}}},Gr={form:zr},Ur={buttons:{skip:{label:"Пропустить"}}},Wr={form:Ur};function _r(e){var T,f,C,k,h,x;const{uuid:t}=M(),{containerElement:a}=I(),{payer:r}=le(),{t:s}=P({en:Gr,ru:Wr}),i=V(),[o,l]=c.useState(U.init),[m,d]=c.useState(!1),[u]=c.useState(((T=a.computedStyleMap().get("color-scheme"))==null?void 0:T.toString())==="dark"),y=(f=a.computedStyleMap().get("--surface-card"))==null?void 0:f.toString(),b=sr(t!=null?t:"",{staleTime:1/0,refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1}),w=ir(t!=null?t:"",{initialData:ae.unknown,refetchInterval:Mr,refetchIntervalInBackground:!0});c.useEffect(()=>{var p;if(!((p=e.requestGroupSettings)!=null&&p.required))[U.pending,U.prechecked,U.queued,U.completed,U.onHold].includes(o)&&e.onSuccess({status:ae.unknown});else{const A=[ae.green,ae.yellow];w.data&&A.includes(w.data)&&e.onSuccess({status:w.data})}},[w.data,(C=e.requestGroupSettings)==null?void 0:C.required,o]);const S=()=>g(this,null,function*(){var p;try{return(p=(yield b.refetch()).data)!=null?p:""}catch(A){i(A)}}),q=()=>g(this,null,function*(){e.onSuccess({status:ae.unknown})}),$=(p,A)=>g(this,null,function*(){try{switch(p){case"idCheck.onReady":return d(!0);case"idCheck.applicantStatus":case"idCheck.onApplicantStatusChanged":const E=A.reviewStatus;return E===U.completed&&(yield new Promise(_=>setTimeout(()=>_(),1500)),yield w.refetch({cancelRefetch:!1})),l(E)}}catch(E){i(E)}});return n.jsxs(n.Fragment,{children:[b.isPending||!m&&n.jsx("div",{className:"flex justify-center items-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})}),b.isSuccess&&n.jsxs("div",{className:"flex flex-col space-y-4",children:[n.jsx("div",{className:m?"block":"hidden",children:n.jsx(St,{accessToken:b.data,config:{lang:me.language,email:(k=r.data)==null?void 0:k.email,phone:(h=r.data)==null?void 0:h.phone,theme:"light",uiConf:{customCssStr:"\n                    body {\n                      font-family: VC Avenir Next,Montserrat,Helvetica,Arial,sans-serif;\n                      ".concat(u?"\n                        background-color: ".concat(y," !important;\n                        filter: invert(1) hue-rotate(180deg);\n                      "):"","\n                    }\n                    \n                    ").concat(u?"\n                      img {\n                        filter: invert(1) hue-rotate(180deg);\n                      }\n                    ":"","\n                    \n                    .iframe2.min-height {\n                      min-height: 400px;\n                    }\n                    \n                    section {\n                      padding: 5px;\n                    }\n                    \n                    section.content {\n                      padding-top: 10px;\n                      background-color: transparent !important;\n                    }\n                    \n                    .upload-payment-item .upload-item {\n                      height: auto;\n                    }\n                    \n                    .upload-payment-item {\n                      margin: 10px 0;\n                    }\n                    \n                    button {\n                      margin-bottom: 0;\n                    }\n   \n                    .sumsub-logo {\n                      margin: 0 !important;\n                    }\n                    \n                    .liveness-step {\n                      padding-bottom: 20px;\n                    }\n\n                    .tutorial {\n                      padding-top: 10px;\n                    }\n\n                    .align-hints-container {\n                      height: 100%;\n                      max-height: 60px;\n                    }\n                  ")}},expirationHandler:()=>S(),onMessage:(p,A)=>$(p,A),onError:({code:p,error:A})=>i(new Error("".concat(p," ").concat(A)))})}),!((x=e.requestGroupSettings)!=null&&x.required)&&n.jsx(H,{label:s("form.buttons.skip.label"),onClick:()=>q()})]})]})}const Qr="Veryfing Payer",Zr={email:{title:"Email"},phone:{title:"Phone"},billing_address:{title:"Billing address"},kyc:{title:"KYC"}},Kr={title:Qr,groups:Zr},Jr="Верификация плательщика",Xr={email:{title:"Эл. почта"},phone:{title:"Телефон"},billing_address:{title:"Платежный адрес"},kyc:{title:"Подтверждение личности"}},Yr={title:Jr,groups:Xr};function es(e){const{uuid:t}=M(),{payer:a,signIn:r,signUp:s,anonymousPayerUuid:i}=le(),[o,l]=c.useState([]),[m,d]=c.useState(!1),u=V(),{t:y}=P({en:Kr,ru:Yr}),b=On(),w=c.useCallback(f=>g(this,null,function*(){return At(k=>g(this,null,function*(){const h=yield b.mutateAsync({uuid:f});if(!h&&k<=3)throw new Error("FormSession ".concat(f," is not completed yet, trying retry..."));return h}),{retries:3,onFailedAttempt({attemptNumber:k}){return new Promise(h=>setTimeout(h,Me(k,1e3)))}})}),[b.mutateAsync]),S=Hn(),q=Vn(t!=null?t:"",{refetchOnWindowFocus:!1,refetchOnMount:!1,refetchOnReconnect:!1});c.useEffect(()=>{if(q.isSuccess)if(q.data.groups.length>0){const f=q.data.groups.map((C,k)=>N(j({},C),{isFilled:!1,isActive:k===0}));l(f),e.onReady()}else g(this,null,function*(){if(!(yield w(t)))throw new Error("FormSession ".concat(t," is not completed although all requests are completed"));e.onSuccess()})},[q.isSuccess,q.data]),c.useEffect(()=>{m&&g(this,null,function*(){var f;try{const C=[...o];if(!(yield w(t)))throw new Error("FormSession ".concat(t," is not completed although all requests are completed"));if(((f=a.data)==null?void 0:f.type)===oe.anonymous){const h=C.find(A=>A.code===ne.phone),x=h==null?void 0:h.settings,p=h==null?void 0:h.data;if(x!=null&&x.confirmable&&(p!=null&&p.phone)&&(p!=null&&p.otpUuid))try{try{yield r.mutateAsync({identity:p.phone,identityType:Y.phone,otpUuid:p.otpUuid})}catch(A){if(A instanceof R&&A.code===401)yield s.mutateAsync({phone:p.phone,otpUuid:p.otpUuid});else throw A}yield S.mutateAsync({uuid:t,anonymousPayerUuid:i})}catch(A){et(E=>{E.captureException(A)})}}e.onSuccess()}catch(C){u(C)}})},[m]);const $=(f,C)=>g(this,null,function*(){try{const k=[...o],h=k.findIndex(p=>p.id===f);if(h===-1)throw new Error("Cannot find active group");k[h].isFilled=!0,k[h].isActive=!1,k[h].data=C;const x=h+1>=o.length;x||(k[h+1].isActive=!0),l(k),d(x)}catch(k){u(k)}}),T=f=>n.jsxs(n.Fragment,{children:[f.code===ne.email&&n.jsx(Nr,{requestGroupId:f.id,requestGroupSettings:f.settings,onSuccess:C=>$(f.id,C)}),f.code===ne.phone&&n.jsx(Rr,{requestGroupId:f.id,requestGroupSettings:f.settings,onSuccess:C=>$(f.id,C)}),f.code===ne.billingAddress&&n.jsx(Hr,{requestGroupId:f.id,requestGroupSettings:f.settings,onSuccess:()=>$(f.id)}),f.code===ne.kyc&&n.jsx(_r,{requestGroupId:f.id,requestGroupSettings:f.settings,onSuccess:()=>$(f.id)})]});return n.jsxs(n.Fragment,{children:[q.isPending&&n.jsx("div",{className:"flex justify-center items-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})}),q.isSuccess&&n.jsx(n.Fragment,{children:o.length>0?n.jsxs("div",{className:"flex flex-col space-y-4",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-primary font-semibold",children:q.data.title||y("title")}),q.data.description&&n.jsx("div",{className:"text-secondary",children:q.data.description})]}),n.jsx(tn,{multiple:!1,activeIndex:o.findIndex(({isActive:f})=>f),onTabChange:()=>{},className:"space-y-6",expandIcon:({iconProps:f})=>n.jsx(nn,N(j({},f),{className:"".concat(f.className," w-5 h-5")})),collapseIcon:({iconProps:f})=>n.jsx(an,N(j({},f),{className:"".concat(f.className," w-5 h-5")})),children:o.map((f,C)=>n.jsx(rn,{header:y("groups.".concat(f.code,".title")),disabled:f.isFilled||!f.isActive,headerTemplate:k=>n.jsxs("div",{className:"flex flex-row items-center justify-between w-full",children:[n.jsx("div",{className:"".concat(f.isFilled?"text-success":"text-primary"," font-semibold"),children:k.header}),f.isFilled?n.jsx(sn,{className:"w-5 h-5 text-success"}):k.disabled?n.jsx(on,{className:"w-5 h-5 text-secondary"}):n.jsx(n.Fragment,{})]}),pt:{content:{className:"!pt-3 !pr-0 !pb-0 !pl-0 !border-0"},header:{className:f.isFilled||!f.isActive?"!opacity-70":""},headeraction:{className:"\n                        !p-3 !rounded-lg !border-2 \n                        ".concat(f.isFilled?"!bg-message-success !text-success !border-success":"!bg-transparent !border-primary","\n                      ")}},children:n.jsxs("div",{className:"flex flex-col space-y-4",children:[(f.title||f.description)&&n.jsxs("div",{children:[f.title&&n.jsx("div",{className:"text-primary font-semibold",children:f.title}),f.description&&n.jsx("div",{className:"text-secondary",children:f.description})]}),T(f)]})},C))}),m&&n.jsx("div",{className:"flex justify-center items-center mt-6",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})})]}):n.jsx("div",{className:"flex justify-center items-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})})})]})}function ts(){const e=ye(),{onStepReady:t}=I(),a=()=>e("/steps/finalize");return n.jsx(es,{onSuccess:()=>a(),onReady:()=>t==null?void 0:t(ke.collectPayerDetails)})}const ns="--primary-color",as=e=>c.createElement("svg",j({width:32,height:32,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg"},e),c.createElement("rect",{x:1,y:1,width:30,height:30,rx:5,fill:"none",stroke:"#1C274C",strokeWidth:2}),c.createElement("path",{d:"M6 14.3519C6 10.799 6 9.02253 6.41947 8.4249C6.83892 7.82727 8.50924 7.25551 11.8499 6.11199L12.4864 5.89413C14.2278 5.29804 15.0984 5 16 5C16.9016 5 17.7722 5.29804 19.5137 5.89413L20.1501 6.11199C23.4908 7.25551 25.1611 7.82727 25.5806 8.4249C26 9.02253 26 10.799 26 14.3519C26 14.8884 26 15.4704 26 16.1016C26 22.366 21.29 25.4061 18.3349 26.697C17.5333 27.0471 17.1326 27.2222 16 27.2222C14.8674 27.2222 14.4667 27.0471 13.6651 26.697C10.71 25.4061 6 22.366 6 16.1016C6 15.4704 6 14.8884 6 14.3519Z",stroke:"#1C274C",strokeWidth:2}),c.createElement("g",{clipPath:"url(#clip0_2_19)"},c.createElement("path",{d:"M9 10.7314L11.076 14.4421V16.7056L9.00243 20.409L9 10.7314Z",fill:"#5B57A2"}),c.createElement("path",{d:"M16.971 13.0919L18.9163 11.8996L22.8974 11.8959L16.971 15.5264V13.0919Z",fill:"#D90751"}),c.createElement("path",{d:"M16.96 10.7096L16.971 15.6224L14.8901 14.3439V7L16.96 10.7096Z",fill:"#FAB718"}),c.createElement("path",{d:"M22.8974 11.8959L18.9161 11.8996L16.96 10.7096L14.8901 7L22.8974 11.8959Z",fill:"#ED6F26"}),c.createElement("path",{d:"M16.971 20.4296V18.046L14.8901 16.7917L14.8913 24.1429L16.971 20.4296Z",fill:"#63B22F"}),c.createElement("path",{d:"M18.9114 19.2481L11.0759 14.4421L9 10.7314L22.889 19.2433L18.9114 19.2481Z",fill:"#1487C9"}),c.createElement("path",{d:"M14.8914 24.1429L16.9709 20.4296L18.9113 19.2481L22.8889 19.2433L14.8914 24.1429Z",fill:"#017F36"}),c.createElement("path",{d:"M9.00243 20.409L14.9071 16.7919L12.922 15.5739L11.076 16.7056L9.00243 20.409Z",fill:"#984995"})),c.createElement("defs",null,c.createElement("clipPath",{id:"clip0_2_19"},c.createElement("rect",{x:9,y:7,width:14,height:17.1429,rx:7,fill:"white"}))));function rs(e){var l,m,d;const[t,a]=c.useState(!1),{containerElement:r}=I(),s=c.useRef((m=(l=e.paymentAccountDetails.bankDetails)==null?void 0:l.color)!=null?m:getComputedStyle(r).getPropertyValue(ns)),i=((d=e.paymentAccountDetails.card.match(/.{1,4}/g))!=null?d:[]).join(" "),o=()=>g(this,null,function*(){if(e.onReset){a(!0);try{yield e.onReset()}finally{a(!1)}}});return n.jsxs(n.Fragment,{children:[n.jsxs("svg",{viewBox:"0 0 900 600",xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",version:"1.1",className:"absolute left-0 top-0 h-full w-full z-1",preserveAspectRatio:"none",children:[n.jsx("rect",{x:"0",y:"0",width:"900",height:"600",fill:We(s.current,.55)}),n.jsx("path",{d:"M0 400L30 386.5C60 373 120 346 180 334.8C240 323.7 300 328.3 360 345.2C420 362 480 391 540 392C600 393 660 366 720 355.2C780 344.3 840 349.7 870 352.3L900 355L900 601L870 601C840 601 780 601 720 601C660 601 600 601 540 601C480 601 420 601 360 601C300 601 240 601 180 601C120 601 60 601 30 601L0 601Z",fill:We(s.current,.25),strokeLinecap:"round",strokeLinejoin:"miter"})]}),n.jsx("div",{className:"z-2 relative",children:n.jsxs("div",{className:"flex flex-col space-y-12",children:[n.jsxs("div",{className:"flex flex-row justify-between",children:[n.jsx(as,{className:"w-10 h-10"}),e.onReset&&n.jsx(H,{icon:({iconProps:u})=>n.jsx(ln,N(j({},u),{className:"".concat(u.className," w-5 h-5 text-error"),strokeWidth:"3"})),loading:t,disabled:t,onClick:()=>o()})]}),e.paymentAccountDetails.brand&&e.paymentAccountDetails.brand!==se.unsupported?n.jsxs("div",{className:"flex flex-row items-center justify-between space-x-2",children:[n.jsx("span",{className:"font-semibold font-ocr text-primary text-lg sm:text-xl tracking-wider truncate",children:i}),n.jsx("div",{className:"p-3 rounded shadow-lg backdrop-blur-sm bg-clip-padding",style:{background:"rgba(255, 255, 255, 0.2)"},children:n.jsx(Pe,{className:"w-12 h-4",brand:e.paymentAccountDetails.brand})})]}):n.jsx("div",{className:"flex flex-row items-center justify-center",children:n.jsx("span",{className:"font-semibold font-ocr text-primary text-lg sm:text-xl tracking-wider truncate",children:i})})]})})]})}const ss="Well done!",is="You've been successfully verified",os={heading:ss,text:is},ls="Отличная работа!",cs="Вы успешно прошли верификацию данных",ds={heading:ls,text:cs};function us(){const{t:e}=P({en:os,ru:ds});return n.jsx(n.Fragment,{children:n.jsx("div",{className:"z-2 relative",children:n.jsxs("div",{className:"flex flex-row items-center space-x-4",children:[n.jsx(cn,{className:"w-12 h-12",style:{color:"var(--primary-color)"}}),n.jsxs("div",{children:[n.jsx("div",{className:"text-primary font-bold",children:e("heading")}),n.jsx("div",{className:"text-secondary",children:e("text")})]})]})})})}function ms(){const e=ye(),{uuid:t,paymentAccountDetails:a,reset:r}=M(),{onFinalize:s,onReset:i,paymentMethod:o,onStepReady:l}=I(),m=V();a||e(t?"/steps/select-account":"/"),c.useEffect(()=>{if(!t)return e("/");l==null||l(ke.final),s(t)},[]);const d=()=>g(this,null,function*(){try{i(),r(),e("/")}catch(u){m(u)}});return n.jsx(n.Fragment,{children:a?n.jsx(n.Fragment,{children:we.bankCard===o&&n.jsx(rs,{paymentAccountDetails:a,onReset:d})}):n.jsx(us,{})})}const fs={identity:"",identityType:Y.phone},hs=v.object({identity:v.string({required_error:"form.fields.phone.validations.required"}).trim().min(1,"form.fields.phone.validations.required").regex(/\d{11,17}/i,"form.fields.phone.validations.invalidFormat"),identityType:v.enum([Y.phone,Y.email])});var J=(e=>(e.identity="identity",e.otp="otp",e))(J||{});const ys={fields:{phone:{label:"Phone",validations:{required:'"Phone" is required',invalidFormat:'"Phone" has incorrect format'}}},buttons:{submit:{label:"Continue"}}},gs={form:ys},vs={fields:{phone:{label:"Телефон",validations:{required:'"Телефон" обязательное поле',invalidFormat:'"Телефон" имеет неправильный формат'}}},buttons:{submit:{label:"Продолжить"}}},ps={form:vs};function xs(e){const{signIn:t,signUp:a}=le(),{create:r}=M(),[s,i]=c.useState(J.identity),{initialEncryptedData:o}=I(),{t:l}=P({en:gs,ru:ps}),m=V(),d=Xe(),{control:u,handleSubmit:y,getValues:b,setError:w}=fe({defaultValues:fs,resolver:he(hs),reValidateMode:"onChange"}),S=()=>g(this,null,function*(){return i(J.otp)}),q=()=>i(J.identity),$=(f,C,k)=>g(this,null,function*(){try{try{yield t.mutateAsync({identity:k,identityType:C,otpUuid:f})}catch(h){if(h instanceof R&&h.code===401)yield a.mutateAsync({otpUuid:f,phone:k});else throw h}yield r.mutateAsync({initialEncryptedData:o}),yield d.invalidateQueries({queryKey:Re}),e.onSuccess()}catch(h){m(h)}}),T=f=>{if(i(J.identity),f instanceof R&&f.isValidationError()){w("identity",{message:"form.fields.phone.validations.invalidFormat"});return}m(f)};return n.jsxs(n.Fragment,{children:[n.jsxs("form",{className:"flex-col space-y-4 ".concat(s===J.identity?"flex":"hidden"),onSubmit:y(S),children:[n.jsx(be,{name:"identity",control:u,render:({field:f,fieldState:C})=>{var k;return n.jsx(Le,{label:l("form.fields.phone.label"),labelFor:f.name,invalid:C.invalid,errors:(k=C.error)!=null&&k.message?[l(C.error.message)]:void 0,children:n.jsx(W,{id:f.name,className:"w-full ".concat(C.invalid?"p-invalid":""),value:f.value,placeholder:"+79001112233",imask:{mask:"+000000000000000"},autoComplete:"tel",onInput:h=>f.onChange(h.currentTarget.value),onChange:h=>f.onChange(h.target.value)})})}}),n.jsx(O,{type:"submit",label:l("form.buttons.submit.label")})]}),s===J.otp&&n.jsx(dt,{identityType:b().identityType,identity:b().identity,onChangeIdentity:()=>q(),onConfirmed:(f,C,k)=>$(f,C,k),onSendingConfirmationError:f=>T(f),canChangeIdentity:!0,useAutoSubmit:!0,waitingTimeOnResendCodeByAttempt:[60,120,300],maxWaitingTimeOnResendCode:3600})]})}const bs="Sign In / Sign Up",Cs={label:"Back"},ws={title:bs,backButton:Cs},ks="Войти / Зарегистрироваться",js={label:"Назад"},Ss={title:ks,backButton:js};function As(){const e=ye(),{t}=P({en:ws,ru:Ss});return n.jsxs("div",{className:"flex flex-col space-y-4",children:[n.jsx("div",{children:n.jsx(H,{label:t("backButton.label"),icon:({iconProps:a})=>n.jsx(dn,N(j({},a),{className:"".concat(a.className," w-5")})),iconPos:"left",onClick:()=>e(-1)})}),n.jsx("h1",{className:"text-2xl font-bold text-primary",children:t("title")}),n.jsx(xs,{onSuccess:()=>e("/")})]})}function Es(){const[e,t]=c.useState(!0);return c.useEffect(()=>{t(ze.isOnline());const a=ze.subscribe(r=>t(r));return()=>a()},[]),{isOnline:e}}const $s=e=>c.createElement("svg",j({width:"100%",height:"100%",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg"},e),c.createElement("path",{d:"M93.72,183.25C49.49,198.05,16,233.1,16,288c0,66,54,112,120,112H320.37",stroke:"currentColor",strokeWidth:"16px",style:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}}),c.createElement("path",{d:"M467.82,377.74C485.24,363.3,496,341.61,496,312c0-59.82-53-85.76-96-88-8.89-89.54-71-144-144-144-26.16,0-48.79,6.93-67.6,18.14",stroke:"currentColor",strokeWidth:"16px",style:{fill:"none",strokeLinecap:"round",strokeLinejoin:"round"}}),c.createElement("line",{x1:448,y1:448,x2:64,y2:64,stroke:"currentColor",strokeWidth:"24px",style:{fill:"none",strokeLinecap:"round",strokeMiterlimit:10}})),qs="No internet connection",Ns="The application refreshed automatically once have connection to network",Fs={title:qs,text:Ns},Is="Отсутствует подключение до сети интернет",Ts="Приложение будет обновлено автоматически при наличии подключения к сети",Bs={title:Is,text:Ts};function Rs(){const{t:e}=P({en:Fs,ru:Bs});return n.jsxs("div",{className:"flex flex-col items-center justify-center space-y-4",children:[n.jsx($s,{className:"w-14 h-14 drop-shadow-lg",style:{color:"var(--primary-color)"}}),n.jsxs("div",{className:"flex flex-col items-center space-y-2",children:[n.jsx("div",{className:"text-primary",children:e("title")}),n.jsx("div",{className:"text-secondary text-xs",children:e("text")})]})]})}function mt({children:e}){return n.jsx("div",{className:"p-3 sm:p-6 rounded-xl bg-card shadow-card min-w-64 overflow-hidden relative font-avenir subpixel-antialiased",children:e})}function Ze(){const{isInitialized:e}=le(),{create:t,uuid:a}=M(),{useCase:r,initialEncryptedData:s}=I(),i=ye(),o=V();return c.useEffect(()=>{if(a&&e){const l=r===Ce.payment?"/steps/select-account":"/steps/fill-details";return i(l)}e&&t.mutateAsync({initialEncryptedData:s}).catch(l=>o(l))},[a,e]),n.jsx("div",{className:"flex justify-center",children:n.jsx(X,{className:"w-10 h-10",strokeWidth:"5"})})}const Ps={general:"Something went wrong",network:"There was a problem with server connection",api:"An unexpected error occured while calling API"},Ls={label:"Retry"},Ds={error:Ps,retryButton:Ls},Vs={general:"Что-то пошло не так",network:"Проблема с подключением к серверу",api:"При вызове API произошла непредвиденная ошибка"},Os={label:"Повторить"},Hs={error:Vs,retryButton:Os};function Ms(e){const{t}=P({en:Ds,ru:Hs}),a=e.error instanceof R?e.error.isNetworkError()?"error.network":"error.api":"error.general",r=e.isInline?n.jsxs("div",{className:"flex flex-row space-x-4",children:[n.jsx(Fe,{severity:"error",text:t(a)}),e.isRetryable&&e.resetErrorBoundary&&n.jsx(O,{type:"button",icon:({iconProps:s})=>n.jsx(Ne,N(j({},s),{className:"".concat(s.className," w-5")})),onClick:()=>e.resetErrorBoundary()})]}):n.jsxs("div",{className:"flex items-center justify-center flex-col space-y-4",children:[n.jsx(un,{className:"w-14 h-14 text-error drop-shadow-lg"}),n.jsx("div",{className:"text-primary",children:t(a)}),e.isRetryable&&e.resetErrorBoundary&&n.jsx(O,{type:"button",size:"small",label:t("retryButton.label"),icon:({iconProps:s})=>n.jsx(Ne,N(j({},s),{className:"".concat(s.className," w-5")})),onClick:()=>e.resetErrorBoundary()})]});return n.jsx(n.Fragment,{children:e.withLayout?n.jsx(mt,{children:r}):r})}function zs(e){const[t,a]=c.useState(e.maxRetries);return n.jsx(Et,{children:({reset:r})=>n.jsx($t,{fallbackRender:s=>e.fallbackRender(N(j({},s),{leftRetryCount:t})),onError:(s,i)=>{var o;et(l=>{l.setExtras(j({},i)),l.captureException(s)}),(o=e.onError)==null||o.call(e,s,i,{leftRetryCount:t})},onReset:s=>{var i;t<=0||(a(t-1),r(),(i=e.onReset)==null||i.call(e,s))},children:e.children})})}const Gs={maxRetries:1};function Us(e){var a;const{onError:t}=I();return n.jsx(zs,{maxRetries:(a=e.maxRetries)!=null?a:Gs.maxRetries,onError:(r,s,i)=>{i.leftRetryCount||t==null||t(r)},fallbackRender:r=>n.jsx(Ms,{error:r.error,resetErrorBoundary:r.resetErrorBoundary,isRetryable:r.leftRetryCount>0}),children:e.children})}function Ws(){const{isOnline:e}=Es(),{setAppendTo:t}=c.useContext(mn),{containerElement:a}=I();c.useEffect(()=>{a.shadowRoot&&t(a.shadowRoot)},[]);const r=i=>n.jsx(Us,{children:i}),s=[{path:"/",index:!0,element:r(n.jsx(Ze,{}))},{path:"/steps/select-account",element:r(n.jsx(Za,{}))},{path:"/steps/fill-details",element:r(n.jsx(ts,{}))},{path:"/steps/finalize",element:r(n.jsx(ms,{}))},{path:"/sign-in",element:r(n.jsx(As,{}))},{path:"/*",element:r(n.jsx(Ze,{}))}];return n.jsx(mt,{children:e?n.jsxs(n.Fragment,{children:[n.jsx(qt,{router:Nt(s)}),n.jsx(fn,{})]}):n.jsx(Rs,{})})}const F=class F{constructor(t){this.domRoot=void 0,this.queryClient=void 0,this.globalData=void 0;const a=t;a.language||(a.language=Ee.language),a.theme||(a.theme=Ee.theme),a.useCase||(a.useCase=Ee.useCase),this.arguments=Ma.parse(a),this.shadowRoot=this.arguments.containerElement.shadowRoot||this.arguments.containerElement.attachShadow({mode:"open"})}static loadFonts(){return g(this,null,function*(){const t=yield F.getEntryChunkManifest();yield F.setupFonts(t)})}init(){return g(this,null,function*(){this.globalData={containerElement:this.arguments.containerElement,initialEncryptedData:this.arguments.initialEncryptedData,paymentMethod:this.arguments.paymentMethod,useCase:this.arguments.useCase,onStepReady:this.arguments.onStepReady,onFinalize:this.arguments.onFinalize,onReset:this.arguments.onReset,onError:this.arguments.onError,abortController:new AbortController},yield this.setupStyles(this.arguments.theme),this.setupLanguage(this.arguments.language),this.setupSentry(),this.queryClient=new Ft;const t=new yn(Ha);this.domRoot=It(this.shadowRoot),this.domRoot.render(n.jsx(kn,{data:this.globalData,children:n.jsx(hn,{children:n.jsx(Tt,{client:this.queryClient,children:n.jsx(vn,{client:t,children:n.jsx(Mn,{children:n.jsx(qn,{queryClient:this.queryClient,storageClient:t,children:n.jsx(Nn,{children:n.jsx(Ws,{})})})})})})})}))})}destroy(){return g(this,null,function*(){var t,a;(t=this.globalData)==null||t.abortController.abort("App destroyed"),this.queryClient&&(yield this.queryClient.cancelQueries(),this.queryClient.clear(),this.queryClient=void 0),(a=this.domRoot)==null||a.unmount(),this.domRoot=void 0,Array.from(this.shadowRoot.querySelectorAll("*:not(link)")).forEach(r=>this.shadowRoot.removeChild(r))})}static setupFonts(t){return g(this,null,function*(){var m,d,u;let a=(m=t.css)==null?void 0:m.find(y=>y.includes("fonts"));if(!a)return;a="".concat(F.baseUrl,"/").concat(a);const r=(yield fetch(a).then(y=>y.text())).replace(/\n/g,"");if(Array.from(document.head.querySelectorAll("style")).some(y=>{var b;return(b=y.textContent)==null?void 0:b.includes(r)}),document.getElementById(F.styleFontsId))return;const s=document.createElement("style");s.setAttribute("type","text/css"),s.setAttribute("id",F.styleFontsId),s.innerText=r,document.head.appendChild(s);const i=[],o=/url\(([^)]+)\)\s+format\("([^"]+)"\)/gm;let l=null;for(;l=o.exec(r);)i.push({url:(d=l[1])!=null?d:"",format:(u=l[2])!=null?u:""});yield Promise.all(i.filter(({url:y,format:b})=>y&&b).map(({url:y,format:b})=>new Promise(w=>{const S=document.createElement("link");S.rel="preload",S.as="font",S.type="font/".concat(b.toLowerCase()),S.href=y,S.crossOrigin="",S.onload=()=>w(),document.head.appendChild(S)})))})}static getEntryChunkManifest(){return g(this,null,function*(){const t=yield fetch("".concat(F.baseUrl,"/.vite/manifest.json?build=").concat(F.releaseBuild)).then(r=>r.json()),a=Object.values(t).find(r=>r.isEntry);if(!a)throw new Error("Cannot find entry chunk in manifest.json");return a})}setupStyles(t){return g(this,null,function*(){yield Promise.all([g(this,null,function*(){document.getElementById(F.styleFontsId)||(yield F.loadFonts())}),g(this,null,function*(){var s,i;let a;if(!this.shadowRoot.getElementById(F.styleId)){a=a!=null?a:yield F.getEntryChunkManifest();const o=document.createElement("link");o.setAttribute("id",F.styleId),o.setAttribute("rel","stylesheet"),o.setAttribute("href","".concat(F.baseUrl,"/").concat((i=(s=a.css)==null?void 0:s.find(l=>l.includes("index")))!=null?i:"")),this.shadowRoot.appendChild(o)}const r=F.styleThemeIdPrefix+"-"+t;if(!this.shadowRoot.getElementById(r)){a=a!=null?a:yield F.getEntryChunkManifest();const o=document.createElement("link");o.setAttribute("id",r),o.setAttribute("rel","stylesheet"),o.setAttribute("href","".concat(F.baseUrl,"/themes/").concat(t,".css?build=").concat(F.releaseBuild)),this.shadowRoot.appendChild(o)}})])})}setupSentry(){const t="https://9a62f8368cef2595099c81b6562ef017@sentry.veryfy.ai/14";Bt()||Rt({dsn:t,environment:"production",release:F.releaseBuild,integrations:[Pt({useEffect:c.useEffect,useLocation:Ht,useNavigationType:Mt,createRoutesFromChildren:zt,matchRoutes:Gt}),Lt(),Dt({maskAllText:!1,blockAllMedia:!1,networkCaptureBodies:!0,networkDetailDenyUrls:["https://veryfy.ai/api/web/v1/payer-accounts/bank-cards/tokens"],networkDetailAllowUrls:[new RegExp("https://veryfy.ai/api/web/v1","gmi")]})],ignoreErrors:["top.GLOBALS",/_RemoveAllHighlights/i,/alpinejs/i,/TelegramGameProxy/i],denyUrls:[/gtag\/js/i,/google-analytics\.com/i,/pagead\/js/i,/graph\.facebook\.com/i,/connect\.facebook\.net\/en_US\/all\.js/i,/extensions\//i,/^chrome:\/\//i,/^chrome-extension:\/\//i],tracesSampleRate:1,tracePropagationTargets:[new RegExp("^https://veryfy.ai/api/web/v1","gi")],replaysSessionSampleRate:.1,replaysOnErrorSampleRate:1})}setupLanguage(t){me.changeLanguage(t),pn(t),qe.registerLocale(Vt),qe.registerLocale(Ot)}};F.styleThemeIdPrefix="checkout-app-theme",F.styleId="checkout-app-style",F.styleFontsId="checkout-app-fonts",F.baseUrl=import.meta.url.split("/assets/")[0],F.releaseBuild="ls8ng31e-1730200756456";let Be=F;var ke=(e=>(e.selectPaymentAccount="selectPaymentAccount",e.collectPayerDetails="collectPayerDetails",e.final="final",e))(ke||{});window.VeryfyCheckout=Be;window.globalThis=window;
