@paykka/card-checkout-ui 0.11.4 → 0.11.5
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.
|
@@ -11,7 +11,7 @@ components: `).concat(yi(o),"\n```")),[2,c]}})})}}}function Au(){if(!(window.__f
|
|
|
11
11
|
${e}:-moz-placeholder { ${t} }
|
|
12
12
|
${e}:-ms-input-placeholder { ${t} }
|
|
13
13
|
`},Ui=e=>{const{input:n}=e;let t={},r={};return n&&(t=JSON.parse(JSON.stringify(n)),Reflect.deleteProperty(t,"placeholder"),Reflect.deleteProperty(t,"hover"),r={placeholder:n==null?void 0:n.placeholder,hover:n==null?void 0:n.hover},Object.keys(t).forEach(o=>{if(o==="placeholder"||o==="hover")return;const c=t[o];c&&ml.forEach(s=>{r[o]||(r[o]={}),c[s]&&(r[o][s]=c[s],Reflect.deleteProperty(c,s))})})),{...e,inputWrapper:t,input:r}},K1=(e=[])=>e.map(({selector:t,style:r})=>`${t} { ${pn(r)} }`).join(`
|
|
14
|
-
`);var _e=(e=>(e.CARD_NUMBER="CARD_NUMBER",e.CVV="CVV",e.EXPIRE_DATE="EXPIRE_DATE",e))(_e||{});const Gi="data-sf",Zi="secured-iframe",a0="hidden-pay-iframe",ji=e=>{const n=document.createElement("iframe");n.setAttribute("src",e),n.classList.add(Zi),n.setAttribute("allowtransparency","true"),n.setAttribute("referrerpolicy","origin"),Object.defineProperty(n,"src",{configurable:!1,writable:!1});const t=document.createTextNode("<p>Your browser does not support iframes.</p>");return n.appendChild(t),n},ze=(e,n,t="*")=>{if(!n)return;const r=typeof e=="string"?e:JSON.stringify(e);n==null||n.postMessage(r,{targetOrigin:t})},o0=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),i0=(e,n)=>{const t=new URL(e);return Object.entries(n).forEach(([r,a])=>{t.searchParams.append(r,String(a))}),t.toString()},c0=e=>{try{const n=new URL(e),t={};return n.searchParams.forEach((a,o)=>{t[o]=a}),{baseUrl:n.origin+n.pathname,params:t}}catch{return{baseUrl:e,params:{}}}},Yt=e=>{const{request_url:n,request_method:t}=e;if(t==="GET")s0(n,{});else{const{baseUrl:r,params:a}=c0(n);d0(r,a)}},s0=(e,n)=>{const t=i0(e,n);window.location.href=t},d0=(e,n)=>{const t=document.createElement("form");t.method="POST",t.action=e,t.style.display="none",Object.entries(n).forEach(([r,a])=>{const o=document.createElement("input");o.type="hidden",o.name=r,o.value=a,t.appendChild(o)}),document.body.appendChild(t),t.submit()},Yi=(e,n)=>{const t=e.indexOf(n);t!==-1&&e.splice(t,1)},l0=(e,n=document.createElement("div"))=>"on"+e in n,Qi="MM/DD/YYYY",u0=`${Qi} HH:mm:ss`,Wi={date:Qi,datetime:u0},m0=(e,n="datetime")=>{if(!e&&e!==0)return"-";n in Wi&&(n=Wi[n]);let t;["number","string"].includes(typeof e)?t=new Date(e):t=e;const r=a=>a.toString().padStart(2,"0");return n.replace(/YYYY/g,t.getFullYear().toString()).replace(/MM/g,r(t.getMonth()+1)).replace(/DD/g,r(t.getDate())).replace(/HH/g,r(t.getHours())).replace(/mm/g,r(t.getMinutes())).replace(/ss/g,r(t.getSeconds()))},st=(e,n)=>{const t={...e};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])&&typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])?t[r]=st(t[r],n[r]):t[r]=n[r];return t},f0="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";function h0(e,n){return n?e:void 0}function nr(e,n,t){return Pe(n)||(e=Math.max(e,n)),Pe(t)||(e=Math.min(e,t)),e}const rr=(e,n={})=>{try{return JSON.parse(e)}catch{return n}},y0=(e,n="")=>{try{return JSON.stringify(e)}catch{return n}};function zi(e){const[n,t]=e.split("/").map(Number);return new Date(+`20${t}`,n-1)<new Date}const Mn=(...e)=>{if(e.length===0)return[];let n=e[0];for(let t=1;t<e.length;t++){const r=new Set(n);n=e[t].filter(a=>r.has(a))}return n},C0=()=>Object.entries(Object.assign({"./de-DE.ts":()=>Promise.resolve().then(()=>r6),"./en-GB.ts":()=>Promise.resolve().then(()=>g0),"./es-ES.ts":()=>Promise.resolve().then(()=>a6),"./fr-FR.ts":()=>Promise.resolve().then(()=>o6),"./ja-JP.ts":()=>Promise.resolve().then(()=>i6),"./ko-KR.ts":()=>Promise.resolve().then(()=>c6),"./nl-NL.ts":()=>Promise.resolve().then(()=>s6),"./pt-PT.ts":()=>Promise.resolve().then(()=>d6),"./ru-RU.ts":()=>Promise.resolve().then(()=>l6),"./zh-CN.ts":()=>Promise.resolve().then(()=>u6),"./zh-HK.ts":()=>Promise.resolve().then(()=>m6),"./zh-TW.ts":()=>Promise.resolve().then(()=>f6)})).reduce((e,[n,t])=>{const r=n.match(/\.\/(.+)\./)[1];return e[r]=t,e},{});var bn=(e=>(e.deDE="de-DE",e.enGB="en-GB",e.esES="es-ES",e.frFR="fr-FR",e.jaJP="ja-JP",e.koKR="ko-KR",e.nlNL="nl-NL",e.ptPT="pt-PT",e.ruRU="ru-RU",e.zhCN="zh-CN",e.zhHK="zh-HK",e.zhTW="zh-TW",e))(bn||{});const ar={"guideCard.redirectDescription":"After submission, you will be redirected to the payment method provider's page to safely complete the subsequent steps.","guideCard.scanQRCode":"After submitting the order, use {method} to scan the QR code.","dropIn.card.label":"Bank card","dropIn.otherPaymentMethod":"Other payment method","dropIn.boost.label":"Boost","dropIn.TNGWallet.label":"Touch 'n Go eWallet","dropIn.shopeePay.label":"ShopeePay","dropIn.mayBankQRPay.label":"Maybank QRPay","dropIn.grabPay.label":"GrabPay","dropIn.linePay.label":"LinePay","dropIn.ninePay.label":"9Pay","dropIn.gcash.label":"GCash","dropIn.paymaya.label":"Paymaya","card.cardNumber.label":"Card number","card.cardNumber.incomplete":"Your card number is incomplete","card.cardNumber.invalid":"Your card number is invalid","card.cardNumber.placeholder":"1234 5678 9012 3456","card.cardExpireDate.label":"Expiry date","card.cardExpireDate.placeholder":"MM/YY","card.cardExpireDate.incomplete":"Your card expiry date is incomplete","card.cardExpireDate.expired":"Your card has expired","card.cardSecurityCode.label":"CVC/CVV","card.cardSecurityCode.placeholder":"123","card.cardSecurityCode.incomplete":"Your card security code is incomplete","card.cardHolderName.label":"Cardholder name","card.cardHolderName.placeholder":"Full name on card","card.cardHolderName.incomplete":"Your name is incomplete","card.cardSelector.change":"Change","card.cardSelector.useOtherCard":"Use other card","card.storeInfo":"Save my card info. for future use","card.info.label":"Card Information","common.pay":"Buy now","common.payProcessing":"Processing...","common.paySuccess":"Payment Successful","common.payTimeout":"Connection lost","common.pay3DSIncomplete":"3DS Authentication Incomplete","common.queryTimeout":"Query timed out. Please refresh the page or pay again","common.generateQrCode":"Generate QR code","common.recurringTip":"By paying for this order, you authorize the merchant to automatically charge your bank card in the future according to the terms.","common.noData":"No data","common.netError":"Network Error","common.unknownError":"Unknown Error","common.cancel":"Cancel","common.confirm":"Confirm","common.email.label":"Email","common.email.incomplete":"Please enter your email","common.email.incorrect":"Incorrect email","common.accountName.label":"Account name","common.accountName.placeholder":"Full name on the account","common.accountName.incomplete":"Your name is incomplete","address.label":"Billing address","address.country":"Country/Region","address.address1":"Line 1","address.address2":"Line 2","address.city":"City","address.postCode":"Post code","address.province":"State/Province","address.area":"District/County","sepa.iban.label":"IBAN","sepa.iban.placeholder":"DE00 0000 0000 0000 0000 00","sepa.iban.invalid":"Your entered IBAN is invalid","threeDS.paymentIncomplete":"Your last payment is incomplete, ","threeDS.completeFirst":"please complete the processing first.","threeDS.authenticationSuccessful":"Authentication successful,","threeDS.authenticationFailed":"Authentication failed,","threeDS.returnToCheckout":"returning shortly.","qrCode.expired":"The QR code has expired.","qrCode.scanByGcash":"Scan QR code with GCash"},g0=Object.freeze(Object.defineProperty({__proto__:null,default:ar},Symbol.toStringTag,{value:"Module"}));function Ki(e){return e.replaceAll("_","-").toLowerCase()}function qi(e){return e.split("-")[0]}const v0=()=>Object.entries(C0()).map(([e,n])=>({locale:Ki(e),language:qi(e),translation:n}));function p0(e){return v0()}function Ji(e,n){var a,o;const t=p0();e=Ki(e);let r=(a=t.find(c=>c.locale===e))==null?void 0:a.translation;if(!r){const c=qi(e);r=(o=t.find(s=>s.language===c))==null?void 0:o.translation}return r}const b0=e=>{let n=Xi(e);return n||(n=Xi(nn().language)),n||bn.enGB},Xi=e=>{if(Object.values(bn).includes(e))return e;if(e!=null&&e.toLowerCase().startsWith("en"))return bn.enGB;if(e!=null&&e.toLowerCase().startsWith("zh"))return bn.zhCN};async function A0(e,n){let t=Ji(e);if(!t&&e!==nn().language&&(e=nn().language,t=Ji(e)),Bo(t)){const r=await t();return{locale:e,translation:r.default}}return t?{locale:e,translation:t}:{locale:bn.enGB,translation:ar}}var S0=Symbol.for("preact-signals");function q1(){if(Dn>1)Dn--;else{for(var e,n=!1;or!==void 0;){var t=or;for(or=void 0,J1++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&ec(t))try{t.c()}catch(a){n||(e=a,n=!0)}t=r}}if(J1=0,Dn--,n)throw e}}var Fe=void 0,or=void 0,Dn=0,J1=0,Or=0;function $i(e){if(Fe!==void 0){var n=e.n;if(n===void 0||n.t!==Fe)return n={i:0,S:e,p:Fe.s,n:void 0,t:Fe,e:void 0,x:void 0,r:n},Fe.s!==void 0&&(Fe.s.n=n),Fe.s=n,e.n=n,32&Fe.f&&e.S(n),n;if(n.i===-1)return n.i=0,n.n!==void 0&&(n.n.p=n.p,n.p!==void 0&&(n.p.n=n.n),n.p=Fe.s,n.n=void 0,Fe.s.n=n,Fe.s=n),n}}function et(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}et.prototype.brand=S0,et.prototype.h=function(){return!0},et.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)},et.prototype.U=function(e){if(this.t!==void 0){var n=e.e,t=e.x;n!==void 0&&(n.x=t,e.e=void 0),t!==void 0&&(t.e=n,e.x=void 0),e===this.t&&(this.t=t)}},et.prototype.subscribe=function(e){var n=this;return $1(function(){var t=n.value,r=Fe;Fe=void 0;try{e(t)}finally{Fe=r}})},et.prototype.valueOf=function(){return this.value},et.prototype.toString=function(){return this.value+""},et.prototype.toJSON=function(){return this.value},et.prototype.peek=function(){var e=Fe;Fe=void 0;try{return this.value}finally{Fe=e}},Object.defineProperty(et.prototype,"value",{get:function(){var e=$i(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(J1>100)throw new Error("Cycle detected");this.v=e,this.i++,Or++,Dn++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{q1()}}}});function Fr(e){return new et(e)}function ec(e){for(var n=e.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function tc(e){for(var n=e.s;n!==void 0;n=n.n){var t=n.S.n;if(t!==void 0&&(n.r=t),n.S.n=n,n.i=-1,n.n===void 0){e.s=n;break}}}function nc(e){for(var n=e.s,t=void 0;n!==void 0;){var r=n.p;n.i===-1?(n.S.U(n),r!==void 0&&(r.n=n.n),n.n!==void 0&&(n.n.p=r)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=r}e.s=t}function Bn(e){et.call(this,void 0),this.x=e,this.s=void 0,this.g=Or-1,this.f=4}(Bn.prototype=new et).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Or))return!0;if(this.g=Or,this.f|=1,this.i>0&&!ec(this))return this.f&=-2,!0;var e=Fe;try{tc(this),Fe=this;var n=this.x();(16&this.f||this.v!==n||this.i===0)&&(this.v=n,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Fe=e,nc(this),this.f&=-2,!0},Bn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}et.prototype.S.call(this,e)},Bn.prototype.U=function(e){if(this.t!==void 0&&(et.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}},Bn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Bn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=$i(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function rc(e){return new Bn(e)}function ac(e){var n=e.u;if(e.u=void 0,typeof n=="function"){Dn++;var t=Fe;Fe=void 0;try{n()}catch(r){throw e.f&=-2,e.f|=8,X1(e),r}finally{Fe=t,q1()}}}function X1(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,ac(e)}function w0(e){if(Fe!==this)throw new Error("Out-of-order effect");nc(this),Fe=e,this.f&=-2,8&this.f&&X1(this),q1()}function ir(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}ir.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var n=this.x();typeof n=="function"&&(this.u=n)}finally{e()}},ir.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ac(this),tc(this),Dn++;var e=Fe;return Fe=this,w0.bind(this,e)},ir.prototype.N=function(){2&this.f||(this.f|=2,this.o=or,or=this)},ir.prototype.d=function(){this.f|=8,1&this.f||X1(this)};function $1(e){var n=new ir(e);try{n.c()}catch(t){throw n.d(),t}return n.d.bind(n)}var ea;function Vn(e,n){oe[e]=n.bind(null,oe[e]||function(){})}function Ur(e){ea&&ea(),ea=e&&e.S()}function oc(e){var n=this,t=e.data,r=_0(t);r.value=t;var a=It(function(){for(var o=n.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}return n.__$u.c=function(){var c;!Ja(a.peek())&&((c=n.base)==null?void 0:c.nodeType)===3?n.base.data=a.peek():(n.__$f|=1,n.setState({}))},rc(function(){var c=r.value.value;return c===0?0:c===!0?"":c||""})},[]);return a.value}oc.displayName="_st",Object.defineProperties(et.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:oc},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Vn("__b",function(e,n){if(typeof n.type=="string"){var t,r=n.props;for(var a in r)if(a!=="children"){var o=r[a];o instanceof et&&(t||(n.__np=t={}),t[a]=o,r[a]=o.peek())}}e(n)}),Vn("__r",function(e,n){Ur();var t,r=n.__c;r&&(r.__$f&=-2,(t=r.__$u)===void 0&&(r.__$u=t=function(a){var o;return $1(function(){o=this}),o.c=function(){r.__$f|=1,r.setState({})},o}())),Ur(t),e(n)}),Vn("__e",function(e,n,t,r){Ur(),e(n,t,r)}),Vn("diffed",function(e,n){Ur();var t;if(typeof n.type=="string"&&(t=n.__e)){var r=n.__np,a=n.props;if(r){var o=t.U;if(o)for(var c in o){var s=o[c];s!==void 0&&!(c in r)&&(s.d(),o[c]=void 0)}else t.U=o={};for(var d in r){var l=o[d],m=r[d];l===void 0?(l=E0(t,d,m,a),o[d]=l):l.o(m,a)}}}e(n)});function E0(e,n,t,r){var a=n in e&&e.ownerSVGElement===void 0,o=Fr(t);return{o:function(c,s){o.value=c,r=s},d:$1(function(){var c=o.value.value;r[n]!==c&&(r[n]=c,a?e[n]=c:c?e.setAttribute(n,c):e.removeAttribute(n))})}}Vn("unmount",function(e,n){if(typeof n.type=="string"){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var a in r){var o=r[a];o&&o.d()}}}}else{var c=n.__c;if(c){var s=c.__$u;s&&(c.__$u=void 0,s.d())}}e(n)}),Vn("__h",function(e,n,t,r){(r<3||r===9)&&(n.__$f|=2),e(n,t,r)}),Zt.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u;if(!(t&&t.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in n)return!0;for(var a in e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var o in this.props)if(!(o in e))return!0;return!1};function _0(e){return It(function(){return Fr(e)},[])}const jn=class jn{constructor(){Ee(this,"locale");Ee(this,"translation");Ee(this,"isReady",Fr(!1));Ee(this,"currentLoadId",0);return jn.instance||(jn.instance=this),jn.instance}get(n,t){var a;let r=((a=this.translation)==null?void 0:a[n])??"";return t&&typeof r=="string"&&Object.keys(t).forEach(o=>{r=r.replace(new RegExp(`{${o}}`,"g"),String(t[o]))}),r}get ready(){return this.isReady}load(n=nn().language){if(n===this.locale)return;this.locale=n;const t=++this.currentLoadId;this.isReady.value=!1,A0(this.locale).then(r=>{t===this.currentLoadId&&(this.isReady.value=!0,this.locale=r.locale,this.translation=r.translation)}).catch(()=>{this.isReady.value=!1})}};Ee(jn,"instance");let Gr=jn,ta="https://checkout.aq.paykka.com",Ht="https://checkout.aq.paykka.com",Zr="/cp",xn=`${Ht}${Zr}`,ic,cc={},sc,Qe=!1;const cr=e=>{ta=e},sr=e=>{const n=new URL(e);Ht=n.origin,Zr=n.pathname,xn=`${Ht}${Zr==="/"?"":Zr}`},dc=e=>{ic=e},I0=e=>{cc=e},lc=e=>{sc=e},uc=e=>{Qe=e.hidePaymentButton||!1},tt=Ar(null),mc=new WeakMap,jr=(e,n)=>{const t=Object.assign(mc.get(e)??{},n);return mc.set(e,t),t};function An(e,n){const t={},r={updateProps:l,mount:m,unmount:u,get props(){return Di(o)},ref:t},a=e,o={...n},c=jr(r,{vNode:s(),render:d});function s(){return Pn(a,{...o,ref:y=>{Object.assign(t,y)}})}function d(){jr(r,{vNode:s()}),c.dom&&br(c.vNode,c.dom)}function l(y){Object.assign(o,y),d()}function m(y){const h=hn(y)?document.querySelector(y):y;if(!h)throw new Error("Component could not mount. Root node was not found.");return u(),jr(r,{dom:h}),d(),r}function u(){const{dom:y}=c;return y&&(br(null,y),jr(r,{dom:null})),r}return r}var na=(e=>(e.ERROR="ERROR",e.API_ERROR="API_ERROR",e.TIMEOUT="TIMEOUT",e))(na||{});class Se extends Error{constructor(t,r,a){super(r);Ee(this,"type");Ee(this,"code");this.type=t,this.code=a==null?void 0:a.code,this.cause=a==null?void 0:a.cause}}const fc=async({sessionId:e,clientKey:n},t)=>Q0({sessionId:e,clientKey:n},t);class hc{constructor(n,t){ln(this,d1);Ee(this,"sessionId");Ee(this,"clientKey");Ee(this,"checkout");Ee(this,"colors",null);ln(this,wn,gn());this.sessionId=n,this.clientKey=t,id(this,d1,cd).call(this).then(()=>Ye(this,wn).resolve(!0)).catch(r=>{qe(r)?Ye(this,wn).reject(r):Ye(this,wn).reject(new Se("API_ERROR",r.message,{code:r.code}))})}genColors(){var t;const{payButtonBackgroundColor:n}=((t=this.checkout)==null?void 0:t.theme)||{};if(n){const r=Ju(n,{theme:"default",backgroundColor:"#fff"});this.colors={primary:r[5],primaryHover:r[4],primaryActive:r[6]}}}ready(){return Ye(this,wn)}}wn=new WeakMap,d1=new WeakSet,cd=async function(){this.checkout=await fc({sessionId:this.sessionId,clientKey:this.clientKey}),this.genColors()};const P0={eu:"https://checkout.eu.paykka.com",hk:"https://checkout.aq.paykka.com",sandbox:"https://checkout-sandbox.aq.paykka.com"},R0={eu:"https://checkout.eu.paykka.com/cp",hk:"https://checkout.aq.paykka.com/cp",sandbox:"https://checkout-sandbox.aq.paykka.com/cp"},N0={eu:{SR:"pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq"},hk:{SR:"pk_live_51QSXh9Azq7GQL5iqwZNLz3KJ896MIUnai4H7H0z9DtlklJkgoH1VAlHKy382vWPqDm80nTy8MKUdJIKs0fFbTlKx006WcKWEDu"},sandbox:{SR:"pk_test_51QaC2P5VarcojPHdg13yagk5TqrGkIkeK8I21BgQUZe8BzyRmbtmOg3dKsXjkxt6JlsjyjJMTvBH9dFMCZWRxOkt00tWQ1eHFU"}},k0=async(e,n)=>Ne.post("/session/fraud-detection/component/authorization",e,n).then(t=>({authCode:t.auth_code,channel:t.channel,expireTime:t.expire_time})),L0="https://centinelapistag.cardinalcommerce.com",T0=1e4,Yn=class Yn{constructor(n){Ee(this,"iframe",null);Ee(this,"jwt",null);Ee(this,"listener",null);Ee(this,"timer",null);Ee(this,"fraudDetectionId",null);Ee(this,"p");Ee(this,"options");if(Yn.instance)return Yn.instance;this.options=n,Yn.instance=this}async getFraudDetectionId(n){return this.fraudDetectionId?this.fraudDetectionId:this.p?this.p:(this.iframe=null,this.timer&&clearTimeout(this.timer),this.p=this.requestFraudDetectionId(n),this.p)}async requestFraudDetectionId(n){const{onEvent:t}=this.options||{};t==null||t(jt.WORLDPAY_DDC_START);try{return await Promise.all([this.getJWT(),this.initIframe()]),this.sendJWTAndBin(n),new Promise(r=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.clearListener(),console.error("worldpay ddc get id timeout"),t==null||t(jt.WORLDPAY_DDC_TIMEOUT),r("")},T0),this.listenFraudDetectionId(a=>{this.timer&&clearTimeout(this.timer),this.fraudDetectionId=a,t==null||t(jt.WORLDPAY_DDC_SUCCESS),r(a)})})}catch(r){return console.error(r),t==null||t(jt.WORLDPAY_DDC_ERROR),""}}sendJWTAndBin(n){const t={action:Re.DDC_JWT_BIN,jwt:this.jwt||"",bin:n};ze(t,this.iframe.contentWindow,Ht)}listenFraudDetectionId(n){this.listener&&this.clearListener(),this.listener=t=>{var r;if(t.origin===L0){const a=JSON.parse(t.data);if(console.warn("worldpay ddc data",a),a){const o=a.SessionId||((r=a.Payload)==null?void 0:r.SessionId);n(o)}}},window.addEventListener("message",this.listener)}clearListener(){this.listener&&window.removeEventListener("message",this.listener),this.timer&&clearTimeout(this.timer),this.listener=null,this.timer=null}getJWT(){return this.jwt?this.jwt:k0({channel:"WORLD_PAY"}).then(n=>(this.jwt=n.authCode,this.jwt))}initIframe(){if(this.iframe)return;const n=document.createElement("iframe");return n.src=`${xn}/worldpay-ddc.html`,n.style.display="none",n.width="1",n.height="1",document.body.appendChild(n),this.iframe=n,new Promise(t=>{n.onload=()=>{t()}})}};Ee(Yn,"instance",null);let Yr=Yn;var M0={VITE_API_URL:"https://checkout.aq.paykka.com",VITE_CDN_ORIGIN:"https://checkout.aq.paykka.com",VITE_CDN_DIR:"/cp",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const D0={eu:"pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq",hk:"pk_live_51QSXh9Azq7GQL5iqwZNLz3KJ896MIUnai4H7H0z9DtlklJkgoH1VAlHKy382vWPqDm80nTy8MKUdJIKs0fFbTlKx006WcKWEDu",us:M0.VITE_STRIPE_KEY},B0="eu";let ra=null;function V0(e,n,t){return ra||(ra=new x0(e,n,t)),ra}class x0{constructor(n=B0,t=[at.SR,at.WP],r){Ee(this,"options");Ee(this,"collResultMap",{[at.SR]:"",[at.WP]:""});Ee(this,"collMap",{[at.SR]:()=>this.stripeRadarColl(),[at.WP]:()=>this.worldpayDDCColl()});Ee(this,"p");Ee(this,"realMode",[]);Ee(this,"keyMap",{[at.SR]:""});this.realMode=t,this.options=r,t.includes(at.SR)&&(typeof n=="string"?this.keyMap[at.SR]=D0[n]:this.keyMap[at.SR]=n[at.SR])}get fraudDetectionID(){return this.formatFraudDetectionId({s:this.collResultMap[at.SR]})}async getFraudDetectionId(n){return this.formatFraudDetectionId({s:this.collResultMap[at.SR],w:await this.worldpayDDCColl().getFraudDetectionId((n==null?void 0:n.bin)||"")})}async createFraudDetection(){this.p||(this.p=Promise.all(this.realMode.map(async n=>{if(this.collMap[n])return await this.collMap[n]();throw new Error(`Unsupported collection mode: ${n}`)}))),await this.p}formatFraudDetectionId(n){var t,r;try{const a=JSON.stringify(n);return btoa(a)}catch(a){return console.error("[PayKKa Fraud Detection SDK]:",a),(r=(t=this.options)==null?void 0:t.onEvent)==null||r.call(t,jt.FRAUD_DETECTION_TRANSFORM_ERROR),""}}stripeRadarColl(){return new Promise((n,t)=>{const{onEvent:r}=this.options||{};r==null||r(jt.STRIPE_RADAR_START);const a=document.createElement("script");a.type="text/javascript",a.src="https://js.stripe.com/v3/",a.async=!0,a.crossOrigin="",a.onload=async()=>{const o=window.Stripe(this.keyMap[at.SR]),{radarSession:c,error:s}=await o.createRadarSession();s?(console.error(s),r==null||r(jt.STRIPE_RADAR_ERROR),t(s)):(this.collResultMap[at.SR]=c==null?void 0:c.id,r==null||r(jt.STRIPE_RADAR_SUCCESS),n(c))},a.onerror=()=>{r==null||r(jt.STRIPE_RADAR_LOAD_ERROR),t()},document.getElementsByTagName("head")[0].appendChild(a)})}worldpayDDCColl(){return new Yr(this.options)}}const H0="m";class O0{constructor(n){ln(this,Gt,void 0);ln(this,l1,void 0);ln(this,$t,void 0);ln(this,u1,[]);Ee(this,"processingPaymentMethod",null);Ee(this,"enablePaymentMethod",Fr(null));y1(this,Gt,n),this.init()}init(){this.initEnv(),this.initLocale(),this.initExtraParams(),this.initSession(),this.initOtherData()}initSession(){const{sessionId:n,clientKey:t,onPaymentMethodsReady:r,onInitError:a,onSuccess:o}=Ye(this,Gt);if(!n){a==null||a(new Se("ERROR","SessionId is required"));return}y1(this,$t,new hc(n,t)),Ye(this,$t).ready().then(()=>{var d,l;if(Hd((d=Ye(this,$t))==null?void 0:d.checkout)){a==null||a(new Se("ERROR","Checkout is empty"));return}const{paymentMethod:c=[],status:s}=((l=Ye(this,$t))==null?void 0:l.checkout)||{};if(s==="SUCCESS"){o==null||o({});return}r==null||r(c)}).catch(c=>{a==null||a(c)})}initEnv(){const{env:n,_envConfig:t,onInitError:r}=Ye(this,Gt);if(!n){r==null||r(new Se("ERROR","Env is required"));return}cr((t==null?void 0:t.api)||P0[n]),sr((t==null?void 0:t.cdn)||R0[n]),dc((t==null?void 0:t.fraudDetection)||N0[n])}initLocale(){const{locale:n}=Ye(this,Gt);n&&lc(n)}initExtraParams(){const{hidePaymentButton:n=!1}=Ye(this,Gt);uc({hidePaymentButton:n})}initOtherData(){const n=o0(H0);n&&(this.processingPaymentMethod=n)}get session(){return Ye(this,$t)}get envConfig(){return Ye(this,l1)}get config(){return Ye(this,Gt)}create(n,t){var m;const{onSubmit:r,onSuccess:a,onError:o,onTimeout:c,onExpired:s}=Ye(this,Gt),d=this.getCoreProps(),l=An(n,{onSubmit:r,onSuccess:a,onError:o,onTimeout:c,onExpired:s,...t,...d});return(m=Ye(this,u1))==null||m.push(l),l}getCoreProps(){return{session:Ye(this,$t),core:this,threeDSFrame:Ye(this,Gt).threeDSFrame}}resetEnablePaymentMethod(){this.enablePaymentMethod.value=null}}Gt=new WeakMap,l1=new WeakMap,$t=new WeakMap,u1=new WeakMap;const yc=async(e,n,t,{timeout:r=2e4,headers:a,locale:o}={})=>{const c=new AbortController,s=setTimeout(()=>{c.abort()},r);try{const d=Bd(),l=e==="post",m=await d(`${ta}/bk${n}`,{method:e,mode:"cors",cache:"default",credentials:"same-origin",headers:{Accept:"application/json, text/plain, */*","Content-Type":l?"application/json":"text/plain","Accept-Language":o??nn().language,...cc,...a},redirect:"follow",referrerPolicy:"no-referrer-when-downgrade",body:l&&t?y0(t):void 0,signal:c.signal});clearTimeout(s);const u=String(m.status);let y;try{y=await m.json()}catch{y={i18nKey:"common.netError"}}if(u==="500")throw{code:u,...y.ret_msg?{message:y.ret_msg}:{i18nKey:"common.unknownError"}};if(/^(429|5\d{2})$/.test(u))throw{code:u,i18nKey:"common.netError"};if(y.ret_code!=="000000")throw{code:y.ret_code,message:y.ret_msg};return y.data}catch(d){throw d.name==="AbortError"?new Se(na.TIMEOUT):d.code?d:{i18nKey:"common.unknownError"}}},Ne={get:(e,n,t)=>yc("get",e,n,t),post:(e,n,t)=>yc("post",e,n,t)},qe=e=>e instanceof Se&&e.type===na.TIMEOUT,dt=async(e={})=>{const{fraudDetectionId:n}=e,t=await Du();let r="WEB";const a=window.navigator.userAgent.toLowerCase();return t.deviceType==="MOBILE"&&(a.includes("miniprogram")?r="MINI_APP":a.includes("micromessenger")||a.includes("alipay")?r="IN_APP_WAP":Tu(a)?r="APP":r="WAP"),{user_agent:t.userAgent,color_depth:t.colorDepth,language:t.language,java_enabled:t.javaEnabled,device_type:t.deviceType,timezone_offset:t.timezoneOffset,screen_height:t.screenHeight,screen_width:t.screenWidth,cookies:t.cookies,device_os:t.osName,device_finger_print_id:t.deviceFingerprintId,terminal_type:r,fraud_detection_id:n}};function Ut(e){return{amount:e==null?void 0:e.amount,currency:e==null?void 0:e.currency,symbol:e==null?void 0:e.symbol,digits:e==null?void 0:e.default_fraction_digits}}function Be(e){var n,t;return{errorCode:e.error_code,errorMessage:e.error_description,merchantId:e.merchant_id,sessionId:e.session_id,orderId:e.order_id,transAmount:Ut(e.trans_amount),status:e.status,orderStatus:e.order_status,threeDSUrl:(n=e.authentication_result)==null?void 0:n.authentication_url,paymentUrl:(t=e.pay_info)==null?void 0:t.payment_url,paymentExpiredAt:e==null?void 0:e.payment_expire_time,payInfo:e.pay_info}}async function F0({sessionId:e,clientKey:n,bill:t},r,a){const{_getExtraParams:o}=r.config,c=o==null?void 0:o("payment",$.ALI_PAY),s=st({bill:{email:t.email,country:t.country,state:t.province,city:t.city,postal_code:t.postCode,address_line1:t.address1,address_line2:t.address2,county:t.area}},c||{});return Ne.post("/session/payments",{...s,session_id:e,client_key:n,payment:{payment_method:$.ALI_PAY},browser:await dt()},a).then(Be)}async function U0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.ALI_PAY},t).then(Be)}async function Cc({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c){const s=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},o||{});return Ne.post("/session/payments",{...s,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod,card_no:t.cardNo,exp_year:t.expYear,exp_month:t.expMonth,cvv:t.cvv,holder_name:t.holderName,store_payment_method:t.storePaymentMethod,token_usage:t.tokenUsage,token:t.token},browser:a},c).then(Be)}async function gc({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n},t).then(Be)}function vc(e=[]){const n=[],t={};return e.forEach(({value:r,configuration:a={}})=>{r===$.APPLE_PAY?t.applePay={countryCode:a==null?void 0:a.country_code,supportedNetworks:a==null?void 0:a.allowed_card_networks,merchantIdentifier:a==null?void 0:a.merchant_identifier}:r===$.GOOGLE_PAY?t.googlePay={countryCode:a==null?void 0:a.country_code,providerGatewayId:a==null?void 0:a.provider_gateway_id,merchantGatewayId:a==null?void 0:a.merchant_gateway_id,allowedAuthMethods:a==null?void 0:a.allowed_auth_methods,allowedCardNetworks:a==null?void 0:a.allowed_card_networks,environment:a==null?void 0:a.environment,googlePayMerchantId:a==null?void 0:a.merchant_id}:r===$.WECHAT_PAY?t.wechatPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:Ut(a==null?void 0:a.fee),totalAmount:Ut(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}:r===$.ALI_PAY&&(t.aliPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:Ut(a==null?void 0:a.fee),totalAmount:Ut(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}),r===$.BANKCARD?n.push(...a.allowed_card_networks||[]):n.push(r)}),{paymentMethod:n,channelParams:t}}function G0(e={}){return{goodsTax:Ut(e.goods_tax),shippingAmount:Ut(e.shipping_amount),shippingTax:Ut(e.shipping_tax),discount:Ut(e.discount),other:Ut(e.other)}}function Z0(e={}){var s,d,l;const{theme:n,bill:t,payment_methods:r,field:a}=e,o=vc(r),c=e.session_mode==="HOST"?"HOSTED":e.session_mode;return{country:e.country,merchantId:e.merchant_id,sessionId:e.session_id,status:e.status,transAmount:Ut(e.trans_amount),expireTime:e.expire_time,sessionMode:c,merchantName:(s=e.theme)==null?void 0:s.merchant_name,returnUrl:e.return_url,cancelUrl:e.cancel_url,locale:e.locale,paymentType:e.payment_type,goods:e.goods?e.goods:[],theme:{merchantName:n==null?void 0:n.merchant_name,logo:n==null?void 0:n.logo,payButtonBackgroundColor:n==null?void 0:n.pay_btn_background_color,payButtonTextColor:n==null?void 0:n.pay_btn_text_color,showPaykka:n==null?void 0:n.show_paykka},bill:{billingAddressCollection:t==null?void 0:t.billing_address_collection,addressLine1:t==null?void 0:t.address_line1,addressLine2:t==null?void 0:t.address_line2,email:t==null?void 0:t.email,descriptor:t==null?void 0:t.descriptor,country:t==null?void 0:t.country},tokens:(d=e.tokens)==null?void 0:d.map(m=>({token:m.token,last4:m.last4,cardBrand:m.card_brand,billingAddressFilled:m.billing_address_filled})),storePaymentMethod:(l=e.payment)==null?void 0:l.store_payment_method,field:{holderName:{show:!!(a!=null&&a.holder_name_display),required:!!(a!=null&&a.holder_name_required)},email:{show:!!(a!=null&&a.bill_email_display),required:!!(a!=null&&a.bill_email_required),disabled:!!(a!=null&&a.bill_email_disabled)},address:{show:!!(a!=null&&a.bill_address_display),required:!!(a!=null&&a.bill_address_required)}},amountBreakdown:G0(e.amount_breakdown),...o}}const j0=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/info",{session_id:e,client_key:n,browser:await dt()},t),Y0=async({sessionId:e,clientKey:n},t)=>{const r=await j0({sessionId:e,clientKey:n},t);return Z0({...r,...r==null?void 0:r.support_methods})};let aa;const Q0=async({sessionId:e,clientKey:n},t)=>aa||(aa=Y0({sessionId:e,clientKey:n},t));async function W0({sessionId:e,clientKey:n,bill:t,channelUserId:r},a,o){const{_getExtraParams:c}=a.config,s=c==null?void 0:c("payment",$.WECHAT_PAY),d=st({bill:{email:t.email,country:t.country,state:t.province,city:t.city,postal_code:t.postCode,address_line1:t.address1,address_line2:t.address2,county:t.area}},s||{});return Ne.post("/session/payments",{...d,session_id:e,client_key:n,payment:{payment_method:$.WECHAT_PAY},browser:await dt(),channel_user_id:r},o).then(Be)}async function z0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.WECHAT_PAY},t).then(Be)}async function K0(e){return Ne.post("/session/apple-pay/create-session",e)}async function q0({sessionId:e,clientKey:n,token:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.APPLE_PAY),l=st({bill:{first_name:r==null?void 0:r.firstName,middle_name:r==null?void 0:r.middleName,last_name:r==null?void 0:r.lastName,address_line1:r==null?void 0:r.addressLine1,address_line2:r==null?void 0:r.addressLine2,country:r==null?void 0:r.country,state:r==null?void 0:r.state,city:r==null?void 0:r.city,email:r==null?void 0:r.email,postal_code:r==null?void 0:r.postalCode,area_code:r==null?void 0:r.areaCode,phone_number:r==null?void 0:r.phoneNumber,descriptor:r==null?void 0:r.descriptor}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:$.APPLE_PAY,token_data:t},browser:a},c).then(Be)}async function J0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.APPLE_PAY},t).then(Be)}async function X0({sessionId:e,clientKey:n,token:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.GOOGLE_PAY),l=st({bill:{first_name:r==null?void 0:r.firstName,middle_name:r==null?void 0:r.middleName,last_name:r==null?void 0:r.lastName,address_line1:r==null?void 0:r.addressLine1,address_line2:r==null?void 0:r.addressLine2,country:r==null?void 0:r.country,state:r==null?void 0:r.state,city:r==null?void 0:r.city,email:r==null?void 0:r.email,postal_code:r==null?void 0:r.postalCode,area_code:r==null?void 0:r.areaCode,phone_number:r==null?void 0:r.phoneNumber,descriptor:r==null?void 0:r.descriptor}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:$.GOOGLE_PAY,token_data:t},browser:a},c).then(Be)}async function pc({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GOOGLE_PAY},t).then(Be)}async function $0({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.SEPA_DEBIT),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{iban:t.iban,payment_method:$.SEPA_DEBIT,holder_name:t.holderName},browser:a},c).then(Be)}async function e3({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n},t).then(Be)}const t3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},n3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.BOOST},t).then(Be),r3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},a3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.LINE_PAY},t).then(Be),o3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},i3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.MAY_BANK_QR_PAY},t).then(Be),c3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},s3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.NINE_PAY},t).then(Be),d3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},l3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GRAB_PAY},t).then(Be),u3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},m3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.TNG_WALLET},t).then(Be),f3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},h3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.SHOPEE_PAY},t).then(Be),y3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},C3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GCASH},t).then(Be),g3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},v3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.PAYMAYA},t).then(Be),Qr=new WeakMap;function bc(e,{time:n=70,argsResolver:t,resultResolver:r}){function a(...c){const s=Date.now();let d=Qr.get(e);d||Qr.set(e,d={items:[],firstInvokeTime:s});const l=gn();return d.items.push({args:c,invokeTime:s,promise:l}),d.items.length===1&&o(),l}function o(){setTimeout(()=>{const c=Qr.get(e);if(!c)return;Qr.delete(e);const s=t(c.items);e(...s).then(d=>{c.items.forEach((l,m)=>{l.promise.resolve(r(d,l,m,c.items))})}).catch(d=>{c.items.forEach(l=>{l.promise.reject(d)})})},n)}return a}function p3(e){return{addressItem:e==null?void 0:e.address_item,required:e==null?void 0:e.not_null,description:e==null?void 0:e.description}}async function b3(e){return Ne.get("/pub/datadict/get/COUNTRY",void 0,e).then(n=>{var r;const{values:t}=n;return((r=t==null?void 0:t.map)==null?void 0:r.call(t,a=>({label:a.display_name,value:a.value})))??[]})}async function A3(e,n){return Ne.post(`/address/style/${e}`,void 0,n).then(({address_style_list:t})=>t.map(r=>p3(r)))}const S3=bc(A3,{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}});async function w3(e,n){return Ne.post(`/address/province-dict/${e}`,void 0,n).then(t=>{var r;return(r=t==null?void 0:t.map)==null?void 0:r.call(t,({code:a,description:o})=>({label:o,value:a}))})}const E3=bc(w3,{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}});async function _3(e){return Ne.post(`/address/city-dict/${e}`).then(n=>{var t;return(t=n==null?void 0:n.map)==null?void 0:t.call(n,({code:r,description:a})=>({label:a,value:r}))})}class I3{constructor(){ln(this,sn,void 0);Ee(this,"countryOptions");Ee(this,"provinceOptions");Ee(this,"cityOptions");Ee(this,"addressState");Ee(this,"i18n");Ee(this,"addressFormat");Ee(this,"validateAllFields",!1);this.addressState={country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""},this.countryOptions=[]}setI18n({i18n:n}){this.i18n=n}async requestCountryOption(){var n,t;if(!(this.countryOptions.length!==0||(n=Ye(this,sn))!=null&&n.isPending))try{y1(this,sn,gn()),this.countryOptions=await b3({locale:this.i18n.locale}),Ye(this,sn).resolve(!0)}catch{(t=Ye(this,sn))==null||t.resolve(!1)}}async countryOptionReady(){return Ye(this,sn)}getCountryOption(){return this.countryOptions}async requestProvinceOption(n){return this.provinceOptions=await E3(n,{locale:this.i18n.locale}),this.provinceOptions}getProvinceOption(){return this.provinceOptions}async requestCityOption(){}setCountry(n){this.addressState.country=n}getCountry(){return this.addressState.country}setProvince(n){this.addressState.province=n}getProvince(){return this.addressState.province}setAddressFormat(n){this.addressFormat=n}getAddressFormat(){return this.addressFormat}getAddress1(){return this.addressState.address1}setAddress1(n){this.addressState.address1=n}getAddress2(){return this.addressState.address2}setAddress2(n){this.addressState.address2=n}getCity(){return this.addressState.city}setCity(n){this.addressState.city=n}getArea(){return this.addressState.area}setArea(n){this.addressState.area=n}getPostCode(){return this.addressState.postCode}setPostCode(n){this.addressState.postCode=n}setMap(){return{[Le.ADDRESS_1]:n=>this.setAddress1(n),[Le.ADDRESS_2]:n=>this.setAddress2(n),[Le.CITY]:n=>this.setCity(n),[Le.AREA]:n=>this.setArea(n),[Le.POST_CODE]:n=>this.setPostCode(n),[Le.PROVINCE]:n=>this.setProvince(n),COUNTRY:n=>this.setCountry(n)}}setAddressStateByKey(n,t){this.setMap()[n](t)}getAddressState(){return{country:this.addressState.country,province:this.addressState.province,city:this.addressState.city,area:this.addressState.area,postCode:this.addressState.postCode,address1:this.addressState.address1,address2:this.addressState.address2}}setAddressState(n){this.addressState.country=n==null?void 0:n.country,this.addressState.province=n==null?void 0:n.province,this.addressState.city=n==null?void 0:n.city,this.addressState.area=n==null?void 0:n.area,this.addressState.postCode=n==null?void 0:n.postCode,this.addressState.address1=n==null?void 0:n.address1,this.addressState.address2=n==null?void 0:n.address2}getValidateAllFields(){return this.validateAllFields}setValidateAllFields(n){this.validateAllFields=n}getCityOptions(){return this.cityOptions}setCityOptions(n){this.cityOptions=n}getLabel(n,t){var r;return Dt(n)?null:fn(t)&&t.length>0?((r=t.find(a=>a.value===n))==null?void 0:r.label)??null:null}}sn=new WeakMap;let oa;const bt=()=>oa||(oa=new I3);function Ie(e){return Bu(`${R1}-${e}`)}function lt(e){const n=$n(tt),[t]=M((n==null?void 0:n.i18n)??new Gr);return e&&t.load(e),{i18n:t}}function ut(e,n){const[t,r]=M(!1),[a,o]=M(""),[c,s]=M(!1),[d,l]=M(null),{i18n:m}=lt();return ce(()=>{e.ready().then(()=>{var h;s(!0);const u=b0(sc||((h=e.checkout)==null?void 0:h.locale)||nn().language);m.load(u);const y=V0(ic,void 0,{onEvent:w=>{var v,b;(b=n==null?void 0:(v=n.config).onEvent)==null||b.call(v,w)}});l(y),y==null||y.createFraudDetection()})},[]),{validated:t,setValidated:r,errorMsg:a,setErrorMsg:o,i18n:m,fraudDetection:d,sessionReady:c}}function nt(e,{timeout:n=20*1e3,interval:t=2*1e3,onTimeout:r,onEnd:a}){const o=j(null);ce(()=>s,[]);function c(d={}){return new Promise(l=>{d={timeout:n,interval:t,...d};const m=Date.now(),u=async()=>{if(!o.current){s();return}const y=Date.now(),h=await e(nr(y-m,0,d.timeout));o.current&&(h.end?(a==null||a(h.res),l(h)):y-m>d.timeout?r==null||r():o.current=window.setTimeout(u,d.interval))};o.current=window.setTimeout(u,d.interval)})}function s(){o.current&&(clearTimeout(o.current),o.current=null)}return{start:c,stop:s}}const ia={xs:480,sm:928,md:992,lg:1200,xl:1366,xxl:1600},Ac=()=>{const[e,n]=M(()=>typeof window<"u"?window.innerWidth:0);ce(()=>{if(typeof window>"u")return;const c=()=>{n(window.innerWidth)};return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]);const t=It(()=>Object.entries(ia).sort((c,s)=>c[1]-s[1]),[ia]),{matches:r,current:a}=It(()=>{const c={xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1};let s=null;for(let d=t.length-1;d>=0;d--){const[l,m]=t[d],u=e>=m;c[l]=u,u&&!s&&(s=l)}return{matches:c,current:s}},[e,t]);return{matches:r,current:a,smaller:c=>{const s=ia[c];return s===void 0?!1:e<s}}},ca=Ie("form-item"),Kt=ca.bem("label"),Sc=ca.bem("error-text"),sa=Ar(null),wc=Ar(null);function Ec(e,n){return n?(fn(e.trigger)?e.trigger:[e.trigger]).includes(n):!0}function P3(e,n){if(!e)return;if(fn(e))return e.filter(r=>Ec(r,n));const t=h0(e,Ec(e,n));return t?[t]:[]}function _c(e){if(e=e.filter(n=>n.status==="error"),!!e.length)return e.reduce((n,t)=>{const r=Object.keys(t.fields).at(-1);return Hi(n,r,t.fields[r]),n},{})}const R3=e=>Dt(e)||e==="",mt=Ve((e,n)=>{const{label:t,path:r,children:a,triggersOfEmptyValue:o=["submit"],onValidationStatusChange:c,className:s,style:d,showErrorMessage:l=!0,showLabel:m=!0}=e;Oe(n,()=>({validate:b,validateChange:P,getValidateResult:w,resetValidation:p}));const u=$n(wc),[y,h]=M({status:"unValidate",errors:[],fields:{}});function w(){return y}function v(C){h(C),C.status!==y.status&&(c==null||c(C.status))}async function b(C,{trigger:S,setResult:R=!0}){return R3(C)&&!o.includes(S)?p():new Promise(async k=>{const A=P3(e.rule,S);if(!r||!(A!=null&&A.length)){k(y);return}const N=[],Y={};for(const F of A){const{validator:x}=F;if(x)try{await x(C)||(N.push({message:void 0,fieldValue:C,field:r}),Y[r]=N)}catch(U){N.push({message:U.message,fieldValue:C,field:r}),Y[r]=N}}let B={status:"unValidate",errors:N,fields:Y};N.length?(B.status="error",R&&v(B)):R?B=p("success"):B.status="success",k(B)})}function p(C="unValidate",S=[]){const R={status:C,errors:C==="error"?S:[],fields:{}};return v(R),R}async function _(C){return await b(C,{trigger:"blur"})}async function P(C){return await b(C,{trigger:"change"})}function g(C){r&&(u==null||u.setForm(S=>(S={...S},Hi(S,r,C),S)))}function I(){var C;return(C=y.errors)==null?void 0:C[0]}return ce(()=>{const C={internalValidate:b,path:r,resetValidation:p};return r&&(u==null||u.setFormItems(S=>[...S,C])),()=>{r&&(u==null||u.setFormItems(S=>S.filter(R=>R!==C)))}},[]),i("div",{className:fe(he,ca.bem(),s),style:d,children:[m&&!Dt(t)&&i("div",{className:Kt,children:t}),i(sa.Provider,{value:{rule:e.rule,validateBlur:_,validateChange:P,resetValidation:p,validationResult:y,setValue:g},children:a}),l&&y.status==="error"&&i("div",{className:Sc,children:I().message})]})}),At=Ve((e,n)=>{const{children:t}=e;Oe(n,()=>({validate:d,resetValidation:m,validateField:l}));const[r,a]=M(e.form),[o,c]=M([]);function s(u,y){if(!P1(u)||!hn(y))return;const h=y.split(".");return h.length===0?u[y]:h.reduce((w,v)=>w&&w[v],u)}async function d(u,y=!0){const h=await Promise.all(o.map(v=>{const b=s(r,v.path);return v.internalValidate(b,{trigger:"submit",setResult:y})})),w=_c(h);if(w)throw u&&(u==null||u(w)),w;u&&(u==null||u())}async function l(u,y,h=!0){const w=o.filter(p=>u.includes(p.path)),v=await Promise.all(w.map(p=>{const _=s(r,p.path);return p.internalValidate(_,{trigger:"submit",setResult:h})})),b=_c(v);if(b)throw y&&(y==null||y(b)),b;y&&(y==null||y())}function m(){o.forEach(u=>{var y;(y=u.resetValidation)==null||y.call(u)})}return ce(()=>{var u;(u=e.onFormChange)==null||u.call(e,r)},[r]),i(wc.Provider,{value:{form:r,setForm:a,formItems:o,setFormItems:c},children:t})}),Sn=Ie("input"),an=Sn.bem("input-wrapper"),N3={error:Vo,success:Qd},ht=Ve((e,n)=>{const{inputClassName:t,style:r,disabled:a,children:o,showStatus:c=!0}=e;Oe(n,()=>({input:u.current,focus:()=>{l(!0)},blur:()=>{l(!1)},valid:()=>{s==null||s.resetValidation("success")},invalid:g=>{s==null||s.resetValidation("error",[{message:g}])}}));const s=$n(sa),[d,l]=M(!1);let m=!1;const u=j(null);let y=e.status??(s==null?void 0:s.validationResult.status);y==="unValidate"&&(y=void 0);let{rightIcon:h}=e;if(c&&y){const g=N3[y];h=i(g,{size:16})}function w(g){var I;l(!0),(I=e.onFocus)==null||I.call(e,g)}function v(g){var C;l(!1),(C=e.onBlur)==null||C.call(e,g);const{value:I}=g.currentTarget;s==null||s.validateBlur(I)}function b(g){var C;if(g instanceof InputEvent&&!g.isComposing&&(m=!1),m)return;const{value:I}=g.target;g instanceof InputEvent&&g.inputType==="insertCompositionText"||((C=e.onInput)==null||C.call(e,g),s==null||s.setValue(I),s==null||s.validateChange(I))}const p=rc(()=>{const g=Sn.bem("input-wrapper",[y,{focus:d}]),I=Sn.bem("input-wrapper-disabled");return a?`${g} ${I}`:`${g}`});function _(g){var I;m=!0,(I=e.onCompositionStart)==null||I.call(e,g)}function P(g){m=!1,b(g)}return i("div",{className:fe(he,Sn.bem(),t),onClick:()=>{var g;return(g=u.current)==null?void 0:g.focus()},children:i("div",{className:`${p}`,style:r,children:[!!e.leftIcon&&i("div",{class:Sn.bem("left-icon"),children:e.leftIcon}),o||i("input",{ref:u,...e,class:Sn.bem("input"),onFocus:w,onBlur:v,onInput:b,onCompositionStart:_,onCompositionEnd:P,autocomplete:"off"}),!!h&&i("div",{class:Sn.bem("right-icon"),children:h})]})})}),{bem:k3}=Ie("select");function L3(e){const{style:n,children:t}=e;return i("div",{style:n,class:k3("menu"),children:t})}const{bem:Ic}=Ie("select");function T3(e){const{onSelect:n,...t}=e,{label:r}=t;function a(o){o.stopPropagation(),n==null||n({...t})}return i("div",{onClick:o=>a(o),class:Ic("menu-item",[{selected:e.selected}]),children:[Bo(r)?r(e,e.selected):r,e.selected&&i("div",{class:Ic("menu-item-icon"),children:qd({})})]})}const{bem:da}=Ie("select"),Wr=Ve((e,n)=>{const t=$n(sa);e.status??(t==null||t.validationResult.status);const[r,a]=M(!1),[o,c]=M(!1),[s,d]=M([]),[l,m]=M(),[u,y]=M(),[h,w]=M(),v=j(null),[b,p]=M(!1),[_,P]=M(!1);It(()=>{if(d(e.options??[]),!Dt(e.value)&&e.options.length>0){const U=g(e.value,e.options);U&&k(U,!1)}},[e.value,e.options]),ce(()=>{if(e.renderLabel)return;const U=Dt(h)||h==="";if(P(!U),U)d(e.options);else{const Q=e.options.filter(W=>W.label.toLowerCase().includes(h.toLowerCase()));d(Q)}},[h]),Oe(n,()=>({blur:()=>{var U,Q;p(!1),c(!1),(Q=(U=v.current)==null?void 0:U.input)==null||Q.blur()}}));function g(U,Q){for(let W=0;W<Q.length;W++){const J=Q[W];if(J.value===U)return J}}function I(U){var Q;p(!0),a(!0),(Q=e.onFocus)==null||Q.call(e,U)}function C(){var U,Q;(Q=(U=v.current)==null?void 0:U.input)==null||Q.focus()}function S(U){var Q;if(a(!1),(Q=e.onBlur)==null||Q.call(e,U),(Dt(h)||h==="")&&c(!1),s.length===0&&e.options.length!==0)w(""),c(!1);else{const{value:W}=U.currentTarget;t==null||t.validateBlur(W)}}function R(U){c(!0),w(U.currentTarget.value)}function k(U,Q=!0){var te,ve;const{value:W,label:J}=U;w(""),y(W),m(((te=e.renderLabel)==null?void 0:te.call(e,U))||J),p(!1),c(!1),Q&&((ve=e==null?void 0:e.onSelect)==null||ve.call(e,W,U))}function A(U){c(!0),w(U.currentTarget.value)}let N,Y;document.addEventListener("mousedown",U=>{N=U}),document.addEventListener("mouseup",U=>{Y=U,B(Y,N)});function B(U,Q){var K,z;if(!F.current)return;const W=U==null?void 0:U.target,J=Q==null?void 0:Q.target,te=((K=F.current)==null?void 0:K.contains(W))||((z=F.current)==null?void 0:z.contains(J)),ve=F.current===W;te||ve||p(!1)}const F=dd(),x=Kd({style:{transform:b?"rotate(-180deg)":"rotate(0deg)",transition:"transform 0.3s ease"}});return i("div",{class:da("wrapper"),ref:F,onClick:()=>{var U,Q;return(Q=(U=v.current)==null?void 0:U.input)==null?void 0:Q.focus()},children:[i(ht,{ref:v,value:h,readOnly:!e.filterable,onInput:R,onFocus:I,onBlur:S,onChange:A,onCompositionStart:()=>c(!0),placeholder:r||o||!Dt(u)?"":e.placeholder,rightIcon:e.rightIcon||x,inputClassName:e.inputClassName}),i("div",{class:da("render-label",[{placeholder:r,hidden:o}]),onClick:C,children:l}),i(L3,{style:{display:b?"block":"none"},children:[_&&s.length===0?i("div",{class:da("menu-no-data"),children:e.noDataTip}):s.map(U=>i(T3,{onSelect:k,selected:u===U.value,...U,label:e.renderLabel?()=>{var Q;return(Q=e.renderLabel)==null?void 0:Q.call(e,U)}:U.label})),e.action]})]})}),{bem:la}=Ie("address-field"),M3={country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""},kt=Ve((e,n)=>{const{onAddressChange:t}=e,{i18n:r}=lt(),a=bt(),[o,c]=M({...a.getAddressState()}),[s,d]=M(a.getCountryOption()??[]),[l,m]=M(a.getProvinceOption()??[]),[u,y]=M([]),[h,w]=M(a.getAddressFormat()),v=j(null),b=j(null),p=j(null),_=j(null),P=j(null),g=j(null),I=j(null);It(()=>{r.ready.value&&(a.setI18n({i18n:r}),a.requestCountryOption(),a.countryOptionReady().then(()=>{N(),d(a.getCountryOption())}))},[r.ready.value]);const C={[Le.ADDRESS_1]:D=>{c(Object.assign(o,{address1:D}))},[Le.ADDRESS_2]:D=>{c(Object.assign(o,{address2:D}))},[Le.CITY]:D=>{c(Object.assign(o,{city:D}))},[Le.AREA]:D=>{c(Object.assign(o,{area:D}))},[Le.POST_CODE]:D=>{c(Object.assign(o,{postCode:D}))},[Le.PROVINCE]:D=>{c(Object.assign(o,{province:D}))},COUNTRY:D=>{c(Object.assign(o,{country:D}))}};function S(D,G){C[D](G)}function R(D,G){S(D,G),a.setAddressStateByKey(D,G)}function k(D){w(D),a.setAddressFormat(D)}Oe(n,()=>({update:D=>{c(D),a.setAddressState(D),k(a.getAddressFormat()),m(a.getProvinceOption()??[]),y(a.getCityOptions()??[])}}));function A(D){D.map(G=>{S(G,""),a.setAddressStateByKey(G,"")})}async function N(){const D=e.country;F(D||""),t({country:o.country??"",province:o.province??"",city:o.city??"",area:o.area??"",postCode:o.postCode??"",address1:o.address1??"",address2:o.address2??""})}const Y={[Le.ADDRESS_1]:ve,[Le.ADDRESS_2]:K,[Le.CITY]:pe,[Le.AREA]:Ce,[Le.POST_CODE]:z,[Le.PROVINCE]:O};function B(){return{trigger:["blur","submit"],validator(D){if(!D)throw new Error;return!0}}}async function F(D){k([]),R("COUNTRY",D);const G=await S3(D,{locale:r.locale}),re=[],be=G.map(({addressItem:me,required:f,description:E})=>(re.push(me),{addressItem:me,required:f,description:E}));x(re,D),k(be),A([Le.PROVINCE,Le.CITY,Le.AREA,Le.POST_CODE,Le.ADDRESS_1,Le.ADDRESS_2]),y([]),a.setCityOptions([]),t({...M3,country:D})}async function x(D,G){if(D.includes(Le.PROVINCE)){U(G);return}if(!D.includes(Le.PROVINCE)&&D.includes(Le.CITY)){W(G);return}}async function U(D){a.requestProvinceOption(D).then(G=>{m(G)})}async function Q(D){var G;R(Le.PROVINCE,D),W(D),A([Le.CITY]),(G=p.current)==null||G.validateChange(""),t({country:o.country??"",province:D,city:"",postCode:o.postCode,address1:o.address1,address2:o.address2,area:o.area})}async function W(D){const G=await _3(D);if(G)return y(G),a.setCityOptions(G),G}function J(D){R(Le.CITY,D),t({country:o.country??"",province:o.province??"",city:D,postCode:o.postCode??"",address1:o.address1??"",address2:o.address2??"",area:o.area})}function te(){return i(mt,{ref:v,label:r.get("address.label"),path:"address.country",rule:B(),showErrorMessage:!1,children:i(Wr,{value:o.country,filterable:!0,options:s,onSelect:D=>F(D),placeholder:r.get("address.country"),inputClassName:la("first-item"),noDataTip:r.get("common.noData")})})}function ve({description:D,className:G}){return i(mt,{ref:g,path:"address.address1",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.address1,onInput:re=>R(Le.ADDRESS_1,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.address1")}function K({description:D,className:G}){return i(mt,{ref:I,path:"address.address2",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.address2,onInput:re=>R(Le.ADDRESS_2,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.address2")}function z({description:D,className:G}){return i(mt,{ref:P,path:"address.postCode",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.postCode,onInput:re=>R(Le.POST_CODE,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.postCode")}function Ce({description:D,className:G}){return i(mt,{ref:_,path:"address.area",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.area,onInput:re=>R(Le.AREA,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.area")}function pe({description:D,className:G}){return i(mt,{ref:p,path:"address.city",rule:B(),showErrorMessage:!1,children:fn(u)&&u.length>0?i(Wr,{value:o.city,filterable:!0,options:u,onSelect:re=>J(re),placeholder:D,inputClassName:G,noDataTip:r.get("common.noData")}):i(ht,{value:o.city,onInput:re=>R(Le.CITY,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.city")}function O({description:D,className:G}){return i(mt,{ref:b,path:"address.province",rule:B(),showErrorMessage:!1,children:fn(l)&&l.length>0?i(Wr,{value:o.province,filterable:!0,options:l,onSelect:re=>Q(re),placeholder:D,inputClassName:G,noDataTip:r.get("common.noData")}):i(ht,{value:o.province,onInput:re=>R(Le.PROVINCE,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.province")}function ee(D){const G=h==null?void 0:h.length;return Dt(G)||G===1?"":D===G-1?la("last-item"):la("mid-item")}return i("div",{style:"width: 100%",children:[te(),h==null?void 0:h.map((D,G)=>Y[D.addressItem]({description:D.description,className:ee(G)}))]})});class D3{constructor(n){Ee(this,"_email");Ee(this,"_isValid",!1);this._email=n??""}get email(){return this._email}set email(n){this._email=n}get isValid(){return this._isValid}set isValid(n){this._isValid=n}}let ua;const St=e=>ua||(ua=new D3(e)),Lt=Ve((e,n)=>{const{className:t,style:r,disabled:a}=e,{i18n:o}=lt(),[c,s]=M(""),d=j(null),l=St(e.value??"");Oe(n,()=>({update:h=>{var w;m(h),(l.isValid||Od(h))&&((w=d.current)==null||w.validate(h,{trigger:"submit",setResult:!0}))}})),ce(()=>{m(e.value)},[e.value]);const m=h=>{l.email=h??"",s(h??"")},u={trigger:["blur","submit"],validator(h){if(!h)throw new Error(o.get("common.email.incomplete"));if(!new RegExp(f0).test(h))throw new Error(o.get("common.email.incorrect"));return!0}},y=h=>{var v;const{currentTarget:w}=h;m(w.value),(v=e.onInput)==null||v.call(e,h)};return i(mt,{ref:d,label:o.get("common.email.label"),path:"email",rule:u,className:t,style:r,children:i(ht,{value:c,disabled:a,maxLength:100,onInput:y})})}),{bem:ma}=Ie("info"),B3={error:Vo};function yt(e){const{type:n="error",content:t,className:r,style:a}=e,o=B3[n];return i("div",{className:fe(he,ma([n]),r),style:a,children:[i("div",{className:ma("icon"),children:i(o,{size:16})}),i("div",{className:ma("content"),children:t})]})}const{bem:Pc}=Ie("recurring-tip");function fa(){return i(tt.Consumer,{children:e=>{var n;return i("div",{className:Pc(),children:[i("div",{className:Pc("icon"),children:zd({size:16})}),i("div",{children:(n=e==null?void 0:e.i18n)==null?void 0:n.get("common.recurringTip")})]})}})}const{bem:Rc}=Ie("button");function ha(e){const{style:n,className:t,children:r,icon:a,loading:o,disabled:c,dashed:s}=e;function d(l){var m;o||c||(m=e.onClick)==null||m.call(e,l)}return i("button",{className:fe(he,Rc({loading:o,disabled:c,dashed:s}),t),style:n,onClick:d,children:[!!a&&i("div",{className:Rc("icon"),children:a}),r]})}const ya=40,V3=`0 0 ${ya} ${ya}`,Nc=3.3,kc=ya/2-Nc-.5,Lc=2*Math.PI*kc,x3=3.2,{bem:Ca}=Ie("loading-check");function H3({color:e="currentColor",checkedColor:n="currentColor",checked:t=!1,size:r,className:a,style:o,onCheckShow:c}){const[s,d]=M(75),[l,m]=M(!1),[u,y]=M(!1),h=Pe(r)?"1em":`${r}px`,v={strokeDasharray:`${Lc*(s/100)} ${Lc}`,animationPlayState:l?"running":"paused"};t?(d(100),m(!1)):(y(!0),m(!0),d(75));function b(){y(!1),c==null||c()}return i("div",{className:fe(he,Ca(),a),style:Xu({width:h,height:h},o),children:i("svg",{width:h,height:h,viewBox:V3,children:[u&&i("circle",{className:Ca("circle",["loading"]),cx:"50%",cy:"50%",r:kc,fill:"none",stroke:e,"stroke-width":Nc,"stroke-linecap":"round",style:v}),t&&i("polyline",{className:Ca("check"),points:"8.5,20 18.2,29.5 31.5,10.5",fill:"none",stroke:n,"stroke-width":x3,"stroke-linecap":"round","stroke-linejoin":"miter",onAnimationStart:b})]})})}const{bem:Tc}=Ie("submit-button"),wt=e=>{const{text:n=ar["common.pay"],loadingText:t=ar["common.payProcessing"],successText:r=ar["common.paySuccess"],status:a="unSubmit",onClick:o,className:c,style:s,icon:d=Yd}=e,[l,m]=M(n),u=()=>a==="unSubmit"?i(d,{size:20,disabled:!e.verified}):i(H3,{checked:a==="success",size:20,onCheckShow:()=>m(r)});return ce(()=>{a!=="success"&&m(a==="loading"?t:n)},[a,n]),i(ha,{icon:u(),onClick:o,className:fe(Tc({success:a==="success"}),c),style:s,loading:a==="loading",disabled:e.disabled||a==="success",children:i("span",{class:Tc("text",{"not-verified":!e.verified}),children:l})})},{bem:zr}=Ie("ali-pay"),O3=Ve((e,n)=>{var F,x,U,Q,W,J,te,ve;const{session:t}=e,r=bt(),a=St(),{setErrorMsg:o,i18n:c,errorMsg:s,sessionReady:d}=ut(t,e.core),[l,m]=M("unSubmit"),u=j(null),[y,h]=M({email:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[w,v]=M(!1),b=j(!1),[p,_]=M(!1),P=j(null),g=j(null);Oe(n,()=>({stopRetry:()=>{R(),m("unSubmit")},startRetry:K=>{m("loading"),S({timeout:K})},updateAddress:()=>{var K;h(Object.assign(y,{address:r.getAddressState()})),(K=P.current)==null||K.update(r.getAddressState())},updateEmail:()=>{var K;h(Object.assign(y,{email:a.email})),(K=g.current)==null||K.update(a.email)}}));function I(){var K;(K=u.current)==null||K.validate(void 0,!1).then(()=>{v(!0)}).catch(()=>{v(!1)})}ce(()=>{I()},[y]),ce(()=>{var K;d&&((t==null?void 0:t.checkout.status)==="SUCCESS"&&(m("success"),(K=e.onSuccess)==null||K.call(e)),y.email=(t==null?void 0:t.checkout.bill.email)??"",b.current=!!(t!=null&&t.checkout.bill.email),(t==null?void 0:t.checkout.bill.billingAddressCollection)==="REQUIRED"?_(!0):_(!1),!p&&setTimeout(()=>{I()},100))},[d]);const C=$e(K=>{var z;o(K||c.get("common.payTimeout")),m("unSubmit"),(z=e.onTimeout)==null||z.call(e,"retry")},[c,e.onTimeout]),{start:S,stop:R}=nt(K=>k(!0,K),{onTimeout:()=>C(c.get("common.queryTimeout"))});async function k(K=!1,z){var Ce,pe,O,ee,D,G,re;try{const be=K?await U0({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale,timeout:z}):await F0({sessionId:t.sessionId,clientKey:t.clientKey,bill:p?{email:y.email,...y.address,province:r.getLabel(y.address.province,r.getProvinceOption())??y.address.province,city:r.getLabel(y.address.city,r.getCityOptions())??y.address.city}:{email:y.email}},e.core,{locale:c.locale,timeout:z}),{status:me,orderStatus:f,errorMessage:E,errorCode:H}=be;if(!K&&((Ce=e.onSubmitResponse)==null||Ce.call(e,be)),me==="PROCESSING")if(f){if(f==="SUCCESS")return m("success"),(pe=e.onSuccess)==null||pe.call(e),{end:!0};if(f==="FAILURE")return o(E),m("unSubmit"),(O=e.onError)==null||O.call(e,new Se("API_ERROR",E,{code:H})),{end:!0};if(f==="PROCESSING")return!K&&S(),{end:!1};if(f==="CANCELED")return m("unSubmit"),(ee=e.onTimeout)==null||ee.call(e,"channel"),{end:!0}}else return m("unSubmit"),{end:!0};else{if(me==="SUCCESS")return m("success"),(D=e.onSuccess)==null||D.call(e),{end:!0};if(me==="EXPIRED")return m("unSubmit"),(G=e.onExpired)==null||G.call(e),{end:!0}}return m("unSubmit"),{end:!0}}catch(be){if(qe(be))return K?{end:!1}:(C(),{end:!0});{const me=be.i18nKey?c.get(be.i18nKey):be.message;return o(me),(re=e.onError)==null||re.call(e,new Se("API_ERROR",me,{code:be.code,cause:be})),m("unSubmit"),{end:!0}}}}async function A(){var K;o(""),(K=u.current)==null||K.validate(async z=>{var Ce;if(p&&r.setValidateAllFields(!0),(Ce=e.onSubmit)==null||Ce.call(e,z),z){m("unSubmit");return}o(""),m("loading"),await k()})}const N=()=>{const{transAmount:K,channelParams:z={}}=(t==null?void 0:t.checkout)??{},{totalAmount:Ce}=z.aliPay??{},pe=(Ce!=null&&Ce.amount?Ce:K)||{},O=pe!=null&&pe.amount?pt(pe).jointSymbol():"",ee=c.get("common.pay")+(O?` ${O}`:"");return i(wt,{className:zr("button"),status:l,text:ee,loadingText:c.get("common.payProcessing"),successText:c.get("common.paySuccess"),onClick:A,verified:w})},Y=K=>{u.current=K,K&&I()},B={[ae("button-bg-color")]:(F=t==null?void 0:t.colors)==null?void 0:F.primary,[ae("button-bg-color-hover")]:(x=t==null?void 0:t.colors)==null?void 0:x.primaryHover,[ae("button-bg-color-active")]:(U=t==null?void 0:t.colors)==null?void 0:U.primaryActive,[ae("button-text-color")]:(W=(Q=t==null?void 0:t.checkout)==null?void 0:Q.theme)==null?void 0:W.payButtonTextColor,[ae("input-color")]:(J=t==null?void 0:t.colors)==null?void 0:J.primary};return i(tt.Provider,{value:{i18n:c,session:t},children:d&&c.ready.value&&i(At,{form:y,ref:Y,onFormChange:K=>h(K),children:i("div",{className:fe(he,zr()),style:B,children:[i(Lt,{ref:g,className:zr("email"),value:y.email,disabled:!!b.current}),p&&i(kt,{ref:P,value:y.address,country:((te=t==null?void 0:t.checkout)==null?void 0:te.country)||((ve=t==null?void 0:t.checkout)==null?void 0:ve.bill.country),onAddressChange:K=>h(Object.assign(y,{address:K}))}),(t==null?void 0:t.checkout.paymentType)===yn.RECURRING&&fa(),!!s&&i(yt,{className:zr("error"),content:s}),N()]})})})}),{bem:Mc}=Ie("card-brands");function Dc(e){const{supportedCardBrands:n,max:t=6,className:r,style:a}=e,o=j(null),[c,s]=M(0),d=Er(n).map(y=>T1(y)),l=d.length-t,m=d.slice(t-1),u=m[c];return ce(()=>(o.current=window.setInterval(()=>{s(y=>{const h=y+1,w=m.length;return h===w?0:nr(h,0,w-1)})},3e3),()=>{o.current&&(window.clearInterval(o.current),o.current=null)}),[]),i("div",{className:fe(he,Mc(),r),style:a,children:[d.slice(0,t-1).map(y=>y.icon&&i(y.icon,{size:32},y.code)),!!(u!=null&&u.icon)&&i(u.icon,{size:32},u.code),l>0&&i("div",{className:Mc("more"),children:["+",l]})]})}const ga=Ve((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,c=j(null),s=j(null);Oe(n,()=>({input:c.current,focus:()=>{var h;(h=c.current)==null||h.focus()},blur:()=>{var h;(h=c.current)==null||h.blur()},resetValidation:(h,w)=>{var v;(v=s.current)==null||v.resetValidation(h,[{message:w}])}}));const{i18n:d}=lt(),[l,m]=M(""),u={trigger:["blur","submit"],validator(h){if(a){const w=s.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Pe(h)||h.length!==5)throw new Error(d.get("card.cardExpireDate.incomplete"));if(zi(h))throw new Error(d.get("card.cardExpireDate.expired"));return!0}};function y(h){var _,P,g,I;const{inputType:w,currentTarget:v}=h,b=v.selectionStart;let p;if(w==="insertText"){const{data:C}=h;p=vn(v.value);const S=p.length;S===1&&+p>1?p=`0${p}`:S===2&&(+p>12?p=`01${C}`:p=`${p}`),S>=2&&!p.includes("/")&&(p=p.slice(0,2)+"/"+p.slice(2,4))}else{p=v.value;const C=l.slice(b,b+1),S=l.length;if(S>3&&C==="/"){m(v.value=l),v.setSelectionRange(b,b),(_=e.onInput)==null||_.call(e,h);return}else if(b===1){const R=l.slice(0,2);S>2&&+R>=10?p=`01${l.slice(2,S)}`:p=p.slice(0,1)}else if(b===0&&p.length>1){C==="0"?m(v.value=l):C==="1"&&m(v.value=`0${p}`),v.setSelectionRange(0,0),(P=e.onInput)==null||P.call(e,h);return}else if(b===3)if(S===4)p=p.slice(0,2);else{m(v.value=p),v.setSelectionRange(b-1,b-1),(g=e.onInput)==null||g.call(e,h);return}}m(v.value=p),w!=="insertText"&&v.setSelectionRange(b+1,b+1),(I=e.onInput)==null||I.call(e,h)}return i(mt,{label:d.get("card.cardExpireDate.label"),showLabel:o,path:"expireDate",ref:s,rule:u,className:t,style:r,children:i(ht,{type:"text",inputmode:"numeric",ref:c,maxLength:5,value:l,onInput:y,placeholder:d.get("card.cardExpireDate.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.EXPIRE_DATE})})})});function Bc(e){const{className:n,style:t,disabled:r}=e,{i18n:a}=lt(),o={trigger:["blur","submit"],validator(s){if(!s)throw new Error(a.get("card.cardHolderName.incomplete"));return!0}};function c(s){var d;(d=e.onInput)==null||d.call(e,s)}return i(mt,{label:a.get("card.cardHolderName.label"),path:"holderName",rule:o,className:n,style:t,children:i(ht,{maxLength:100,placeholder:a.get("card.cardHolderName.placeholder"),onInput:c,disabled:r})})}const va=Ve((e,n)=>{const{supportedCardBrands:t=[],className:r,security:a,showLabel:o,onBinValue:c}=e,s=j(null),d=j(null);Oe(n,()=>({input:s.current,focus:()=>{var k;(k=s.current)==null||k.focus()},blur:()=>{var k;(k=s.current)==null||k.blur()},resetValidation:(k,A)=>{var N;(N=d.current)==null||N.resetValidation(k,[{message:A}])},binValueChanged:k=>{u(k)},binValue:()=>m,brandChanged:k=>{if(k){const A=M1(k);p(()=>A==null?void 0:A.icon),P(A==null?void 0:A.code)}else p(void 0),P(void 0)},getCardBrand:()=>_r(Ft(m),w)||{code:_}}));const{i18n:l}=lt(),[m,u]=M(""),[y,h]=M(""),w=Er(t),v=Uo(w),[b,p]=M(void 0),[_,P]=M(void 0),[g,I]=M("");ce(()=>{const k=Ft(m);p(m?()=>{var N;return(N=_r(k,w))==null?void 0:N.icon}:void 0);const A=k.substring(0,6);I(A.length<6?"":A)},[m]),ce(()=>{c==null||c(g)},[g]);const C={trigger:["blur","submit"],validator(k){if(a){const N=d.current.getValidateResult();if(N.status==="error")throw new Error(N.errors[0].message);if(N.status==="success")return!0}if(k=Ft(k??""),!v.includes(k.length))throw new Error(l.get("card.cardNumber.incomplete"));if(!_r(k,w))throw new Error(l.get("card.cardNumber.invalid"));return!0}};function S(k){var x;const{currentTarget:A,inputType:N}=k,Y=A.selectionStart;let B=vn(A.value);B=B.replace(/(\d{4})(?=\d)/g,"$1 ");let F=Y;F%5===0&&(F=nr(Y+(N==="insertText"?1:-1),0)),u(A.value=B),A.setSelectionRange(F,F),(x=e.onInput)==null||x.call(e,k)}const R=()=>{if(y!=="error")return i(b??L1,{size:32})};return i(mt,{label:l.get("card.cardNumber.label"),showLabel:o,path:"number",ref:d,rule:C,onValidationStatusChange:h,className:r,children:i(ht,{type:"text",inputmode:"numeric",ref:s,maxLength:23,value:m,onInput:S,rightIcon:R(),placeholder:l.get("card.cardNumber.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.CARD_NUMBER})})})}),Kr=Ve((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,c=j(null),s=j(null);Oe(n,()=>({input:c.current,focus:()=>{var h;(h=c.current)==null||h.focus()},blur:()=>{var h;(h=c.current)==null||h.blur()},resetValidation:(h,w)=>{var v;(v=s.current)==null||v.resetValidation(h,[{message:w}])}}));const{i18n:d}=lt(),[l,m]=M(""),u={trigger:["blur","submit"],validator(h){if(a){const w=s.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Pe(h)||h.length<3)throw new Error(d.get("card.cardSecurityCode.incomplete"));return!0}};function y(h){var v;const w=vn(h.currentTarget.value);m(h.currentTarget.value=w),(v=e.onInput)==null||v.call(e,h)}return i(mt,{label:d.get("card.cardSecurityCode.label"),showLabel:o,path:"securityCode",ref:s,rule:u,className:t,style:r,children:i(ht,{type:"text",inputmode:"numeric",ref:c,maxLength:4,value:l,onInput:y,placeholder:d.get("card.cardSecurityCode.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.CVV})})})}),{bem:pa}=Ie("card-no"),Vc=e=>{const{value:n,className:t,style:r}=e;return i("div",{className:fe(he,pa("wrapper"),t),style:r,children:[Array.from({length:4},(a,o)=>o).map(()=>i("span",{className:pa("dot")})),i("span",{className:pa("card-no"),children:n})]})},xc=e=>{const{cardList:n=[],onCardChange:t,onClickEdit:r,className:a,style:o,onClickChange:c,value:s}=e,{i18n:d}=lt(),{bem:l}=Ie("card-selector"),m=j(null),u=j(null),y={trigger:["blur","submit"],validator(){return!0}},h=()=>n.map(g=>({label:"",value:g.token,...g})),[w,v]=M(s);ce(()=>{if(s){const g=h().find(({token:I})=>s===I);b(s,g)}},[s]);const b=(g,I)=>{v(g),t==null||t(I)},p=g=>{var C;const I=((C=M1(g.cardBrand))==null?void 0:C.icon)??L1;return i("div",{className:l("label"),children:[i(I,{size:32}),i("div",{className:l("card-no"),children:i(Vc,{value:g.last4})}),i("span",{})]})},_=()=>i("div",{className:l("change"),onClick:c,children:[i(xo,{}),i("span",{style:{marginLeft:"4px"},children:d.get("card.cardSelector.change")})]}),P=()=>{const g=()=>{var I;(I=m.current)==null||I.blur(),r==null||r()};return i("div",{className:l("action"),children:i(ha,{style:{borderRadius:"6px",fontSize:"14px"},dashed:!0,icon:i(Jd,{}),onClick:g,children:d.get("card.cardSelector.useOtherCard")})})};return i(mt,{label:d.get("card.cardNumber.label"),path:"token",rule:y,className:a,style:o,ref:u,children:i(Wr,{value:w,ref:m,options:h(),renderLabel:p,onSelect:b,noDataTip:d.get("common.noData"),action:P(),rightIcon:_()})})};function F3({size:e,style:n,className:t}){const r=Pe(e)?"1em":`${e}px`;return i("svg",{width:r,height:r,viewBox:"0 0 8 7",fill:"#fff",xmlns:"http://www.w3.org/2000/svg",style:n,className:fe(he,t),children:i("g",{children:i("g",{id:"_图层_1","data-name":"图层_1",children:i("path",{class:"cls-1",d:"M7.4.9c-.2-.2-.5-.2-.7,0l-3.8,3.9-1.3-1.3c-.2-.2-.5-.2-.7,0l-.4.4c-.2.2-.2.5,0,.7l2,2c.1.1.3.2.4.1.1,0,.3,0,.4-.2L7.8,1.9c.2-.2.2-.5,0-.7l-.4-.4Z"})})})})}const{bem:Hc}=Ie("check-box"),U3=e=>{const{checked:n,onChange:t,label:r,style:a}=e,o=()=>{t==null||t(!n)};return i("div",{className:fe(he,Hc({checked:n})),onClick:o,style:a,children:[i("div",{className:Hc("inner"),children:i(F3,{size:10})}),i("span",{children:r})]})},G3=e=>e?Array.prototype.slice.call(e.querySelectorAll(`[${Gi}]`)):[];class Z3{constructor(n){Ee(this,"iframe");Ee(this,"iframeWindow");Ee(this,"hiddenIframe");Ee(this,"config");this.config=n,this.init()}init(){const{iframeSrc:n,iframeClassName:t,fieldNode:r}=this.config,a=ji(n);a.width="100%",a.height="100%",a.style.border="none",r.appendChild(a);const o=r.querySelector(`.${t}`);o&&(this.iframe=o,o.addEventListener("load",()=>this.onFieldIframeLoad()))}onFieldIframeLoad(){this.iframeWindow=this.iframe.contentWindow;const{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o}=this.config,c={action:Re.INIT,config:{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o},hidden:!1,cdnUrl:xn};ze(c,this.iframeWindow,Ht)}}const Oc=Ve((e,n)=>{const{sessionMode:t,i18n:r,targetElement:a}=e,o=j(null),c=j(null),s=(v,b)=>{const p={action:Re.PAYMENT,formData:v,extraParams:b,locale:e.i18n.locale};ze(p,c.current.contentWindow,Ht)};if(Oe(n,()=>({payment:s,reload:()=>{t!==Ke.HOSTED&&(window.removeEventListener("message",w),c.current&&document.body.removeChild(c.current),u())},encryptCard:v=>{const b={action:Re.ENCRYPT_CARD,...v};ze(b,c.current.contentWindow,Ht)},validate:()=>{Object.values(l.current).forEach(v=>{const b={action:Re.VALIDATE};ze(b,v.iframe.contentWindow,Ht)})},setConfig:v=>{e.style=v.style}})),!frames&&t===Ke.HOSTED)return e.children;let d=[];const l=j({}),m={[_e.CARD_NUMBER]:r.get("card.cardNumber.placeholder"),[_e.CVV]:r.get("card.cardSecurityCode.placeholder"),[_e.EXPIRE_DATE]:r.get("card.cardExpireDate.placeholder")};ce(()=>{u()},[]);const u=async()=>{d=G3(a||o.current),d.length&&(await y(),h(),window.addEventListener("message",w))},y=async()=>{const v=ji(`${xn}/secured-iframe.html`);v.name=`${a0}-${Date.now()}`,v.width="0",v.height="0",v.style.border="none",c.current=v;const b={action:Re.INIT,hidden:!0,apiUrl:ta,cdnUrl:xn};v.addEventListener("load",()=>{ze(b,c.current.contentWindow,Ht)}),window.document.body.appendChild(v)},h=()=>{d.forEach(v=>{const b=v.getAttribute(Gi);l.current[b]=new Z3({fieldNode:v,hiddenIframe:c.current,hiddenIframeName:c.current.name,rootNode:o.current,iframeSrc:`${xn}/secured-iframe.html`,iframeClassName:Zi,fieldType:b,placeholder:m[b],style:e.style,supportedCardBrands:e.supportedCardBrands,onFocus:e.onFocus,onBinValue:e.onBinValue,onAfterPayment:e.onAfterPayment,onPaymentError:e.onPaymentError,onPaymentTimeout:e.onPaymentTimeout,onValidStatusChanged:e.onValidStatusChanged})})},w=$e(v=>{var P,g,I,C,S,R,k,A,N,Y,B,F;const{data:b,origin:p}=v;if(p!==Ht)return;const _=rr(b);if(Reflect.has(_,"action"))switch(_.action){case Re.FOCUS:(P=e.onFocus)==null||P.call(e,_);break;case Re.BIN_VALUE:(g=e.onBinValue)==null||g.call(e,_);break;case Re.BRAND:(I=e.onBrand)==null||I.call(e,_);break;case Re.AFTER_PAYMENT:(C=e.onAfterPayment)==null||C.call(e,_);break;case Re.PAYMENT_ERROR:(S=e.onPaymentError)==null||S.call(e,_);break;case Re.PAYMENT_TIMEOUT:(R=e.onPaymentTimeout)==null||R.call(e,_);break;case Re.VALID_STATUS_CHANGED:(k=e.onValidStatusChanged)==null||k.call(e,_);break;case Re.AUTHORIZED:(A=e.onAuthorized)==null||A.call(e,_);break;case Re.ACTIVATED:(N=e.onActivated)==null||N.call(e,_);break;case Re.CARD_ENCRYPTED:(Y=e.onCardEncrypted)==null||Y.call(e,_);break;case Re.CARD_ENCRYPTION_FAILED:(B=e.onCardEncryptionFailed)==null||B.call(e,_);break;case Re.VALIDATED:(F=e.onValidated)==null||F.call(e,_);break}},[]);return i("div",{ref:o,children:!a&&e.children})}),{bem:Hn}=Ie("modal"),Fc=Ve(e=>{const{show:n=!1,width:t,height:r,maskClosable:a,header:o,children:c,onChange:s,style:d,appendToBody:l=!1}=e,[m,u]=M(),[y,h]=M(),{i18n:w}=lt();It(()=>{u(typeof t=="number"?`${t}px`:t),h(typeof r=="number"?`${r}px`:r)},[t,r]);const v=()=>{a&&(s==null||s(!1))},b=()=>{s==null||s(!1)},p=i(de,{children:n&&i("div",{className:Hn(),children:[i("div",{className:Hn("mask"),onClick:v}),i("div",{className:Hn("content"),style:{width:m,height:y,...d},children:[o||i("div",{className:Hn("header"),children:i("div",{className:Hn("close"),onClick:b,children:w.get("common.cancel")})}),i("div",{className:Hn("body"),children:c})]})]})});return l?n?wd(p,document.body):null:p}),{bem:ba}=Ie("three-ds-auth"),Uc=e=>{const{show:n=!1,onClose:t,url:r,incomplete:a=!0,width:o,height:c="72vh",theme:s}=e,d=Ac(),[l,m]=M(!1),u=j(),y=j(null),{i18n:h}=lt(),w=()=>{m(!0)},v=p=>{!p&&(t==null||t())},b=It(()=>n?o||(d.smaller("sm")?"90vw":"600px"):"0",[n,o,d.matches]);return ce(()=>{n?(u.current&&window.removeEventListener("message",u.current),u.current=p=>{const{data:_,origin:P}=p;if(P!==Ht)return;switch(rr(_).action){case Re.CHECK_THREE_DS:{v(!1);break}}},window.addEventListener("message",u.current)):u.current&&window.removeEventListener("message",u.current)},[n]),i(Fc,{show:n,onChange:v,width:b,height:c,style:{maxWidth:"100vw",maxHeight:"100vh",minHeight:"500px",minWidth:"350px"},children:i("div",{className:ba("content"),children:!a||l?i("iframe",{ref:y,width:"100%",height:"100%",frameBorder:0,src:r}):i("div",{className:ba("last-three-ds"),children:[i(Xd,{size:60}),i("div",{className:ba("last-three-ds-title"),children:[i("div",{children:h.get("threeDS.paymentIncomplete")}),i("div",{children:h.get("threeDS.completeFirst")})]}),i("div",{children:i(ha,{style:{backgroundColor:s==null?void 0:s.payButtonBackgroundColor,color:s==null?void 0:s.payButtonTextColor},onClick:w,children:h.get("common.confirm")})})]})})})},{bem:dr}=Ie("combined-card-info"),Aa=Ve((e,n)=>{const{supportedCardBrands:t=[],className:r,showLabel:a=!1,security:o}=e,c=j(null),s=j(null),{i18n:d}=lt();Oe(n,()=>({input:c.current,focus:()=>{var v;(v=c.current)==null||v.focus()},blur:()=>{var v;(v=c.current)==null||v.blur()},resetValidation:(v,b)=>{var p;(p=s.current)==null||p.resetValidation(v,[{message:b}])},binValueChanged:v=>{u(v)},binValue:()=>m,brandChanged:v=>{if(v){const b=M1(v);h(()=>b==null?void 0:b.icon)}else h(void 0)},getCardBrand:()=>_r(Ft(m),Er(t))||{}}));const l={trigger:["submit"],validator(){if(o){const v=s.current.getValidateResult();if(v.status==="error")throw new Error(v.errors[0].message);if(v.status==="success")return!0}return!0}},[m,u]=M(""),[y,h]=M(void 0),w=()=>i(y??L1,{size:32});return i(mt,{showLabel:a,ref:s,label:d.get("card.info.label"),className:r,path:"cardInfo",rule:l,children:i(ht,{ref:c,leftIcon:w(),rightIcon:i("div",{className:dr("blank-icon")}),children:i("div",{className:dr(),children:[i("div",{className:dr("card-number"),"data-sf":_e.CARD_NUMBER}),i("div",{className:dr("expire-date"),"data-sf":_e.EXPIRE_DATE}),i("div",{className:dr("cvv"),"data-sf":_e.CVV})]})})})}),{bem:Tt}=Ie("card"),lr=Tt("field"),Gc=Ve((e,n)=>{var Xs,$s,ed,td,nd,rd,ad,od;const{showCardBrands:t=!0,session:r,cardInfoLayout:a="split",showHolderName:o=!0,showEmail:c=!1,showAddress:s=!1,threeDSFrame:d,styles:l,enable3DSModal:m=!0,isDropIn:u,core:y}=e,h=bt(),w=St(),{i18n:v,fraudDetection:b,sessionReady:p}=ut(r,y),_=j(null),P=j(null),g=j(null),I=j(null),[C,S]=M({email:"",number:"",expireDate:"",securityCode:"",holderName:"",cardInfo:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[R,k]=M(!1),[A,N]=M("unSubmit"),[Y,B]=M(""),[F,x]=M(!1),[U,Q]=M(!1),[W,J]=M(!1),[te,ve]=M([]),[K,z]=M(!1),[Ce,pe]=M(),[O,ee]=M(),[D,G]=M(!1),[re,be]=M(!0),[me,f]=M({}),[E]=M(a==="split");Oe(n,()=>({checkThreeDS:za,updateAddress:()=>{var V;O!=null&&O.address.show&&(S(Object.assign(C,{address:h.getAddressState()})),(V=_.current)==null||V.update(h.getAddressState()))},updateEmail:()=>{var V;O!=null&&O.email.show&&(S(Object.assign(C,{email:w.email})),C.email=w.email,(V=P.current)==null||V.update(w.email),_n())},payment:()=>{Qe&&Te()}}));const H=()=>{var V;return{returnUrl:(V=r==null?void 0:r.checkout)==null?void 0:V.returnUrl}},T=()=>{const{field:V,sessionMode:ne}=r.checkout,{email:Ae,address:we,holderName:Ue}=V;ne===Ke.COMPONENT&&(Ae.disabled&&(Ae.show=c),s&&!(we!=null&&we.show)&&(we.show=!0),o&&!(Ue!=null&&Ue.show)&&(Ue.show=!0,Ue.disabled=!0)),ee({...V})},q=()=>{if(!l)return;const{input:V}=Ui(l);V&&f(V)};ce(()=>{var Ue,Ge;if(!p)return;const{status:V,paymentMethod:ne=[],bill:Ae={},sessionMode:we}=(r==null?void 0:r.checkout)||{};if(we===Ke.DROP_IN&&!u){(Ge=(Ue=e.core.config).onInitError)==null||Ge.call(Ue,new Se("ERROR","Please send the correct session when creating the checkout"));return}Mn(ne,k1).length&&(T(),q(),G(we!==Ke.HOSTED),C.email=Ae.email??"",ve(Mn(Oo,ne||[])),J(!0),V==="SUCCESS"&&(N("success"),ie()))},[p]);const le=$e(V=>{var ne;B(V||v.get("common.payTimeout")),N("unSubmit"),(ne=e.onTimeout)==null||ne.call(e),y.resetEnablePaymentMethod()},[v,e.onTimeout]),ie=()=>{var V;(V=e.onSuccess)==null||V.call(e,H())},L=V=>{var ne;(ne=e.onError)==null||ne.call(e,V),y.resetEnablePaymentMethod()},{start:Z}=nt(V=>ke(!0,V),{onTimeout:()=>le(v.get("common.queryTimeout"))}),ue=j(gn()),ye=V=>{In.current[V.fieldType].status=V.status;const ne=Object.values(In.current);ne.includes(null)||(ne.every(we=>we.status==="success")?ue.current.resolve(!0):ue.current.reject(!1))},se=async()=>{var V;ue.current=gn(),Object.keys(In.current).forEach(ne=>{In.current[ne]=null}),(V=h1.current)==null||V.validate();try{await ue.current,console.log("校验通过")}catch{console.log("校验失败")}};async function Te(){var V;B(""),!E&&D&&await se(),(V=I.current)==null||V.validate(async ne=>{var Ae;if(O!=null&&O.address.show&&h.setValidateAllFields(!0),(Ae=e.onSubmit)==null||Ae.call(e,ne),ne){N("unSubmit");return}B(""),N("loading"),await ke()})}const He=async()=>{var Je,rt,_t;const V=Ft(C.number),ne=Fo(V),[Ae,we]=C.expireDate.split("/"),Ue=f1&&!U;let Ge=null;f1?Ge=$.BANKCARD:D?Ge=(Je=(E?Kn:g).current)==null?void 0:Je.getCardBrand().code:Ge=ne.code;let xe;return D&&(xe=E?(rt=Kn.current)==null?void 0:rt.binValue():(_t=g.current)==null?void 0:_t.binValue()),{sessionId:r.sessionId,clientKey:r.clientKey,payment:{paymentMethod:Ge,cvv:C.securityCode,...Ue?{token:C.token}:{holderName:C.holderName,expYear:`20${we}`,expMonth:Ae,cardNo:V,...Gs?{storePaymentMethod:F}:null}},bill:O!=null&&O.address.show?{email:C.email,...C.address,province:h.getLabel(C.address.province,h.getProvinceOption())??C.address.province,city:h.getLabel(C.address.city,h.getCityOptions())??C.address.city}:{email:C.email},browser:await dt({fraudDetectionId:await(b==null?void 0:b.getFraudDetectionId({bin:V||xe||""}))})}};async function ke(V=!1,ne){var Ae,we,Ue,Ge;try{const xe=await He(),Je=(we=(Ae=y.config)._getExtraParams)==null?void 0:we.call(Ae,"payment",xe.payment.paymentMethod);if(!V&&D)return(Ue=h1.current)==null||Ue.payment(xe,Je),{end:!0};const rt={locale:v.locale,timeout:ne};let _t={};return V?_t=await gc({sessionId:r.sessionId,clientKey:r.clientKey},rt):_t=await Cc(xe,Je,rt),Qn(_t,V)}catch(xe){if(qe(xe))return V?{end:!1}:(le(),{end:!0});{const Je=xe.i18nKey?v.get(xe.i18nKey):xe.message;return B(Je),(Ge=e.onError)==null||Ge.call(e,new Se("API_ERROR",Je,{code:xe.code,cause:xe})),N("unSubmit"),zn(),{end:!0}}}}const Et=(V,ne)=>{var Ae;m?(console.log("3ds open"),z(!0),pe({url:V,incomplete:ne,width:d==null?void 0:d.modalWidth,height:d==null?void 0:d.modalHeight})):(Ae=e.onThreeDS)==null||Ae.call(e,V,ne)},dn=()=>{console.log("3ds close"),z(!1),pe(void 0),za()},Qn=(V,ne=!1)=>{var Je,rt;const{status:Ae,orderStatus:we,errorMessage:Ue,errorCode:Ge,threeDSUrl:xe}=V;if(Ae==="PROCESSING"){if(!we)N("unSubmit");else if(we==="SUCCESS")N("success"),ie();else{if(we==="PROCESSING")return!ne&&Z(),{end:!1};we==="FAILURE"?(B(Ue),N("unSubmit"),L(new Se("API_ERROR",Ue,{code:Ge}))):we==="AUTHORIZED"?(N("unSubmit"),(Je=e.onAuthorized)==null||Je.call(e)):we==="IN_THREED"?Et(xe,!1):we==="IN_PREVIOUS_THREED"&&Et(xe,!0)}return{end:!0}}else{if(Ae==="SUCCESS")return N("success"),ie(),{end:!0};if(Ae==="EXPIRED")return N("unSubmit"),(rt=e.onExpired)==null||rt.call(e),{end:!0}}return N("unSubmit"),{end:!0}},En=V=>{const ne=V.i18nKey?v.get(V.i18nKey):V.message;B(ne),N("unSubmit"),L(new Se("API_ERROR",ne,{code:V.code,cause:V}))},_n=()=>{var V;(V=I.current)==null||V.validate(void 0,!1).then(()=>{k(!0)}).catch(()=>{k(!1)})};ce(()=>{_n()},[C]);const m1=()=>{var we;const V=(we=r==null?void 0:r.checkout)==null?void 0:we.transAmount,ne=V!=null&&V.amount?pt(V).jointSymbol():"",Ae=v.get("common.pay")+(ne?` ${ne}`:"");return i(wt,{className:Tt("button"),status:A,text:Ae,loadingText:v.get("common.payProcessing"),successText:v.get("common.paySuccess"),onClick:Te,verified:R})},Wn={[ae("button-bg-color")]:(Xs=r==null?void 0:r.colors)==null?void 0:Xs.primary,[ae("button-bg-color-hover")]:($s=r==null?void 0:r.colors)==null?void 0:$s.primaryHover,[ae("button-bg-color-active")]:(ed=r==null?void 0:r.colors)==null?void 0:ed.primaryActive,[ae("button-text-color")]:(nd=(td=r==null?void 0:r.checkout)==null?void 0:td.theme)==null?void 0:nd.payButtonTextColor,[ae("input-color")]:(rd=r==null?void 0:r.colors)==null?void 0:rd.primary},{start:Wa,stop:zn}=nt(V=>za(!0,V),{timeout:12*1e3,onTimeout:()=>le(v.get("common.queryTimeout"))});async function za(V=!1,ne=2e4){var Ae,we,Ue;if(!r)return{end:!0};try{const Ge=await gc({sessionId:r.sessionId,clientKey:r.clientKey},{locale:v.locale,timeout:ne}),{status:xe,orderStatus:Je,errorMessage:rt,errorCode:_t}=Ge;if(xe==="PROCESSING"){if(Je==="PROCESSING")Z();else if(Je==="FAILURE")B(rt),N("unSubmit"),L(new Se("API_ERROR",rt,{code:_t}));else if(Je==="AUTHORIZED")N("unSubmit"),(Ae=e.onAuthorized)==null||Ae.call(e);else{if(Je==="IN_THREED")return N("loading"),!V&&Wa(),{end:!1};Je==="IN_PREVIOUS_THREED"?(B(v.get("common.pay3DSIncomplete")),N("unSubmit")):Je||N("unSubmit")}return zn(),{end:!0}}else{if(xe==="SUCCESS")return N("success"),ie(),zn(),{end:!0};if(xe==="EXPIRED")return N("unSubmit"),(we=e.onExpired)==null||we.call(e),zn(),{end:!0}}return ie(),N("unSubmit"),zn(),{end:!0}}catch(Ge){if(qe(Ge))return V?{end:!1}:(le(v.get("common.queryTimeout")),{end:!0});{const xe=Ge.i18nKey?v.get(Ge.i18nKey):Ge.message;return B(xe),(Ue=e.onError)==null||Ue.call(e,new Se("API_ERROR",xe,{code:Ge.code,cause:Ge})),N("unSubmit"),zn(),{end:!0}}}}const f1=It(()=>{var Ae;if(!(r!=null&&r.checkout))return;const V=(r==null?void 0:r.checkout.paymentType)===yn.PURCHASE,ne=!!((Ae=r==null?void 0:r.checkout.tokens)!=null&&Ae.length);return V&&ne},[r==null?void 0:r.checkout]),Gs=It(()=>{if(r!=null&&r.checkout)return(r==null?void 0:r.checkout.paymentType)===yn.PURCHASE&&(r==null?void 0:r.checkout.storePaymentMethod)},[r==null?void 0:r.checkout]),h6=()=>{const V=ne=>{x(ne)};return i("div",{className:Tt("store-checkbox"),children:i(U3,{label:v.get("card.storeInfo"),checked:F,onChange:V})})},y6=()=>{var we,Ue,Ge;const V=((we=r==null?void 0:r.checkout)==null?void 0:we.paymentType)===yn.PURCHASE,ne=!!((Ge=(Ue=r==null?void 0:r.checkout)==null?void 0:Ue.tokens)!=null&&Ge.length),Ae=()=>{var xe;(xe=I.current)==null||xe.resetValidation(),Q(!1)};return V&&ne&&i("div",{className:Tt("change-box"),onClick:Ae,children:[i(xo,{}),i("span",{style:{marginLeft:"2px"},children:v.get("card.cardSelector.change")})]})},Zs=()=>{var V;(V=I.current)==null||V.resetValidation(),Q(!0)},C6=()=>{var ne;(((ne=r==null?void 0:r.checkout)==null?void 0:ne.tokens)||[]).length>1||Zs()},g6=V=>{be(!1),S(Object.assign(C,{token:V==null?void 0:V.token}))},js=V=>{I.current=V,V&&_n()},Kn=j(null),Ys=j(null),Ka=j(null),h1=j(null),Qs=It(()=>f1&&!U,[f1,U]);ce(()=>{var V;(V=h1.current)==null||V.reload()},[Qs]);const Ws={[_e.CARD_NUMBER]:Kn,[_e.CVV]:Ka,[_e.EXPIRE_DATE]:Ys},v6=V=>{var Ae,we;const ne=E?Ws[V.fieldType]:g;V.focus?(Ae=ne.current)==null||Ae.focus():(we=ne.current)==null||we.blur()},p6=[_e.CARD_NUMBER,_e.EXPIRE_DATE,_e.CVV],In=j({[_e.CARD_NUMBER]:null,[_e.EXPIRE_DATE]:null,[_e.CVV]:null}),b6=V=>{var we,Ue,Ge,xe;const ne=E?Ws[V.fieldType]:g,Ae=V.errorTip&&v.get(V.errorTip);if(E)(xe=ne.current)==null||xe.resetValidation(V.status,Ae);else{In.current[V.fieldType]={status:V.status,errorTip:Ae};for(const rt of p6){const _t=In.current[rt];if((_t==null?void 0:_t.status)==="error"){(we=ne.current)==null||we.resetValidation(_t.status,_t.errorTip);return}}Object.values(In.current).every(rt=>(rt==null?void 0:rt.status)==="success")?(Ue=ne.current)==null||Ue.resetValidation("success"):(Ge=ne.current)==null||Ge.resetValidation("unValidate")}setTimeout(()=>{_n()},100)},A6=V=>{var Ae;(Ae=(E?Kn:g).current)==null||Ae.brandChanged(V.brand)},zs=V=>{var Ae;let ne="";typeof V=="string"?ne=V:((Ae=(E?Kn:g).current)==null||Ae.binValueChanged(V.binValue),ne=V.binValue),ne&&new Yr().getFraudDetectionId(ne)},S6=V=>{Qn(V.response)},w6=V=>{En(V.error)},Ks=()=>i(de,{children:(O==null?void 0:O.email.show)&&i("div",{className:lr,children:i(Lt,{ref:P,value:C.email,disabled:O==null?void 0:O.email.disabled})})}),qs=()=>{var V,ne;return i(de,{children:(O==null?void 0:O.address.show)&&i("div",{className:Tt("address"),children:i(kt,{ref:_,value:C.address,country:((V=r==null?void 0:r.checkout)==null?void 0:V.country)||((ne=r==null?void 0:r.checkout)==null?void 0:ne.bill.country),onAddressChange:Ae=>S(Object.assign(C,{address:Ae}))})})})},Js=()=>i(de,{children:!!Y&&i(yt,{content:Y,style:{marginTop:"12px"}})}),E6=$e(()=>{var V,ne,Ae,we;return E?i(de,{children:[i("div",{className:lr,children:[i("div",{className:Tt("card-number-wrapper"),children:[i(va,{supportedCardBrands:(ne=(V=r==null?void 0:r.checkout)==null?void 0:V.paymentMethod)==null?void 0:ne.filter(Boolean),security:D,ref:Kn,onBinValue:zs}),y6()]}),t&&i(Dc,{className:Tt("card-brands"),supportedCardBrands:(we=(Ae=r==null?void 0:r.checkout)==null?void 0:Ae.paymentMethod)==null?void 0:we.filter(Boolean)})]}),i("div",{className:Tt("center"),children:[i(ga,{security:D,className:lr,ref:Ys}),i(Kr,{security:D,className:lr,ref:Ka})]})]}):i("div",{className:Tt("card-info"),children:i(Aa,{ref:g,supportedCardBrands:te,showLabel:!0,security:D})})},[E,D]),_6=()=>{var V;return i(At,{form:C,ref:js,onFormChange:ne=>S(ne),children:i("div",{className:fe(he,Tt()),style:Wn,children:[Ks(),E6(),(O==null?void 0:O.holderName.show)&&i("div",{className:Tt("holder-name"),children:i(Bc,{disabled:O==null?void 0:O.holderName.disabled})}),qs(),((V=r==null?void 0:r.checkout)==null?void 0:V.paymentType)===yn.RECURRING&&fa(),Gs&&h6(),Js(),!Qe&&m1()]})})},I6=()=>{var V,ne,Ae,we;return i(At,{form:C,ref:js,onFormChange:Ue=>S(Ue),children:i("div",{className:fe(he,Tt()),style:Wn,children:[Ks(),i("div",{className:Tt("card-selector-wrapper"),children:[i(xc,{value:(Ae=(ne=(V=r==null?void 0:r.checkout)==null?void 0:V.tokens)==null?void 0:ne[0])==null?void 0:Ae.token,cardList:(we=r==null?void 0:r.checkout)==null?void 0:we.tokens,onClickEdit:Zs,onClickChange:C6,onCardChange:g6,style:{flex:2,marginRight:"12px"}}),i(Kr,{className:lr,style:{flex:1,marginLeft:"12px"},security:D,ref:Ka})]}),re&&qs(),Js(),!Qe&&m1()]})})};return i(tt.Provider,{value:{i18n:v},children:W&&v.ready.value&&i(de,{children:[i(Oc,{ref:h1,i18n:v,sessionMode:(ad=r.checkout)==null?void 0:ad.sessionMode,supportedCardBrands:te,style:me||Ho,onFocus:v6,onBinValue:zs,onBrand:A6,onAfterPayment:S6,onPaymentError:w6,onPaymentTimeout:({message:V})=>le(v.get(V)),onValidStatusChanged:b6,onValidated:ye,children:Qs?I6():_6()}),i(Uc,{show:K,theme:(od=r==null?void 0:r.checkout)==null?void 0:od.theme,onClose:dn,...Ce})]})})}),{bem:qr}=Ie("wechat-pay"),j3=Ve((e,n)=>{var F,x,U,Q,W,J,te,ve,K;const{session:t}=e,r=bt(),a=St(),o=j(null);Oe(n,()=>({stopRetry:()=>{R(),u("unSubmit")},startRetry:z=>{u("loading"),S({timeout:z})},updateAddress:()=>{var z;w(Object.assign(h,{address:r.getAddressState()})),(z=g.current)==null||z.update(r.getAddressState())},updateEmail:()=>{var z;w(Object.assign(h,{email:a.email})),(z=o.current)==null||z.update(a.email)}}));const{setErrorMsg:c,i18n:s,errorMsg:d,sessionReady:l}=ut(t,e.core),[m,u]=M("unSubmit"),y=j(null),[h,w]=M({email:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[v,b]=M(!1),p=j(!1),[_,P]=M(!1),g=j(null);function I(){var z;(z=y.current)==null||z.validate(void 0,!1).then(()=>{b(!0)}).catch(()=>{b(!1)})}ce(()=>{I()},[h]),ce(()=>{var z;l&&((t==null?void 0:t.checkout.status)==="SUCCESS"&&(u("success"),(z=e.onSuccess)==null||z.call(e)),h.email=(t==null?void 0:t.checkout.bill.email)??"",p.current=!!(t!=null&&t.checkout.bill.email),(t==null?void 0:t.checkout.bill.billingAddressCollection)==="REQUIRED"?P(!0):P(!1),!_&&setTimeout(()=>{I()},100))},[l]);const C=$e(z=>{var Ce;c(z||s.get("common.payTimeout")),u("unSubmit"),(Ce=e.onTimeout)==null||Ce.call(e,"retry")},[s,e.onTimeout]),{start:S,stop:R}=nt(z=>k(!0,z),{timeout:2*60*1e3,onTimeout:()=>C(s.get("common.queryTimeout"))});async function k(z=!1,Ce){var pe,O,ee,D,G,re,be,me,f;try{const E=z?await z0({sessionId:t.sessionId,clientKey:t.clientKey},{locale:s.locale,timeout:Ce}):await W0({sessionId:t.sessionId,clientKey:t.clientKey,bill:_?{email:h.email,...h.address,province:r.getLabel(h.address.province,r.getProvinceOption())??h.address.province,city:r.getLabel(h.address.city,r.getCityOptions())??h.address.city}:{email:h.email},channelUserId:await((pe=e.onGetOpenId)==null?void 0:pe.call(e))},e.core,{locale:s.locale,timeout:Ce}),{status:H,orderStatus:T,errorMessage:q,payInfo:le,errorCode:ie}=E;if(!z&&((O=e.onSubmitResponse)==null||O.call(e,E)),H==="PROCESSING")if(T){if(T==="SUCCESS")return u("success"),(ee=e.onSuccess)==null||ee.call(e),{end:!0};if(T==="FAILURE")return c(q),u("unSubmit"),(D=e.onError)==null||D.call(e,new Se("API_ERROR",q,{code:ie})),{end:!0};if(T==="PROCESSING")return z||(await((G=e.onCallWxPayBox)==null?void 0:G.call(e,le)),S()),{end:!1};if(T==="CANCELED")return u("unSubmit"),(re=e.onTimeout)==null||re.call(e,"channel"),{end:!0}}else return u("unSubmit"),{end:!0};else{if(H==="SUCCESS")return u("success"),(be=e.onSuccess)==null||be.call(e),{end:!0};if(H==="EXPIRED")return u("unSubmit"),(me=e.onExpired)==null||me.call(e),{end:!0}}return u("unSubmit"),{end:!0}}catch(E){if(qe(E))return z?{end:!1}:(C(),{end:!0});{const H=E.i18nKey?s.get(E.i18nKey):E.message;return c(H),(f=e.onError)==null||f.call(e,new Se("API_ERROR",H,{code:E.code,cause:E})),u("unSubmit"),{end:!0}}}}async function A(){var z;c(""),(z=y.current)==null||z.validate(async Ce=>{var pe;if(_&&r.setValidateAllFields(!0),(pe=e.onSubmit)==null||pe.call(e,Ce),Ce){u("unSubmit");return}c(""),u("loading"),await k()})}const N=()=>{const{transAmount:z,channelParams:Ce={}}=(t==null?void 0:t.checkout)??{},{totalAmount:pe}=Ce.wechatPay??{},O=(pe!=null&&pe.amount?pe:z)||{},ee=O!=null&&O.amount?pt(O).jointSymbol():"",D=s.get("common.pay")+(ee?` ${ee}`:"");return i(wt,{className:qr("button"),status:m,text:D,loadingText:s.get("common.payProcessing"),successText:s.get("common.paySuccess"),onClick:A,verified:v})},Y=z=>{y.current=z,z&&I()},B={[ae("button-bg-color")]:(F=t==null?void 0:t.colors)==null?void 0:F.primary,[ae("button-bg-color-hover")]:(x=t==null?void 0:t.colors)==null?void 0:x.primaryHover,[ae("button-bg-color-active")]:(U=t==null?void 0:t.colors)==null?void 0:U.primaryActive,[ae("button-text-color")]:(W=(Q=t==null?void 0:t.checkout)==null?void 0:Q.theme)==null?void 0:W.payButtonTextColor,[ae("input-color")]:(J=t==null?void 0:t.colors)==null?void 0:J.primary};return i(tt.Provider,{value:{i18n:s,session:t},children:l&&s.ready.value&&i(At,{form:h,ref:Y,onFormChange:z=>w(z),children:i("div",{className:fe(he,qr()),style:B,children:[i(Lt,{ref:o,className:qr("email"),value:h.email,disabled:!!p.current}),_&&i(kt,{ref:g,value:h.address,country:((te=t==null?void 0:t.checkout)==null?void 0:te.country)||((ve=t==null?void 0:t.checkout)==null?void 0:ve.bill.country),onAddressChange:z=>w(Object.assign(h,{address:z}))}),((K=t==null?void 0:t.checkout)==null?void 0:K.paymentType)===yn.RECURRING&&fa(),!!d&&i(yt,{className:qr("error"),content:d}),N()]})})})}),Zc=e=>{var o;const{src:n,onload:t=null,onerror:r=null}=e,a=document.createElement("script");a.type="text/javascript",a.src=n,a.onload=t,a.onerror=r,Object.assign(a,e.extraOptions),(o=document.getElementsByTagName("head")[0])==null||o.appendChild(a)},Y3=(e,n)=>{Zc({src:"https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",onload:e,onerror:n,extraOptions:{async:!0,crossOrigin:""}})};async function Q3(e){var t,r;if(!e||!ApplePaySession)return!1;if(!((t=ApplePaySession.canMakePayments)!=null&&t.call(ApplePaySession)))return;const n=await((r=ApplePaySession.applePayCapabilities)==null?void 0:r.call(ApplePaySession,e));return!!["paymentCredentialsAvailable","paymentCredentialStatusUnknown","paymentCredentialsUnavailable"].includes(n.paymentCredentialStatus)}const{bem:jc}=Ie("apple-pay"),Yc=Ve(e=>{const{session:n,isDropIn:t}=e;let r;const{i18n:a,sessionReady:o,fraudDetection:c}=ut(n,e.core),[s,d]=M(""),[l,m]=M(!1),u=()=>({returnUrl:n==null?void 0:n.checkout.returnUrl});ce(()=>{var g,I,C;if(!o)return;const{status:p,paymentMethod:_=[],sessionMode:P}=(n==null?void 0:n.checkout)||{};if(P===Ke.DROP_IN&&!t){(I=(g=e.core.config).onInitError)==null||I.call(g,new Se("ERROR","Please send the correct session when creating the checkout"));return}_.includes($.APPLE_PAY)&&(Y3(async()=>{var R,k,A,N;await Q3((A=(k=(R=n==null?void 0:n.checkout)==null?void 0:R.channelParams)==null?void 0:k.applePay)==null?void 0:A.merchantIdentifier)&&(m(!0),(N=e.onLoad)==null||N.call(e,!0))},()=>{var S;m(!1),(S=e.onLoad)==null||S.call(e,!1)}),p==="SUCCESS"&&((C=e.onSuccess)==null||C.call(e,u())))},[o]);const y=$e(p=>{var P;const _=p||a.get("common.payTimeout");r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,_)]}),d(_),(P=e.onTimeout)==null||P.call(e,"retry")},[a,e.onTimeout]),{start:h}=nt(p=>w(!0,p),{onTimeout:()=>y(a.get("common.queryTimeout"))});async function w(p=!1,_,P,g,I){var C,S,R,k,A,N,Y;d("");try{const B=await(p?J0({sessionId:n.sessionId,clientKey:n.clientKey},{locale:a.locale,timeout:_}):async function(){var J,te;const W=t0(g==null?void 0:g.phoneNumber);return q0({sessionId:n.sessionId,clientKey:n.clientKey,token:JSON.stringify({token:P}),bill:{firstName:g==null?void 0:g.familyName,lastName:g==null?void 0:g.givenName,addressLine1:(J=g==null?void 0:g.addressLines)==null?void 0:J[0],addressLine2:(te=g==null?void 0:g.addressLines)==null?void 0:te[1],state:g==null?void 0:g.administrativeArea,city:g==null?void 0:g.locality,postalCode:g==null?void 0:g.postalCode,areaCode:W==null?void 0:W.areaCode,phoneNumber:W==null?void 0:W.phoneNumber,email:(g==null?void 0:g.emailAddress)||(I==null?void 0:I.emailAddress)||(n==null?void 0:n.checkout.bill.email),country:g==null?void 0:g.countryCode},browser:await dt({fraudDetectionId:await(c==null?void 0:c.getFraudDetectionId())})},e.core,{locale:a.locale})}()),{status:F,orderStatus:x,errorMessage:U,errorCode:Q}=B;if(F==="PROCESSING"){if(x==="SUCCESS")return r.completePayment({status:0}),(C=e.onSuccess)==null||C.call(e,u()),{end:!0};if(x==="PROCESSING")return!p&&await h(),{end:!p};if(x==="FAILURE")return d(U),(S=e.onError)==null||S.call(e,new Se("API_ERROR",U,{code:Q})),r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,U)]}),{end:!0};if(x==="AUTHORIZED")return r.completePayment({status:0}),(R=e.onAuthorized)==null||R.call(e),{end:!0};if(!x)return r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,"")]}),{end:!0}}else{if(F==="SUCCESS")return(k=e.onSuccess)==null||k.call(e,u()),r.completePayment({status:0}),{end:!0};if(F==="EXPIRED")return(A=e.onExpired)==null||A.call(e),r.abort(),{end:!0}}return(N=e.onSuccess)==null||N.call(e,u()),{end:!0}}catch(B){if(qe(B))return p?{end:!1}:(y(),{end:!0});{const F=B.i18nKey?a.get(B.i18nKey):B.message;return d(F),(Y=e.onError)==null||Y.call(e,new Se("API_ERROR",F,{code:B.code,cause:B})),r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,F)]}),{end:!0}}}}function v(){var I,C,S,R;if((I=e.onBtnClick)==null||I.call(e),!ApplePaySession)return;const p=n==null?void 0:n.checkout,{applePay:_}=(p==null?void 0:p.channelParams)??{},P=["name","email"];((C=p==null?void 0:p.bill)==null?void 0:C.billingAddressCollection)==="REQUIRED"&&P.push("postalAddress");const g={merchantCapabilities:["supports3DS"],countryCode:(_==null?void 0:_.countryCode)??"",requiredBillingContactFields:P,requiredShippingContactFields:["email"],currencyCode:(p==null?void 0:p.transAmount.currency)??"",supportedNetworks:((R=(S=_==null?void 0:_.supportedNetworks)==null?void 0:S.map)==null?void 0:R.call(S,k=>$u(k)))??[],total:{label:(p==null?void 0:p.theme.merchantName)??"",type:"final",amount:String(p==null?void 0:p.transAmount.amount)}};r=new ApplePaySession(3,g),r.onvalidatemerchant=async()=>{const k=await K0();console.log("onvalidatemerchant"),r.completeMerchantValidation(k)},r.onpaymentauthorized=async k=>{var A;(A=e.onSubmit)==null||A.call(e),console.log("onpaymentauthorized"),console.log("apple pay token: ",k.payment.token),console.log("apple pay shippingContact: ",k.payment.shippingContact),console.log("apple pay billingContact",k.payment.billingContact),w(!1,void 0,k.payment.token,k.payment.billingContact,k.payment.shippingContact)},r.oncancel=()=>{var k;(k=e.onCancel)==null||k.call(e)},r.begin()}const b=()=>i("div",{className:jc("button"),children:i("apple-pay-button",{id:"apple-pay-button",buttonstyle:"black",type:"plain",onClick:v})});return i("div",{children:o&&l&&a.ready.value&&i(de,{children:[!!s&&i(yt,{className:jc("error"),content:s}),b()]})})});function W3(e,n,t,r){const{transAmount:a,theme:{merchantName:o}}=e,{googlePay:c}=(e==null?void 0:e.channelParams)??{},s={apiVersion:2,apiVersionMinor:0},d={type:"PAYMENT_GATEWAY",parameters:{gateway:c==null?void 0:c.providerGatewayId,gatewayMerchantId:c==null?void 0:c.merchantGatewayId}},l=(c==null?void 0:c.allowedCardNetworks)??[],u={type:"CARD",parameters:{allowedAuthMethods:(c==null?void 0:c.allowedAuthMethods)??[],allowedCardNetworks:l,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}};function y(){return Object.assign({},s,{allowedPaymentMethods:[u]})}const h=Object.assign({tokenizationSpecification:d},u);function w(){return{countryCode:c==null?void 0:c.countryCode,currencyCode:a.currency,totalPriceStatus:"FINAL",totalPrice:String(a.amount),totalPriceLabel:"Total"}}let v;function b(){const C=Object.assign({},s);return C.emailRequired=!0,C.allowedPaymentMethods=[h],C.transactionInfo=w(),C.merchantInfo={merchantId:c==null?void 0:c.googlePayMerchantId,merchantName:o},C.callbackIntents=["PAYMENT_AUTHORIZATION"],C}function p(){return v||(v=new google.payments.api.PaymentsClient({environment:c==null?void 0:c.environment,paymentDataCallbacks:{onPaymentAuthorized:_}})),v}function _(C){return new Promise(function(S){var Q,W;console.log("google pay token",C.paymentMethodData.tokenizationData.token),console.log("google pay billingAddress",(Q=C.paymentMethodData.info)==null?void 0:Q.billingAddress);const{name:R,address1:k,address2:A,address3:N,countryCode:Y,administrativeArea:B,locality:F,postalCode:x,phoneNumber:U}=((W=C.paymentMethodData.info)==null?void 0:W.billingAddress)??{};n(C.paymentMethodData.tokenizationData.token,{email:C.email,name:R,address1:k,address2:A,address3:N,countryCode:Y??"",administrativeArea:B??"",locality:F??"",postalCode:x??"",phoneNumber:U??""}).then(J=>{S(J==null?void 0:J.res)})})}function P(C){p().isReadyToPay(y()).then(function(R){R.result?g(C):r==null||r(!1)}).catch(function(R){console.error(R)})}function g(C){const R=p().createButton({buttonColor:"default",buttonType:"pay",buttonRadius:8,buttonSizeMode:"fill",onClick:I,allowedPaymentMethods:[u]});C==null||C.appendChild(R)}function I(){t==null||t();const C=b();C.transactionInfo=w();const S=p();console.log("paymentDataRequest",C),S.loadPaymentData(C)}return{onGooglePayLoaded:P}}const z3=(e,n)=>{var t;(t=window.google)!=null&&t.payments||Zc({src:"https://pay.google.com/gp/p/js/pay.js",onload:e,onerror:n,extraOptions:{async:!0}})},{bem:K3}=Ie("google-pay"),Qc=Ve((e,n)=>{var B;const{session:t,threeDSFrame:r,isDropIn:a}=e;Oe(n,()=>({checkThreeDS:A}));const{sessionReady:o,i18n:c,fraudDetection:s}=ut(t,e.core),[d,l]=M(""),[m,u]=M(!1),[y,h]=M(!1),[w,v]=M(),[b,p]=M(!0),_=$e(F=>{var x;l(F||c.get("common.payTimeout")),(x=e.onTimeout)==null||x.call(e,"retry")},[c,e.onTimeout]),P=()=>({returnUrl:t==null?void 0:t.checkout.returnUrl});ce(()=>{var Q,W,J;if(!o)return;const{status:F,paymentMethod:x=[],sessionMode:U}=(t==null?void 0:t.checkout)||{};if(U===Ke.DROP_IN&&!a){(W=(Q=e.core.config).onInitError)==null||W.call(Q,new Se("ERROR","Please send the correct session when creating the checkout"));return}x.includes($.GOOGLE_PAY)&&(z3(()=>{var te;u(!0),(te=e.onLoad)==null||te.call(e,!0)},()=>{var te;u(!1),(te=e.onLoad)==null||te.call(e,!1)}),p(U===Ke.HOSTED),F==="SUCCESS"&&((J=e.onSuccess)==null||J.call(e,P())))},[o]);const g=(F,x)=>{var U;b?(U=e.onThreeDS)==null||U.call(e,F,x):(h(!0),v({url:F,incomplete:x,width:r==null?void 0:r.modalWidth,height:r==null?void 0:r.modalHeight}))},I=()=>{h(!1),v(void 0),A()},{start:C}=nt(async F=>await S(void 0,void 0,!0,F),{onTimeout:()=>_(c.get("common.queryTimeout"))});async function S(F,x,U=!1,Q){var W,J,te,ve,K,z,Ce,pe;l(""),U||(W=e.onSubmit)==null||W.call(e);try{const O=await(U?pc({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale,timeout:Q}):async function(){const me=e0(x==null?void 0:x.phoneNumber);return X0({sessionId:t.sessionId,clientKey:t.clientKey,token:F??"",bill:{firstName:x==null?void 0:x.name,addressLine1:x==null?void 0:x.address1,addressLine2:(x==null?void 0:x.address2)??""+(x==null?void 0:x.address3)??"",country:x==null?void 0:x.countryCode,state:x==null?void 0:x.administrativeArea,city:x==null?void 0:x.locality,email:x==null?void 0:x.email,postalCode:x==null?void 0:x.postalCode,phoneNumber:me==null?void 0:me.phoneNumber,areaCode:me==null?void 0:me.areaCode},browser:await dt({fraudDetectionId:await(s==null?void 0:s.getFraudDetectionId())})},e.core,{locale:c.locale})}()),{status:ee,orderStatus:D,errorMessage:G,threeDSUrl:re,errorCode:be}=O;if(ee==="PROCESSING"){if(D==="SUCCESS")return(J=e.onSuccess)==null||J.call(e,P()),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="PROCESSING"){const me=await C();return(me==null?void 0:me.end)===!0?{end:!0,res:me.res}:await C()}else{if(D==="FAILURE")return l(G),(te=e.onError)==null||te.call(e,new Se("API_ERROR",G,{code:be})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:G,reason:"OTHER_ERROR"}}};if(D==="AUTHORIZED")return(ve=e.onAuthorized)==null||ve.call(e),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="IN_THREED")return g(re,!1),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="IN_PREVIOUS_THREED")return g(re,!0),{end:!0,res:{transactionState:"SUCCESS"}};if(!D)return{end:!0,res:{transactionState:"SUCCESS"}}}}else{if(ee==="SUCCESS")return(K=e.onSuccess)==null||K.call(e,P()),{end:!0,res:{transactionState:"SUCCESS"}};if(ee==="EXPIRED")return(z=e.onExpired)==null||z.call(e),{end:!0,res:{transactionState:"SUCCESS"}}}return(Ce=e.onSuccess)==null||Ce.call(e,P()),{end:!1,res:{transactionState:"SUCCESS"}}}catch(O){if(qe(O))return U?{end:!1}:(_(),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:c.get("common.payTimeout"),reason:"OTHER_ERROR"}}});{const ee=O.i18nKey?c.get(O.i18nKey):O.message;return l(ee),(pe=e.onError)==null||pe.call(e,new Se("API_ERROR",ee,{code:O.code,cause:O})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:ee,reason:"OTHER_ERROR"}}}}}}const{start:R,stop:k}=nt(()=>A(!0),{timeout:12*1e3,onTimeout:()=>_(c.get("common.queryTimeout"))});async function A(F=!1){var x,U,Q,W,J;if(!t)return{end:!0};try{const te=await pc({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale}),{status:ve,orderStatus:K,errorMessage:z}=te;if(ve==="PROCESSING"){if(K==="PROCESSING")C();else if(K==="FAILURE")l(z);else if(K==="AUTHORIZED")(x=e.onAuthorized)==null||x.call(e);else{if(K==="IN_THREED")return!F&&R(),{end:!1};K==="IN_PREVIOUS_THREED"&&l(c.get("common.pay3DSIncomplete"))}return k(),{end:!0}}else{if(ve==="SUCCESS")return(U=e.onSuccess)==null||U.call(e,P()),k(),{end:!0};if(ve==="EXPIRED")return(Q=e.onExpired)==null||Q.call(e),k(),{end:!0}}return(W=e.onSuccess)==null||W.call(e,P()),k(),{end:!0}}catch(te){if(qe(te))return F?{end:!1}:(_(c.get("common.queryTimeout")),{end:!0});{const ve=te.i18nKey?c.get(te.i18nKey):te.message;return l(ve),(J=e.onError)==null||J.call(e,new Se("API_ERROR",ve,{code:te.code,cause:te})),{end:!0}}}}const N=j(null);ce(()=>{if(N&&(t!=null&&t.checkout)&&m){const{onGooglePayLoaded:F}=W3(t==null?void 0:t.checkout,S,e.onBtnClick,e.onCanUse);F(N.current)}},[o,N,c.ready.value,m]);const Y=()=>i("div",{style:"width: 100%; height: 44px",children:i("div",{id:"container",style:"width:100%; height: 44px",ref:N})});return i("div",{children:o&&m&&c.ready.value&&i(de,{children:[!!d&&i(yt,{className:K3("error"),content:d}),Y(),i(Uc,{show:y,theme:(B=t==null?void 0:t.checkout)==null?void 0:B.theme,...w,onClose:I})]})})}),q3=()=>{let e,n;const t=j(""),[r,a]=M("");let o,c;const[s,d]=M(void 0),l=P=>{e=P.fieldType,n=P.supportedCardBrands,o=Er(n),c=Uo(o)},m=()=>{let P={maxLength:0,onInput:g=>{}};switch(e){case _e.CVV:{P={maxLength:4,inputMode:"numeric",onInput:u,validator:w};break}case _e.CARD_NUMBER:{P={maxLength:23,inputMode:"numeric",onInput:y,validator:v};break}case _e.EXPIRE_DATE:{P={maxLength:5,inputMode:"numeric",onInput:h,validator:b};break}}return P},u=P=>{const g=P.currentTarget,I=vn(g.value);t.current=g.value=I},y=P=>{var A;const{inputType:g}=P,I=P.currentTarget,C=I.selectionStart;let S=vn(I.value);S=S.replace(/(\d{4})(?=\d)/g,"$1 ");let R=C;R%5===0&&(R=nr(C+(g==="insertText"?1:-1),0)),t.current=I.value=S,I.setSelectionRange(R,R);const k=Ft(I.value).substring(0,6);a(k.length<6?"":k),d((A=p(Ft(I.value)))==null?void 0:A.code)},h=P=>{const{inputType:g}=P,I=P.currentTarget,C=I.selectionStart;let S;if(g==="insertText"){const{data:R}=P;S=vn(I.value);const k=S.length;k===1&&+S>1?S=`0${S}`:k===2&&(+S>12?S=`01${R}`:S=`${S}`),k>=2&&!S.includes("/")&&(S=S.slice(0,2)+"/"+S.slice(2,4))}else{S=I.value;const R=t.current.slice(C,C+1),k=t.current.length;if(k>3&&R==="/"){t.current=I.value=t.current,I.setSelectionRange(C,C);return}else if(C===1){const A=t.current.slice(0,2);k>2&&+A>=10?S=`01${t.current.slice(2,k)}`:S=S.slice(0,1)}else if(C===0&&S.length>1){R==="0"?t.current=I.value=t.current:R==="1"&&(t.current=I.value=`0${S}`),I.setSelectionRange(0,0);return}else if(C===3)if(k===4)S=S.slice(0,2);else{t.current=I.value=S,I.setSelectionRange(C-1,C-1);return}}t.current=I.value=S,g!=="insertText"&&I.setSelectionRange(C+1,C+1)},w=()=>{if(Pe(t.current)||t.current.length<3)throw new Error("card.cardSecurityCode.incomplete");return!0},v=()=>{const P=Ft(t.current??"");if(!c.includes(P.length))throw new Error("card.cardNumber.incomplete");if(!p(P))throw new Error("card.cardNumber.invalid");return!0},b=()=>{if(Pe(t.current)||t.current.length!==5)throw new Error("card.cardExpireDate.incomplete");if(zi(t.current))throw new Error("card.cardExpireDate.expired")},p=P=>Fo(P,o);return{value:t,cardBin:r,initSecuredInput:l,getConfigByFieldType:m,getCurrCardBrand:p,brand:s,validate:()=>{if(e===_e.CARD_NUMBER)return v();if(e===_e.CVV)return w();if(e===_e.EXPIRE_DATE)return b()}}},Ct=r0("input"),J3=e=>{const n=window.parent.frames[e.hiddenIframeName],t=j(null),{initSecuredInput:r,getConfigByFieldType:a,getCurrCardBrand:o,cardBin:c,value:s,brand:d}=q3(),[l,m]=M(!1),u="securedInput",y=()=>{r({fieldType:e.fieldType,supportedCardBrands:e.supportedCardBrands,sendMessage:S=>{ze(S,window.parent)}}),h(e.style)},h=(S={})=>{const{base:R,hover:k,focus:A,valid:N,invalid:Y,placeholder:B}=S,F=`input { ${pn(R)} }`,x=`input.${Ct.hover} { ${pn(k)} }`,U=`input.${Ct.focus} { ${pn(A)} }`,Q=`input.${Ct.valid} { ${pn(N)} }`,W=`input.${Ct.invalid} { ${pn(Y)} }`,J=Fi("input",B==null?void 0:B.base),te=Fi(`input.${Ct.focus}`,B==null?void 0:B.focus),ve=`
|
|
14
|
+
`);var _e=(e=>(e.CARD_NUMBER="CARD_NUMBER",e.CVV="CVV",e.EXPIRE_DATE="EXPIRE_DATE",e))(_e||{});const Gi="data-sf",Zi="secured-iframe",a0="hidden-pay-iframe",ji=e=>{const n=document.createElement("iframe");n.setAttribute("src",e),n.classList.add(Zi),n.setAttribute("allowtransparency","true"),n.setAttribute("referrerpolicy","origin"),Object.defineProperty(n,"src",{configurable:!1,writable:!1});const t=document.createTextNode("<p>Your browser does not support iframes.</p>");return n.appendChild(t),n},ze=(e,n,t="*")=>{if(!n)return;const r=typeof e=="string"?e:JSON.stringify(e);n==null||n.postMessage(r,{targetOrigin:t})},o0=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),i0=(e,n)=>{const t=new URL(e);return Object.entries(n).forEach(([r,a])=>{t.searchParams.append(r,String(a))}),t.toString()},c0=e=>{try{const n=new URL(e),t={};return n.searchParams.forEach((a,o)=>{t[o]=a}),{baseUrl:n.origin+n.pathname,params:t}}catch{return{baseUrl:e,params:{}}}},Yt=e=>{const{request_url:n,request_method:t}=e;if(t==="GET")s0(n,{});else{const{baseUrl:r,params:a}=c0(n);d0(r,a)}},s0=(e,n)=>{const t=i0(e,n);window.location.href=t},d0=(e,n)=>{const t=document.createElement("form");t.method="POST",t.action=e,t.style.display="none",Object.entries(n).forEach(([r,a])=>{const o=document.createElement("input");o.type="hidden",o.name=r,o.value=a,t.appendChild(o)}),document.body.appendChild(t),t.submit()},Yi=(e,n)=>{const t=e.indexOf(n);t!==-1&&e.splice(t,1)},l0=(e,n=document.createElement("div"))=>"on"+e in n,Qi="MM/DD/YYYY",u0=`${Qi} HH:mm:ss`,Wi={date:Qi,datetime:u0},m0=(e,n="datetime")=>{if(!e&&e!==0)return"-";n in Wi&&(n=Wi[n]);let t;["number","string"].includes(typeof e)?t=new Date(e):t=e;const r=a=>a.toString().padStart(2,"0");return n.replace(/YYYY/g,t.getFullYear().toString()).replace(/MM/g,r(t.getMonth()+1)).replace(/DD/g,r(t.getDate())).replace(/HH/g,r(t.getHours())).replace(/mm/g,r(t.getMinutes())).replace(/ss/g,r(t.getSeconds()))},st=(e,n)=>{const t={...e};for(const r in n)Object.prototype.hasOwnProperty.call(n,r)&&typeof n[r]=="object"&&n[r]!==null&&!Array.isArray(n[r])&&typeof t[r]=="object"&&t[r]!==null&&!Array.isArray(t[r])?t[r]=st(t[r],n[r]):t[r]=n[r];return t},f0="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$";function h0(e,n){return n?e:void 0}function nr(e,n,t){return Pe(n)||(e=Math.max(e,n)),Pe(t)||(e=Math.min(e,t)),e}const rr=(e,n={})=>{try{return JSON.parse(e)}catch{return n}},y0=(e,n="")=>{try{return JSON.stringify(e)}catch{return n}};function zi(e){const[n,t]=e.split("/").map(Number);return new Date(+`20${t}`,n-1)<new Date}const Mn=(...e)=>{if(e.length===0)return[];let n=e[0];for(let t=1;t<e.length;t++){const r=new Set(n);n=e[t].filter(a=>r.has(a))}return n},C0=()=>Object.entries(Object.assign({"./de-DE.ts":()=>Promise.resolve().then(()=>r6),"./en-GB.ts":()=>Promise.resolve().then(()=>g0),"./es-ES.ts":()=>Promise.resolve().then(()=>a6),"./fr-FR.ts":()=>Promise.resolve().then(()=>o6),"./ja-JP.ts":()=>Promise.resolve().then(()=>i6),"./ko-KR.ts":()=>Promise.resolve().then(()=>c6),"./nl-NL.ts":()=>Promise.resolve().then(()=>s6),"./pt-PT.ts":()=>Promise.resolve().then(()=>d6),"./ru-RU.ts":()=>Promise.resolve().then(()=>l6),"./zh-CN.ts":()=>Promise.resolve().then(()=>u6),"./zh-HK.ts":()=>Promise.resolve().then(()=>m6),"./zh-TW.ts":()=>Promise.resolve().then(()=>f6)})).reduce((e,[n,t])=>{const r=n.match(/\.\/(.+)\./)[1];return e[r]=t,e},{});var bn=(e=>(e.deDE="de-DE",e.enGB="en-GB",e.esES="es-ES",e.frFR="fr-FR",e.jaJP="ja-JP",e.koKR="ko-KR",e.nlNL="nl-NL",e.ptPT="pt-PT",e.ruRU="ru-RU",e.zhCN="zh-CN",e.zhHK="zh-HK",e.zhTW="zh-TW",e))(bn||{});const ar={"guideCard.redirectDescription":"After submission, you will be redirected to the payment method provider's page to safely complete the subsequent steps.","guideCard.scanQRCode":"After submitting the order, use {method} to scan the QR code.","dropIn.card.label":"Bank card","dropIn.otherPaymentMethod":"Other payment method","dropIn.boost.label":"Boost","dropIn.TNGWallet.label":"Touch 'n Go eWallet","dropIn.shopeePay.label":"ShopeePay","dropIn.mayBankQRPay.label":"Maybank QRPay","dropIn.grabPay.label":"GrabPay","dropIn.linePay.label":"LinePay","dropIn.ninePay.label":"9Pay","dropIn.gcash.label":"GCash","dropIn.paymaya.label":"Paymaya","card.cardNumber.label":"Card number","card.cardNumber.incomplete":"Your card number is incomplete","card.cardNumber.invalid":"Your card number is invalid","card.cardNumber.placeholder":"1234 5678 9012 3456","card.cardExpireDate.label":"Expiry date","card.cardExpireDate.placeholder":"MM/YY","card.cardExpireDate.incomplete":"Your card expiry date is incomplete","card.cardExpireDate.expired":"Your card has expired","card.cardSecurityCode.label":"CVC/CVV","card.cardSecurityCode.placeholder":"123","card.cardSecurityCode.incomplete":"Your card security code is incomplete","card.cardHolderName.label":"Cardholder name","card.cardHolderName.placeholder":"Full name on card","card.cardHolderName.incomplete":"Your name is incomplete","card.cardSelector.change":"Change","card.cardSelector.useOtherCard":"Use other card","card.storeInfo":"Save my card info. for future use","card.info.label":"Card Information","common.pay":"Buy now","common.payProcessing":"Processing...","common.paySuccess":"Payment Successful","common.payTimeout":"Connection lost","common.pay3DSIncomplete":"3DS Authentication Incomplete","common.queryTimeout":"Query timed out. Please refresh the page or pay again","common.generateQrCode":"Generate QR code","common.recurringTip":"By paying for this order, you authorize the merchant to automatically charge your bank card in the future according to the terms.","common.noData":"No data","common.netError":"Network Error","common.unknownError":"Unknown Error","common.cancel":"Cancel","common.confirm":"Confirm","common.email.label":"Email","common.email.incomplete":"Please enter your email","common.email.incorrect":"Incorrect email","common.accountName.label":"Account name","common.accountName.placeholder":"Full name on the account","common.accountName.incomplete":"Your name is incomplete","address.label":"Billing address","address.country":"Country/Region","address.address1":"Line 1","address.address2":"Line 2","address.city":"City","address.postCode":"Post code","address.province":"State/Province","address.area":"District/County","sepa.iban.label":"IBAN","sepa.iban.placeholder":"DE00 0000 0000 0000 0000 00","sepa.iban.invalid":"Your entered IBAN is invalid","threeDS.paymentIncomplete":"Your last payment is incomplete, ","threeDS.completeFirst":"please complete the processing first.","threeDS.authenticationSuccessful":"Authentication successful,","threeDS.authenticationFailed":"Authentication failed,","threeDS.returnToCheckout":"returning shortly.","qrCode.expired":"The QR code has expired.","qrCode.scanByGcash":"Scan QR code with GCash"},g0=Object.freeze(Object.defineProperty({__proto__:null,default:ar},Symbol.toStringTag,{value:"Module"}));function Ki(e){return e.replaceAll("_","-").toLowerCase()}function qi(e){return e.split("-")[0]}const v0=()=>Object.entries(C0()).map(([e,n])=>({locale:Ki(e),language:qi(e),translation:n}));function p0(e){return v0()}function Ji(e,n){var a,o;const t=p0();e=Ki(e);let r=(a=t.find(c=>c.locale===e))==null?void 0:a.translation;if(!r){const c=qi(e);r=(o=t.find(s=>s.language===c))==null?void 0:o.translation}return r}const b0=e=>{let n=Xi(e);return n||(n=Xi(nn().language)),n||bn.enGB},Xi=e=>{if(Object.values(bn).includes(e))return e;if(e!=null&&e.toLowerCase().startsWith("en"))return bn.enGB;if(e!=null&&e.toLowerCase().startsWith("zh"))return bn.zhCN};async function A0(e,n){let t=Ji(e);if(!t&&e!==nn().language&&(e=nn().language,t=Ji(e)),Bo(t)){const r=await t();return{locale:e,translation:r.default}}return t?{locale:e,translation:t}:{locale:bn.enGB,translation:ar}}var S0=Symbol.for("preact-signals");function q1(){if(Dn>1)Dn--;else{for(var e,n=!1;or!==void 0;){var t=or;for(or=void 0,J1++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&ec(t))try{t.c()}catch(a){n||(e=a,n=!0)}t=r}}if(J1=0,Dn--,n)throw e}}var Fe=void 0,or=void 0,Dn=0,J1=0,Or=0;function $i(e){if(Fe!==void 0){var n=e.n;if(n===void 0||n.t!==Fe)return n={i:0,S:e,p:Fe.s,n:void 0,t:Fe,e:void 0,x:void 0,r:n},Fe.s!==void 0&&(Fe.s.n=n),Fe.s=n,e.n=n,32&Fe.f&&e.S(n),n;if(n.i===-1)return n.i=0,n.n!==void 0&&(n.n.p=n.p,n.p!==void 0&&(n.p.n=n.n),n.p=Fe.s,n.n=void 0,Fe.s.n=n,Fe.s=n),n}}function et(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}et.prototype.brand=S0,et.prototype.h=function(){return!0},et.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)},et.prototype.U=function(e){if(this.t!==void 0){var n=e.e,t=e.x;n!==void 0&&(n.x=t,e.e=void 0),t!==void 0&&(t.e=n,e.x=void 0),e===this.t&&(this.t=t)}},et.prototype.subscribe=function(e){var n=this;return $1(function(){var t=n.value,r=Fe;Fe=void 0;try{e(t)}finally{Fe=r}})},et.prototype.valueOf=function(){return this.value},et.prototype.toString=function(){return this.value+""},et.prototype.toJSON=function(){return this.value},et.prototype.peek=function(){var e=Fe;Fe=void 0;try{return this.value}finally{Fe=e}},Object.defineProperty(et.prototype,"value",{get:function(){var e=$i(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(J1>100)throw new Error("Cycle detected");this.v=e,this.i++,Or++,Dn++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{q1()}}}});function Fr(e){return new et(e)}function ec(e){for(var n=e.s;n!==void 0;n=n.n)if(n.S.i!==n.i||!n.S.h()||n.S.i!==n.i)return!0;return!1}function tc(e){for(var n=e.s;n!==void 0;n=n.n){var t=n.S.n;if(t!==void 0&&(n.r=t),n.S.n=n,n.i=-1,n.n===void 0){e.s=n;break}}}function nc(e){for(var n=e.s,t=void 0;n!==void 0;){var r=n.p;n.i===-1?(n.S.U(n),r!==void 0&&(r.n=n.n),n.n!==void 0&&(n.n.p=r)):t=n,n.S.n=n.r,n.r!==void 0&&(n.r=void 0),n=r}e.s=t}function Bn(e){et.call(this,void 0),this.x=e,this.s=void 0,this.g=Or-1,this.f=4}(Bn.prototype=new et).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Or))return!0;if(this.g=Or,this.f|=1,this.i>0&&!ec(this))return this.f&=-2,!0;var e=Fe;try{tc(this),Fe=this;var n=this.x();(16&this.f||this.v!==n||this.i===0)&&(this.v=n,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return Fe=e,nc(this),this.f&=-2,!0},Bn.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var n=this.s;n!==void 0;n=n.n)n.S.S(n)}et.prototype.S.call(this,e)},Bn.prototype.U=function(e){if(this.t!==void 0&&(et.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var n=this.s;n!==void 0;n=n.n)n.S.U(n)}},Bn.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty(Bn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=$i(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function rc(e){return new Bn(e)}function ac(e){var n=e.u;if(e.u=void 0,typeof n=="function"){Dn++;var t=Fe;Fe=void 0;try{n()}catch(r){throw e.f&=-2,e.f|=8,X1(e),r}finally{Fe=t,q1()}}}function X1(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,ac(e)}function w0(e){if(Fe!==this)throw new Error("Out-of-order effect");nc(this),Fe=e,this.f&=-2,8&this.f&&X1(this),q1()}function ir(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}ir.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var n=this.x();typeof n=="function"&&(this.u=n)}finally{e()}},ir.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,ac(this),tc(this),Dn++;var e=Fe;return Fe=this,w0.bind(this,e)},ir.prototype.N=function(){2&this.f||(this.f|=2,this.o=or,or=this)},ir.prototype.d=function(){this.f|=8,1&this.f||X1(this)};function $1(e){var n=new ir(e);try{n.c()}catch(t){throw n.d(),t}return n.d.bind(n)}var ea;function Vn(e,n){oe[e]=n.bind(null,oe[e]||function(){})}function Ur(e){ea&&ea(),ea=e&&e.S()}function oc(e){var n=this,t=e.data,r=_0(t);r.value=t;var a=It(function(){for(var o=n.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}return n.__$u.c=function(){var c;!Ja(a.peek())&&((c=n.base)==null?void 0:c.nodeType)===3?n.base.data=a.peek():(n.__$f|=1,n.setState({}))},rc(function(){var c=r.value.value;return c===0?0:c===!0?"":c||""})},[]);return a.value}oc.displayName="_st",Object.defineProperties(et.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:oc},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Vn("__b",function(e,n){if(typeof n.type=="string"){var t,r=n.props;for(var a in r)if(a!=="children"){var o=r[a];o instanceof et&&(t||(n.__np=t={}),t[a]=o,r[a]=o.peek())}}e(n)}),Vn("__r",function(e,n){Ur();var t,r=n.__c;r&&(r.__$f&=-2,(t=r.__$u)===void 0&&(r.__$u=t=function(a){var o;return $1(function(){o=this}),o.c=function(){r.__$f|=1,r.setState({})},o}())),Ur(t),e(n)}),Vn("__e",function(e,n,t,r){Ur(),e(n,t,r)}),Vn("diffed",function(e,n){Ur();var t;if(typeof n.type=="string"&&(t=n.__e)){var r=n.__np,a=n.props;if(r){var o=t.U;if(o)for(var c in o){var s=o[c];s!==void 0&&!(c in r)&&(s.d(),o[c]=void 0)}else t.U=o={};for(var d in r){var l=o[d],m=r[d];l===void 0?(l=E0(t,d,m,a),o[d]=l):l.o(m,a)}}}e(n)});function E0(e,n,t,r){var a=n in e&&e.ownerSVGElement===void 0,o=Fr(t);return{o:function(c,s){o.value=c,r=s},d:$1(function(){var c=o.value.value;r[n]!==c&&(r[n]=c,a?e[n]=c:c?e.setAttribute(n,c):e.removeAttribute(n))})}}Vn("unmount",function(e,n){if(typeof n.type=="string"){var t=n.__e;if(t){var r=t.U;if(r){t.U=void 0;for(var a in r){var o=r[a];o&&o.d()}}}}else{var c=n.__c;if(c){var s=c.__$u;s&&(c.__$u=void 0,s.d())}}e(n)}),Vn("__h",function(e,n,t,r){(r<3||r===9)&&(n.__$f|=2),e(n,t,r)}),Zt.prototype.shouldComponentUpdate=function(e,n){var t=this.__$u;if(!(t&&t.s!==void 0||4&this.__$f)||3&this.__$f)return!0;for(var r in n)return!0;for(var a in e)if(a!=="__source"&&e[a]!==this.props[a])return!0;for(var o in this.props)if(!(o in e))return!0;return!1};function _0(e){return It(function(){return Fr(e)},[])}const jn=class jn{constructor(){Ee(this,"locale");Ee(this,"translation");Ee(this,"isReady",Fr(!1));Ee(this,"currentLoadId",0);return jn.instance||(jn.instance=this),jn.instance}get(n,t){var a;let r=((a=this.translation)==null?void 0:a[n])??"";return t&&typeof r=="string"&&Object.keys(t).forEach(o=>{r=r.replace(new RegExp(`{${o}}`,"g"),String(t[o]))}),r}get ready(){return this.isReady}load(n=nn().language){if(n===this.locale)return;this.locale=n;const t=++this.currentLoadId;this.isReady.value=!1,A0(this.locale).then(r=>{t===this.currentLoadId&&(this.isReady.value=!0,this.locale=r.locale,this.translation=r.translation)}).catch(()=>{this.isReady.value=!1})}};Ee(jn,"instance");let Gr=jn,ta="https://checkout.aq.paykka.com",Ht="https://checkout.aq.paykka.com",Zr="/cp",xn=`${Ht}${Zr}`,ic,cc={},sc,Qe=!1;const cr=e=>{ta=e},sr=e=>{const n=new URL(e);Ht=n.origin,Zr=n.pathname,xn=`${Ht}${Zr==="/"?"":Zr}`},dc=e=>{ic=e},I0=e=>{cc=e},lc=e=>{sc=e},uc=e=>{Qe=e.hidePaymentButton||!1},tt=Ar(null),mc=new WeakMap,jr=(e,n)=>{const t=Object.assign(mc.get(e)??{},n);return mc.set(e,t),t};function An(e,n){const t={},r={updateProps:l,mount:m,unmount:u,get props(){return Di(o)},ref:t},a=e,o={...n},c=jr(r,{vNode:s(),render:d});function s(){return Pn(a,{...o,ref:y=>{Object.assign(t,y)}})}function d(){jr(r,{vNode:s()}),c.dom&&br(c.vNode,c.dom)}function l(y){Object.assign(o,y),d()}function m(y){const h=hn(y)?document.querySelector(y):y;if(!h)throw new Error("Component could not mount. Root node was not found.");return u(),jr(r,{dom:h}),d(),r}function u(){const{dom:y}=c;return y&&(br(null,y),jr(r,{dom:null})),r}return r}var na=(e=>(e.ERROR="ERROR",e.API_ERROR="API_ERROR",e.TIMEOUT="TIMEOUT",e))(na||{});class Se extends Error{constructor(t,r,a){super(r);Ee(this,"type");Ee(this,"code");this.type=t,this.code=a==null?void 0:a.code,this.cause=a==null?void 0:a.cause}}const fc=async({sessionId:e,clientKey:n},t)=>Q0({sessionId:e,clientKey:n},t);class hc{constructor(n,t){ln(this,d1);Ee(this,"sessionId");Ee(this,"clientKey");Ee(this,"checkout");Ee(this,"colors",null);ln(this,wn,gn());this.sessionId=n,this.clientKey=t,id(this,d1,cd).call(this).then(()=>Ye(this,wn).resolve(!0)).catch(r=>{qe(r)?Ye(this,wn).reject(r):Ye(this,wn).reject(new Se("API_ERROR",r.message,{code:r.code}))})}genColors(){var t;const{payButtonBackgroundColor:n}=((t=this.checkout)==null?void 0:t.theme)||{};if(n){const r=Ju(n,{theme:"default",backgroundColor:"#fff"});this.colors={primary:r[5],primaryHover:r[4],primaryActive:r[6]}}}ready(){return Ye(this,wn)}}wn=new WeakMap,d1=new WeakSet,cd=async function(){this.checkout=await fc({sessionId:this.sessionId,clientKey:this.clientKey}),this.genColors()};const P0={eu:"https://checkout.eu.paykka.com",hk:"https://checkout.aq.paykka.com",sandbox:"https://checkout-sandbox.aq.paykka.com"},R0={eu:"https://checkout.eu.paykka.com/cp",hk:"https://checkout.aq.paykka.com/cp",sandbox:"https://checkout-sandbox.aq.paykka.com/cp"},N0={eu:{SR:"pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq"},hk:{SR:"pk_live_51QSXh9Azq7GQL5iqwZNLz3KJ896MIUnai4H7H0z9DtlklJkgoH1VAlHKy382vWPqDm80nTy8MKUdJIKs0fFbTlKx006WcKWEDu"},sandbox:{SR:"pk_test_51QaC2P5VarcojPHdg13yagk5TqrGkIkeK8I21BgQUZe8BzyRmbtmOg3dKsXjkxt6JlsjyjJMTvBH9dFMCZWRxOkt00tWQ1eHFU"}},k0=async(e,n)=>Ne.post("/session/fraud-detection/component/authorization",e,n).then(t=>({authCode:t.auth_code,channel:t.channel,expireTime:t.expire_time})),L0="https://centinelapistag.cardinalcommerce.com",T0=1e4,Yn=class Yn{constructor(n){Ee(this,"iframe",null);Ee(this,"jwt",null);Ee(this,"listener",null);Ee(this,"timer",null);Ee(this,"fraudDetectionId",null);Ee(this,"p");Ee(this,"options");if(Yn.instance)return Yn.instance;this.options=n,Yn.instance=this}async getFraudDetectionId(n){return this.fraudDetectionId?this.fraudDetectionId:this.p?this.p:(this.iframe=null,this.timer&&clearTimeout(this.timer),this.p=this.requestFraudDetectionId(n),this.p)}async requestFraudDetectionId(n){const{onEvent:t}=this.options||{};t==null||t(jt.WORLDPAY_DDC_START);try{return await Promise.all([this.getJWT(),this.initIframe()]),this.sendJWTAndBin(n),new Promise(r=>{this.timer&&clearTimeout(this.timer),this.timer=setTimeout(()=>{this.clearListener(),console.error("worldpay ddc get id timeout"),t==null||t(jt.WORLDPAY_DDC_TIMEOUT),r("")},T0),this.listenFraudDetectionId(a=>{this.timer&&clearTimeout(this.timer),this.fraudDetectionId=a,t==null||t(jt.WORLDPAY_DDC_SUCCESS),r(a)})})}catch(r){return console.error(r),t==null||t(jt.WORLDPAY_DDC_ERROR),""}}sendJWTAndBin(n){const t={action:Re.DDC_JWT_BIN,jwt:this.jwt||"",bin:n};ze(t,this.iframe.contentWindow,Ht)}listenFraudDetectionId(n){this.listener&&this.clearListener(),this.listener=t=>{var r;if(t.origin===L0){const a=JSON.parse(t.data);if(console.warn("worldpay ddc data",a),a){const o=a.SessionId||((r=a.Payload)==null?void 0:r.SessionId);n(o)}}},window.addEventListener("message",this.listener)}clearListener(){this.listener&&window.removeEventListener("message",this.listener),this.timer&&clearTimeout(this.timer),this.listener=null,this.timer=null}getJWT(){return this.jwt?this.jwt:k0({channel:"WORLD_PAY"}).then(n=>(this.jwt=n.authCode,this.jwt))}initIframe(){if(this.iframe)return;const n=document.createElement("iframe");return n.src=`${xn}/worldpay-ddc.html`,n.style.display="none",n.width="1",n.height="1",document.body.appendChild(n),this.iframe=n,new Promise(t=>{n.onload=()=>{t()}})}};Ee(Yn,"instance",null);let Yr=Yn;var M0={VITE_API_URL:"https://checkout.aq.paykka.com",VITE_CDN_ORIGIN:"https://checkout.aq.paykka.com",VITE_CDN_DIR:"/cp",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const D0={eu:"pk_live_51QSXl2G2tOepMLcRVNu0S2T6MxyB1AIgCP5g7qMQvAviQS37v0wkPhJRKqfcbTql6ZkCkGktux4ixfXuZtFy6ZpP00awbGlLEq",hk:"pk_live_51QSXh9Azq7GQL5iqwZNLz3KJ896MIUnai4H7H0z9DtlklJkgoH1VAlHKy382vWPqDm80nTy8MKUdJIKs0fFbTlKx006WcKWEDu",us:M0.VITE_STRIPE_KEY},B0="eu";let ra=null;function V0(e,n,t){return ra||(ra=new x0(e,n,t)),ra}class x0{constructor(n=B0,t=[at.SR,at.WP],r){Ee(this,"options");Ee(this,"collResultMap",{[at.SR]:"",[at.WP]:""});Ee(this,"collMap",{[at.SR]:()=>this.stripeRadarColl(),[at.WP]:()=>this.worldpayDDCColl()});Ee(this,"p");Ee(this,"realMode",[]);Ee(this,"keyMap",{[at.SR]:""});this.realMode=t,this.options=r,t.includes(at.SR)&&(typeof n=="string"?this.keyMap[at.SR]=D0[n]:this.keyMap[at.SR]=n[at.SR])}get fraudDetectionID(){return this.formatFraudDetectionId({s:this.collResultMap[at.SR]})}async getFraudDetectionId(n){return this.formatFraudDetectionId({s:this.collResultMap[at.SR],w:await this.worldpayDDCColl().getFraudDetectionId((n==null?void 0:n.bin)||"")})}async createFraudDetection(){this.p||(this.p=Promise.all(this.realMode.map(async n=>{if(this.collMap[n])return await this.collMap[n]();throw new Error(`Unsupported collection mode: ${n}`)}))),await this.p}formatFraudDetectionId(n){var t,r;try{const a=JSON.stringify(n);return btoa(a)}catch(a){return console.error("[PayKKa Fraud Detection SDK]:",a),(r=(t=this.options)==null?void 0:t.onEvent)==null||r.call(t,jt.FRAUD_DETECTION_TRANSFORM_ERROR),""}}stripeRadarColl(){return new Promise((n,t)=>{const{onEvent:r}=this.options||{};r==null||r(jt.STRIPE_RADAR_START);const a=document.createElement("script");a.type="text/javascript",a.src="https://js.stripe.com/v3/",a.async=!0,a.crossOrigin="",a.onload=async()=>{const o=window.Stripe(this.keyMap[at.SR]),{radarSession:c,error:s}=await o.createRadarSession();s?(console.error(s),r==null||r(jt.STRIPE_RADAR_ERROR),t(s)):(this.collResultMap[at.SR]=c==null?void 0:c.id,r==null||r(jt.STRIPE_RADAR_SUCCESS),n(c))},a.onerror=()=>{r==null||r(jt.STRIPE_RADAR_LOAD_ERROR),t()},document.getElementsByTagName("head")[0].appendChild(a)})}worldpayDDCColl(){return new Yr(this.options)}}const H0="m";class O0{constructor(n){ln(this,Gt,void 0);ln(this,l1,void 0);ln(this,$t,void 0);ln(this,u1,[]);Ee(this,"processingPaymentMethod",null);Ee(this,"enablePaymentMethod",Fr(null));y1(this,Gt,n),this.init()}init(){this.initEnv(),this.initLocale(),this.initExtraParams(),this.initSession(),this.initOtherData()}initSession(){const{sessionId:n,clientKey:t,onPaymentMethodsReady:r,onInitError:a,onSuccess:o}=Ye(this,Gt);if(!n){a==null||a(new Se("ERROR","SessionId is required"));return}y1(this,$t,new hc(n,t)),Ye(this,$t).ready().then(()=>{var d,l;if(Hd((d=Ye(this,$t))==null?void 0:d.checkout)){a==null||a(new Se("ERROR","Checkout is empty"));return}const{paymentMethod:c=[],status:s}=((l=Ye(this,$t))==null?void 0:l.checkout)||{};if(s==="SUCCESS"){o==null||o({});return}r==null||r(c)}).catch(c=>{a==null||a(c)})}initEnv(){const{env:n,_envConfig:t,onInitError:r}=Ye(this,Gt);if(!n){r==null||r(new Se("ERROR","Env is required"));return}cr((t==null?void 0:t.api)||P0[n]),sr((t==null?void 0:t.cdn)||R0[n]),dc((t==null?void 0:t.fraudDetection)||N0[n])}initLocale(){const{locale:n}=Ye(this,Gt);n&&lc(n)}initExtraParams(){const{hidePaymentButton:n=!1}=Ye(this,Gt);uc({hidePaymentButton:n})}initOtherData(){const n=o0(H0);n&&(this.processingPaymentMethod=n)}get session(){return Ye(this,$t)}get envConfig(){return Ye(this,l1)}get config(){return Ye(this,Gt)}create(n,t){var m;const{onSubmit:r,onSuccess:a,onError:o,onTimeout:c,onExpired:s}=Ye(this,Gt),d=this.getCoreProps(),l=An(n,{onSubmit:r,onSuccess:a,onError:o,onTimeout:c,onExpired:s,...t,...d});return(m=Ye(this,u1))==null||m.push(l),l}getCoreProps(){return{session:Ye(this,$t),core:this,threeDSFrame:Ye(this,Gt).threeDSFrame}}resetEnablePaymentMethod(){this.enablePaymentMethod.value=null}}Gt=new WeakMap,l1=new WeakMap,$t=new WeakMap,u1=new WeakMap;const yc=async(e,n,t,{timeout:r=2e4,headers:a,locale:o}={})=>{const c=new AbortController,s=setTimeout(()=>{c.abort()},r);try{const d=Bd(),l=e==="post",m=await d(`${ta}/bk${n}`,{method:e,mode:"cors",cache:"default",credentials:"same-origin",headers:{Accept:"application/json, text/plain, */*","Content-Type":l?"application/json":"text/plain","Accept-Language":o??nn().language,...cc,...a},redirect:"follow",referrerPolicy:"no-referrer-when-downgrade",body:l&&t?y0(t):void 0,signal:c.signal});clearTimeout(s);const u=String(m.status);let y;try{y=await m.json()}catch{y={i18nKey:"common.netError"}}if(u==="500")throw{code:u,...y.ret_msg?{message:y.ret_msg}:{i18nKey:"common.unknownError"}};if(/^(429|5\d{2})$/.test(u))throw{code:u,i18nKey:"common.netError"};if(y.ret_code!=="000000")throw{code:y.ret_code,message:y.ret_msg};return y.data}catch(d){throw d.name==="AbortError"?new Se(na.TIMEOUT):d.code?d:{i18nKey:"common.unknownError"}}},Ne={get:(e,n,t)=>yc("get",e,n,t),post:(e,n,t)=>yc("post",e,n,t)},qe=e=>e instanceof Se&&e.type===na.TIMEOUT,dt=async(e={})=>{const{fraudDetectionId:n}=e,t=await Du();let r="WEB";const a=window.navigator.userAgent.toLowerCase();return t.deviceType==="MOBILE"&&(a.includes("miniprogram")?r="MINI_APP":a.includes("micromessenger")||a.includes("alipay")?r="IN_APP_WAP":Tu(a)?r="APP":r="WAP"),{user_agent:t.userAgent,color_depth:t.colorDepth,language:t.language,java_enabled:t.javaEnabled,device_type:t.deviceType,timezone_offset:t.timezoneOffset,screen_height:t.screenHeight,screen_width:t.screenWidth,cookies:t.cookies,device_os:t.osName,device_finger_print_id:t.deviceFingerprintId,terminal_type:r,fraud_detection_id:n}};function Ut(e){return{amount:e==null?void 0:e.amount,currency:e==null?void 0:e.currency,symbol:e==null?void 0:e.symbol,digits:e==null?void 0:e.default_fraction_digits}}function Be(e){var n,t;return{errorCode:e.error_code,errorMessage:e.error_description,merchantId:e.merchant_id,sessionId:e.session_id,orderId:e.order_id,transAmount:Ut(e.trans_amount),status:e.status,orderStatus:e.order_status,threeDSUrl:(n=e.authentication_result)==null?void 0:n.authentication_url,paymentUrl:(t=e.pay_info)==null?void 0:t.payment_url,paymentExpiredAt:e==null?void 0:e.payment_expire_time,payInfo:e.pay_info}}async function F0({sessionId:e,clientKey:n,bill:t},r,a){const{_getExtraParams:o}=r.config,c=o==null?void 0:o("payment",$.ALI_PAY),s=st({bill:{email:t.email,country:t.country,state:t.province,city:t.city,postal_code:t.postCode,address_line1:t.address1,address_line2:t.address2,county:t.area}},c||{});return Ne.post("/session/payments",{...s,session_id:e,client_key:n,payment:{payment_method:$.ALI_PAY},browser:await dt()},a).then(Be)}async function U0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.ALI_PAY},t).then(Be)}async function Cc({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c){const s=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},o||{});return Ne.post("/session/payments",{...s,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod,card_no:t.cardNo,exp_year:t.expYear,exp_month:t.expMonth,cvv:t.cvv,holder_name:t.holderName,store_payment_method:t.storePaymentMethod,token_usage:t.tokenUsage,token:t.token},browser:a},c).then(Be)}async function gc({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n},t).then(Be)}function vc(e=[]){const n=[],t={};return e.forEach(({value:r,configuration:a={}})=>{r===$.APPLE_PAY?t.applePay={countryCode:a==null?void 0:a.country_code,supportedNetworks:a==null?void 0:a.allowed_card_networks,merchantIdentifier:a==null?void 0:a.merchant_identifier}:r===$.GOOGLE_PAY?t.googlePay={countryCode:a==null?void 0:a.country_code,providerGatewayId:a==null?void 0:a.provider_gateway_id,merchantGatewayId:a==null?void 0:a.merchant_gateway_id,allowedAuthMethods:a==null?void 0:a.allowed_auth_methods,allowedCardNetworks:a==null?void 0:a.allowed_card_networks,environment:a==null?void 0:a.environment,googlePayMerchantId:a==null?void 0:a.merchant_id}:r===$.WECHAT_PAY?t.wechatPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:Ut(a==null?void 0:a.fee),totalAmount:Ut(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}:r===$.ALI_PAY&&(t.aliPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:Ut(a==null?void 0:a.fee),totalAmount:Ut(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}),r===$.BANKCARD?n.push(...a.allowed_card_networks||[]):n.push(r)}),{paymentMethod:n,channelParams:t}}function G0(e={}){return{goodsTax:Ut(e.goods_tax),shippingAmount:Ut(e.shipping_amount),shippingTax:Ut(e.shipping_tax),discount:Ut(e.discount),other:Ut(e.other)}}function Z0(e={}){var s,d,l;const{theme:n,bill:t,payment_methods:r,field:a}=e,o=vc(r),c=e.session_mode==="HOST"?"HOSTED":e.session_mode;return{country:e.country,merchantId:e.merchant_id,sessionId:e.session_id,status:e.status,transAmount:Ut(e.trans_amount),expireTime:e.expire_time,sessionMode:c,merchantName:(s=e.theme)==null?void 0:s.merchant_name,returnUrl:e.return_url,cancelUrl:e.cancel_url,locale:e.locale,paymentType:e.payment_type,goods:e.goods?e.goods:[],theme:{merchantName:n==null?void 0:n.merchant_name,logo:n==null?void 0:n.logo,payButtonBackgroundColor:n==null?void 0:n.pay_btn_background_color,payButtonTextColor:n==null?void 0:n.pay_btn_text_color,showPaykka:n==null?void 0:n.show_paykka},bill:{billingAddressCollection:t==null?void 0:t.billing_address_collection,addressLine1:t==null?void 0:t.address_line1,addressLine2:t==null?void 0:t.address_line2,email:t==null?void 0:t.email,descriptor:t==null?void 0:t.descriptor,country:t==null?void 0:t.country},tokens:(d=e.tokens)==null?void 0:d.map(m=>({token:m.token,last4:m.last4,cardBrand:m.card_brand,billingAddressFilled:m.billing_address_filled})),storePaymentMethod:(l=e.payment)==null?void 0:l.store_payment_method,field:{holderName:{show:!!(a!=null&&a.holder_name_display),required:!!(a!=null&&a.holder_name_required)},email:{show:!!(a!=null&&a.bill_email_display),required:!!(a!=null&&a.bill_email_required),disabled:!!(a!=null&&a.bill_email_disabled)},address:{show:!!(a!=null&&a.bill_address_display),required:!!(a!=null&&a.bill_address_required)}},amountBreakdown:G0(e.amount_breakdown),...o}}const j0=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/info",{session_id:e,client_key:n,browser:await dt()},t),Y0=async({sessionId:e,clientKey:n},t)=>{const r=await j0({sessionId:e,clientKey:n},t);return Z0({...r,...r==null?void 0:r.support_methods})};let aa;const Q0=async({sessionId:e,clientKey:n},t)=>aa||(aa=Y0({sessionId:e,clientKey:n},t));async function W0({sessionId:e,clientKey:n,bill:t,channelUserId:r},a,o){const{_getExtraParams:c}=a.config,s=c==null?void 0:c("payment",$.WECHAT_PAY),d=st({bill:{email:t.email,country:t.country,state:t.province,city:t.city,postal_code:t.postCode,address_line1:t.address1,address_line2:t.address2,county:t.area}},s||{});return Ne.post("/session/payments",{...d,session_id:e,client_key:n,payment:{payment_method:$.WECHAT_PAY},browser:await dt(),channel_user_id:r},o).then(Be)}async function z0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.WECHAT_PAY},t).then(Be)}async function K0(e){return Ne.post("/session/apple-pay/create-session",e)}async function q0({sessionId:e,clientKey:n,token:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.APPLE_PAY),l=st({bill:{first_name:r==null?void 0:r.firstName,middle_name:r==null?void 0:r.middleName,last_name:r==null?void 0:r.lastName,address_line1:r==null?void 0:r.addressLine1,address_line2:r==null?void 0:r.addressLine2,country:r==null?void 0:r.country,state:r==null?void 0:r.state,city:r==null?void 0:r.city,email:r==null?void 0:r.email,postal_code:r==null?void 0:r.postalCode,area_code:r==null?void 0:r.areaCode,phone_number:r==null?void 0:r.phoneNumber,descriptor:r==null?void 0:r.descriptor}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:$.APPLE_PAY,token_data:t},browser:a},c).then(Be)}async function J0({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.APPLE_PAY},t).then(Be)}async function X0({sessionId:e,clientKey:n,token:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.GOOGLE_PAY),l=st({bill:{first_name:r==null?void 0:r.firstName,middle_name:r==null?void 0:r.middleName,last_name:r==null?void 0:r.lastName,address_line1:r==null?void 0:r.addressLine1,address_line2:r==null?void 0:r.addressLine2,country:r==null?void 0:r.country,state:r==null?void 0:r.state,city:r==null?void 0:r.city,email:r==null?void 0:r.email,postal_code:r==null?void 0:r.postalCode,area_code:r==null?void 0:r.areaCode,phone_number:r==null?void 0:r.phoneNumber,descriptor:r==null?void 0:r.descriptor}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:$.GOOGLE_PAY,token_data:t},browser:a},c).then(Be)}async function pc({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GOOGLE_PAY},t).then(Be)}async function $0({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c){const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",$.SEPA_DEBIT),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{iban:t.iban,payment_method:$.SEPA_DEBIT,holder_name:t.holderName},browser:a},c).then(Be)}async function e3({sessionId:e,clientKey:n},t){return Ne.post("/session/payments/query",{session_id:e,client_key:n},t).then(Be)}const t3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},n3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.BOOST},t).then(Be),r3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},a3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.LINE_PAY},t).then(Be),o3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},i3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.MAY_BANK_QR_PAY},t).then(Be),c3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},s3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.NINE_PAY},t).then(Be),d3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},l3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GRAB_PAY},t).then(Be),u3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},m3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.TNG_WALLET},t).then(Be),f3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},h3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.SHOPEE_PAY},t).then(Be),y3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},C3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.GCASH},t).then(Be),g3=async({sessionId:e,clientKey:n,payment:t,bill:r,browser:a},o,c)=>{const{_getExtraParams:s}=o.config,d=s==null?void 0:s("payment",t.paymentMethod),l=st({bill:{email:r.email,country:r.country,state:r.province,city:r.city,postal_code:r.postCode,address_line1:r.address1,address_line2:r.address2,county:r.area}},d||{});return Ne.post("/session/payments",{...l,session_id:e,client_key:n,payment:{payment_method:t.paymentMethod},browser:a},c).then(Be)},v3=async({sessionId:e,clientKey:n},t)=>Ne.post("/session/payments/query",{session_id:e,client_key:n,payment_method:$.PAYMAYA},t).then(Be),Qr=new WeakMap;function bc(e,{time:n=70,argsResolver:t,resultResolver:r}){function a(...c){const s=Date.now();let d=Qr.get(e);d||Qr.set(e,d={items:[],firstInvokeTime:s});const l=gn();return d.items.push({args:c,invokeTime:s,promise:l}),d.items.length===1&&o(),l}function o(){setTimeout(()=>{const c=Qr.get(e);if(!c)return;Qr.delete(e);const s=t(c.items);e(...s).then(d=>{c.items.forEach((l,m)=>{l.promise.resolve(r(d,l,m,c.items))})}).catch(d=>{c.items.forEach(l=>{l.promise.reject(d)})})},n)}return a}function p3(e){return{addressItem:e==null?void 0:e.address_item,required:e==null?void 0:e.not_null,description:e==null?void 0:e.description}}async function b3(e){return Ne.get("/pub/datadict/get/COUNTRY",void 0,e).then(n=>{var r;const{values:t}=n;return((r=t==null?void 0:t.map)==null?void 0:r.call(t,a=>({label:a.display_name,value:a.value})))??[]})}async function A3(e,n){return Ne.post(`/address/style/${e}`,void 0,n).then(({address_style_list:t})=>t.map(r=>p3(r)))}const S3=bc(A3,{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}});async function w3(e,n){return Ne.post(`/address/province-dict/${e}`,void 0,n).then(t=>{var r;return(r=t==null?void 0:t.map)==null?void 0:r.call(t,({code:a,description:o})=>({label:o,value:a}))})}const E3=bc(w3,{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}});async function _3(e){return Ne.post(`/address/city-dict/${e}`).then(n=>{var t;return(t=n==null?void 0:n.map)==null?void 0:t.call(n,({code:r,description:a})=>({label:a,value:r}))})}class I3{constructor(){ln(this,sn,void 0);Ee(this,"countryOptions");Ee(this,"provinceOptions");Ee(this,"cityOptions");Ee(this,"addressState");Ee(this,"i18n");Ee(this,"addressFormat");Ee(this,"validateAllFields",!1);this.addressState={country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""},this.countryOptions=[]}setI18n({i18n:n}){this.i18n=n}async requestCountryOption(){var n,t;if(!(this.countryOptions.length!==0||(n=Ye(this,sn))!=null&&n.isPending))try{y1(this,sn,gn()),this.countryOptions=await b3({locale:this.i18n.locale}),Ye(this,sn).resolve(!0)}catch{(t=Ye(this,sn))==null||t.resolve(!1)}}async countryOptionReady(){return Ye(this,sn)}getCountryOption(){return this.countryOptions}async requestProvinceOption(n){return this.provinceOptions=await E3(n,{locale:this.i18n.locale}),this.provinceOptions}getProvinceOption(){return this.provinceOptions}async requestCityOption(){}setCountry(n){this.addressState.country=n}getCountry(){return this.addressState.country}setProvince(n){this.addressState.province=n}getProvince(){return this.addressState.province}setAddressFormat(n){this.addressFormat=n}getAddressFormat(){return this.addressFormat}getAddress1(){return this.addressState.address1}setAddress1(n){this.addressState.address1=n}getAddress2(){return this.addressState.address2}setAddress2(n){this.addressState.address2=n}getCity(){return this.addressState.city}setCity(n){this.addressState.city=n}getArea(){return this.addressState.area}setArea(n){this.addressState.area=n}getPostCode(){return this.addressState.postCode}setPostCode(n){this.addressState.postCode=n}setMap(){return{[Le.ADDRESS_1]:n=>this.setAddress1(n),[Le.ADDRESS_2]:n=>this.setAddress2(n),[Le.CITY]:n=>this.setCity(n),[Le.AREA]:n=>this.setArea(n),[Le.POST_CODE]:n=>this.setPostCode(n),[Le.PROVINCE]:n=>this.setProvince(n),COUNTRY:n=>this.setCountry(n)}}setAddressStateByKey(n,t){this.setMap()[n](t)}getAddressState(){return{country:this.addressState.country,province:this.addressState.province,city:this.addressState.city,area:this.addressState.area,postCode:this.addressState.postCode,address1:this.addressState.address1,address2:this.addressState.address2}}setAddressState(n){this.addressState.country=n==null?void 0:n.country,this.addressState.province=n==null?void 0:n.province,this.addressState.city=n==null?void 0:n.city,this.addressState.area=n==null?void 0:n.area,this.addressState.postCode=n==null?void 0:n.postCode,this.addressState.address1=n==null?void 0:n.address1,this.addressState.address2=n==null?void 0:n.address2}getValidateAllFields(){return this.validateAllFields}setValidateAllFields(n){this.validateAllFields=n}getCityOptions(){return this.cityOptions}setCityOptions(n){this.cityOptions=n}getLabel(n,t){var r;return Dt(n)?null:fn(t)&&t.length>0?((r=t.find(a=>a.value===n))==null?void 0:r.label)??null:null}}sn=new WeakMap;let oa;const bt=()=>oa||(oa=new I3);function Ie(e){return Bu(`${R1}-${e}`)}function lt(e){const n=$n(tt),[t]=M((n==null?void 0:n.i18n)??new Gr);return e&&t.load(e),{i18n:t}}function ut(e,n){const[t,r]=M(!1),[a,o]=M(""),[c,s]=M(!1),[d,l]=M(null),{i18n:m}=lt();return ce(()=>{e.ready().then(()=>{var h;s(!0);const u=b0(sc||((h=e.checkout)==null?void 0:h.locale)||nn().language);m.load(u);const y=V0(ic,void 0,{onEvent:w=>{var v,b;(b=n==null?void 0:(v=n.config).onEvent)==null||b.call(v,w)}});l(y),y==null||y.createFraudDetection()})},[]),{validated:t,setValidated:r,errorMsg:a,setErrorMsg:o,i18n:m,fraudDetection:d,sessionReady:c}}function nt(e,{timeout:n=20*1e3,interval:t=2*1e3,onTimeout:r,onEnd:a}){const o=j(null);ce(()=>s,[]);function c(d={}){return new Promise(l=>{d={timeout:n,interval:t,...d};const m=Date.now(),u=async()=>{if(!o.current){s();return}const y=Date.now(),h=await e(nr(y-m,0,d.timeout));o.current&&(h.end?(a==null||a(h.res),l(h)):y-m>d.timeout?r==null||r():o.current=window.setTimeout(u,d.interval))};o.current=window.setTimeout(u,d.interval)})}function s(){o.current&&(clearTimeout(o.current),o.current=null)}return{start:c,stop:s}}const ia={xs:480,sm:928,md:992,lg:1200,xl:1366,xxl:1600},Ac=()=>{const[e,n]=M(()=>typeof window<"u"?window.innerWidth:0);ce(()=>{if(typeof window>"u")return;const c=()=>{n(window.innerWidth)};return window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]);const t=It(()=>Object.entries(ia).sort((c,s)=>c[1]-s[1]),[ia]),{matches:r,current:a}=It(()=>{const c={xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1};let s=null;for(let d=t.length-1;d>=0;d--){const[l,m]=t[d],u=e>=m;c[l]=u,u&&!s&&(s=l)}return{matches:c,current:s}},[e,t]);return{matches:r,current:a,smaller:c=>{const s=ia[c];return s===void 0?!1:e<s}}},ca=Ie("form-item"),Kt=ca.bem("label"),Sc=ca.bem("error-text"),sa=Ar(null),wc=Ar(null);function Ec(e,n){return n?(fn(e.trigger)?e.trigger:[e.trigger]).includes(n):!0}function P3(e,n){if(!e)return;if(fn(e))return e.filter(r=>Ec(r,n));const t=h0(e,Ec(e,n));return t?[t]:[]}function _c(e){if(e=e.filter(n=>n.status==="error"),!!e.length)return e.reduce((n,t)=>{const r=Object.keys(t.fields).at(-1);return Hi(n,r,t.fields[r]),n},{})}const R3=e=>Dt(e)||e==="",mt=Ve((e,n)=>{const{label:t,path:r,children:a,triggersOfEmptyValue:o=["submit"],onValidationStatusChange:c,className:s,style:d,showErrorMessage:l=!0,showLabel:m=!0}=e;Oe(n,()=>({validate:b,validateChange:P,getValidateResult:w,resetValidation:p}));const u=$n(wc),[y,h]=M({status:"unValidate",errors:[],fields:{}});function w(){return y}function v(C){h(C),C.status!==y.status&&(c==null||c(C.status))}async function b(C,{trigger:S,setResult:R=!0}){return R3(C)&&!o.includes(S)?p():new Promise(async k=>{const A=P3(e.rule,S);if(!r||!(A!=null&&A.length)){k(y);return}const N=[],Y={};for(const F of A){const{validator:x}=F;if(x)try{await x(C)||(N.push({message:void 0,fieldValue:C,field:r}),Y[r]=N)}catch(U){N.push({message:U.message,fieldValue:C,field:r}),Y[r]=N}}let B={status:"unValidate",errors:N,fields:Y};N.length?(B.status="error",R&&v(B)):R?B=p("success"):B.status="success",k(B)})}function p(C="unValidate",S=[]){const R={status:C,errors:C==="error"?S:[],fields:{}};return v(R),R}async function _(C){return await b(C,{trigger:"blur"})}async function P(C){return await b(C,{trigger:"change"})}function g(C){r&&(u==null||u.setForm(S=>(S={...S},Hi(S,r,C),S)))}function I(){var C;return(C=y.errors)==null?void 0:C[0]}return ce(()=>{const C={internalValidate:b,path:r,resetValidation:p};return r&&(u==null||u.setFormItems(S=>[...S,C])),()=>{r&&(u==null||u.setFormItems(S=>S.filter(R=>R!==C)))}},[]),i("div",{className:fe(he,ca.bem(),s),style:d,children:[m&&!Dt(t)&&i("div",{className:Kt,children:t}),i(sa.Provider,{value:{rule:e.rule,validateBlur:_,validateChange:P,resetValidation:p,validationResult:y,setValue:g},children:a}),l&&y.status==="error"&&i("div",{className:Sc,children:I().message})]})}),At=Ve((e,n)=>{const{children:t}=e;Oe(n,()=>({validate:d,resetValidation:m,validateField:l}));const[r,a]=M(e.form),[o,c]=M([]);function s(u,y){if(!P1(u)||!hn(y))return;const h=y.split(".");return h.length===0?u[y]:h.reduce((w,v)=>w&&w[v],u)}async function d(u,y=!0){const h=await Promise.all(o.map(v=>{const b=s(r,v.path);return v.internalValidate(b,{trigger:"submit",setResult:y})})),w=_c(h);if(w)throw u&&(u==null||u(w)),w;u&&(u==null||u())}async function l(u,y,h=!0){const w=o.filter(p=>u.includes(p.path)),v=await Promise.all(w.map(p=>{const _=s(r,p.path);return p.internalValidate(_,{trigger:"submit",setResult:h})})),b=_c(v);if(b)throw y&&(y==null||y(b)),b;y&&(y==null||y())}function m(){o.forEach(u=>{var y;(y=u.resetValidation)==null||y.call(u)})}return ce(()=>{var u;(u=e.onFormChange)==null||u.call(e,r)},[r]),i(wc.Provider,{value:{form:r,setForm:a,formItems:o,setFormItems:c},children:t})}),Sn=Ie("input"),an=Sn.bem("input-wrapper"),N3={error:Vo,success:Qd},ht=Ve((e,n)=>{const{inputClassName:t,style:r,disabled:a,children:o,showStatus:c=!0}=e;Oe(n,()=>({input:u.current,focus:()=>{l(!0)},blur:()=>{l(!1)},valid:()=>{s==null||s.resetValidation("success")},invalid:g=>{s==null||s.resetValidation("error",[{message:g}])}}));const s=$n(sa),[d,l]=M(!1);let m=!1;const u=j(null);let y=e.status??(s==null?void 0:s.validationResult.status);y==="unValidate"&&(y=void 0);let{rightIcon:h}=e;if(c&&y){const g=N3[y];h=i(g,{size:16})}function w(g){var I;l(!0),(I=e.onFocus)==null||I.call(e,g)}function v(g){var C;l(!1),(C=e.onBlur)==null||C.call(e,g);const{value:I}=g.currentTarget;s==null||s.validateBlur(I)}function b(g){var C;if(g instanceof InputEvent&&!g.isComposing&&(m=!1),m)return;const{value:I}=g.target;g instanceof InputEvent&&g.inputType==="insertCompositionText"||((C=e.onInput)==null||C.call(e,g),s==null||s.setValue(I),s==null||s.validateChange(I))}const p=rc(()=>{const g=Sn.bem("input-wrapper",[y,{focus:d}]),I=Sn.bem("input-wrapper-disabled");return a?`${g} ${I}`:`${g}`});function _(g){var I;m=!0,(I=e.onCompositionStart)==null||I.call(e,g)}function P(g){m=!1,b(g)}return i("div",{className:fe(he,Sn.bem(),t),onClick:()=>{var g;return(g=u.current)==null?void 0:g.focus()},children:i("div",{className:`${p}`,style:r,children:[!!e.leftIcon&&i("div",{class:Sn.bem("left-icon"),children:e.leftIcon}),o||i("input",{ref:u,...e,class:Sn.bem("input"),onFocus:w,onBlur:v,onInput:b,onCompositionStart:_,onCompositionEnd:P,autocomplete:"off"}),!!h&&i("div",{class:Sn.bem("right-icon"),children:h})]})})}),{bem:k3}=Ie("select");function L3(e){const{style:n,children:t}=e;return i("div",{style:n,class:k3("menu"),children:t})}const{bem:Ic}=Ie("select");function T3(e){const{onSelect:n,...t}=e,{label:r}=t;function a(o){o.stopPropagation(),n==null||n({...t})}return i("div",{onClick:o=>a(o),class:Ic("menu-item",[{selected:e.selected}]),children:[Bo(r)?r(e,e.selected):r,e.selected&&i("div",{class:Ic("menu-item-icon"),children:qd({})})]})}const{bem:da}=Ie("select"),Wr=Ve((e,n)=>{const t=$n(sa);e.status??(t==null||t.validationResult.status);const[r,a]=M(!1),[o,c]=M(!1),[s,d]=M([]),[l,m]=M(),[u,y]=M(),[h,w]=M(),v=j(null),[b,p]=M(!1),[_,P]=M(!1);It(()=>{if(d(e.options??[]),!Dt(e.value)&&e.options.length>0){const U=g(e.value,e.options);U&&k(U,!1)}},[e.value,e.options]),ce(()=>{if(e.renderLabel)return;const U=Dt(h)||h==="";if(P(!U),U)d(e.options);else{const Q=e.options.filter(W=>W.label.toLowerCase().includes(h.toLowerCase()));d(Q)}},[h]),Oe(n,()=>({blur:()=>{var U,Q;p(!1),c(!1),(Q=(U=v.current)==null?void 0:U.input)==null||Q.blur()}}));function g(U,Q){for(let W=0;W<Q.length;W++){const J=Q[W];if(J.value===U)return J}}function I(U){var Q;p(!0),a(!0),(Q=e.onFocus)==null||Q.call(e,U)}function C(){var U,Q;(Q=(U=v.current)==null?void 0:U.input)==null||Q.focus()}function S(U){var Q;if(a(!1),(Q=e.onBlur)==null||Q.call(e,U),(Dt(h)||h==="")&&c(!1),s.length===0&&e.options.length!==0)w(""),c(!1);else{const{value:W}=U.currentTarget;t==null||t.validateBlur(W)}}function R(U){c(!0),w(U.currentTarget.value)}function k(U,Q=!0){var te,ve;const{value:W,label:J}=U;w(""),y(W),m(((te=e.renderLabel)==null?void 0:te.call(e,U))||J),p(!1),c(!1),Q&&((ve=e==null?void 0:e.onSelect)==null||ve.call(e,W,U))}function A(U){c(!0),w(U.currentTarget.value)}let N,Y;document.addEventListener("mousedown",U=>{N=U}),document.addEventListener("mouseup",U=>{Y=U,B(Y,N)});function B(U,Q){var K,z;if(!F.current)return;const W=U==null?void 0:U.target,J=Q==null?void 0:Q.target,te=((K=F.current)==null?void 0:K.contains(W))||((z=F.current)==null?void 0:z.contains(J)),ve=F.current===W;te||ve||p(!1)}const F=dd(),x=Kd({style:{transform:b?"rotate(-180deg)":"rotate(0deg)",transition:"transform 0.3s ease"}});return i("div",{class:da("wrapper"),ref:F,onClick:()=>{var U,Q;return(Q=(U=v.current)==null?void 0:U.input)==null?void 0:Q.focus()},children:[i(ht,{ref:v,value:h,readOnly:!e.filterable,onInput:R,onFocus:I,onBlur:S,onChange:A,onCompositionStart:()=>c(!0),placeholder:r||o||!Dt(u)?"":e.placeholder,rightIcon:e.rightIcon||x,inputClassName:e.inputClassName}),i("div",{class:da("render-label",[{placeholder:r,hidden:o}]),onClick:C,children:l}),i(L3,{style:{display:b?"block":"none"},children:[_&&s.length===0?i("div",{class:da("menu-no-data"),children:e.noDataTip}):s.map(U=>i(T3,{onSelect:k,selected:u===U.value,...U,label:e.renderLabel?()=>{var Q;return(Q=e.renderLabel)==null?void 0:Q.call(e,U)}:U.label})),e.action]})]})}),{bem:la}=Ie("address-field"),M3={country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""},kt=Ve((e,n)=>{const{onAddressChange:t}=e,{i18n:r}=lt(),a=bt(),[o,c]=M({...a.getAddressState()}),[s,d]=M(a.getCountryOption()??[]),[l,m]=M(a.getProvinceOption()??[]),[u,y]=M([]),[h,w]=M(a.getAddressFormat()),v=j(null),b=j(null),p=j(null),_=j(null),P=j(null),g=j(null),I=j(null);It(()=>{r.ready.value&&(a.setI18n({i18n:r}),a.requestCountryOption(),a.countryOptionReady().then(()=>{N(),d(a.getCountryOption())}))},[r.ready.value]);const C={[Le.ADDRESS_1]:D=>{c(Object.assign(o,{address1:D}))},[Le.ADDRESS_2]:D=>{c(Object.assign(o,{address2:D}))},[Le.CITY]:D=>{c(Object.assign(o,{city:D}))},[Le.AREA]:D=>{c(Object.assign(o,{area:D}))},[Le.POST_CODE]:D=>{c(Object.assign(o,{postCode:D}))},[Le.PROVINCE]:D=>{c(Object.assign(o,{province:D}))},COUNTRY:D=>{c(Object.assign(o,{country:D}))}};function S(D,G){C[D](G)}function R(D,G){S(D,G),a.setAddressStateByKey(D,G)}function k(D){w(D),a.setAddressFormat(D)}Oe(n,()=>({update:D=>{c(D),a.setAddressState(D),k(a.getAddressFormat()),m(a.getProvinceOption()??[]),y(a.getCityOptions()??[])}}));function A(D){D.map(G=>{S(G,""),a.setAddressStateByKey(G,"")})}async function N(){const D=e.country;F(D||""),t({country:o.country??"",province:o.province??"",city:o.city??"",area:o.area??"",postCode:o.postCode??"",address1:o.address1??"",address2:o.address2??""})}const Y={[Le.ADDRESS_1]:ve,[Le.ADDRESS_2]:K,[Le.CITY]:pe,[Le.AREA]:Ce,[Le.POST_CODE]:z,[Le.PROVINCE]:O};function B(){return{trigger:["blur","submit"],validator(D){if(!D)throw new Error;return!0}}}async function F(D){k([]),R("COUNTRY",D);const G=await S3(D,{locale:r.locale}),re=[],be=G.map(({addressItem:me,required:f,description:E})=>(re.push(me),{addressItem:me,required:f,description:E}));x(re,D),k(be),A([Le.PROVINCE,Le.CITY,Le.AREA,Le.POST_CODE,Le.ADDRESS_1,Le.ADDRESS_2]),y([]),a.setCityOptions([]),t({...M3,country:D})}async function x(D,G){if(D.includes(Le.PROVINCE)){U(G);return}if(!D.includes(Le.PROVINCE)&&D.includes(Le.CITY)){W(G);return}}async function U(D){a.requestProvinceOption(D).then(G=>{m(G)})}async function Q(D){var G;R(Le.PROVINCE,D),W(D),A([Le.CITY]),(G=p.current)==null||G.validateChange(""),t({country:o.country??"",province:D,city:"",postCode:o.postCode,address1:o.address1,address2:o.address2,area:o.area})}async function W(D){const G=await _3(D);if(G)return y(G),a.setCityOptions(G),G}function J(D){R(Le.CITY,D),t({country:o.country??"",province:o.province??"",city:D,postCode:o.postCode??"",address1:o.address1??"",address2:o.address2??"",area:o.area})}function te(){return i(mt,{ref:v,label:r.get("address.label"),path:"address.country",rule:B(),showErrorMessage:!1,children:i(Wr,{value:o.country,filterable:!0,options:s,onSelect:D=>F(D),placeholder:r.get("address.country"),inputClassName:la("first-item"),noDataTip:r.get("common.noData")})})}function ve({description:D,className:G}){return i(mt,{ref:g,path:"address.address1",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.address1,onInput:re=>R(Le.ADDRESS_1,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.address1")}function K({description:D,className:G}){return i(mt,{ref:I,path:"address.address2",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.address2,onInput:re=>R(Le.ADDRESS_2,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.address2")}function z({description:D,className:G}){return i(mt,{ref:P,path:"address.postCode",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.postCode,onInput:re=>R(Le.POST_CODE,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.postCode")}function Ce({description:D,className:G}){return i(mt,{ref:_,path:"address.area",rule:B(),showErrorMessage:!1,children:i(ht,{value:o.area,onInput:re=>R(Le.AREA,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.area")}function pe({description:D,className:G}){return i(mt,{ref:p,path:"address.city",rule:B(),showErrorMessage:!1,children:fn(u)&&u.length>0?i(Wr,{value:o.city,filterable:!0,options:u,onSelect:re=>J(re),placeholder:D,inputClassName:G,noDataTip:r.get("common.noData")}):i(ht,{value:o.city,onInput:re=>R(Le.CITY,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.city")}function O({description:D,className:G}){return i(mt,{ref:b,path:"address.province",rule:B(),showErrorMessage:!1,children:fn(l)&&l.length>0?i(Wr,{value:o.province,filterable:!0,options:l,onSelect:re=>Q(re),placeholder:D,inputClassName:G,noDataTip:r.get("common.noData")}):i(ht,{value:o.province,onInput:re=>R(Le.PROVINCE,re.currentTarget.value),placeholder:D,inputClassName:G})},"address.province")}function ee(D){const G=h==null?void 0:h.length;return Dt(G)||G===1?"":D===G-1?la("last-item"):la("mid-item")}return i("div",{style:"width: 100%",children:[te(),h==null?void 0:h.map((D,G)=>Y[D.addressItem]({description:D.description,className:ee(G)}))]})});class D3{constructor(n){Ee(this,"_email");Ee(this,"_isValid",!1);this._email=n??""}get email(){return this._email}set email(n){this._email=n}get isValid(){return this._isValid}set isValid(n){this._isValid=n}}let ua;const St=e=>ua||(ua=new D3(e)),Lt=Ve((e,n)=>{const{className:t,style:r,disabled:a}=e,{i18n:o}=lt(),[c,s]=M(""),d=j(null),l=St(e.value??"");Oe(n,()=>({update:h=>{var w;m(h),(l.isValid||Od(h))&&((w=d.current)==null||w.validate(h,{trigger:"submit",setResult:!0}))}})),ce(()=>{m(e.value)},[e.value]);const m=h=>{l.email=h??"",s(h??"")},u={trigger:["blur","submit"],validator(h){if(!h)throw new Error(o.get("common.email.incomplete"));if(!new RegExp(f0).test(h))throw new Error(o.get("common.email.incorrect"));return!0}},y=h=>{var v;const{currentTarget:w}=h;m(w.value),(v=e.onInput)==null||v.call(e,h)};return i(mt,{ref:d,label:o.get("common.email.label"),path:"email",rule:u,className:t,style:r,children:i(ht,{value:c,disabled:a,maxLength:100,onInput:y})})}),{bem:ma}=Ie("info"),B3={error:Vo};function yt(e){const{type:n="error",content:t,className:r,style:a}=e,o=B3[n];return i("div",{className:fe(he,ma([n]),r),style:a,children:[i("div",{className:ma("icon"),children:i(o,{size:16})}),i("div",{className:ma("content"),children:t})]})}const{bem:Pc}=Ie("recurring-tip");function fa(){return i(tt.Consumer,{children:e=>{var n;return i("div",{className:Pc(),children:[i("div",{className:Pc("icon"),children:zd({size:16})}),i("div",{children:(n=e==null?void 0:e.i18n)==null?void 0:n.get("common.recurringTip")})]})}})}const{bem:Rc}=Ie("button");function ha(e){const{style:n,className:t,children:r,icon:a,loading:o,disabled:c,dashed:s}=e;function d(l){var m;o||c||(m=e.onClick)==null||m.call(e,l)}return i("button",{className:fe(he,Rc({loading:o,disabled:c,dashed:s}),t),style:n,onClick:d,children:[!!a&&i("div",{className:Rc("icon"),children:a}),r]})}const ya=40,V3=`0 0 ${ya} ${ya}`,Nc=3.3,kc=ya/2-Nc-.5,Lc=2*Math.PI*kc,x3=3.2,{bem:Ca}=Ie("loading-check");function H3({color:e="currentColor",checkedColor:n="currentColor",checked:t=!1,size:r,className:a,style:o,onCheckShow:c}){const[s,d]=M(75),[l,m]=M(!1),[u,y]=M(!1),h=Pe(r)?"1em":`${r}px`,v={strokeDasharray:`${Lc*(s/100)} ${Lc}`,animationPlayState:l?"running":"paused"};t?(d(100),m(!1)):(y(!0),m(!0),d(75));function b(){y(!1),c==null||c()}return i("div",{className:fe(he,Ca(),a),style:Xu({width:h,height:h},o),children:i("svg",{width:h,height:h,viewBox:V3,children:[u&&i("circle",{className:Ca("circle",["loading"]),cx:"50%",cy:"50%",r:kc,fill:"none",stroke:e,"stroke-width":Nc,"stroke-linecap":"round",style:v}),t&&i("polyline",{className:Ca("check"),points:"8.5,20 18.2,29.5 31.5,10.5",fill:"none",stroke:n,"stroke-width":x3,"stroke-linecap":"round","stroke-linejoin":"miter",onAnimationStart:b})]})})}const{bem:Tc}=Ie("submit-button"),wt=e=>{const{text:n=ar["common.pay"],loadingText:t=ar["common.payProcessing"],successText:r=ar["common.paySuccess"],status:a="unSubmit",onClick:o,className:c,style:s,icon:d=Yd}=e,[l,m]=M(n),u=()=>a==="unSubmit"?i(d,{size:20,disabled:!e.verified}):i(H3,{checked:a==="success",size:20,onCheckShow:()=>m(r)});return ce(()=>{a!=="success"&&m(a==="loading"?t:n)},[a,n]),i(ha,{icon:u(),onClick:o,className:fe(Tc({success:a==="success"}),c),style:s,loading:a==="loading",disabled:e.disabled||a==="success",children:i("span",{class:Tc("text",{"not-verified":!e.verified}),children:l})})},{bem:zr}=Ie("ali-pay"),O3=Ve((e,n)=>{var F,x,U,Q,W,J,te,ve;const{session:t}=e,r=bt(),a=St(),{setErrorMsg:o,i18n:c,errorMsg:s,sessionReady:d}=ut(t,e.core),[l,m]=M("unSubmit"),u=j(null),[y,h]=M({email:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[w,v]=M(!1),b=j(!1),[p,_]=M(!1),P=j(null),g=j(null);Oe(n,()=>({stopRetry:()=>{R(),m("unSubmit")},startRetry:K=>{m("loading"),S({timeout:K})},updateAddress:()=>{var K;h(Object.assign(y,{address:r.getAddressState()})),(K=P.current)==null||K.update(r.getAddressState())},updateEmail:()=>{var K;h(Object.assign(y,{email:a.email})),(K=g.current)==null||K.update(a.email)}}));function I(){var K;(K=u.current)==null||K.validate(void 0,!1).then(()=>{v(!0)}).catch(()=>{v(!1)})}ce(()=>{I()},[y]),ce(()=>{var K;d&&((t==null?void 0:t.checkout.status)==="SUCCESS"&&(m("success"),(K=e.onSuccess)==null||K.call(e)),y.email=(t==null?void 0:t.checkout.bill.email)??"",b.current=!!(t!=null&&t.checkout.bill.email),(t==null?void 0:t.checkout.bill.billingAddressCollection)==="REQUIRED"?_(!0):_(!1),!p&&setTimeout(()=>{I()},100))},[d]);const C=$e(K=>{var z;o(K||c.get("common.payTimeout")),m("unSubmit"),(z=e.onTimeout)==null||z.call(e,"retry")},[c,e.onTimeout]),{start:S,stop:R}=nt(K=>k(!0,K),{onTimeout:()=>C(c.get("common.queryTimeout"))});async function k(K=!1,z){var Ce,pe,O,ee,D,G,re;try{const be=K?await U0({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale,timeout:z}):await F0({sessionId:t.sessionId,clientKey:t.clientKey,bill:p?{email:y.email,...y.address,province:r.getLabel(y.address.province,r.getProvinceOption())??y.address.province,city:r.getLabel(y.address.city,r.getCityOptions())??y.address.city}:{email:y.email}},e.core,{locale:c.locale,timeout:z}),{status:me,orderStatus:f,errorMessage:E,errorCode:H}=be;if(!K&&((Ce=e.onSubmitResponse)==null||Ce.call(e,be)),me==="PROCESSING")if(f){if(f==="SUCCESS")return m("success"),(pe=e.onSuccess)==null||pe.call(e),{end:!0};if(f==="FAILURE")return o(E),m("unSubmit"),(O=e.onError)==null||O.call(e,new Se("API_ERROR",E,{code:H})),{end:!0};if(f==="PROCESSING")return!K&&S(),{end:!1};if(f==="CANCELED")return m("unSubmit"),(ee=e.onTimeout)==null||ee.call(e,"channel"),{end:!0}}else return m("unSubmit"),{end:!0};else{if(me==="SUCCESS")return m("success"),(D=e.onSuccess)==null||D.call(e),{end:!0};if(me==="EXPIRED")return m("unSubmit"),(G=e.onExpired)==null||G.call(e),{end:!0}}return m("unSubmit"),{end:!0}}catch(be){if(qe(be))return K?{end:!1}:(C(),{end:!0});{const me=be.i18nKey?c.get(be.i18nKey):be.message;return o(me),(re=e.onError)==null||re.call(e,new Se("API_ERROR",me,{code:be.code,cause:be})),m("unSubmit"),{end:!0}}}}async function A(){var K;o(""),(K=u.current)==null||K.validate(async z=>{var Ce;if(p&&r.setValidateAllFields(!0),(Ce=e.onSubmit)==null||Ce.call(e,z),z){m("unSubmit");return}o(""),m("loading"),await k()})}const N=()=>{const{transAmount:K,channelParams:z={}}=(t==null?void 0:t.checkout)??{},{totalAmount:Ce}=z.aliPay??{},pe=(Ce!=null&&Ce.amount?Ce:K)||{},O=pe!=null&&pe.amount?pt(pe).jointSymbol():"",ee=c.get("common.pay")+(O?` ${O}`:"");return i(wt,{className:zr("button"),status:l,text:ee,loadingText:c.get("common.payProcessing"),successText:c.get("common.paySuccess"),onClick:A,verified:w})},Y=K=>{u.current=K,K&&I()},B={[ae("button-bg-color")]:(F=t==null?void 0:t.colors)==null?void 0:F.primary,[ae("button-bg-color-hover")]:(x=t==null?void 0:t.colors)==null?void 0:x.primaryHover,[ae("button-bg-color-active")]:(U=t==null?void 0:t.colors)==null?void 0:U.primaryActive,[ae("button-text-color")]:(W=(Q=t==null?void 0:t.checkout)==null?void 0:Q.theme)==null?void 0:W.payButtonTextColor,[ae("input-color")]:(J=t==null?void 0:t.colors)==null?void 0:J.primary};return i(tt.Provider,{value:{i18n:c,session:t},children:d&&c.ready.value&&i(At,{form:y,ref:Y,onFormChange:K=>h(K),children:i("div",{className:fe(he,zr()),style:B,children:[i(Lt,{ref:g,className:zr("email"),value:y.email,disabled:!!b.current}),p&&i(kt,{ref:P,value:y.address,country:((te=t==null?void 0:t.checkout)==null?void 0:te.country)||((ve=t==null?void 0:t.checkout)==null?void 0:ve.bill.country),onAddressChange:K=>h(Object.assign(y,{address:K}))}),(t==null?void 0:t.checkout.paymentType)===yn.RECURRING&&fa(),!!s&&i(yt,{className:zr("error"),content:s}),N()]})})})}),{bem:Mc}=Ie("card-brands");function Dc(e){const{supportedCardBrands:n,max:t=6,className:r,style:a}=e,o=j(null),[c,s]=M(0),d=Er(n).map(y=>T1(y)),l=d.length-t,m=d.slice(t-1),u=m[c];return ce(()=>(o.current=window.setInterval(()=>{s(y=>{const h=y+1,w=m.length;return h===w?0:nr(h,0,w-1)})},3e3),()=>{o.current&&(window.clearInterval(o.current),o.current=null)}),[]),i("div",{className:fe(he,Mc(),r),style:a,children:[d.slice(0,t-1).map(y=>y.icon&&i(y.icon,{size:32},y.code)),!!(u!=null&&u.icon)&&i(u.icon,{size:32},u.code),l>0&&i("div",{className:Mc("more"),children:["+",l]})]})}const ga=Ve((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,c=j(null),s=j(null);Oe(n,()=>({input:c.current,focus:()=>{var h;(h=c.current)==null||h.focus()},blur:()=>{var h;(h=c.current)==null||h.blur()},resetValidation:(h,w)=>{var v;(v=s.current)==null||v.resetValidation(h,[{message:w}])}}));const{i18n:d}=lt(),[l,m]=M(""),u={trigger:["blur","submit"],validator(h){if(a){const w=s.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Pe(h)||h.length!==5)throw new Error(d.get("card.cardExpireDate.incomplete"));if(zi(h))throw new Error(d.get("card.cardExpireDate.expired"));return!0}};function y(h){var _,P,g,I;const{inputType:w,currentTarget:v}=h,b=v.selectionStart;let p;if(w==="insertText"){const{data:C}=h;p=vn(v.value);const S=p.length;S===1&&+p>1?p=`0${p}`:S===2&&(+p>12?p=`01${C}`:p=`${p}`),S>=2&&!p.includes("/")&&(p=p.slice(0,2)+"/"+p.slice(2,4))}else{p=v.value;const C=l.slice(b,b+1),S=l.length;if(S>3&&C==="/"){m(v.value=l),v.setSelectionRange(b,b),(_=e.onInput)==null||_.call(e,h);return}else if(b===1){const R=l.slice(0,2);S>2&&+R>=10?p=`01${l.slice(2,S)}`:p=p.slice(0,1)}else if(b===0&&p.length>1){C==="0"?m(v.value=l):C==="1"&&m(v.value=`0${p}`),v.setSelectionRange(0,0),(P=e.onInput)==null||P.call(e,h);return}else if(b===3)if(S===4)p=p.slice(0,2);else{m(v.value=p),v.setSelectionRange(b-1,b-1),(g=e.onInput)==null||g.call(e,h);return}}m(v.value=p),w!=="insertText"&&v.setSelectionRange(b+1,b+1),(I=e.onInput)==null||I.call(e,h)}return i(mt,{label:d.get("card.cardExpireDate.label"),showLabel:o,path:"expireDate",ref:s,rule:u,className:t,style:r,children:i(ht,{type:"text",inputmode:"numeric",ref:c,maxLength:5,value:l,onInput:y,placeholder:d.get("card.cardExpireDate.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.EXPIRE_DATE})})})});function Bc(e){const{className:n,style:t,disabled:r}=e,{i18n:a}=lt(),o={trigger:["blur","submit"],validator(s){if(!s)throw new Error(a.get("card.cardHolderName.incomplete"));return!0}};function c(s){var d;(d=e.onInput)==null||d.call(e,s)}return i(mt,{label:a.get("card.cardHolderName.label"),path:"holderName",rule:o,className:n,style:t,children:i(ht,{maxLength:100,placeholder:a.get("card.cardHolderName.placeholder"),onInput:c,disabled:r})})}const va=Ve((e,n)=>{const{supportedCardBrands:t=[],className:r,security:a,showLabel:o,onBinValue:c}=e,s=j(null),d=j(null);Oe(n,()=>({input:s.current,focus:()=>{var k;(k=s.current)==null||k.focus()},blur:()=>{var k;(k=s.current)==null||k.blur()},resetValidation:(k,A)=>{var N;(N=d.current)==null||N.resetValidation(k,[{message:A}])},binValueChanged:k=>{u(k)},binValue:()=>m,brandChanged:k=>{if(k){const A=M1(k);p(()=>A==null?void 0:A.icon),P(A==null?void 0:A.code)}else p(void 0),P(void 0)},getCardBrand:()=>_r(Ft(m),w)||{code:_}}));const{i18n:l}=lt(),[m,u]=M(""),[y,h]=M(""),w=Er(t),v=Uo(w),[b,p]=M(void 0),[_,P]=M(void 0),[g,I]=M("");ce(()=>{const k=Ft(m);p(m?()=>{var N;return(N=_r(k,w))==null?void 0:N.icon}:void 0);const A=k.substring(0,6);I(A.length<6?"":A)},[m]),ce(()=>{c==null||c(g)},[g]);const C={trigger:["blur","submit"],validator(k){if(a){const N=d.current.getValidateResult();if(N.status==="error")throw new Error(N.errors[0].message);if(N.status==="success")return!0}if(k=Ft(k??""),!v.includes(k.length))throw new Error(l.get("card.cardNumber.incomplete"));if(!_r(k,w))throw new Error(l.get("card.cardNumber.invalid"));return!0}};function S(k){var x;const{currentTarget:A,inputType:N}=k,Y=A.selectionStart;let B=vn(A.value);B=B.replace(/(\d{4})(?=\d)/g,"$1 ");let F=Y;F%5===0&&(F=nr(Y+(N==="insertText"?1:-1),0)),u(A.value=B),A.setSelectionRange(F,F),(x=e.onInput)==null||x.call(e,k)}const R=()=>{if(y!=="error")return i(b??L1,{size:32})};return i(mt,{label:l.get("card.cardNumber.label"),showLabel:o,path:"number",ref:d,rule:C,onValidationStatusChange:h,className:r,children:i(ht,{type:"text",inputmode:"numeric",ref:s,maxLength:23,value:m,onInput:S,rightIcon:R(),placeholder:l.get("card.cardNumber.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.CARD_NUMBER})})})}),Kr=Ve((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,c=j(null),s=j(null);Oe(n,()=>({input:c.current,focus:()=>{var h;(h=c.current)==null||h.focus()},blur:()=>{var h;(h=c.current)==null||h.blur()},resetValidation:(h,w)=>{var v;(v=s.current)==null||v.resetValidation(h,[{message:w}])}}));const{i18n:d}=lt(),[l,m]=M(""),u={trigger:["blur","submit"],validator(h){if(a){const w=s.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Pe(h)||h.length<3)throw new Error(d.get("card.cardSecurityCode.incomplete"));return!0}};function y(h){var v;const w=vn(h.currentTarget.value);m(h.currentTarget.value=w),(v=e.onInput)==null||v.call(e,h)}return i(mt,{label:d.get("card.cardSecurityCode.label"),showLabel:o,path:"securityCode",ref:s,rule:u,className:t,style:r,children:i(ht,{type:"text",inputmode:"numeric",ref:c,maxLength:4,value:l,onInput:y,placeholder:d.get("card.cardSecurityCode.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":_e.CVV})})})}),{bem:pa}=Ie("card-no"),Vc=e=>{const{value:n,className:t,style:r}=e;return i("div",{className:fe(he,pa("wrapper"),t),style:r,children:[Array.from({length:4},(a,o)=>o).map(()=>i("span",{className:pa("dot")})),i("span",{className:pa("card-no"),children:n})]})},xc=e=>{const{cardList:n=[],onCardChange:t,onClickEdit:r,className:a,style:o,onClickChange:c,value:s}=e,{i18n:d}=lt(),{bem:l}=Ie("card-selector"),m=j(null),u=j(null),y={trigger:["blur","submit"],validator(){return!0}},h=()=>n.map(g=>({label:"",value:g.token,...g})),[w,v]=M(s);ce(()=>{if(s){const g=h().find(({token:I})=>s===I);b(s,g)}},[s]);const b=(g,I)=>{v(g),t==null||t(I)},p=g=>{var C;const I=((C=M1(g.cardBrand))==null?void 0:C.icon)??L1;return i("div",{className:l("label"),children:[i(I,{size:32}),i("div",{className:l("card-no"),children:i(Vc,{value:g.last4})}),i("span",{})]})},_=()=>i("div",{className:l("change"),onClick:c,children:[i(xo,{}),i("span",{style:{marginLeft:"4px"},children:d.get("card.cardSelector.change")})]}),P=()=>{const g=()=>{var I;(I=m.current)==null||I.blur(),r==null||r()};return i("div",{className:l("action"),children:i(ha,{style:{borderRadius:"6px",fontSize:"14px"},dashed:!0,icon:i(Jd,{}),onClick:g,children:d.get("card.cardSelector.useOtherCard")})})};return i(mt,{label:d.get("card.cardNumber.label"),path:"token",rule:y,className:a,style:o,ref:u,children:i(Wr,{value:w,ref:m,options:h(),renderLabel:p,onSelect:b,noDataTip:d.get("common.noData"),action:P(),rightIcon:_()})})};function F3({size:e,style:n,className:t}){const r=Pe(e)?"1em":`${e}px`;return i("svg",{width:r,height:r,viewBox:"0 0 8 7",fill:"#fff",xmlns:"http://www.w3.org/2000/svg",style:n,className:fe(he,t),children:i("g",{children:i("g",{id:"_图层_1","data-name":"图层_1",children:i("path",{class:"cls-1",d:"M7.4.9c-.2-.2-.5-.2-.7,0l-3.8,3.9-1.3-1.3c-.2-.2-.5-.2-.7,0l-.4.4c-.2.2-.2.5,0,.7l2,2c.1.1.3.2.4.1.1,0,.3,0,.4-.2L7.8,1.9c.2-.2.2-.5,0-.7l-.4-.4Z"})})})})}const{bem:Hc}=Ie("check-box"),U3=e=>{const{checked:n,onChange:t,label:r,style:a}=e,o=()=>{t==null||t(!n)};return i("div",{className:fe(he,Hc({checked:n})),onClick:o,style:a,children:[i("div",{className:Hc("inner"),children:i(F3,{size:10})}),i("span",{children:r})]})},G3=e=>e?Array.prototype.slice.call(e.querySelectorAll(`[${Gi}]`)):[];class Z3{constructor(n){Ee(this,"iframe");Ee(this,"iframeWindow");Ee(this,"hiddenIframe");Ee(this,"config");this.config=n,this.init()}init(){const{iframeSrc:n,iframeClassName:t,fieldNode:r}=this.config,a=ji(n);a.width="100%",a.height="100%",a.style.border="none",r.appendChild(a);const o=r.querySelector(`.${t}`);o&&(this.iframe=o,o.addEventListener("load",()=>this.onFieldIframeLoad()))}onFieldIframeLoad(){this.iframeWindow=this.iframe.contentWindow;const{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o}=this.config,c={action:Re.INIT,config:{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o},hidden:!1,cdnUrl:xn};ze(c,this.iframeWindow,Ht)}}const Oc=Ve((e,n)=>{const{sessionMode:t,i18n:r,targetElement:a}=e,o=j(null),c=j(null),s=(v,b)=>{const p={action:Re.PAYMENT,formData:v,extraParams:b,locale:e.i18n.locale};ze(p,c.current.contentWindow,Ht)};if(Oe(n,()=>({payment:s,reload:()=>{t!==Ke.HOSTED&&(window.removeEventListener("message",w),c.current&&document.body.removeChild(c.current),u())},encryptCard:v=>{const b={action:Re.ENCRYPT_CARD,...v};ze(b,c.current.contentWindow,Ht)},validate:()=>{Object.values(l.current).forEach(v=>{const b={action:Re.VALIDATE};ze(b,v.iframe.contentWindow,Ht)})},setConfig:v=>{e.style=v.style}})),!frames&&t===Ke.HOSTED)return e.children;let d=[];const l=j({}),m={[_e.CARD_NUMBER]:r.get("card.cardNumber.placeholder"),[_e.CVV]:r.get("card.cardSecurityCode.placeholder"),[_e.EXPIRE_DATE]:r.get("card.cardExpireDate.placeholder")};ce(()=>{u()},[]);const u=async()=>{d=G3(a||o.current),d.length&&(await y(),h(),window.addEventListener("message",w))},y=async()=>{const v=ji(`${xn}/secured-iframe.html`);v.name=`${a0}-${Date.now()}`,v.width="0",v.height="0",v.style.border="none",c.current=v;const b={action:Re.INIT,hidden:!0,apiUrl:ta,cdnUrl:xn};v.addEventListener("load",()=>{ze(b,c.current.contentWindow,Ht)}),window.document.body.appendChild(v)},h=()=>{d.forEach(v=>{const b=v.getAttribute(Gi);l.current[b]=new Z3({fieldNode:v,hiddenIframe:c.current,hiddenIframeName:c.current.name,rootNode:o.current,iframeSrc:`${xn}/secured-iframe.html`,iframeClassName:Zi,fieldType:b,placeholder:m[b],style:e.style,supportedCardBrands:e.supportedCardBrands,onFocus:e.onFocus,onBinValue:e.onBinValue,onAfterPayment:e.onAfterPayment,onPaymentError:e.onPaymentError,onPaymentTimeout:e.onPaymentTimeout,onValidStatusChanged:e.onValidStatusChanged})})},w=$e(v=>{var P,g,I,C,S,R,k,A,N,Y,B,F;const{data:b,origin:p}=v;if(p!==Ht)return;const _=rr(b);if(Reflect.has(_,"action"))switch(_.action){case Re.FOCUS:(P=e.onFocus)==null||P.call(e,_);break;case Re.BIN_VALUE:(g=e.onBinValue)==null||g.call(e,_);break;case Re.BRAND:(I=e.onBrand)==null||I.call(e,_);break;case Re.AFTER_PAYMENT:(C=e.onAfterPayment)==null||C.call(e,_);break;case Re.PAYMENT_ERROR:(S=e.onPaymentError)==null||S.call(e,_);break;case Re.PAYMENT_TIMEOUT:(R=e.onPaymentTimeout)==null||R.call(e,_);break;case Re.VALID_STATUS_CHANGED:(k=e.onValidStatusChanged)==null||k.call(e,_);break;case Re.AUTHORIZED:(A=e.onAuthorized)==null||A.call(e,_);break;case Re.ACTIVATED:(N=e.onActivated)==null||N.call(e,_);break;case Re.CARD_ENCRYPTED:(Y=e.onCardEncrypted)==null||Y.call(e,_);break;case Re.CARD_ENCRYPTION_FAILED:(B=e.onCardEncryptionFailed)==null||B.call(e,_);break;case Re.VALIDATED:(F=e.onValidated)==null||F.call(e,_);break}},[]);return i("div",{ref:o,children:!a&&e.children})}),{bem:Hn}=Ie("modal"),Fc=Ve(e=>{const{show:n=!1,width:t,height:r,maskClosable:a,header:o,children:c,onChange:s,style:d,appendToBody:l=!1}=e,[m,u]=M(),[y,h]=M(),{i18n:w}=lt();It(()=>{u(typeof t=="number"?`${t}px`:t),h(typeof r=="number"?`${r}px`:r)},[t,r]);const v=()=>{a&&(s==null||s(!1))},b=()=>{s==null||s(!1)},p=i(de,{children:n&&i("div",{className:Hn(),children:[i("div",{className:Hn("mask"),onClick:v}),i("div",{className:Hn("content"),style:{width:m,height:y,...d},children:[o||i("div",{className:Hn("header"),children:i("div",{className:Hn("close"),onClick:b,children:w.get("common.cancel")})}),i("div",{className:Hn("body"),children:c})]})]})});return l?n?wd(p,document.body):null:p}),{bem:ba}=Ie("three-ds-auth"),Uc=e=>{const{show:n=!1,onClose:t,url:r,incomplete:a=!0,width:o,height:c="72vh",theme:s}=e,d=Ac(),[l,m]=M(!1),u=j(),y=j(null),{i18n:h}=lt(),w=()=>{m(!0)},v=p=>{!p&&(t==null||t())},b=It(()=>n?o||(d.smaller("sm")?"90vw":"600px"):"0",[n,o,d.matches]);return ce(()=>{n?(u.current&&window.removeEventListener("message",u.current),u.current=p=>{const{data:_,origin:P}=p;if(P!==Ht)return;switch(rr(_).action){case Re.CHECK_THREE_DS:{v(!1);break}}},window.addEventListener("message",u.current)):u.current&&window.removeEventListener("message",u.current)},[n]),i(Fc,{show:n,onChange:v,width:b,height:c,style:{maxWidth:"100vw",maxHeight:"100vh",minHeight:"500px",minWidth:"350px"},children:i("div",{className:ba("content"),children:!a||l?i("iframe",{ref:y,width:"100%",height:"100%",frameBorder:0,src:r}):i("div",{className:ba("last-three-ds"),children:[i(Xd,{size:60}),i("div",{className:ba("last-three-ds-title"),children:[i("div",{children:h.get("threeDS.paymentIncomplete")}),i("div",{children:h.get("threeDS.completeFirst")})]}),i("div",{children:i(ha,{style:{backgroundColor:s==null?void 0:s.payButtonBackgroundColor,color:s==null?void 0:s.payButtonTextColor},onClick:w,children:h.get("common.confirm")})})]})})})},{bem:dr}=Ie("combined-card-info"),Aa=Ve((e,n)=>{const{supportedCardBrands:t=[],className:r,showLabel:a=!1,security:o}=e,c=j(null),s=j(null),{i18n:d}=lt();Oe(n,()=>({input:c.current,focus:()=>{var v;(v=c.current)==null||v.focus()},blur:()=>{var v;(v=c.current)==null||v.blur()},resetValidation:(v,b)=>{var p;(p=s.current)==null||p.resetValidation(v,[{message:b}])},binValueChanged:v=>{u(v)},binValue:()=>m,brandChanged:v=>{if(v){const b=M1(v);h(()=>b==null?void 0:b.icon)}else h(void 0)},getCardBrand:()=>_r(Ft(m),Er(t))||{}}));const l={trigger:["submit"],validator(){if(o){const v=s.current.getValidateResult();if(v.status==="error")throw new Error(v.errors[0].message);if(v.status==="success")return!0}return!0}},[m,u]=M(""),[y,h]=M(void 0),w=()=>i(y??L1,{size:32});return i(mt,{showLabel:a,ref:s,label:d.get("card.info.label"),className:r,path:"cardInfo",rule:l,children:i(ht,{ref:c,leftIcon:w(),rightIcon:i("div",{className:dr("blank-icon")}),children:i("div",{className:dr(),children:[i("div",{className:dr("card-number"),"data-sf":_e.CARD_NUMBER}),i("div",{className:dr("expire-date"),"data-sf":_e.EXPIRE_DATE}),i("div",{className:dr("cvv"),"data-sf":_e.CVV})]})})})}),{bem:Tt}=Ie("card"),lr=Tt("field"),Gc=Ve((e,n)=>{var Xs,$s,ed,td,nd,rd,ad,od;const{showCardBrands:t=!0,session:r,cardInfoLayout:a="split",showHolderName:o=!0,showEmail:c=!1,showAddress:s=!1,threeDSFrame:d,styles:l,enable3DSModal:m=!0,isDropIn:u,core:y}=e,h=bt(),w=St(),{i18n:v,fraudDetection:b,sessionReady:p}=ut(r,y),_=j(null),P=j(null),g=j(null),I=j(null),[C,S]=M({email:"",number:"",expireDate:"",securityCode:"",holderName:"",cardInfo:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[R,k]=M(!1),[A,N]=M("unSubmit"),[Y,B]=M(""),[F,x]=M(!1),[U,Q]=M(!1),[W,J]=M(!1),[te,ve]=M([]),[K,z]=M(!1),[Ce,pe]=M(),[O,ee]=M(),[D,G]=M(!1),[re,be]=M(!0),[me,f]=M({}),[E]=M(a==="split");Oe(n,()=>({checkThreeDS:za,updateAddress:()=>{var V;O!=null&&O.address.show&&(S(Object.assign(C,{address:h.getAddressState()})),(V=_.current)==null||V.update(h.getAddressState()))},updateEmail:()=>{var V;O!=null&&O.email.show&&(S(Object.assign(C,{email:w.email})),C.email=w.email,(V=P.current)==null||V.update(w.email),_n())},payment:()=>{Qe&&Te()}}));const H=()=>{var V;return{returnUrl:(V=r==null?void 0:r.checkout)==null?void 0:V.returnUrl}},T=()=>{const{field:V,sessionMode:ne}=r.checkout,{email:Ae,address:we,holderName:Ue}=V;ne===Ke.COMPONENT&&(Ae.disabled&&(Ae.show=c),s&&!(we!=null&&we.show)&&(we.show=!0),o&&!(Ue!=null&&Ue.show)&&(Ue.show=!0,Ue.disabled=!0)),ee({...V})},q=()=>{if(!l)return;const{input:V}=Ui(l);V&&f(V)};ce(()=>{var Ue,Ge;if(!p)return;const{status:V,paymentMethod:ne=[],bill:Ae={},sessionMode:we}=(r==null?void 0:r.checkout)||{};if(we===Ke.DROP_IN&&!u){(Ge=(Ue=e.core.config).onInitError)==null||Ge.call(Ue,new Se("ERROR","Please send the correct session when creating the checkout"));return}Mn(ne,k1).length&&(T(),q(),G(we!==Ke.HOSTED),C.email=Ae.email??"",ve(Mn(Oo,ne||[])),J(!0),V==="SUCCESS"&&(N("success"),ie()))},[p]);const le=$e(V=>{var ne;B(V||v.get("common.payTimeout")),N("unSubmit"),(ne=e.onTimeout)==null||ne.call(e),y.resetEnablePaymentMethod()},[v,e.onTimeout]),ie=()=>{var V;(V=e.onSuccess)==null||V.call(e,H())},L=V=>{var ne;(ne=e.onError)==null||ne.call(e,V),y.resetEnablePaymentMethod()},{start:Z}=nt(V=>ke(!0,V),{onTimeout:()=>le(v.get("common.queryTimeout"))}),ue=j(gn()),ye=V=>{In.current[V.fieldType].status=V.status;const ne=Object.values(In.current);ne.includes(null)||(ne.every(we=>we.status==="success")?ue.current.resolve(!0):ue.current.reject(!1))},se=async()=>{var V;ue.current=gn(),Object.keys(In.current).forEach(ne=>{In.current[ne]=null}),(V=h1.current)==null||V.validate();try{await ue.current,console.log("校验通过")}catch{console.log("校验失败")}};async function Te(){var V;B(""),!E&&D&&await se(),(V=I.current)==null||V.validate(async ne=>{var Ae;if(O!=null&&O.address.show&&h.setValidateAllFields(!0),(Ae=e.onSubmit)==null||Ae.call(e,ne),ne){N("unSubmit");return}B(""),N("loading"),await ke()})}const He=async()=>{var Je,rt,_t;const V=Ft(C.number),ne=Fo(V),[Ae,we]=C.expireDate.split("/"),Ue=f1&&!U;let Ge=null;f1?Ge=$.BANKCARD:D?Ge=(Je=(E?Kn:g).current)==null?void 0:Je.getCardBrand().code:Ge=ne.code;let xe;return D&&(xe=E?(rt=Kn.current)==null?void 0:rt.binValue():(_t=g.current)==null?void 0:_t.binValue()),{sessionId:r.sessionId,clientKey:r.clientKey,payment:{paymentMethod:Ge,cvv:C.securityCode,...Ue?{token:C.token}:{holderName:C.holderName,expYear:`20${we}`,expMonth:Ae,cardNo:V,...Gs?{storePaymentMethod:F}:null}},bill:O!=null&&O.address.show?{email:C.email,...C.address,province:h.getLabel(C.address.province,h.getProvinceOption())??C.address.province,city:h.getLabel(C.address.city,h.getCityOptions())??C.address.city}:{email:C.email},browser:await dt({fraudDetectionId:await(b==null?void 0:b.getFraudDetectionId({bin:V||xe||""}))})}};async function ke(V=!1,ne){var Ae,we,Ue,Ge;try{const xe=await He(),Je=(we=(Ae=y.config)._getExtraParams)==null?void 0:we.call(Ae,"payment",xe.payment.paymentMethod);if(!V&&D)return(Ue=h1.current)==null||Ue.payment(xe,Je),{end:!0};const rt={locale:v.locale,timeout:ne};let _t={};return V?_t=await gc({sessionId:r.sessionId,clientKey:r.clientKey},rt):_t=await Cc(xe,Je,rt),Qn(_t,V)}catch(xe){if(qe(xe))return V?{end:!1}:(le(),{end:!0});{const Je=xe.i18nKey?v.get(xe.i18nKey):xe.message;return B(Je),(Ge=e.onError)==null||Ge.call(e,new Se("API_ERROR",Je,{code:xe.code,cause:xe})),N("unSubmit"),zn(),{end:!0}}}}const Et=(V,ne)=>{var Ae;m?(console.log("3ds open"),z(!0),pe({url:V,incomplete:ne,width:d==null?void 0:d.modalWidth,height:d==null?void 0:d.modalHeight})):(Ae=e.onThreeDS)==null||Ae.call(e,V,ne)},dn=()=>{console.log("3ds close"),z(!1),pe(void 0),za()},Qn=(V,ne=!1)=>{var Je,rt;const{status:Ae,orderStatus:we,errorMessage:Ue,errorCode:Ge,threeDSUrl:xe}=V;if(Ae==="PROCESSING"){if(!we)N("unSubmit");else if(we==="SUCCESS")N("success"),ie();else{if(we==="PROCESSING")return!ne&&Z(),{end:!1};we==="FAILURE"?(B(Ue),N("unSubmit"),L(new Se("API_ERROR",Ue,{code:Ge}))):we==="AUTHORIZED"?(N("unSubmit"),(Je=e.onAuthorized)==null||Je.call(e)):we==="IN_THREED"?Et(xe,!1):we==="IN_PREVIOUS_THREED"&&Et(xe,!0)}return{end:!0}}else{if(Ae==="SUCCESS")return N("success"),ie(),{end:!0};if(Ae==="EXPIRED")return N("unSubmit"),(rt=e.onExpired)==null||rt.call(e),{end:!0}}return N("unSubmit"),{end:!0}},En=V=>{const ne=V.i18nKey?v.get(V.i18nKey):V.message;B(ne),N("unSubmit"),L(new Se("API_ERROR",ne,{code:V.code,cause:V}))},_n=()=>{var V;(V=I.current)==null||V.validate(void 0,!1).then(()=>{k(!0)}).catch(()=>{k(!1)})};ce(()=>{_n()},[C]);const m1=()=>{var we;const V=(we=r==null?void 0:r.checkout)==null?void 0:we.transAmount,ne=V!=null&&V.amount?pt(V).jointSymbol():"",Ae=v.get("common.pay")+(ne?` ${ne}`:"");return i(wt,{className:Tt("button"),status:A,text:Ae,loadingText:v.get("common.payProcessing"),successText:v.get("common.paySuccess"),onClick:Te,verified:R})},Wn={[ae("button-bg-color")]:(Xs=r==null?void 0:r.colors)==null?void 0:Xs.primary,[ae("button-bg-color-hover")]:($s=r==null?void 0:r.colors)==null?void 0:$s.primaryHover,[ae("button-bg-color-active")]:(ed=r==null?void 0:r.colors)==null?void 0:ed.primaryActive,[ae("button-text-color")]:(nd=(td=r==null?void 0:r.checkout)==null?void 0:td.theme)==null?void 0:nd.payButtonTextColor,[ae("input-color")]:(rd=r==null?void 0:r.colors)==null?void 0:rd.primary},{start:Wa,stop:zn}=nt(V=>za(!0,V),{timeout:12*1e3,onTimeout:()=>le(v.get("common.queryTimeout"))});async function za(V=!1,ne=2e4){var Ae,we,Ue;if(!r)return{end:!0};try{const Ge=await gc({sessionId:r.sessionId,clientKey:r.clientKey},{locale:v.locale,timeout:ne}),{status:xe,orderStatus:Je,errorMessage:rt,errorCode:_t}=Ge;if(xe==="PROCESSING"){if(Je==="PROCESSING")Z();else if(Je==="FAILURE")B(rt),N("unSubmit"),L(new Se("API_ERROR",rt,{code:_t}));else if(Je==="AUTHORIZED")N("unSubmit"),(Ae=e.onAuthorized)==null||Ae.call(e);else{if(Je==="IN_THREED")return N("loading"),!V&&Wa(),{end:!1};Je==="IN_PREVIOUS_THREED"?(B(v.get("common.pay3DSIncomplete")),N("unSubmit")):Je||N("unSubmit")}return zn(),{end:!0}}else{if(xe==="SUCCESS")return N("success"),ie(),zn(),{end:!0};if(xe==="EXPIRED")return N("unSubmit"),(we=e.onExpired)==null||we.call(e),zn(),{end:!0}}return ie(),N("unSubmit"),zn(),{end:!0}}catch(Ge){if(qe(Ge))return V?{end:!1}:(le(v.get("common.queryTimeout")),{end:!0});{const xe=Ge.i18nKey?v.get(Ge.i18nKey):Ge.message;return B(xe),(Ue=e.onError)==null||Ue.call(e,new Se("API_ERROR",xe,{code:Ge.code,cause:Ge})),N("unSubmit"),zn(),{end:!0}}}}const f1=It(()=>{var Ae;if(!(r!=null&&r.checkout))return;const V=(r==null?void 0:r.checkout.paymentType)===yn.PURCHASE,ne=!!((Ae=r==null?void 0:r.checkout.tokens)!=null&&Ae.length);return V&&ne},[r==null?void 0:r.checkout]),Gs=It(()=>{if(r!=null&&r.checkout)return(r==null?void 0:r.checkout.paymentType)===yn.PURCHASE&&(r==null?void 0:r.checkout.storePaymentMethod)},[r==null?void 0:r.checkout]),h6=()=>{const V=ne=>{x(ne)};return i("div",{className:Tt("store-checkbox"),children:i(U3,{label:v.get("card.storeInfo"),checked:F,onChange:V})})},y6=()=>{var we,Ue,Ge;const V=((we=r==null?void 0:r.checkout)==null?void 0:we.paymentType)===yn.PURCHASE,ne=!!((Ge=(Ue=r==null?void 0:r.checkout)==null?void 0:Ue.tokens)!=null&&Ge.length),Ae=()=>{var xe;(xe=I.current)==null||xe.resetValidation(),Q(!1)};return V&&ne&&i("div",{className:Tt("change-box"),onClick:Ae,children:[i(xo,{}),i("span",{style:{marginLeft:"2px"},children:v.get("card.cardSelector.change")})]})},Zs=()=>{var V;(V=I.current)==null||V.resetValidation(),Q(!0)},C6=()=>{var ne;(((ne=r==null?void 0:r.checkout)==null?void 0:ne.tokens)||[]).length>1||Zs()},g6=V=>{be(!1),S(Object.assign(C,{token:V==null?void 0:V.token}))},js=V=>{I.current=V,V&&_n()},Kn=j(null),Ys=j(null),Ka=j(null),h1=j(null),Qs=It(()=>f1&&!U,[f1,U]);ce(()=>{var V;(V=h1.current)==null||V.reload()},[Qs]);const Ws={[_e.CARD_NUMBER]:Kn,[_e.CVV]:Ka,[_e.EXPIRE_DATE]:Ys},v6=V=>{var Ae,we;const ne=E?Ws[V.fieldType]:g;V.focus?(Ae=ne.current)==null||Ae.focus():(we=ne.current)==null||we.blur()},p6=[_e.CARD_NUMBER,_e.EXPIRE_DATE,_e.CVV],In=j({[_e.CARD_NUMBER]:null,[_e.EXPIRE_DATE]:null,[_e.CVV]:null}),b6=V=>{var we,Ue,Ge,xe;const ne=E?Ws[V.fieldType]:g,Ae=V.errorTip&&v.get(V.errorTip);if(E)(xe=ne.current)==null||xe.resetValidation(V.status,Ae);else{In.current[V.fieldType]={status:V.status,errorTip:Ae};for(const rt of p6){const _t=In.current[rt];if((_t==null?void 0:_t.status)==="error"){(we=ne.current)==null||we.resetValidation(_t.status,_t.errorTip);return}}Object.values(In.current).every(rt=>(rt==null?void 0:rt.status)==="success")?(Ue=ne.current)==null||Ue.resetValidation("success"):(Ge=ne.current)==null||Ge.resetValidation("unValidate")}setTimeout(()=>{_n()},100)},A6=V=>{var Ae;(Ae=(E?Kn:g).current)==null||Ae.brandChanged(V.brand)},zs=V=>{var Ae;let ne="";typeof V=="string"?ne=V:((Ae=(E?Kn:g).current)==null||Ae.binValueChanged(V.binValue),ne=V.binValue),ne&&new Yr().getFraudDetectionId(ne)},S6=V=>{Qn(V.response)},w6=V=>{En(V.error)},Ks=()=>i(de,{children:(O==null?void 0:O.email.show)&&i("div",{className:lr,children:i(Lt,{ref:P,value:C.email,disabled:O==null?void 0:O.email.disabled})})}),qs=()=>{var V,ne;return i(de,{children:(O==null?void 0:O.address.show)&&i("div",{className:Tt("address"),children:i(kt,{ref:_,value:C.address,country:((V=r==null?void 0:r.checkout)==null?void 0:V.country)||((ne=r==null?void 0:r.checkout)==null?void 0:ne.bill.country),onAddressChange:Ae=>S(Object.assign(C,{address:Ae}))})})})},Js=()=>i(de,{children:!!Y&&i(yt,{content:Y,style:{marginTop:"12px"}})}),E6=$e(()=>{var V,ne,Ae,we;return E?i(de,{children:[i("div",{className:lr,children:[i("div",{className:Tt("card-number-wrapper"),children:[i(va,{supportedCardBrands:(ne=(V=r==null?void 0:r.checkout)==null?void 0:V.paymentMethod)==null?void 0:ne.filter(Boolean),security:D,ref:Kn,onBinValue:zs}),y6()]}),t&&i(Dc,{className:Tt("card-brands"),supportedCardBrands:(we=(Ae=r==null?void 0:r.checkout)==null?void 0:Ae.paymentMethod)==null?void 0:we.filter(Boolean)})]}),i("div",{className:Tt("center"),children:[i(ga,{security:D,className:lr,ref:Ys}),i(Kr,{security:D,className:lr,ref:Ka})]})]}):i("div",{className:Tt("card-info"),children:i(Aa,{ref:g,supportedCardBrands:te,showLabel:!0,security:D})})},[E,D]),_6=()=>{var V;return i(At,{form:C,ref:js,onFormChange:ne=>S(ne),children:i("div",{className:fe(he,Tt()),style:Wn,children:[Ks(),E6(),(O==null?void 0:O.holderName.show)&&i("div",{className:Tt("holder-name"),children:i(Bc,{disabled:O==null?void 0:O.holderName.disabled})}),qs(),((V=r==null?void 0:r.checkout)==null?void 0:V.paymentType)===yn.RECURRING&&fa(),Gs&&h6(),Js(),!Qe&&m1()]})})},I6=()=>{var V,ne,Ae,we;return i(At,{form:C,ref:js,onFormChange:Ue=>S(Ue),children:i("div",{className:fe(he,Tt()),style:Wn,children:[Ks(),i("div",{className:Tt("card-selector-wrapper"),children:[i(xc,{value:(Ae=(ne=(V=r==null?void 0:r.checkout)==null?void 0:V.tokens)==null?void 0:ne[0])==null?void 0:Ae.token,cardList:(we=r==null?void 0:r.checkout)==null?void 0:we.tokens,onClickEdit:Zs,onClickChange:C6,onCardChange:g6,style:{flex:2,marginRight:"12px"}}),i(Kr,{className:lr,style:{flex:1,marginLeft:"12px"},security:D,ref:Ka})]}),re&&qs(),Js(),!Qe&&m1()]})})};return i(tt.Provider,{value:{i18n:v},children:W&&v.ready.value&&i(de,{children:[i(Oc,{ref:h1,i18n:v,sessionMode:(ad=r.checkout)==null?void 0:ad.sessionMode,supportedCardBrands:te,style:me||Ho,onFocus:v6,onBinValue:zs,onBrand:A6,onAfterPayment:S6,onPaymentError:w6,onPaymentTimeout:({message:V})=>le(v.get(V)),onValidStatusChanged:b6,onValidated:ye,children:Qs?I6():_6()}),i(Uc,{show:K,theme:(od=r==null?void 0:r.checkout)==null?void 0:od.theme,onClose:dn,...Ce})]})})}),{bem:qr}=Ie("wechat-pay"),j3=Ve((e,n)=>{var F,x,U,Q,W,J,te,ve,K;const{session:t}=e,r=bt(),a=St(),o=j(null);Oe(n,()=>({stopRetry:()=>{R(),u("unSubmit")},startRetry:z=>{u("loading"),S({timeout:z})},updateAddress:()=>{var z;w(Object.assign(h,{address:r.getAddressState()})),(z=g.current)==null||z.update(r.getAddressState())},updateEmail:()=>{var z;w(Object.assign(h,{email:a.email})),(z=o.current)==null||z.update(a.email)}}));const{setErrorMsg:c,i18n:s,errorMsg:d,sessionReady:l}=ut(t,e.core),[m,u]=M("unSubmit"),y=j(null),[h,w]=M({email:"",address:{country:"",province:"",city:"",area:"",postCode:"",address1:"",address2:""}}),[v,b]=M(!1),p=j(!1),[_,P]=M(!1),g=j(null);function I(){var z;(z=y.current)==null||z.validate(void 0,!1).then(()=>{b(!0)}).catch(()=>{b(!1)})}ce(()=>{I()},[h]),ce(()=>{var z;l&&((t==null?void 0:t.checkout.status)==="SUCCESS"&&(u("success"),(z=e.onSuccess)==null||z.call(e)),h.email=(t==null?void 0:t.checkout.bill.email)??"",p.current=!!(t!=null&&t.checkout.bill.email),(t==null?void 0:t.checkout.bill.billingAddressCollection)==="REQUIRED"?P(!0):P(!1),!_&&setTimeout(()=>{I()},100))},[l]);const C=$e(z=>{var Ce;c(z||s.get("common.payTimeout")),u("unSubmit"),(Ce=e.onTimeout)==null||Ce.call(e,"retry")},[s,e.onTimeout]),{start:S,stop:R}=nt(z=>k(!0,z),{timeout:2*60*1e3,onTimeout:()=>C(s.get("common.queryTimeout"))});async function k(z=!1,Ce){var pe,O,ee,D,G,re,be,me,f;try{const E=z?await z0({sessionId:t.sessionId,clientKey:t.clientKey},{locale:s.locale,timeout:Ce}):await W0({sessionId:t.sessionId,clientKey:t.clientKey,bill:_?{email:h.email,...h.address,province:r.getLabel(h.address.province,r.getProvinceOption())??h.address.province,city:r.getLabel(h.address.city,r.getCityOptions())??h.address.city}:{email:h.email},channelUserId:await((pe=e.onGetOpenId)==null?void 0:pe.call(e))},e.core,{locale:s.locale,timeout:Ce}),{status:H,orderStatus:T,errorMessage:q,payInfo:le,errorCode:ie}=E;if(!z&&((O=e.onSubmitResponse)==null||O.call(e,E)),H==="PROCESSING")if(T){if(T==="SUCCESS")return u("success"),(ee=e.onSuccess)==null||ee.call(e),{end:!0};if(T==="FAILURE")return c(q),u("unSubmit"),(D=e.onError)==null||D.call(e,new Se("API_ERROR",q,{code:ie})),{end:!0};if(T==="PROCESSING")return z||(await((G=e.onCallWxPayBox)==null?void 0:G.call(e,le)),S()),{end:!1};if(T==="CANCELED")return u("unSubmit"),(re=e.onTimeout)==null||re.call(e,"channel"),{end:!0}}else return u("unSubmit"),{end:!0};else{if(H==="SUCCESS")return u("success"),(be=e.onSuccess)==null||be.call(e),{end:!0};if(H==="EXPIRED")return u("unSubmit"),(me=e.onExpired)==null||me.call(e),{end:!0}}return u("unSubmit"),{end:!0}}catch(E){if(qe(E))return z?{end:!1}:(C(),{end:!0});{const H=E.i18nKey?s.get(E.i18nKey):E.message;return c(H),(f=e.onError)==null||f.call(e,new Se("API_ERROR",H,{code:E.code,cause:E})),u("unSubmit"),{end:!0}}}}async function A(){var z;c(""),(z=y.current)==null||z.validate(async Ce=>{var pe;if(_&&r.setValidateAllFields(!0),(pe=e.onSubmit)==null||pe.call(e,Ce),Ce){u("unSubmit");return}c(""),u("loading"),await k()})}const N=()=>{const{transAmount:z,channelParams:Ce={}}=(t==null?void 0:t.checkout)??{},{totalAmount:pe}=Ce.wechatPay??{},O=(pe!=null&&pe.amount?pe:z)||{},ee=O!=null&&O.amount?pt(O).jointSymbol():"",D=s.get("common.pay")+(ee?` ${ee}`:"");return i(wt,{className:qr("button"),status:m,text:D,loadingText:s.get("common.payProcessing"),successText:s.get("common.paySuccess"),onClick:A,verified:v})},Y=z=>{y.current=z,z&&I()},B={[ae("button-bg-color")]:(F=t==null?void 0:t.colors)==null?void 0:F.primary,[ae("button-bg-color-hover")]:(x=t==null?void 0:t.colors)==null?void 0:x.primaryHover,[ae("button-bg-color-active")]:(U=t==null?void 0:t.colors)==null?void 0:U.primaryActive,[ae("button-text-color")]:(W=(Q=t==null?void 0:t.checkout)==null?void 0:Q.theme)==null?void 0:W.payButtonTextColor,[ae("input-color")]:(J=t==null?void 0:t.colors)==null?void 0:J.primary};return i(tt.Provider,{value:{i18n:s,session:t},children:l&&s.ready.value&&i(At,{form:h,ref:Y,onFormChange:z=>w(z),children:i("div",{className:fe(he,qr()),style:B,children:[i(Lt,{ref:o,className:qr("email"),value:h.email,disabled:!!p.current}),_&&i(kt,{ref:g,value:h.address,country:((te=t==null?void 0:t.checkout)==null?void 0:te.country)||((ve=t==null?void 0:t.checkout)==null?void 0:ve.bill.country),onAddressChange:z=>w(Object.assign(h,{address:z}))}),((K=t==null?void 0:t.checkout)==null?void 0:K.paymentType)===yn.RECURRING&&fa(),!!d&&i(yt,{className:qr("error"),content:d}),N()]})})})}),Zc=e=>{var o;const{src:n,onload:t=null,onerror:r=null}=e,a=document.createElement("script");a.type="text/javascript",a.src=n,a.onload=t,a.onerror=r,Object.assign(a,e.extraOptions),(o=document.getElementsByTagName("head")[0])==null||o.appendChild(a)},Y3=(e,n)=>{Zc({src:"https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",onload:e,onerror:n,extraOptions:{async:!0,crossOrigin:""}})};async function Q3(e){var t,r;if(!e||!ApplePaySession)return!1;if(!((t=ApplePaySession.canMakePayments)!=null&&t.call(ApplePaySession)))return;const n=await((r=ApplePaySession.applePayCapabilities)==null?void 0:r.call(ApplePaySession,e));return!!["paymentCredentialsAvailable","paymentCredentialStatusUnknown","paymentCredentialsUnavailable"].includes(n.paymentCredentialStatus)}const{bem:jc}=Ie("apple-pay"),Yc=Ve(e=>{const{session:n,isDropIn:t}=e;let r;const{i18n:a,sessionReady:o,fraudDetection:c}=ut(n,e.core),[s,d]=M(""),[l,m]=M(!1),u=()=>({returnUrl:n==null?void 0:n.checkout.returnUrl});ce(()=>{var g,I,C;if(!o)return;const{status:p,paymentMethod:_=[],sessionMode:P}=(n==null?void 0:n.checkout)||{};if(P===Ke.DROP_IN&&!t){(I=(g=e.core.config).onInitError)==null||I.call(g,new Se("ERROR","Please send the correct session when creating the checkout"));return}_.includes($.APPLE_PAY)&&(Y3(async()=>{var R,k,A,N;await Q3((A=(k=(R=n==null?void 0:n.checkout)==null?void 0:R.channelParams)==null?void 0:k.applePay)==null?void 0:A.merchantIdentifier)&&(m(!0),(N=e.onLoad)==null||N.call(e,!0))},()=>{var S;m(!1),(S=e.onLoad)==null||S.call(e,!1)}),p==="SUCCESS"&&((C=e.onSuccess)==null||C.call(e,u())))},[o]);const y=$e(p=>{var P;const _=p||a.get("common.payTimeout");r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,_)]}),d(_),(P=e.onTimeout)==null||P.call(e,"retry")},[a,e.onTimeout]),{start:h}=nt(p=>w(!0,p),{onTimeout:()=>y(a.get("common.queryTimeout"))});async function w(p=!1,_,P,g,I){var C,S,R,k,A,N,Y;d("");try{const B=await(p?J0({sessionId:n.sessionId,clientKey:n.clientKey},{locale:a.locale,timeout:_}):async function(){var J,te;const W=t0(g==null?void 0:g.phoneNumber);return q0({sessionId:n.sessionId,clientKey:n.clientKey,token:JSON.stringify({token:P}),bill:{firstName:g==null?void 0:g.familyName,lastName:g==null?void 0:g.givenName,addressLine1:(J=g==null?void 0:g.addressLines)==null?void 0:J[0],addressLine2:(te=g==null?void 0:g.addressLines)==null?void 0:te[1],state:g==null?void 0:g.administrativeArea,city:g==null?void 0:g.locality,postalCode:g==null?void 0:g.postalCode,areaCode:W==null?void 0:W.areaCode,phoneNumber:W==null?void 0:W.phoneNumber,email:(g==null?void 0:g.emailAddress)||(I==null?void 0:I.emailAddress)||(n==null?void 0:n.checkout.bill.email),country:g==null?void 0:g.countryCode},browser:await dt({fraudDetectionId:await(c==null?void 0:c.getFraudDetectionId())})},e.core,{locale:a.locale})}()),{status:F,orderStatus:x,errorMessage:U,errorCode:Q}=B;if(F==="PROCESSING"){if(x==="SUCCESS")return r.completePayment({status:0}),(C=e.onSuccess)==null||C.call(e,u()),{end:!0};if(x==="PROCESSING")return!p&&await h(),{end:!p};if(x==="FAILURE")return d(U),(S=e.onError)==null||S.call(e,new Se("API_ERROR",U,{code:Q})),r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,U)]}),{end:!0};if(x==="AUTHORIZED")return r.completePayment({status:0}),(R=e.onAuthorized)==null||R.call(e),{end:!0};if(!x)return r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,"")]}),{end:!0}}else{if(F==="SUCCESS")return(k=e.onSuccess)==null||k.call(e,u()),r.completePayment({status:0}),{end:!0};if(F==="EXPIRED")return(A=e.onExpired)==null||A.call(e),r.abort(),{end:!0}}return(N=e.onSuccess)==null||N.call(e,u()),{end:!0}}catch(B){if(qe(B))return p?{end:!1}:(y(),{end:!0});{const F=B.i18nKey?a.get(B.i18nKey):B.message;return d(F),(Y=e.onError)==null||Y.call(e,new Se("API_ERROR",F,{code:B.code,cause:B})),r.completePayment({status:1,errors:[new ApplePayError("unknown",void 0,F)]}),{end:!0}}}}function v(){var I,C,S,R;if((I=e.onBtnClick)==null||I.call(e),!ApplePaySession)return;const p=n==null?void 0:n.checkout,{applePay:_}=(p==null?void 0:p.channelParams)??{},P=["name","email"];((C=p==null?void 0:p.bill)==null?void 0:C.billingAddressCollection)==="REQUIRED"&&P.push("postalAddress");const g={merchantCapabilities:["supports3DS"],countryCode:(_==null?void 0:_.countryCode)??"",requiredBillingContactFields:P,requiredShippingContactFields:["email"],currencyCode:(p==null?void 0:p.transAmount.currency)??"",supportedNetworks:((R=(S=_==null?void 0:_.supportedNetworks)==null?void 0:S.map)==null?void 0:R.call(S,k=>$u(k)))??[],total:{label:(p==null?void 0:p.theme.merchantName)??"",type:"final",amount:String(p==null?void 0:p.transAmount.amount)}};r=new ApplePaySession(3,g),r.onvalidatemerchant=async()=>{const k=await K0();console.log("onvalidatemerchant"),r.completeMerchantValidation(k)},r.onpaymentauthorized=async k=>{var A;(A=e.onSubmit)==null||A.call(e),console.log("onpaymentauthorized"),console.log("apple pay token: ",k.payment.token),console.log("apple pay shippingContact: ",k.payment.shippingContact),console.log("apple pay billingContact",k.payment.billingContact),w(!1,void 0,k.payment.token,k.payment.billingContact,k.payment.shippingContact)},r.oncancel=()=>{var k;(k=e.onCancel)==null||k.call(e)},r.begin()}const b=()=>i("div",{className:jc("button"),children:i("apple-pay-button",{id:"apple-pay-button",buttonstyle:"black",type:"plain",onClick:v})});return i("div",{children:o&&l&&a.ready.value&&i(de,{children:[!!s&&i(yt,{className:jc("error"),content:s}),b()]})})});function W3(e,n,t,r){const{transAmount:a,theme:{merchantName:o}}=e,{googlePay:c}=(e==null?void 0:e.channelParams)??{},s={apiVersion:2,apiVersionMinor:0},d={type:"PAYMENT_GATEWAY",parameters:{gateway:c==null?void 0:c.providerGatewayId,gatewayMerchantId:c==null?void 0:c.merchantGatewayId}},l=(c==null?void 0:c.allowedCardNetworks)??[],u={type:"CARD",parameters:{allowedAuthMethods:(c==null?void 0:c.allowedAuthMethods)??[],allowedCardNetworks:l,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}};function y(){return Object.assign({},s,{allowedPaymentMethods:[u]})}const h=Object.assign({tokenizationSpecification:d},u);function w(){return{countryCode:c==null?void 0:c.countryCode,currencyCode:a.currency,totalPriceStatus:"FINAL",totalPrice:String(a.amount),totalPriceLabel:"Total"}}let v;function b(){const C=Object.assign({},s);return C.emailRequired=!0,C.allowedPaymentMethods=[h],C.transactionInfo=w(),C.merchantInfo={merchantId:c==null?void 0:c.googlePayMerchantId,merchantName:o},C.callbackIntents=["PAYMENT_AUTHORIZATION"],C}function p(){return v||(v=new google.payments.api.PaymentsClient({environment:c==null?void 0:c.environment,paymentDataCallbacks:{onPaymentAuthorized:_}})),v}function _(C){return new Promise(function(S){var Q,W;console.log("google pay token",C.paymentMethodData.tokenizationData.token),console.log("google pay billingAddress",(Q=C.paymentMethodData.info)==null?void 0:Q.billingAddress);const{name:R,address1:k,address2:A,address3:N,countryCode:Y,administrativeArea:B,locality:F,postalCode:x,phoneNumber:U}=((W=C.paymentMethodData.info)==null?void 0:W.billingAddress)??{};n(C.paymentMethodData.tokenizationData.token,{email:C.email,name:R,address1:k,address2:A,address3:N,countryCode:Y??"",administrativeArea:B??"",locality:F??"",postalCode:x??"",phoneNumber:U??""}).then(J=>{S(J==null?void 0:J.res)})})}function P(C){p().isReadyToPay(y()).then(function(R){R.result?g(C):r==null||r(!1)}).catch(function(R){console.error(R)})}function g(C){const R=p().createButton({buttonColor:"default",buttonType:"pay",buttonRadius:8,buttonSizeMode:"fill",onClick:I,allowedPaymentMethods:[u]});C==null||C.appendChild(R)}function I(){t==null||t();const C=b();C.transactionInfo=w();const S=p();console.log("paymentDataRequest",C),S.loadPaymentData(C)}return{onGooglePayLoaded:P}}const z3=(e,n)=>{var t;if((t=window.google)!=null&&t.payments){e==null||e();return}Zc({src:"https://pay.google.com/gp/p/js/pay.js",onload:e,onerror:n,extraOptions:{async:!0}})},{bem:K3}=Ie("google-pay"),Qc=Ve((e,n)=>{var B;const{session:t,threeDSFrame:r,isDropIn:a}=e;Oe(n,()=>({checkThreeDS:A}));const{sessionReady:o,i18n:c,fraudDetection:s}=ut(t,e.core),[d,l]=M(""),[m,u]=M(!1),[y,h]=M(!1),[w,v]=M(),[b,p]=M(!0),_=$e(F=>{var x;l(F||c.get("common.payTimeout")),(x=e.onTimeout)==null||x.call(e,"retry")},[c,e.onTimeout]),P=()=>({returnUrl:t==null?void 0:t.checkout.returnUrl});ce(()=>{var Q,W,J;if(!o)return;const{status:F,paymentMethod:x=[],sessionMode:U}=(t==null?void 0:t.checkout)||{};if(U===Ke.DROP_IN&&!a){(W=(Q=e.core.config).onInitError)==null||W.call(Q,new Se("ERROR","Please send the correct session when creating the checkout"));return}x.includes($.GOOGLE_PAY)&&(z3(()=>{var te;u(!0),(te=e.onLoad)==null||te.call(e,!0)},()=>{var te;u(!1),(te=e.onLoad)==null||te.call(e,!1)}),p(U===Ke.HOSTED),F==="SUCCESS"&&((J=e.onSuccess)==null||J.call(e,P())))},[o]);const g=(F,x)=>{var U;b?(U=e.onThreeDS)==null||U.call(e,F,x):(h(!0),v({url:F,incomplete:x,width:r==null?void 0:r.modalWidth,height:r==null?void 0:r.modalHeight}))},I=()=>{h(!1),v(void 0),A()},{start:C}=nt(async F=>await S(void 0,void 0,!0,F),{onTimeout:()=>_(c.get("common.queryTimeout"))});async function S(F,x,U=!1,Q){var W,J,te,ve,K,z,Ce,pe;l(""),U||(W=e.onSubmit)==null||W.call(e);try{const O=await(U?pc({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale,timeout:Q}):async function(){const me=e0(x==null?void 0:x.phoneNumber);return X0({sessionId:t.sessionId,clientKey:t.clientKey,token:F??"",bill:{firstName:x==null?void 0:x.name,addressLine1:x==null?void 0:x.address1,addressLine2:(x==null?void 0:x.address2)??""+(x==null?void 0:x.address3)??"",country:x==null?void 0:x.countryCode,state:x==null?void 0:x.administrativeArea,city:x==null?void 0:x.locality,email:x==null?void 0:x.email,postalCode:x==null?void 0:x.postalCode,phoneNumber:me==null?void 0:me.phoneNumber,areaCode:me==null?void 0:me.areaCode},browser:await dt({fraudDetectionId:await(s==null?void 0:s.getFraudDetectionId())})},e.core,{locale:c.locale})}()),{status:ee,orderStatus:D,errorMessage:G,threeDSUrl:re,errorCode:be}=O;if(ee==="PROCESSING"){if(D==="SUCCESS")return(J=e.onSuccess)==null||J.call(e,P()),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="PROCESSING"){const me=await C();return(me==null?void 0:me.end)===!0?{end:!0,res:me.res}:await C()}else{if(D==="FAILURE")return l(G),(te=e.onError)==null||te.call(e,new Se("API_ERROR",G,{code:be})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:G,reason:"OTHER_ERROR"}}};if(D==="AUTHORIZED")return(ve=e.onAuthorized)==null||ve.call(e),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="IN_THREED")return g(re,!1),{end:!0,res:{transactionState:"SUCCESS"}};if(D==="IN_PREVIOUS_THREED")return g(re,!0),{end:!0,res:{transactionState:"SUCCESS"}};if(!D)return{end:!0,res:{transactionState:"SUCCESS"}}}}else{if(ee==="SUCCESS")return(K=e.onSuccess)==null||K.call(e,P()),{end:!0,res:{transactionState:"SUCCESS"}};if(ee==="EXPIRED")return(z=e.onExpired)==null||z.call(e),{end:!0,res:{transactionState:"SUCCESS"}}}return(Ce=e.onSuccess)==null||Ce.call(e,P()),{end:!1,res:{transactionState:"SUCCESS"}}}catch(O){if(qe(O))return U?{end:!1}:(_(),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:c.get("common.payTimeout"),reason:"OTHER_ERROR"}}});{const ee=O.i18nKey?c.get(O.i18nKey):O.message;return l(ee),(pe=e.onError)==null||pe.call(e,new Se("API_ERROR",ee,{code:O.code,cause:O})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:ee,reason:"OTHER_ERROR"}}}}}}const{start:R,stop:k}=nt(()=>A(!0),{timeout:12*1e3,onTimeout:()=>_(c.get("common.queryTimeout"))});async function A(F=!1){var x,U,Q,W,J;if(!t)return{end:!0};try{const te=await pc({sessionId:t.sessionId,clientKey:t.clientKey},{locale:c.locale}),{status:ve,orderStatus:K,errorMessage:z}=te;if(ve==="PROCESSING"){if(K==="PROCESSING")C();else if(K==="FAILURE")l(z);else if(K==="AUTHORIZED")(x=e.onAuthorized)==null||x.call(e);else{if(K==="IN_THREED")return!F&&R(),{end:!1};K==="IN_PREVIOUS_THREED"&&l(c.get("common.pay3DSIncomplete"))}return k(),{end:!0}}else{if(ve==="SUCCESS")return(U=e.onSuccess)==null||U.call(e,P()),k(),{end:!0};if(ve==="EXPIRED")return(Q=e.onExpired)==null||Q.call(e),k(),{end:!0}}return(W=e.onSuccess)==null||W.call(e,P()),k(),{end:!0}}catch(te){if(qe(te))return F?{end:!1}:(_(c.get("common.queryTimeout")),{end:!0});{const ve=te.i18nKey?c.get(te.i18nKey):te.message;return l(ve),(J=e.onError)==null||J.call(e,new Se("API_ERROR",ve,{code:te.code,cause:te})),{end:!0}}}}const N=j(null);ce(()=>{if(N&&(t!=null&&t.checkout)&&m){const{onGooglePayLoaded:F}=W3(t==null?void 0:t.checkout,S,e.onBtnClick,e.onCanUse);F(N.current)}},[o,N,c.ready.value,m]);const Y=()=>i("div",{style:"width: 100%; height: 44px",children:i("div",{id:"container",style:"width:100%; height: 44px",ref:N})});return i("div",{children:o&&m&&c.ready.value&&i(de,{children:[!!d&&i(yt,{className:K3("error"),content:d}),Y(),i(Uc,{show:y,theme:(B=t==null?void 0:t.checkout)==null?void 0:B.theme,...w,onClose:I})]})})}),q3=()=>{let e,n;const t=j(""),[r,a]=M("");let o,c;const[s,d]=M(void 0),l=P=>{e=P.fieldType,n=P.supportedCardBrands,o=Er(n),c=Uo(o)},m=()=>{let P={maxLength:0,onInput:g=>{}};switch(e){case _e.CVV:{P={maxLength:4,inputMode:"numeric",onInput:u,validator:w};break}case _e.CARD_NUMBER:{P={maxLength:23,inputMode:"numeric",onInput:y,validator:v};break}case _e.EXPIRE_DATE:{P={maxLength:5,inputMode:"numeric",onInput:h,validator:b};break}}return P},u=P=>{const g=P.currentTarget,I=vn(g.value);t.current=g.value=I},y=P=>{var A;const{inputType:g}=P,I=P.currentTarget,C=I.selectionStart;let S=vn(I.value);S=S.replace(/(\d{4})(?=\d)/g,"$1 ");let R=C;R%5===0&&(R=nr(C+(g==="insertText"?1:-1),0)),t.current=I.value=S,I.setSelectionRange(R,R);const k=Ft(I.value).substring(0,6);a(k.length<6?"":k),d((A=p(Ft(I.value)))==null?void 0:A.code)},h=P=>{const{inputType:g}=P,I=P.currentTarget,C=I.selectionStart;let S;if(g==="insertText"){const{data:R}=P;S=vn(I.value);const k=S.length;k===1&&+S>1?S=`0${S}`:k===2&&(+S>12?S=`01${R}`:S=`${S}`),k>=2&&!S.includes("/")&&(S=S.slice(0,2)+"/"+S.slice(2,4))}else{S=I.value;const R=t.current.slice(C,C+1),k=t.current.length;if(k>3&&R==="/"){t.current=I.value=t.current,I.setSelectionRange(C,C);return}else if(C===1){const A=t.current.slice(0,2);k>2&&+A>=10?S=`01${t.current.slice(2,k)}`:S=S.slice(0,1)}else if(C===0&&S.length>1){R==="0"?t.current=I.value=t.current:R==="1"&&(t.current=I.value=`0${S}`),I.setSelectionRange(0,0);return}else if(C===3)if(k===4)S=S.slice(0,2);else{t.current=I.value=S,I.setSelectionRange(C-1,C-1);return}}t.current=I.value=S,g!=="insertText"&&I.setSelectionRange(C+1,C+1)},w=()=>{if(Pe(t.current)||t.current.length<3)throw new Error("card.cardSecurityCode.incomplete");return!0},v=()=>{const P=Ft(t.current??"");if(!c.includes(P.length))throw new Error("card.cardNumber.incomplete");if(!p(P))throw new Error("card.cardNumber.invalid");return!0},b=()=>{if(Pe(t.current)||t.current.length!==5)throw new Error("card.cardExpireDate.incomplete");if(zi(t.current))throw new Error("card.cardExpireDate.expired")},p=P=>Fo(P,o);return{value:t,cardBin:r,initSecuredInput:l,getConfigByFieldType:m,getCurrCardBrand:p,brand:s,validate:()=>{if(e===_e.CARD_NUMBER)return v();if(e===_e.CVV)return w();if(e===_e.EXPIRE_DATE)return b()}}},Ct=r0("input"),J3=e=>{const n=window.parent.frames[e.hiddenIframeName],t=j(null),{initSecuredInput:r,getConfigByFieldType:a,getCurrCardBrand:o,cardBin:c,value:s,brand:d}=q3(),[l,m]=M(!1),u="securedInput",y=()=>{r({fieldType:e.fieldType,supportedCardBrands:e.supportedCardBrands,sendMessage:S=>{ze(S,window.parent)}}),h(e.style)},h=(S={})=>{const{base:R,hover:k,focus:A,valid:N,invalid:Y,placeholder:B}=S,F=`input { ${pn(R)} }`,x=`input.${Ct.hover} { ${pn(k)} }`,U=`input.${Ct.focus} { ${pn(A)} }`,Q=`input.${Ct.valid} { ${pn(N)} }`,W=`input.${Ct.invalid} { ${pn(Y)} }`,J=Fi("input",B==null?void 0:B.base),te=Fi(`input.${Ct.focus}`,B==null?void 0:B.focus),ve=`
|
|
15
15
|
${F}
|
|
16
16
|
${x}
|
|
17
17
|
${U}
|