@paykka/card-checkout-ui 0.13.13 → 0.13.14

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(Ps(o),"\n```"),[2,s]}})})}}}function o4(){if(!(window.__fp
11
11
  ${e}:-moz-placeholder { ${t} }
12
12
  ${e}:-ms-input-placeholder { ${t} }
13
13
  `},qs=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 s=t[o];s&&Wi.forEach(c=>{r[o]||(r[o]={}),s[c]&&(r[o][c]=s[c],Reflect.deleteProperty(s,c))})})),{...e,inputWrapper:t,input:r}},Xa=(e=[])=>e.map(({selector:t,style:r})=>`${t} { ${Vn(r)} }`).join(`
14
- `);var Oe=(e=>(e.CARD_NUMBER="CARD_NUMBER",e.CVV="CVV",e.EXPIRE_DATE="EXPIRE_DATE",e))(Oe||{}),R1=(e=>(e.CPF="CPF",e))(R1||{});const Ws="data-sf",Qs="secured-iframe",Y4="hidden-pay-iframe",j4="field-pay-iframe",q4="three-ds-iframe",Ks=e=>{const n=document.createElement("iframe");n.setAttribute("src",e),n.classList.add(Qs),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},mt=(e,n,t="*")=>{if(!n||n===window)return;const r=typeof e=="string"?e:JSON.stringify(e);n==null||n.postMessage(r,{targetOrigin:t})},W4=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Q4=(e,n)=>{const t=new URL(e);return Object.entries(n).forEach(([r,a])=>{t.searchParams.append(r,String(a))}),t.toString()},$a=e=>{try{const n=new URL(e),t={};return n.searchParams.forEach((a,o)=>{t[o]=a}),{baseUrl:n.origin+n.pathname,params:t,origin:n.origin}}catch{return{baseUrl:e,params:{},origin:""}}},It=e=>{const{requestMethod:n,targetUrl:t}=e;if(t)if(n==="GET")K4(t,{});else{const{baseUrl:r,params:a}=$a(t);z4(r,a)}},K4=(e,n)=>{const t=Q4(e,n);window.location.href=t},z4=(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()},zs=(e,n)=>{const t=e.indexOf(n);t!==-1&&e.splice(t,1)},J4=(e,n=document.createElement("div"))=>"on"+e in n,Js="MM/DD/YYYY",X4=`${Js} HH:mm:ss`,Xs={date:Js,datetime:X4},$4=(e,n="datetime")=>{if(!e&&e!==0)return"-";n in Xs&&(n=Xs[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()))},e5=e=>Ln(e)?e.split("."):e;function $s(e,n,t){const r=e5(n);if(!r.length)return;let a=e;const o=r.pop();for(let s=0,c=r.length;s<c;s++){const d=r[s];if(Dt(a[d])){const f=(r==null?void 0:r[s+1])??o;a[d]=hl(f)?[]:{}}a=a[d]}a[o]=t}const L1=(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]=L1(t[r],n[r]):t[r]=n[r];return t};function e2(e){const n={...e};for(const t of Object.keys(n))La(n[t])&&(n[t]=e2(n[t]));return Object.freeze(n)}const t5="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",yr=(e,n)=>{var a,o,s,c,d,f,u,m,h,g,w;const{status:t,orderStatus:r}=e;switch(t){case"PROCESSING":{switch(r){case"PROCESSING":{(a=n.onProcessing)==null||a.call(n);break}case"AUTHORIZED":{(o=n.onAuthorized)==null||o.call(n);break}case"IN_THREED":{(s=n.onInThreeDS)==null||s.call(n);break}case"IN_PREVIOUS_THREED":{(c=n.onInPreviousThreeDS)==null||c.call(n);break}case"CANCELED":{(d=n.onCanceled)==null||d.call(n);break}case"SUCCESS":{(f=n.onSuccess)==null||f.call(n);break}case"FAILURE":{(u=n.onFailure)==null||u.call(n);break}default:{(m=n.onDefault)==null||m.call(n);break}}break}case"SUCCESS":{(h=n.onSuccess)==null||h.call(n);break}case"EXPIRED":{(g=n.onExpired)==null||g.call(n);break}default:{(w=n.onDefault)==null||w.call(n);break}}},ft=e=>{var n,t,r;return{returnUrl:e==null?void 0:e.returnUrl,sessionId:e==null?void 0:e.sessionId,merchantId:e==null?void 0:e.merchantId,orderId:e==null?void 0:e.orderId,errorCode:e==null?void 0:e.errorCode,errorMessage:e==null?void 0:e.errorMessage,transAmount:e==null?void 0:e.transAmount,status:e==null?void 0:e.status,orderStatus:e==null?void 0:e.orderStatus,paymentMethod:e==null?void 0:e.paymentMethod,finishTime:e==null?void 0:e.finishTime,payInfo:{threeDSUrl:(n=e==null?void 0:e.payInfo)==null?void 0:n.threeDSUrl,paymentUrl:(t=e==null?void 0:e.payInfo)==null?void 0:t.paymentUrl,paymentExpiredAt:(r=e==null?void 0:e.payInfo)==null?void 0:r.paymentExpiredAt,...e==null?void 0:e.payInfo},rawResponse:e==null?void 0:e.rawResponse}},n5=(e={})=>Object.entries(e).map(([n,t])=>Dt(t)?"":`${n}: ${t};`).join(""),t2=(e=12)=>{let n="";for(;n.length<e;)n+=Math.random().toString(36).slice(2);return n.slice(0,e)},eo=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)};function r5(e,n){return n?e:void 0}function N1(e,n,t){return Ie(n)||(e=Math.max(e,n)),Ie(t)||(e=Math.min(e,t)),e}const M1=(e,n={})=>{try{return JSON.parse(e)}catch{return n}},a5=(e,n="")=>{try{return JSON.stringify(e)}catch{return n}};function n2(e){const[n,t]=e.split("/").map(Number);return new Date(+`20${t}`,n-1)<new Date}const Kn=(...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},o5=()=>Object.entries(Object.assign({"./de-DE.ts":()=>Promise.resolve().then(()=>x6),"./en-GB.ts":()=>Promise.resolve().then(()=>i5),"./es-ES.ts":()=>Promise.resolve().then(()=>O6),"./fr-FR.ts":()=>Promise.resolve().then(()=>F6),"./ja-JP.ts":()=>Promise.resolve().then(()=>B6),"./ko-KR.ts":()=>Promise.resolve().then(()=>H6),"./nl-NL.ts":()=>Promise.resolve().then(()=>U6),"./pt-PT.ts":()=>Promise.resolve().then(()=>Z6),"./ru-RU.ts":()=>Promise.resolve().then(()=>G6),"./zh-CN.ts":()=>Promise.resolve().then(()=>Y6),"./zh-HK.ts":()=>Promise.resolve().then(()=>j6),"./zh-TW.ts":()=>Promise.resolve().then(()=>q6)})).reduce((e,[n,t])=>{const r=n.match(/\.\/(.+)\./)[1];return e[r]=t,e},{});var Dn=(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))(Dn||{});const r2={"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":"Maya","dropIn.zalopay.label":"Zalopay","dropIn.vietqr.label":"VietQR","dropIn.pix.label":"Pix","dropIn.picPay.label":"PicPay","dropIn.opayWallet.label":"OPay Wallet","dropIn.pagaWallet.label":"Paga Wallet","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","qrCode.scanByZalopay":"Scan QR code with Zalopay","qrCode.scanByVietqr":"Scan QR code with VietQR","cpf.label":"CPF/CNPJ","cpf.incomplete":"Your CPF/CNPJ is incomplete","cpf.placeholder":"123.456.789-00",iofTip:"This is a International purchase. IOF fees may be charged by your card issuer. Final amount depends on your bank statement."},i5=Object.freeze(Object.defineProperty({__proto__:null,default:r2},Symbol.toStringTag,{value:"Module"}));function a2(e){return e.replaceAll("_","-").toLowerCase()}function o2(e){return e.split("-")[0]}const s5=()=>Object.entries(o5()).map(([e,n])=>({locale:a2(e),language:o2(e),translation:n}));function c5(e){return s5()}function i2(e,n){var a,o;const t=c5();e=a2(e);let r=(a=t.find(s=>s.locale===e))==null?void 0:a.translation;if(!r){const s=o2(e);r=(o=t.find(c=>c.language===s))==null?void 0:o.translation}return r}const d5=e=>{let n=s2(e);return n||(n=s2(gn().language)),n||Dn.enGB},s2=e=>{if(Object.values(Dn).includes(e))return e;if(e!=null&&e.toLowerCase().startsWith("en"))return Dn.enGB;if(e!=null&&e.toLowerCase().startsWith("zh"))return Dn.zhCN};async function l5(e,n){let t=i2(e);if(!t&&e!==gn().language&&(e=gn().language,t=i2(e)),Hi(t)){const r=await t();return{locale:e,translation:r.default}}return t?{locale:e,translation:t}:{locale:Dn.enGB,translation:r2}}var u5=Symbol.for("preact-signals");function to(){if(zn>1)zn--;else{for(var e,n=!1;T1!==void 0;){var t=T1;for(T1=void 0,no++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&d2(t))try{t.c()}catch(a){n||(e=a,n=!0)}t=r}}if(no=0,zn--,n)throw e}}var Ye=void 0,T1=void 0,zn=0,no=0,gr=0;function c2(e){if(Ye!==void 0){var n=e.n;if(n===void 0||n.t!==Ye)return n={i:0,S:e,p:Ye.s,n:void 0,t:Ye,e:void 0,x:void 0,r:n},Ye.s!==void 0&&(Ye.s.n=n),Ye.s=n,e.n=n,32&Ye.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=Ye.s,n.n=void 0,Ye.s.n=n,Ye.s=n),n}}function vt(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}vt.prototype.brand=u5,vt.prototype.h=function(){return!0},vt.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)},vt.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)}},vt.prototype.subscribe=function(e){var n=this;return ao(function(){var t=n.value,r=Ye;Ye=void 0;try{e(t)}finally{Ye=r}})},vt.prototype.valueOf=function(){return this.value},vt.prototype.toString=function(){return this.value+""},vt.prototype.toJSON=function(){return this.value},vt.prototype.peek=function(){var e=Ye;Ye=void 0;try{return this.value}finally{Ye=e}},Object.defineProperty(vt.prototype,"value",{get:function(){var e=c2(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(no>100)throw new Error("Cycle detected");this.v=e,this.i++,gr++,zn++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{to()}}}});function k1(e){return new vt(e)}function d2(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 l2(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 u2(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 Jn(e){vt.call(this,void 0),this.x=e,this.s=void 0,this.g=gr-1,this.f=4}(Jn.prototype=new vt).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gr))return!0;if(this.g=gr,this.f|=1,this.i>0&&!d2(this))return this.f&=-2,!0;var e=Ye;try{l2(this),Ye=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 Ye=e,u2(this),this.f&=-2,!0},Jn.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)}vt.prototype.S.call(this,e)},Jn.prototype.U=function(e){if(this.t!==void 0&&(vt.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)}},Jn.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(Jn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=c2(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function m2(e){return new Jn(e)}function f2(e){var n=e.u;if(e.u=void 0,typeof n=="function"){zn++;var t=Ye;Ye=void 0;try{n()}catch(r){throw e.f&=-2,e.f|=8,ro(e),r}finally{Ye=t,to()}}}function ro(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,f2(e)}function m5(e){if(Ye!==this)throw new Error("Out-of-order effect");u2(this),Ye=e,this.f&=-2,8&this.f&&ro(this),to()}function V1(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}V1.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()}},V1.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,f2(this),l2(this),zn++;var e=Ye;return Ye=this,m5.bind(this,e)},V1.prototype.N=function(){2&this.f||(this.f|=2,this.o=T1,T1=this)},V1.prototype.d=function(){this.f|=8,1&this.f||ro(this)};function ao(e){var n=new V1(e);try{n.c()}catch(t){throw n.d(),t}return n.d.bind(n)}var oo;function Xn(e,n){be[e]=n.bind(null,be[e]||function(){})}function pr(e){oo&&oo(),oo=e&&e.S()}function h2(e){var n=this,t=e.data,r=h5(t);r.value=t;var a=Ht(function(){for(var o=n.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}return n.__$u.c=function(){var s;!ri(a.peek())&&((s=n.base)==null?void 0:s.nodeType)===3?n.base.data=a.peek():(n.__$f|=1,n.setState({}))},m2(function(){var s=r.value.value;return s===0?0:s===!0?"":s||""})},[]);return a.value}h2.displayName="_st",Object.defineProperties(vt.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:h2},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Xn("__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 vt&&(t||(n.__np=t={}),t[a]=o,r[a]=o.peek())}}e(n)}),Xn("__r",function(e,n){pr();var t,r=n.__c;r&&(r.__$f&=-2,(t=r.__$u)===void 0&&(r.__$u=t=function(a){var o;return ao(function(){o=this}),o.c=function(){r.__$f|=1,r.setState({})},o}())),pr(t),e(n)}),Xn("__e",function(e,n,t,r){pr(),e(n,t,r)}),Xn("diffed",function(e,n){pr();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 s in o){var c=o[s];c!==void 0&&!(s in r)&&(c.d(),o[s]=void 0)}else t.U=o={};for(var d in r){var f=o[d],u=r[d];f===void 0?(f=f5(t,d,u,a),o[d]=f):f.o(u,a)}}}e(n)});function f5(e,n,t,r){var a=n in e&&e.ownerSVGElement===void 0,o=k1(t);return{o:function(s,c){o.value=s,r=c},d:ao(function(){var s=o.value.value;r[n]!==s&&(r[n]=s,a?e[n]=s:s?e.setAttribute(n,s):e.removeAttribute(n))})}}Xn("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 s=n.__c;if(s){var c=s.__$u;c&&(s.__$u=void 0,c.d())}}e(n)}),Xn("__h",function(e,n,t,r){(r<3||r===9)&&(n.__$f|=2),e(n,t,r)}),en.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 h5(e){return Ht(function(){return k1(e)},[])}const l1=class l1{constructor(){Ae(this,"locale");Ae(this,"translation");Ae(this,"isReady",k1(!1));Ae(this,"currentLoadId",0);return l1.instance||(l1.instance=this),l1.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=gn().language){if(n===this.locale)return;this.locale=n;const t=++this.currentLoadId;this.isReady.value=!1,l5(this.locale).then(r=>{t===this.currentLoadId&&(this.isReady.value=!0,this.locale=r.locale,this.translation=r.translation)}).catch(()=>{this.isReady.value=!1})}};Ae(l1,"instance");let vr=l1,io="https://checkout.aq.paykka.com",jt="https://checkout.aq.paykka.com",br="/cp",$n=`${jt}${br}`,so,C2={},y2,Re="/session";const e1=e=>{io=e},t1=e=>{const n=new URL(e);jt=n.origin,br=n.pathname,$n=`${jt}${br==="/"?"":br}`},g2=e=>{so=e},C5=e=>{C2=e},p2=e=>{y2=e},co=e=>{Re=e},ze=X1(null),v2=new WeakMap,Ar=(e,n)=>{const t=Object.assign(v2.get(e)??{},n);return v2.set(e,t),t};function xn(e,n){const t={},r={updateProps:f,mount:u,unmount:m,get props(){return e2(o)},ref:t},a=e,o={...n},s=Ar(r,{vNode:c(),render:d});function c(){return Un(a,{...o,ref:h=>{Object.assign(t,h)}})}function d(){Ar(r,{vNode:c()}),s.dom&&J1(s.vNode,s.dom)}function f(h){Object.assign(o,h),d()}function u(h){const g=Ln(h)?document.querySelector(h):h;if(!g)throw new Error("Component could not mount. Root node was not found.");return m(),Ar(r,{dom:g}),d(),r}function m(){const{dom:h}=s;return h&&(J1(null,h),Ar(r,{dom:null})),r}return r}var n1=(e=>(e.ERROR="ERROR",e.API_ERROR="API_ERROR",e.TIMEOUT="TIMEOUT",e))(n1||{});class Ee extends Error{constructor(t,r,a){super(r);Ae(this,"type");Ae(this,"code");this.type=t,this.code=a==null?void 0:a.code,this.cause=a==null?void 0:a.cause}}const b2=async(e,n={},t)=>b8(e,n,t);class A2{constructor(n,t={}){Et(this,da);Et(this,la);Ae(this,"sessionId");Ae(this,"clientKey");Ae(this,"paykkaDetectionKey");Ae(this,"checkout");Ae(this,"theme",k1({}));Ae(this,"extraParams",{});Et(this,u1,kn());const{sessionId:r,clientKey:a}=n;this.sessionId=r,this.clientKey=a,this.extraParams=t,ga(this,da,Od).call(this)}ready(){return Ne(this,u1)}}u1=new WeakMap,da=new WeakSet,Od=async function(){try{await ga(this,la,Fd).call(this),Ne(this,u1).resolve(!0)}catch(n){const t=We(n)?n:new Ee("API_ERROR",n.message,{code:n.code});Ne(this,u1).reject(t)}},la=new WeakSet,Fd=async function(){this.checkout=await b2({sessionId:this.sessionId,clientKey:this.clientKey},this.extraParams);const{sessionId:n,clientKey:t}=this.checkout||{};this.sessionId=n,t&&(this.paykkaDetectionKey=t)};const w2={eu:"https://checkout.eu.paykka.com",hk:"https://checkout.aq.paykka.com",sandbox:"https://checkout-sandbox.aq.paykka.com",fat:"",dev:""},E2={eu:"https://checkout.eu.paykka.com/cp",hk:"https://checkout.aq.paykka.com/cp",sandbox:"https://checkout-sandbox.aq.paykka.com/cp",fat:"",dev:""},y5=e=>{let n="WEB";const t=window.navigator.userAgent.toLowerCase();return e==="MOBILE"&&(t.includes("miniprogram")?n="MINI_APP":t.includes("micromessenger")||t.includes("alipay")?n="IN_APP_WAP":p4(t)?n="APP":n="WAP"),n},g5=async(e={})=>{var o,s;const{fraudDetectionId:n,origin:t}=e,r=await b4(),a=y5(r.deviceType);return{origin:btoa(t||window.location.origin),referer:btoa(document.referrer||((s=(o=window.frames)==null?void 0:o.top)==null?void 0:s.document.referrer)||""),user_agent:r.userAgent,color_depth:r.colorDepth,language:r.language,java_enabled:r.javaEnabled,device_type:r.deviceType,timezone_offset:r.timezoneOffset,screen_height:r.screenHeight,screen_width:r.screenWidth,cookies:r.cookies,device_os:r.osName,terminal_type:a,fraud_detection_id:n,app_version:"0.13.13"}},Je=async(e={})=>({...await g5(e),device_finger_print_id:await _s()}),p5=async(e,n)=>{const{channel:t,browser:r}=e;return Se.post("/pub/channel/sdk/config",{browser:r,channel_code_list:[...t.map(a=>({channel_code:a}))]},n).then(a=>{const{stripe:o,world_pay:s}=a||{};return{stripe:{key:(o==null?void 0:o.public_key)||""},worldPay:{authCode:(s==null?void 0:s.auth_code)||"",ddcCollectUrl:(s==null?void 0:s.channel_collect_url)||""}}})},v5=async e=>Se.post("/pub/fraud-detection/report/urls",{client_key:e.clientKey,fraud_detection_mode:e.fraudDetectionMode,data:e.data}),b5={organizationId:"dzppsd1h",profilingDomain:"ddc.worldpay.com"},A5={organizationId:"afevfjm6",profilingDomain:"ddc-test.worldpay.com"},w5="https://js.stripe.com/v3/",E5=1e4;/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function P5(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function S5(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function bt(e,n,t=""){const r=P5(e),a=e==null?void 0:e.length,o=n!==void 0;if(!r||o&&a!==n){const s=t&&`"${t}" `,c=o?` of length ${n}`:"",d=r?`length=${a}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+d)}return e}function wr(e,n=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(n&&e.finished)throw new Error("Hash#digest() has already been called")}function P2(e,n){bt(e,void 0,"output");const t=n.outputLen;if(e.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function I5(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function dn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ln(...e){for(let n=0;n<e.length;n++)e[n].fill(0)}function Er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const _5=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function R5(...e){let n=0;for(let r=0;r<e.length;r++){const a=e[r];bt(a),n+=a.length}const t=new Uint8Array(n);for(let r=0,a=0;r<e.length;r++){const o=e[r];t.set(o,a),a+=o.length}return t}function L5(e,n){if(e.length!==n.length)return!1;let t=0;for(let r=0;r<e.length;r++)t|=e[r]^n[r];return t===0}const N5=(e,n)=>{function t(r,...a){if(bt(r,void 0,"key"),!_5)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){const u=a[0];bt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}const o=e.tagLength;o&&a[1]!==void 0&&bt(a[1],void 0,"AAD");const s=n(r,...a),c=(u,m)=>{if(m!==void 0){if(u!==2)throw new Error("cipher output not supported");bt(m,void 0,"output")}};let d=!1;return{encrypt(u,m){if(d)throw new Error("cannot encrypt() twice with same key + nonce");return d=!0,bt(u),c(s.encrypt.length,m),s.encrypt(u,m)},decrypt(u,m){if(bt(u),o&&u.length<o)throw new Error('"ciphertext" expected length bigger than tagLength='+o);return c(s.decrypt.length,m),s.decrypt(u,m)}}}return Object.assign(t,e),t};function M5(e,n,t=!0){if(n===void 0)return new Uint8Array(e);if(n.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+n.length);if(t&&!Pr(n))throw new Error("invalid output, must be aligned");return n}function T5(e,n,t){const r=new Uint8Array(16),a=Er(r);return a.setBigUint64(0,BigInt(n),t),a.setBigUint64(8,BigInt(e),t),r}function Pr(e){return e.byteOffset%4===0}function On(e){return Uint8Array.from(e)}function k5(e=32){const n=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(n==null?void 0:n.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");return n.getRandomValues(new Uint8Array(e))}function V5(e,n=k5){const{nonceLength:t}=e;S5(t);const r=(a,o)=>{const s=R5(a,o);return o.fill(0),s};return(a,...o)=>({encrypt(s){bt(s);const c=n(t),d=e(a,c,...o).encrypt(s);return d instanceof Promise?d.then(f=>r(c,f)):r(c,d)},decrypt(s){bt(s);const c=s.subarray(0,t),d=s.subarray(t);return e(a,c,...o).decrypt(d)}})}const un=16,lo=new Uint8Array(16),tn=dn(lo),D5=225,x5=(e,n,t,r)=>{const a=r&1;return{s3:t<<31|r>>>1,s2:n<<31|t>>>1,s1:e<<31|n>>>1,s0:e>>>1^D5<<24&-(a&1)}},qt=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function O5(e){e.reverse();const n=e[15]&1;let t=0;for(let r=0;r<e.length;r++){const a=e[r];e[r]=a>>>1|t,t=(a&1)<<7}return e[0]^=-n&225,e}const F5=e=>e>64*1024?8:e>1024?4:2;class S2{constructor(n,t){Ae(this,"blockLen",un);Ae(this,"outputLen",un);Ae(this,"s0",0);Ae(this,"s1",0);Ae(this,"s2",0);Ae(this,"s3",0);Ae(this,"finished",!1);Ae(this,"t");Ae(this,"W");Ae(this,"windowSize");bt(n,16,"key"),n=On(n);const r=Er(n);let a=r.getUint32(0,!1),o=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const d=[];for(let w=0;w<128;w++)d.push({s0:qt(a),s1:qt(o),s2:qt(s),s3:qt(c)}),{s0:a,s1:o,s2:s,s3:c}=x5(a,o,s,c);const f=F5(t||1024);if(![1,2,4,8].includes(f))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=f;const m=128/f,h=this.windowSize=2**f,g=[];for(let w=0;w<m;w++)for(let P=0;P<h;P++){let E=0,v=0,b=0,N=0;for(let S=0;S<f;S++){if(!(P>>>f-S-1&1))continue;const{s0:A,s1:R,s2:y,s3:_}=d[f*w+S];E^=A,v^=R,b^=y,N^=_}g.push({s0:E,s1:v,s2:b,s3:N})}this.t=g}_updateBlock(n,t,r,a){n^=this.s0,t^=this.s1,r^=this.s2,a^=this.s3;const{W:o,t:s,windowSize:c}=this;let d=0,f=0,u=0,m=0;const h=(1<<o)-1;let g=0;for(const w of[n,t,r,a])for(let P=0;P<4;P++){const E=w>>>8*P&255;for(let v=8/o-1;v>=0;v--){const b=E>>>o*v&h,{s0:N,s1:S,s2:T,s3:A}=s[g*c+b];d^=N,f^=S,u^=T,m^=A,g+=1}}this.s0=d,this.s1=f,this.s2=u,this.s3=m}update(n){wr(this),bt(n),n=On(n);const t=dn(n),r=Math.floor(n.length/un),a=n.length%un;for(let o=0;o<r;o++)this._updateBlock(t[o*4+0],t[o*4+1],t[o*4+2],t[o*4+3]);return a&&(lo.set(n.subarray(r*un)),this._updateBlock(tn[0],tn[1],tn[2],tn[3]),ln(tn)),this}destroy(){const{t:n}=this;for(const t of n)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(n){wr(this),P2(n,this),this.finished=!0;const{s0:t,s1:r,s2:a,s3:o}=this,s=dn(n);return s[0]=t,s[1]=r,s[2]=a,s[3]=o,n}digest(){const n=new Uint8Array(un);return this.digestInto(n),this.destroy(),n}}class B5 extends S2{constructor(n,t){bt(n);const r=O5(On(n));super(r,t),ln(r)}update(n){wr(this),bt(n),n=On(n);const t=dn(n),r=n.length%un,a=Math.floor(n.length/un);for(let o=0;o<a;o++)this._updateBlock(qt(t[o*4+3]),qt(t[o*4+2]),qt(t[o*4+1]),qt(t[o*4+0]));return r&&(lo.set(n.subarray(a*un)),this._updateBlock(qt(tn[3]),qt(tn[2]),qt(tn[1]),qt(tn[0])),ln(tn)),this}digestInto(n){wr(this),P2(n,this),this.finished=!0;const{s0:t,s1:r,s2:a,s3:o}=this,s=dn(n);return s[0]=t,s[1]=r,s[2]=a,s[3]=o,n.reverse()}}function I2(e){const n=(r,a)=>e(a,r.length).update(r).digest(),t=e(new Uint8Array(16),0);return n.outputLen=t.outputLen,n.blockLen=t.blockLen,n.create=(r,a)=>e(r,a),n}const _2=I2((e,n)=>new S2(e,n));I2((e,n)=>new B5(e,n));const uo=16,H5=4,Sr=new Uint8Array(uo),U5=283;function Z5(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function mo(e){return e<<1^U5&-(e>>7)}function R2(e,n){let t=0;for(;n>0;n>>=1)t^=e&-(n&1),e=mo(e);return t}const G5=(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=mo(r))e[t]=r;const n=new Uint8Array(256);n[0]=99;for(let t=0;t<255;t++){let r=e[255-t];r|=r<<8,n[e[t]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return ln(e),n})(),Y5=e=>e<<24|e>>>8,fo=e=>e<<8|e>>>24;function j5(e,n){if(e.length!==256)throw new Error("Wrong sbox length");const t=new Uint32Array(256).map((f,u)=>n(e[u])),r=t.map(fo),a=r.map(fo),o=a.map(fo),s=new Uint32Array(256*256),c=new Uint32Array(256*256),d=new Uint16Array(256*256);for(let f=0;f<256;f++)for(let u=0;u<256;u++){const m=f*256+u;s[m]=t[f]^r[u],c[m]=a[f]^o[u],d[m]=e[f]<<8|e[u]}return{sbox:e,sbox2:d,T0:t,T1:r,T2:a,T3:o,T01:s,T23:c}}const L2=j5(G5,e=>R2(e,3)<<24|e<<16|e<<8|R2(e,2)),q5=(()=>{const e=new Uint8Array(16);for(let n=0,t=1;n<16;n++,t=mo(t))e[n]=t;return e})();function W5(e){bt(e);const n=e.length;Z5(e);const{sbox2:t}=L2,r=[];Pr(e)||r.push(e=On(e));const a=dn(e),o=a.length,s=d=>D1(t,d,d,d,d),c=new Uint32Array(n+28);c.set(a);for(let d=o;d<c.length;d++){let f=c[d-1];d%o===0?f=s(Y5(f))^q5[d/o-1]:o>6&&d%o===4&&(f=s(f)),c[d]=c[d-o]^f}return ln(...r),c}function Ir(e,n,t,r,a,o){return e[t<<8&65280|r>>>8&255]^n[a>>>8&65280|o>>>24&255]}function D1(e,n,t,r,a){return e[n&255|t&65280]|e[r>>>16&255|a>>>16&65280]<<16}function N2(e,n,t,r,a){const{sbox2:o,T01:s,T23:c}=L2;let d=0;n^=e[d++],t^=e[d++],r^=e[d++],a^=e[d++];const f=e.length/4-2;for(let w=0;w<f;w++){const P=e[d++]^Ir(s,c,n,t,r,a),E=e[d++]^Ir(s,c,t,r,a,n),v=e[d++]^Ir(s,c,r,a,n,t),b=e[d++]^Ir(s,c,a,n,t,r);n=P,t=E,r=v,a=b}const u=e[d++]^D1(o,n,t,r,a),m=e[d++]^D1(o,t,r,a,n),h=e[d++]^D1(o,r,a,n,t),g=e[d++]^D1(o,a,n,t,r);return{s0:u,s1:m,s2:h,s3:g}}function _r(e,n,t,r,a){bt(t,uo,"nonce"),bt(r),a=M5(r.length,a);const o=t,s=dn(o),c=Er(o),d=dn(r),f=dn(a),u=n?0:12,m=r.length;let h=c.getUint32(u,n),{s0:g,s1:w,s2:P,s3:E}=N2(e,s[0],s[1],s[2],s[3]);for(let b=0;b+4<=d.length;b+=4)f[b+0]=d[b+0]^g,f[b+1]=d[b+1]^w,f[b+2]=d[b+2]^P,f[b+3]=d[b+3]^E,h=h+1>>>0,c.setUint32(u,h,n),{s0:g,s1:w,s2:P,s3:E}=N2(e,s[0],s[1],s[2],s[3]);const v=uo*Math.floor(d.length/H5);if(v<m){const b=new Uint32Array([g,w,P,E]),N=I5(b);for(let S=v,T=0;S<m;S++,T++)a[S]=r[S]^N[T];ln(b)}return a}function Q5(e,n,t,r,a){const o=a?a.length:0,s=e.create(t,r.length+o);a&&s.update(a);const c=T5(8*r.length,8*o,n);s.update(r),s.update(c);const d=s.digest();return ln(c),d}const K5=N5({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(n,t,r){if(t.length<8)throw new Error("aes/gcm: invalid nonce length");const a=16;function o(c,d,f){const u=Q5(_2,!1,c,f,r);for(let m=0;m<d.length;m++)u[m]^=d[m];return u}function s(){const c=W5(n),d=Sr.slice(),f=Sr.slice();if(_r(c,!1,f,f,d),t.length===12)f.set(t);else{const m=Sr.slice();Er(m).setBigUint64(8,BigInt(t.length*8),!1);const g=_2.create(d).update(t).update(m);g.digestInto(f),g.destroy()}const u=_r(c,!1,f,Sr);return{xk:c,authKey:d,counter:f,tagMask:u}}return{encrypt(c){const{xk:d,authKey:f,counter:u,tagMask:m}=s(),h=new Uint8Array(c.length+a),g=[d,f,u,m];Pr(c)||g.push(c=On(c)),_r(d,!1,u,c,h.subarray(0,c.length));const w=o(f,m,h.subarray(0,h.length-a));return g.push(w),h.set(w,c.length),ln(...g),h},decrypt(c){const{xk:d,authKey:f,counter:u,tagMask:m}=s(),h=[d,f,m,u];Pr(c)||h.push(c=On(c));const g=c.subarray(0,-a),w=c.subarray(-a),P=o(f,m,g);if(h.push(P),!L5(P,w))throw new Error("aes/gcm: invalid ghash tag");const E=_r(d,!1,u,g);return ln(...h),E}}}),z5=async e=>{const n=typeof e=="string"?new TextEncoder().encode(e):e,t=await crypto.subtle.digest("SHA-256",n);return new Uint8Array(t)},J5=e=>btoa(String.fromCharCode(...e)),X5=async(e,n)=>{const t=V5(K5)(await z5(e)).encrypt(new TextEncoder().encode(n));return J5(t)};class Rr{constructor(n){Ae(this,"channel");Ae(this,"options");Ae(this,"fraudDetectionId","");Ae(this,"channelConfig");Ae(this,"timeout",null);Ae(this,"timer",null);Ae(this,"initPromise",null);this.channel=n.channel,this.channelConfig=n.channelConfig,this.timeout=n.timeout,this.options=n.options}validateChannelConfig(){return!0}load(){return Promise.resolve()}async init(...n){if(!this.fraudDetectionId)return this.initPromise?this.initPromise:(this.initPromise=new Promise(async t=>{var r;if(this.reportEvent(zt.FRAUD_DETECTION_START),!((r=this.validateChannelConfig)!=null&&r.call(this))){this.reportEvent(zt.FRAUD_DETECTION_CHANNEL_CONFIG_ERROR),t();return}try{await this.load()}catch{this.reportEvent(zt.FRAUD_DETECTION_LOAD_ERROR),t();return}try{if(this.clearTimer(),this.timeout){const a=await Promise.race([this.collect(...n),this.createTimeoutPromise()]);if(a instanceof Ee&&a.type===n1.TIMEOUT){this.reportEvent(zt.FRAUD_DETECTION_TIMEOUT),t();return}else this.fraudDetectionId=a}else this.fraudDetectionId=await this.collect(...n);this.clearTimer()}catch(a){this.clearTimer(),this.reportEvent(zt.FRAUD_DETECTION_ERROR,{message:a==null?void 0:a.message}),t();return}this.reportEvent(zt.FRAUD_DETECTION_SUCCESS),t()}),this.initPromise)}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}createTimeoutPromise(){return new Promise(n=>{this.timer=setTimeout(()=>{n(new Ee(n1.TIMEOUT))},this.timeout)})}getFraudDetectionId(){return this.fraudDetectionId}onError(n){this.reportEvent(zt.FRAUD_DETECTION_ERROR,{message:n==null?void 0:n.message})}onWarning(n){this.reportEvent(zt.FRAUD_DETECTION_WARNING,{message:n})}reportEvent(n,t){var r,a;(a=(r=this.options)==null?void 0:r.onEvent)==null||a.call(r,n,{...t||{},channel:this.channel})}}const m1=class m1 extends Rr{constructor(n,t){if(m1.instance)return m1.instance;super({channel:Mn.PAYKKA,channelConfig:t,options:n}),m1.instance=this}validateChannelConfig(){var r;const{clientKey:n,sessionMode:t}=((r=this.channelConfig)==null?void 0:r.paykka)||{};return!!n&&!!t}async collect(){var o;const{clientKey:n,sessionMode:t}=((o=this.channelConfig)==null?void 0:o.paykka)||{},r={originUrl:this.getOrigin(),refererUrl:this.getReferer()};return await v5({clientKey:n,fraudDetectionMode:t,data:await X5(n,JSON.stringify(r))})}getReferer(){var t,r;const n=document.referrer||((r=(t=window.frames)==null?void 0:t.top)==null?void 0:r.document.referrer)||"";return $a(n).origin}getOrigin(){return $a(window.location.href).origin}};Ae(m1,"instance",null);let ho=m1;const f1=class f1 extends Rr{constructor(n,t){if(f1.instance)return f1.instance;super({channel:Mn.STRIPE,channelConfig:t,options:n}),f1.instance=this}validateChannelConfig(){var n,t;return!!((t=(n=this.channelConfig)==null?void 0:n.stripe)!=null&&t.key)}async collect(){var o,s;const n=(s=(o=this.channelConfig)==null?void 0:o.stripe)==null?void 0:s.key,t=window.Stripe(n),{radarSession:r,error:a}=await t.createRadarSession();if(a)throw new Ee(n1.ERROR,a==null?void 0:a.message);return r==null?void 0:r.id}load(){return new Promise((n,t)=>{eo({src:w5,extraOptions:{async:!0,crossOrigin:""},onload:()=>{n()},onerror:()=>{t()}})})}};Ae(f1,"instance",null);let Co=f1;const h1=class h1 extends Rr{constructor(t,r){if(h1.instance)return h1.instance;super({channel:Mn.WORLDPAY,channelConfig:r,timeout:E5,options:t});Ae(this,"iframe",null);Ae(this,"listener",null);h1.instance=this}validateChannelConfig(){var a;const{authCode:t,ddcCollectUrl:r}=((a=this.channelConfig)==null?void 0:a.worldPay)||{};return!!t&&!!r}load(){if(this.iframe)return Promise.resolve();const t=document.createElement("iframe");return t.src=`${$n}/worldpay-ddc.html`,t.style.display="none",t.width="1",t.height="1",document.body.appendChild(t),this.iframe=t,new Promise(r=>{t.onload=()=>{r()}})}async collect(t){return this.sendJWTAndBin(t),new Promise(r=>{this.listenFraudDetectionId(a=>{this.fraudDetectionId=a,r(a)})})}sendJWTAndBin(t){var s;const{authCode:r,ddcCollectUrl:a}=((s=this.channelConfig)==null?void 0:s.worldPay)||{},o={action:Ve.DDC_JWT_BIN,jwt:r||"",bin:t,url:a||""};mt(o,this.iframe.contentWindow,jt)}listenFraudDetectionId(t){this.listener&&this.clearListener(),this.listener=r=>{var a,o,s;if(r.origin===((o=(a=this.channelConfig)==null?void 0:a.worldPay)==null?void 0:o.ddcOrigin)){const c=r.data;if(typeof c!="string")return;let d={};try{d=JSON.parse(c)}catch(f){console.error(f);return}if(console.warn("worldpay ddc data",d),d){const f=d.SessionId||((s=d.Payload)==null?void 0:s.SessionId)||"";t(f)}}},window.addEventListener("message",this.listener)}clearListener(){this.listener&&window.removeEventListener("message",this.listener),this.listener=null}};Ae(h1,"instance",null);let Lr=h1;window.worldpayJSCOrigin=window.worldpayJSCOrigin||{},window.worldpayJSCOrigin.version=4,window.worldpayJSCOrigin.create_url=function(e,n,t,r,a){function o(){return Math.floor(2742745743359*Math.random())}function s(){return c(o())}function c(g){return(g+78364164096).toString(36)}var d=o(),f=o(),u=885187064159;f=((f=f-f%256+window.worldpayJSCOrigin.version)+d)%2742745743359,u=(u+d)%2742745743359;var m="https://"+e+"/"+(d=s()+c(d))+n,h=[(f=c(u)+c(f))+"="+t,s()+s()+"="+r];return a!==void 0&&a.length>0&&h.push(s()+s()+"="+a),m+"?"+h.join("&")},window.worldpayJSCOrigin.beacon=function(e,n,t,r){var a="turn:aa.online-metrix.net?transport=",o="1:"+n+":"+t,s={iceServers:[{urls:a+"tcp",username:o,credential:t},{urls:a+"udp",username:o,credential:t}]};try{var c=new RTCPeerConnection(s);c.createDataChannel(Math.random().toString());var d=function(){},f=function(u){c.setLocalDescription(u,d,d)};typeof Promise>"u"||c.createOffer.length>0?c.createOffer(f,d):c.createOffer().then(f,d),setInterval(function(){c.close()},1e4)}catch{}},window.worldpayJSCOrigin.load_tags=function(e,n,t,r){window.worldpayJSCOrigin.beacon(e,n,t,r);var a=document.getElementsByTagName("head").item(0),o=document.createElement("script");o.id="tmx_tags_js",o.setAttribute("type","text/javascript");var s=window.worldpayJSCOrigin.create_url(e,".js",n,t,r);o.setAttribute("src",s),window.worldpayJSCOrigin.set_csp_nonce(o),a.appendChild(o)},window.worldpayJSCOrigin.csp_nonce=null,window.worldpayJSCOrigin.register_csp_nonce=function(e){if(e.currentScript!==void 0&&e.currentScript!==null){var n=e.currentScript.getAttribute("nonce");n!=null&&n!==""?window.worldpayJSCOrigin.csp_nonce=n:e.currentScript.nonce!==void 0&&e.currentScript.nonce!==null&&e.currentScript.nonce!==""&&(window.worldpayJSCOrigin.csp_nonce=e.currentScript.nonce)}},window.worldpayJSCOrigin.set_csp_nonce=function(e){window.worldpayJSCOrigin.csp_nonce!==null&&(e.setAttribute("nonce",window.worldpayJSCOrigin.csp_nonce),e.getAttribute("nonce")!==window.worldpayJSCOrigin.csp_nonce&&(e.nonce=window.worldpayJSCOrigin.csp_nonce))},window.worldpayJSCOrigin.cleanup=function(){let e=null,n=null,t=null;for(;(e=document.getElementById("tdz_ifrm"))!==null;)e.parentElement.removeChild(e);for(;(n=document.getElementById("tmx_tags_iframe"))!==null;)n.parentElement.removeChild(n);for(;(t=document.getElementById("tmx_tags_js"))!==null;)t.parentElement.removeChild(t)},window.worldpayJSCOrigin.load=function(e,n,t,r){e!==void 0&&n!==void 0&&t!==void 0&&n.length===8&&(window.worldpayJSCOrigin.cleanup(),window.worldpayJSCOrigin.register_csp_nonce(document),window.worldpayJSCOrigin.load_tags(e,n,t,r))};const C1=class C1 extends Rr{constructor(n,t){if(C1.instance)return C1.instance;super({channel:Mn.WORLDPAY_JSC,channelConfig:t,options:n}),C1.instance=this}validateChannelConfig(){var r;const{organizationId:n,profilingDomain:t}=((r=this.channelConfig)==null?void 0:r.worldPayJSC)||{};return!!n&&!!t}async collect(){var a,o;const n=this.getRandomId(),{organizationId:t,profilingDomain:r}=((a=this.channelConfig)==null?void 0:a.worldPayJSC)||{};return(o=window.worldpayJSCOrigin)==null||o.load(r,t,n),n}getRandomId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}};Ae(C1,"instance",null);let yo=C1;const $5="eu";let go=null;function e8(e,n,t){return go||(go=new t8(e,t,n)),go}class t8{constructor(n,t=[Kt.SR,Kt.WP,Kt.WJ],r){Ae(this,"options");Ae(this,"clientKey");Ae(this,"collMap",{[Kt.SR]:()=>this.stripeRadarColl(),[Kt.WP]:()=>this.worldpayDDCColl(),[Kt.WJ]:()=>this.worldpayJSCColl()});Ae(this,"p");Ae(this,"realMode",[]);Ae(this,"env");Ae(this,"channelConfig");Ae(this,"channelConfigPromise");Ae(this,"isIIFE",typeof __IS_IIFE__<"u"&&__IS_IIFE__);Et(this,Y1,void 0);const{env:a,clientKey:o}=n;this.realMode=t,this.options=r,this.env=a||$5,this.clientKey=o,Qt(this,Y1,this.isIIFE?"API":r==null?void 0:r.sessionMode),this.isIIFE&&(e1(w2[this.env]),t1(E2[this.env]),co("/session"))}async getFraudDetectionId(n){await this.setChannelSDKConfig(),await Promise.all([this.worldpayDDCColl().init((n==null?void 0:n.bin)||""),this.paykkaDetectionColl().init()]);const t=this.realMode;return this.formatFraudDetectionId({s:t.includes(Kt.SR)?this.stripeRadarColl().getFraudDetectionId():"",w:t.includes(Kt.WP)?this.worldpayDDCColl().getFraudDetectionId():"",wr:t.includes(Kt.WJ)?this.worldpayJSCColl().getFraudDetectionId():"",p:this.paykkaDetectionColl().getFraudDetectionId()})}async createFraudDetection(){await this.setChannelSDKConfig(),this.p||(this.p=Promise.all([...this.realMode.map(async n=>{if(this.collMap[n])return this.collMap[n]();throw new Error(`Unsupported collection mode: ${n}`)}),this.paykkaDetectionColl()])),await this.p}formatFraudDetectionId(n){var t,r;try{const a=JSON.stringify(n);return btoa(a)}catch{return(r=(t=this.options)==null?void 0:t.onEvent)==null||r.call(t,zt.FRAUD_DETECTION_TRANSFORM_ERROR),""}}async setChannelSDKConfig(){if(!this.channelConfig)return this.channelConfigPromise?this.channelConfigPromise:(this.channelConfigPromise=new Promise(async n=>{let t={},r={};try{t=await Je(),r=await p5({channel:[Mn.STRIPE,Mn.WORLDPAY],browser:t})}catch{}const{worldPay:a}=r||{};let o="";try{o=new URL((a==null?void 0:a.ddcCollectUrl)||"").origin}catch{o=""}this.channelConfig={...r,worldPay:{...a,ddcOrigin:o},worldPayJSC:["eu","hk"].includes(this.env)?b5:A5,paykka:{clientKey:this.clientKey,sessionMode:Ne(this,Y1)}},n()}),this.channelConfigPromise)}worldpayDDCColl(){return new Lr(this.options,this.channelConfig)}worldpayJSCColl(){const n=new yo(this.options,this.channelConfig);return n.init(),n}stripeRadarColl(){const n=new Co(this.options,this.channelConfig);return n.init(),n}paykkaDetectionColl(){const n=new ho(this.options,this.channelConfig);return n.init(),n}}Y1=new WeakMap;const Nr=new WeakMap;function M2(e,{time:n=70,argsResolver:t,resultResolver:r}){function a(...s){const c=Date.now();let d=Nr.get(e);d||Nr.set(e,d={items:[],firstInvokeTime:c});const f=kn();return d.items.push({args:s,invokeTime:c,promise:f}),d.items.length===1&&o(),f}function o(){setTimeout(()=>{const s=Nr.get(e);if(!s)return;Nr.delete(e);const c=t(s.items);e(...c).then(d=>{s.items.forEach((f,u)=>{f.promise.resolve(r(d,f,u,s.items))})}).catch(d=>{s.items.forEach(f=>{f.promise.reject(d)})})},n)}return a}function n8(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}}const r8=async e=>Se.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})))??[]}),a8=M2(async(e,n)=>Se.post(`/address/style/${e}`,void 0,n).then(({address_style_list:t})=>t.map(r=>n8(r))),{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}}),o8=M2(async(e,n)=>Se.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}))}),{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}}),i8=async e=>Se.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 s8{constructor(){Et(this,wn,void 0);Ae(this,"countryOptions");Ae(this,"provinceOptions");Ae(this,"cityOptions");Ae(this,"addressState");Ae(this,"i18n");Ae(this,"addressFormat");Ae(this,"validateAllFields",!1);this.addressState={country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0},this.countryOptions=[]}setI18n({i18n:n}){this.i18n=n}async requestCountryOption(){var n,t;if(!(this.countryOptions.length!==0||(n=Ne(this,wn))!=null&&n.isPending))try{Qt(this,wn,kn()),this.countryOptions=await r8({locale:this.i18n.locale}),Ne(this,wn).resolve(!0)}catch{(t=Ne(this,wn))==null||t.resolve(!1)}}async countryOptionReady(){return Ne(this,wn)}getCountryOption(){return this.countryOptions}async requestProvinceOption(n){return this.provinceOptions=await o8(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{[xe.ADDRESS_1]:n=>this.setAddress1(n),[xe.ADDRESS_2]:n=>this.setAddress2(n),[xe.CITY]:n=>this.setCity(n),[xe.AREA]:n=>this.setArea(n),[xe.POST_CODE]:n=>this.setPostCode(n),[xe.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:Rn(t)&&t.length>0?((r=t.find(a=>a.value===n))==null?void 0:r.label)??null:null}}wn=new WeakMap;function _e(e){return A4(`${Ui}-${e}`)}function yt(e){const n=Yn(ze),[t]=O((n==null?void 0:n.i18n)??new vr);return e&&t.load(e),{i18n:t}}function et(e,n){const[t,r]=O(!1),[a,o]=O(""),[s,c]=O(!1),[d,f]=O(null),{i18n:u}=yt();return Ce(()=>{e.ready().then(()=>{var g,w;c(!0);const m=d5(y2||((g=e.checkout)==null?void 0:g.locale)||gn().language);u.load(m);const h=e8({clientKey:e.paykkaDetectionKey,env:so},{sessionMode:(w=e.checkout)==null?void 0:w.sessionMode,onEvent:(P,E)=>{var v,b;(b=n==null?void 0:(v=n.config).onEvent)==null||b.call(v,P,E)}});f(h),h==null||h.createFraudDetection()})},[]),{validated:t,setValidated:r,errorMsg:a,setErrorMsg:o,i18n:u,fraudDetection:d,sessionReady:s}}function Xe(e,{timeout:n=2e4,interval:t=2e3,onTimeout:r,onEnd:a}){const o=$(null);Ce(()=>c,[]);function s(d={}){return new Promise(f=>{d={timeout:n,interval:t,...d};const u=Date.now(),m=async()=>{if(!o.current){c();return}const h=Date.now(),g=await e(N1(h-u,0,d.timeout));o.current&&(g.end?(a==null||a(g.res),f(g)):h-u>d.timeout?r==null||r():o.current=window.setTimeout(m,d.interval))};o.current=window.setTimeout(m,d.interval)})}function c(){o.current&&(clearTimeout(o.current),o.current=null)}return{start:s,stop:c}}const po={xs:480,sm:928,md:992,lg:1200,xl:1366,xxl:1600},T2=()=>{const[e,n]=O(()=>typeof window<"u"?window.innerWidth:0);Ce(()=>{if(typeof window>"u")return;const s=()=>{n(window.innerWidth)};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);const t=Ht(()=>Object.entries(po).sort((s,c)=>s[1]-c[1]),[po]),{matches:r,current:a}=Ht(()=>{const s={xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1};let c=null;for(let d=t.length-1;d>=0;d--){const[f,u]=t[d],m=e>=u;s[f]=m,m&&!c&&(c=f)}return{matches:s,current:c}},[e,t]);return{matches:r,current:a,smaller:s=>{const c=po[s];return c===void 0?!1:e<c}}},k2=()=>{const[e,n]=O("unSubmit"),[t,r]=O("");return{paymentButtonStatus:e,setPaymentButtonStatus:n,errorMsg:t,setErrorMsg:r}};class c8{constructor(n){Et(this,y1,void 0);Et(this,En,{});Qt(this,y1,_e(`theme-${n}`).bem())}init(n){const{payButtonBackgroundColor:t,payButtonTextColor:r}=n||{};if(Qt(this,En,{...Ne(this,En),"--paykka-button-font-color":r}),t){const o=F4(t);Qt(this,En,{...Ne(this,En),"--paykka-button-bg-color":o[5],"--paykka-button-bg-color-hover":o[4],"--paykka-button-bg-color-active":o[6]})}const a=n5(Ne(this,En));Ja(`.${Ne(this,y1)}{${a}}`)}get className(){return Ne(this,y1)}}y1=new WeakMap,En=new WeakMap;const d8="m",l8={enableInitValidation:!0,apiPrefix:"/session",addressMode:"address"};class u8{constructor(n){Et(this,fa);Et(this,g1,void 0);Et(this,Mt,void 0);Et(this,ua,void 0);Et(this,rn,void 0);Et(this,p1,void 0);Et(this,ma,[]);Et(this,v1,void 0);Et(this,Bn,void 0);Ae(this,"processingPaymentMethod",null);Ae(this,"enablePaymentMethod",k1(null));Qt(this,g1,t2(6)),Qt(this,Mt,n),this.init()}async init(){return Ne(this,Bn)?Ne(this,Bn):(Qt(this,Bn,ga(this,fa,Bd).call(this)),Ne(this,Bn))}initCheckoutConfig(){Ne(this,Mt)._checkoutConfig=L1(l8,Ne(this,Mt)._checkoutConfig||{}),co(Ne(this,Mt)._checkoutConfig.apiPrefix)}async initSession(){var f,u;const{sessionId:n,clientKey:t,onPaymentMethodsReady:r,onInitError:a,onSuccess:o,_checkoutConfig:s={}}=Ne(this,Mt),{enableInitValidation:c}=s;if(c&&!n){a==null||a(new Ee("ERROR","SessionId is required"));return}const d=(u=(f=Ne(this,Mt))._getExtraParams)==null?void 0:u.call(f,"info");return Qt(this,rn,new A2({sessionId:n,clientKey:t},d)),Ne(this,rn).ready().then(()=>{var g,w;if(Cl((g=Ne(this,rn))==null?void 0:g.checkout)){a==null||a(new Ee("ERROR","Checkout is empty"));return}const{supportMethods:m=[],status:h}=((w=Ne(this,rn))==null?void 0:w.checkout)||{};if(h==="SUCCESS"){o==null||o({});return}r==null||r(m)}).catch(m=>{a==null||a(m)})}initEnv(){const{env:n,_envConfig:t,onInitError:r}=Ne(this,Mt);if(!n){r==null||r(new Ee("ERROR","Env is required"));return}e1((t==null?void 0:t.api)||w2[n]),t1((t==null?void 0:t.cdn)||E2[n]),g2((t==null?void 0:t.fraudDetection)||n||so)}initLocale(){const{locale:n}=Ne(this,Mt);n&&p2(n)}initTheme(){var n;Qt(this,p1,new c8(Ne(this,g1))),Ne(this,p1).init((n=Ne(this,rn).checkout)==null?void 0:n.theme)}initOtherData(){const n=W4(d8);n&&(this.processingPaymentMethod=n)}get session(){return Ne(this,rn)}get theme(){return Ne(this,p1)}get envConfig(){return Ne(this,ua)}get config(){return Ne(this,Mt)}get id(){return Ne(this,g1)}create(n,t){var m;const{onSubmit:r,onSuccess:a,onError:o,onTimeout:s,onExpired:c}=Ne(this,Mt),d=this.getCoreProps(),f={onSubmit:r,onSuccess:a,onError:o,onTimeout:s,onExpired:c,...d,...t},u=xn(n,{...f,onError:h=>{var g,w,P;(g=f.onError)==null||g.call(f,h),(P=(w=this.config).onEvent)==null||P.call(w,ka.PAYMENT_FAILURE,{message:h.message,code:h.code})}});return(m=Ne(this,ma))==null||m.push(u),u}getCoreProps(){return{session:Ne(this,rn),core:this,threeDSFrame:Ne(this,Mt).threeDSFrame,hidePaymentButton:Ne(this,Mt).hidePaymentButton}}resetEnablePaymentMethod(){this.enablePaymentMethod.value=null}getAddressCore(){return Ne(this,v1)||Qt(this,v1,new s8),Ne(this,v1)}}g1=new WeakMap,Mt=new WeakMap,ua=new WeakMap,rn=new WeakMap,p1=new WeakMap,ma=new WeakMap,v1=new WeakMap,Bn=new WeakMap,fa=new WeakSet,Bd=async function(){this.initCheckoutConfig(),this.initEnv(),this.initLocale(),await this.initSession(),this.initTheme(),this.initOtherData()};const V2=async(e,n,t,{timeout:r=2e4,headers:a,locale:o}={})=>{const s=new AbortController,c=setTimeout(()=>{s.abort()},r);try{const d=ml(),f=e==="post",u=await d(`${io}/bk${n}`,{method:e,mode:"cors",cache:"default",credentials:"same-origin",headers:{Accept:"application/json, text/plain, */*","Content-Type":f?"application/json":"text/plain","Accept-Language":o??gn().language,...C2,...a},redirect:"follow",referrerPolicy:"no-referrer-when-downgrade",body:f&&t?a5(t):void 0,signal:s.signal});clearTimeout(c);const m=String(u.status);let h;try{h=await u.json()}catch{h={i18nKey:"common.netError"}}if(m==="500")throw{code:m,...h.ret_msg?{message:h.ret_msg}:{i18nKey:"common.unknownError"}};if(/^(429|5\d{2})$/.test(m))throw{code:m,i18nKey:"common.netError"};if(h.ret_code!=="000000")throw{code:h.ret_code,message:h.ret_msg};return h.data}catch(d){throw d.name==="AbortError"?new Ee(n1.TIMEOUT):d.code?d:{i18nKey:"common.unknownError"}}},Se={get:(e,n,t)=>V2("get",e,n,t),post:(e,n,t)=>V2("post",e,n,t)},We=e=>e instanceof Ee&&e.type===n1.TIMEOUT,st=(e,n={})=>{const{bill:t,payment:r,customer:a}=e;return{...L1({bill:{first_name:t==null?void 0:t.firstName,middle_name:t==null?void 0:t.middleName,last_name:t==null?void 0:t.lastName,email:t==null?void 0:t.email,country:t==null?void 0:t.country,state:t==null?void 0:t.state,city:t==null?void 0:t.city,postal_code:t==null?void 0:t.postalCode,address_line1:t==null?void 0:t.addressLine1,address_line2:t==null?void 0:t.addressLine2,district:t==null?void 0:t.district,area_code:t==null?void 0:t.areaCode,phone_number:t==null?void 0:t.phoneNumber}},n||{}),session_id:e.sessionId,client_key:e.clientKey,channel_user_id:e.channelUserId,payment:{payment_method:r.paymentMethod,store_payment_method:r.storePaymentMethod,token_data:r.tokenData,iban:r.iban,token:r.token,card_no:r.cardNo,exp_year:r.expYear,exp_month:r.expMonth,cvv:r.cvv,holder_name:r.holderName},customer:{document:a==null?void 0:a.document},browser:e.browser}},ct=(e,n={})=>{const{sessionId:t,clientKey:r,paymentMethod:a,browser:o}=e;return{...n,session_id:t,client_key:r,payment_method:a,browser:o}},$t=e=>({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}),Me=e=>{var t;const n=e.pay_info||{};return{sessionId:e.session_id,merchantId:e.merchant_id,errorCode:e.error_code,errorMessage:e.error_description,orderId:e.order_id,transAmount:$t(e.trans_amount),status:e.status,orderStatus:e.order_status,paymentMethod:e.payment_method,finishTime:e.utc_finish_time,payInfo:{threeDSUrl:(t=e.authentication_result)==null?void 0:t.authentication_url,targetUrl:n.payment_url||n.request_url,requestMethod:n.request_method,paymentExpiredAt:e==null?void 0:e.payment_expire_time,...n},rawResponse:e}},m8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},f8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},D2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},x2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)};class h8{constructor(){Ae(this,"cache",new Map)}cacheRequest(n,t){const r=this.cache.get(n);if(r)return r;const o=t.catch(s=>{throw this.cache.delete(n),s});return this.cache.set(n,o),o}}const O2=(e=[])=>{const n=[],t={};return e.forEach(({value:r,configuration:a={}})=>{r===G.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===G.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===G.WECHAT_PAY?t.wechatPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:$t(a==null?void 0:a.fee),totalAmount:$t(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}:r===G.ALI_PAY&&(t.aliPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:$t(a==null?void 0:a.fee),totalAmount:$t(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}),r===G.BANKCARD?n.push(...a.allowed_card_networks||[]):n.push(r)}),{supportMethods:n,channelParams:t}},C8=(e={})=>({goodsTax:$t(e.goods_tax),shippingAmount:$t(e.shipping_amount),shippingTax:$t(e.shipping_tax),discount:$t(e.discount),other:$t(e.other)}),y8=(e={})=>{var f,u;const{theme:n,field:t,support_methods:r={}}=e,{payment_methods:a,bill:o,tokens:s}=r,c=O2(a),d=e.session_mode==="HOST"?"HOSTED":e.session_mode;return{country:e.country,merchantId:e.merchant_id,sessionId:e.session_id,clientKey:e.client_key,status:e.status,transAmount:$t(e.trans_amount),expireTime:e.expire_time,paymentMethod:e.payment_method,sessionMode:d||"HOSTED",merchantName:(f=e.theme)==null?void 0:f.merchant_name,returnUrl:e.return_url,cancelUrl:e.cancel_url,locale:e.locale,paymentType:e.payment_type||"PURCHASE",orderId:e.order_id,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:o==null?void 0:o.billing_address_collection,addressLine1:o==null?void 0:o.address_line1,addressLine2:o==null?void 0:o.address_line2,email:o==null?void 0:o.email,descriptor:o==null?void 0:o.descriptor,country:o==null?void 0:o.country},tokens:s==null?void 0:s.map(m=>({token:m.token,last4:m.last4,cardBrand:m.card_brand,billingAddressFilled:m.billing_address_filled})),storePaymentMethod:(u=e.payment)==null?void 0:u.store_payment_method,field:{holderName:{show:!!(t!=null&&t.holder_name_display),required:!!(t!=null&&t.holder_name_required)},email:{show:!!(t!=null&&t.bill_email_display),required:!!(t!=null&&t.bill_email_required),disabled:!!(t!=null&&t.bill_email_disabled)},address:{show:!!(t!=null&&t.bill_address_display),required:!!(t!=null&&t.bill_address_required)}},amountBreakdown:C8(e.amount_breakdown),finishTime:e.utc_finish_time,...c,rawResponse:e}},g8=async(e,n={},t)=>Se.post(`${Re}/info`,{session_id:e.sessionId,client_key:e.clientKey,...n,browser:await Je()},t),p8=async(e,n={},t)=>{const r=await g8(e,n,t);return y8(r)},v8=new h8,b8=async(e,n={},t)=>{const r=p8(e,n,t);return v8.cacheRequest(JSON.stringify(e),r)},A8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},w8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},E8=async e=>Se.post(`${Re}/apple-pay/create-session`,e),P8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},S8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},I8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},F2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},_8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},R8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},L8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},N8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},M8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},T8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},k8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},V8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},D8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},x8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},O8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},F8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},B8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},H8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},U8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Z8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},G8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Y8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},j8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},q8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},B2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},H2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},U2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},W8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},Z2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Q8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},K8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},z8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},J8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},X8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},vo=_e("form-item"),mn=vo.bem("label"),G2=vo.bem("error-text"),Mr=X1(null),Y2=X1(null);function j2(e,n){return n?(Rn(e.trigger)?e.trigger:[e.trigger]).includes(n):!0}function $8(e,n){if(!e)return;if(Rn(e))return e.filter(r=>j2(r,n));const t=r5(e,j2(e,n));return t?[t]:[]}function q2(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 $s(n,r,t.fields[r]),n},{})}const eu=e=>Dt(e)||e==="",At=Fe((e,n)=>{const{label:t,path:r,children:a,triggersOfEmptyValue:o=["submit"],onValidationStatusChange:s,className:c,style:d,showErrorMessage:f=!0,showLabel:u=!0}=e;Be(n,()=>({validate:E,validateChange:N,getValidateResult:w,resetValidation:v}));const m=Yn(Y2),[h,g]=O({status:"unValidate",errors:[],fields:{}});function w(){return h}function P(A){g(A),A.status!==h.status&&(s==null||s(A.status))}async function E(A,{trigger:R,setResult:y=!0}){return eu(A)&&!o.includes(R)?v():new Promise(async _=>{const V=$8(e.rule,R);if(!r||!(V!=null&&V.length)){_(h);return}const k=[],p={};for(const K of V){const{validator:ie}=K;if(ie)try{await ie(A)||(k.push({message:void 0,fieldValue:A,field:r}),p[r]=k)}catch(q){k.push({message:q.message,fieldValue:A,field:r}),p[r]=k}}let x={status:"unValidate",errors:k,fields:p};k.length?(x.status="error",y&&P(x)):y?x=v("success"):x.status="success",_(x)})}function v(A="unValidate",R=[]){const y={status:A,errors:A==="error"?R:[],fields:{}};return P(y),y}async function b(A){return await E(A,{trigger:"blur"})}async function N(A){return await E(A,{trigger:"change"})}function S(A){r&&(m==null||m.setForm(R=>(R={...R},$s(R,r,A),R)))}function T(){var A;return(A=h.errors)==null?void 0:A[0]}return Ce(()=>{const A={internalValidate:E,path:r,resetValidation:v};return r&&(m==null||m.setFormItems(R=>[...R,A])),()=>{r&&(m==null||m.setFormItems(R=>R.filter(y=>y!==A)))}},[]),i("div",{className:ye(ge,vo.bem(),c),style:d,children:[u&&!Dt(t)&&i("div",{className:mn,children:t}),i(Mr.Provider,{value:{rule:e.rule,validateBlur:b,validateChange:N,resetValidation:v,validationResult:h,setValue:S},children:a}),f&&h.status==="error"&&i("div",{className:G2,children:T().message})]})}),dt=Fe((e,n)=>{const{children:t}=e;Be(n,()=>({validate:d,resetValidation:u,validateField:f}));const[r,a]=O(e.form),[o,s]=O([]);function c(m,h){if(!La(m)||!Ln(h))return;const g=h.split(".");return g.length===0?m[h]:g.reduce((w,P)=>w&&w[P],m)}async function d(m,h=!0){const g=await Promise.all(o.map(P=>{const E=c(r,P.path);return P.internalValidate(E,{trigger:"submit",setResult:h})})),w=q2(g);if(w)throw m&&(m==null||m(w)),w;m&&(m==null||m())}async function f(m,h,g=!0){const w=o.filter(v=>m.includes(v.path)),P=await Promise.all(w.map(v=>{const b=c(r,v.path);return v.internalValidate(b,{trigger:"submit",setResult:g})})),E=q2(P);if(E)throw h&&(h==null||h(E)),E;h&&(h==null||h())}function u(){o.forEach(m=>{var h;(h=m.resetValidation)==null||h.call(m)})}return Ce(()=>{var m;(m=e.onFormChange)==null||m.call(e,r)},[r]),i(Y2.Provider,{value:{form:r,setForm:a,formItems:o,setFormItems:s},children:t})}),Fn=_e("input"),vn=Fn.bem("input-wrapper"),tu={error:Zi,success:El},_t=Fe((e,n)=>{const{inputClassName:t,style:r,disabled:a,children:o,showStatus:s=!0}=e;Be(n,()=>({input:m.current,focus:()=>{f(!0)},blur:()=>{f(!1)},valid:()=>{c==null||c.resetValidation("success")},invalid:S=>{c==null||c.resetValidation("error",[{message:S}])}}));const c=Yn(Mr),[d,f]=O(!1);let u=!1;const m=$(null);let h=e.status??(c==null?void 0:c.validationResult.status);h==="unValidate"&&(h=void 0);let{rightIcon:g}=e;if(s&&h){const S=tu[h];g=i(S,{size:16})}function w(S){var T;f(!0),(T=e.onFocus)==null||T.call(e,S)}function P(S){var A;f(!1),(A=e.onBlur)==null||A.call(e,S);const{value:T}=S.currentTarget;c==null||c.validateBlur(T)}function E(S){var A;if(S instanceof InputEvent&&!S.isComposing&&(u=!1),u||S instanceof InputEvent&&S.inputType==="insertCompositionText")return;(A=e.onInput)==null||A.call(e,S);const{value:T}=S.target;c==null||c.setValue(T),c==null||c.validateChange(T)}const v=m2(()=>{const S=Fn.bem("input-wrapper",[h,{focus:d}]),T=Fn.bem("input-wrapper-disabled");return a?`${S} ${T}`:`${S}`});function b(S){var T;u=!0,(T=e.onCompositionStart)==null||T.call(e,S)}function N(S){u=!1,E(S)}return i("div",{className:ye(ge,Fn.bem(),t),onClick:()=>{var S;return(S=m.current)==null?void 0:S.focus()},children:i("div",{className:`${v}`,style:r,children:[!!e.leftIcon&&i("div",{class:Fn.bem("left-icon"),children:e.leftIcon}),o||i("input",{ref:m,...e,class:Fn.bem("input"),onFocus:w,onBlur:P,onInput:E,onCompositionStart:b,onCompositionEnd:N,autocomplete:"off"}),!!g&&i("div",{class:Fn.bem("right-icon"),children:g})]})})}),{bem:nu}=_e("select"),ru=e=>{const{style:n,children:t,...r}=e;return i("div",{style:n,class:nu("menu"),onMouseDown:a=>a.preventDefault(),...r,children:t})},{bem:W2}=_e("select");function au(e){const{onSelect:n,...t}=e,{label:r}=t;function a(o){o.preventDefault(),o.stopPropagation(),n==null||n({...t})}return i("div",{onClick:o=>a(o),class:W2("menu-item",[{selected:e.selected}]),children:[Hi(r)?r(e,e.selected):r,e.selected&&i("div",{class:W2("menu-item-icon"),children:Il({})})]})}const{bem:bo}=_e("select"),Tr=Fe((e,n)=>{const t=Yn(Mr);let r=e.status??(t==null?void 0:t.validationResult.status);r==="unValidate"&&(r=void 0);const[a,o]=O(!1),[s,c]=O(!1),[d,f]=O([]),[u,m]=O(),[h,g]=O(),[w,P]=O(),E=$(null),[v,b]=O(!1),[N,S]=O(!1);Ce(()=>{if(!N&&(f(e.options??[]),!Dt(e.value)&&e.options.length>0)){const J=T(e.value,e.options);J&&V(J,!1)}},[e.value,e.options]),Ce(()=>{if(e.renderLabel)return;const J=Dt(w)||w==="";if(S(!J),J)f(e.options);else{const se=e.options.filter(z=>z.label.toLowerCase().includes(w.toLowerCase()));f(se)}},[w]),Be(n,()=>({blur:()=>{var J,se;b(!1),c(!1),(se=(J=E.current)==null?void 0:J.input)==null||se.blur()}}));function T(J,se){for(let z=0;z<se.length;z++){const X=se[z];if(X.value===J)return X}}function A(J){var se;b(!0),o(!0),(se=e.onFocus)==null||se.call(e,J)}function R(){var J,se;(se=(J=E.current)==null?void 0:J.input)==null||se.focus()}function y(J){var se;o(!1),(se=e.onBlur)==null||se.call(e,J),P(""),c(!1),t==null||t.validateBlur(Dt(h)?"":String(h))}function _(J){c(!0),P(J.currentTarget.value)}function V(J,se=!0){var Q,Y,ee,re;const{value:z,label:X}=J;P(""),g(z),m(((Q=e.renderLabel)==null?void 0:Q.call(e,J))||X),b(!1),c(!1),(ee=(Y=E.current)==null?void 0:Y.input)==null||ee.blur(),se&&((re=e==null?void 0:e.onSelect)==null||re.call(e,z,J))}function k(J){c(!0),P(J.currentTarget.value)}let p,x;const K=qe(J=>{p=J},[]),ie=qe(J=>{x=J,q(x,p)},[]);Ce(()=>(document.addEventListener("mousedown",K),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("mouseup",ie)}),[]);function q(J,se){var ee,re;if(!ne.current)return;const z=J==null?void 0:J.target,X=se==null?void 0:se.target,Q=((ee=ne.current)==null?void 0:ee.contains(z))||((re=ne.current)==null?void 0:re.contains(X)),Y=ne.current===z;Q||Y||b(!1)}const ne=$(null),W=Sl({style:{transform:v?"rotate(-180deg)":"rotate(0deg)",transition:"transform 0.3s ease"}});return i("div",{class:bo("wrapper"),ref:ne,onClick:()=>{var J,se;return(se=(J=E.current)==null?void 0:J.input)==null?void 0:se.focus()},children:[i(Mr.Provider,{value:null,children:i(_t,{ref:E,value:w,status:r,readOnly:!e.filterable,onInput:_,onFocus:A,onBlur:y,onChange:k,onCompositionStart:()=>c(!0),placeholder:a||s||!Dt(h)?"":e.placeholder,rightIcon:e.rightIcon||W,inputClassName:e.inputClassName})}),i("div",{class:bo("render-label",[{placeholder:a,hidden:s}]),onClick:R,children:u}),i(ru,{style:{display:v?"block":"none"},children:[N&&d.length===0?i("div",{class:bo("menu-no-data"),children:e.noDataTip}):d.map(J=>i(au,{onSelect:V,selected:h===J.value,...J,label:e.renderLabel?()=>{var se;return(se=e.renderLabel)==null?void 0:se.call(e,J)}:J.label},J.value)),e.action]})]})}),{bem:Ao}=_e("address-field"),Q2={country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0},ht=Fe((e,n)=>{const{onAddressChange:t}=e,{i18n:r}=yt(),a=Yn(ze);if(!(a!=null&&a.core))throw new Error("CoreContext is not found");const o=a.core.getAddressCore(),[s,c]=O({...o.getAddressState()}),[d,f]=O(o.getCountryOption()??[]),[u,m]=O(o.getProvinceOption()??[]),[h,g]=O([]),[w,P]=O(o.getAddressFormat()),E=$(null),v=$(null),b=$(null),N=$(null),S=$(null),T=$(null),A=$(null);Ht(()=>{r.ready.value&&(o.setI18n({i18n:r}),o.requestCountryOption(),o.countryOptionReady().then(()=>{p(),f(o.getCountryOption())}))},[r.ready.value]);const R={[xe.ADDRESS_1]:l=>{c(Object.assign(s,{address1:l}))},[xe.ADDRESS_2]:l=>{c(Object.assign(s,{address2:l}))},[xe.CITY]:l=>{c(Object.assign(s,{city:l}))},[xe.AREA]:l=>{c(Object.assign(s,{area:l}))},[xe.POST_CODE]:l=>{c(Object.assign(s,{postCode:l}))},[xe.PROVINCE]:l=>{c(Object.assign(s,{province:l}))},COUNTRY:l=>{c(Object.assign(s,{country:l}))}};function y(l,C){R[l](C)}function _(l,C){y(l,C),o.setAddressStateByKey(l,C)}function V(l){P(l),o.setAddressFormat(l)}Be(n,()=>({update:l=>{c(l),o.setAddressState(l),V(o.getAddressFormat()),m(o.getProvinceOption()??[]),g(o.getCityOptions()??[])}}));function k(l){l.map(C=>{y(C,""),o.setAddressStateByKey(C,"")})}async function p(){const C=navigator.language.split("-"),I=s.country||((C==null?void 0:C[1])??"US");ie(I||""),t({...s})}const x={[xe.ADDRESS_1]:X,[xe.ADDRESS_2]:Q,[xe.CITY]:re,[xe.AREA]:ee,[xe.POST_CODE]:Y,[xe.PROVINCE]:ae};function K(){return{trigger:["blur","submit"],validator(l){if(!l)throw new Error;return!0}}}async function ie(l){var pe,U;if(V([]),_("COUNTRY",l),((U=(pe=a==null?void 0:a.core)==null?void 0:pe.config._checkoutConfig)==null?void 0:U.addressMode)==="country"){t({...Q2,country:l});return}const I=await a8(l,{locale:r.locale}),j=[],we=I.map(({addressItem:Z,required:B,description:M})=>(j.push(Z),{addressItem:Z,required:B,description:M}));q(j,l),V(we),k([xe.PROVINCE,xe.CITY,xe.AREA,xe.POST_CODE,xe.ADDRESS_1,xe.ADDRESS_2]),g([]),o.setCityOptions([]),t({...Q2,country:l})}async function q(l,C){if(l.includes(xe.PROVINCE)){ne(C);return}if(!l.includes(xe.PROVINCE)&&l.includes(xe.CITY)){J(C);return}}async function ne(l){o.requestProvinceOption(l).then(C=>{m(C)})}async function W(l){var C;_(xe.PROVINCE,l),J(l),k([xe.CITY]),(C=b.current)==null||C.validateChange(""),t({...s,province:l,city:""})}async function J(l){const C=await i8(l);if(C)return g(C),o.setCityOptions(C),C}function se(l){_(xe.CITY,l),t({...s,city:l})}function z(){var C,I;const l=(I=(C=a==null?void 0:a.core)==null?void 0:C.config._checkoutConfig)==null?void 0:I.addressMode;return i(At,{ref:E,label:r.get("address.label"),path:"address.country",rule:K(),showErrorMessage:!1,children:i(Tr,{value:s.country,filterable:!0,options:d,onSelect:j=>ie(j),placeholder:r.get("address.country"),inputClassName:Ao("first-item",{"no-bottom-radius":l==="address"}),noDataTip:r.get("common.noData")})})}function X({description:l,className:C}){return i(At,{ref:T,path:"address.address1",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.address1,onInput:I=>_(xe.ADDRESS_1,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.address1")}function Q({description:l,className:C}){return i(At,{ref:A,path:"address.address2",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.address2,onInput:I=>_(xe.ADDRESS_2,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.address2")}function Y({description:l,className:C}){return i(At,{ref:S,path:"address.postCode",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.postCode,onInput:I=>_(xe.POST_CODE,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.postCode")}function ee({description:l,className:C}){return i(At,{ref:N,path:"address.area",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.area,onInput:I=>_(xe.AREA,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.area")}function re({description:l,className:C}){return i(At,{ref:b,path:"address.city",rule:K(),showErrorMessage:!1,children:Rn(h)&&h.length>0?i(Tr,{value:s.city,filterable:!0,options:h,onSelect:I=>se(I),placeholder:l,inputClassName:C,noDataTip:r.get("common.noData")}):i(_t,{value:s.city,onInput:I=>_(xe.CITY,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.city")}function ae({description:l,className:C}){return i(At,{ref:v,path:"address.province",rule:K(),showErrorMessage:!1,children:Rn(u)&&u.length>0?i(Tr,{value:s.province,filterable:!0,options:u,onSelect:I=>W(I),placeholder:l,inputClassName:C,noDataTip:r.get("common.noData")}):i(_t,{value:s.province,onInput:I=>_(xe.PROVINCE,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.province")}function me(l){const C=w==null?void 0:w.length;return Dt(C)||C===1?"":l===C-1?Ao("last-item"):Ao("mid-item")}return i("div",{style:"width: 100%",children:[z(),w==null?void 0:w.map((l,C)=>x[l.addressItem]({description:l.description,className:me(C)}))]})});class ou{constructor(n){Ae(this,"_email");Ae(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 wo;const lt=e=>wo||(wo=new ou(e)),Ct=Fe((e,n)=>{const{className:t,style:r,disabled:a}=e,{i18n:o}=yt(),[s,c]=O(""),d=$(null),f=lt(e.value??"");Be(n,()=>({update:g=>{var w;u(g),(f.isValid||yl(g))&&((w=d.current)==null||w.validate(g,{trigger:"submit",setResult:!0}))}})),Ce(()=>{u(e.value)},[e.value]);const u=g=>{f.email=g??"",c(g??"")},m={trigger:["blur","submit"],validator(g){if(!g)throw new Error(o.get("common.email.incomplete"));if(!new RegExp(t5).test(g))throw new Error(o.get("common.email.incorrect"));return!0}},h=g=>{var P;const{currentTarget:w}=g;u(w.value),(P=e.onInput)==null||P.call(e,g)};return i(At,{ref:d,label:o.get("common.email.label"),path:"email",rule:m,className:t,style:r,children:i(_t,{value:s,disabled:a,maxLength:100,onInput:h})})}),{bem:Eo}=_e("info"),iu={error:Zi};function nt(e){const{type:n="error",content:t,className:r,style:a}=e,o=iu[n];return i("div",{className:ye(ge,Eo([n]),r),style:a,children:[i("div",{className:Eo("icon"),children:i(o,{size:16})}),i("div",{className:Eo("content"),children:t})]})}const{bem:Po}=_e("recurring-tip");function So(){return i(ze.Consumer,{children:e=>{var n;return i("div",{className:Po(),children:[i("div",{className:Po("icon"),children:Gi({size:16})}),i("div",{className:Po("text"),children:(n=e==null?void 0:e.i18n)==null?void 0:n.get("common.recurringTip")})]})}})}const{bem:K2}=_e("button");function Io(e){const{style:n,className:t,children:r,icon:a,loading:o,disabled:s,dashed:c}=e;function d(f){var u;o||s||(u=e.onClick)==null||u.call(e,f)}return i("button",{className:ye(ge,K2({loading:o,disabled:s,dashed:c}),t),style:n,onClick:d,children:[!!a&&i("div",{className:K2("icon"),children:a}),r]})}const _o=40,su=`0 0 ${_o} ${_o}`,z2=3.3,J2=_o/2-z2-.5,X2=2*Math.PI*J2,cu=3.2,{bem:Ro}=_e("loading-check");function du({color:e="currentColor",checkedColor:n="currentColor",checked:t=!1,size:r,className:a,style:o,onCheckShow:s}){const[c,d]=O(75),[f,u]=O(!1),[m,h]=O(!1),g=Ie(r)?"1em":`${r}px`,P={strokeDasharray:`${X2*(c/100)} ${X2}`,animationPlayState:f?"running":"paused"};t?(d(100),u(!1)):(h(!0),u(!0),d(75));function E(){h(!1),s==null||s()}return i("div",{className:ye(ge,Ro(),a),style:B4({width:g,height:g},o),children:i("svg",{width:g,height:g,viewBox:su,children:[m&&i("circle",{className:Ro("circle",["loading"]),cx:"50%",cy:"50%",r:J2,fill:"none",stroke:e,"stroke-width":z2,"stroke-linecap":"round",style:P}),t&&i("polyline",{className:Ro("check"),points:"8.5,20 18.2,29.5 31.5,10.5",fill:"none",stroke:n,"stroke-width":cu,"stroke-linecap":"round","stroke-linejoin":"miter",onAnimationStart:E})]})})}const{bem:$2}=_e("submit-button"),ut=e=>{const{text:n,loadingText:t,successText:r,status:a="unSubmit",onClick:o,className:s,style:c,icon:d=wl}=e,[f,u]=O(n),{i18n:m}=yt(),h=()=>a==="unSubmit"?i(d,{size:20,disabled:!e.verified}):i(du,{checked:a==="success",size:20,onCheckShow:()=>u(r||m.get("common.paySuccess"))});return Ce(()=>{if(a==="success")return;const g=a==="loading"?t||m.get("common.payProcessing"):n||m.get("common.pay");u(g)},[a,n]),i(Io,{icon:h(),onClick:o,className:ye($2({success:a==="success"}),s),style:c,loading:a==="loading",disabled:e.disabled||a==="success",children:i("span",{class:$2("text",{"not-verified":!e.verified}),children:f})})},{bem:x1}=_e("ali-pay"),ec=x1("field"),lu=Fe((e,n)=>{const{session:t,core:r,showEmail:a=!1,showAddress:o=!1}=e,s=r.getAddressCore(),c=lt(),{setErrorMsg:d,fraudDetection:f,i18n:u,errorMsg:m,sessionReady:h}=et(t,e.core),[g,w]=O("unSubmit"),P=$(null),[E,v]=O({email:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[b,N]=O(!1),[S,T]=O(),A=$(null),R=$(null),[y,_]=O(!1);Be(n,()=>({stopRetry:()=>{ie(),w("unSubmit")},startRetry:Q=>{w("loading"),K({timeout:Q})},updateAddress:()=>{var Y;if(!(S!=null&&S.address.show))return;const Q=Object.assign(E,{address:s.getAddressState()});v(Q),(Y=A.current)==null||Y.update(s.getAddressState()),V()},updateEmail:()=>{var Y;if(!(S!=null&&S.email.show))return;const Q=Object.assign(E,{email:c.email});v(Q),(Y=R.current)==null||Y.update(c.email),V()}}));function V(){var Q;(Q=P.current)==null||Q.validate(void 0,!1).then(()=>{N(!0)}).catch(()=>{N(!1)})}const k=()=>{const{field:Q,sessionMode:Y}=t.checkout,{email:ee,address:re}=Q;Y===Ue.COMPONENT&&(ee.disabled&&(ee.show=a),o&&!(re!=null&&re.show)&&(re.show=!0)),T({...Q})};Ce(()=>{V()},[E]);const p=Q=>{var Y,ee;w("success"),(ee=e.onSuccess)==null||ee.call(e,ft({...Q,returnUrl:(Y=t==null?void 0:t.checkout)==null?void 0:Y.returnUrl}))};Ce(()=>{if(!h)return;const{bill:Q={},supportMethods:Y=[],country:ee}=(t==null?void 0:t.checkout)||{};Y.includes(G.ALI_PAY)&&(k(),_(!0),ee&&s.setCountry(ee),E.email=Q.email??"",E.address.country=ee)},[h]);const x=qe(Q=>{var Y;d(Q||u.get("common.payTimeout")),w("unSubmit"),(Y=e.onTimeout)==null||Y.call(e,"retry")},[u,e.onTimeout]),{start:K,stop:ie}=Xe(Q=>ne(!0,Q),{onTimeout:()=>x(u.get("common.queryTimeout"))}),q=async()=>({sessionId:t.sessionId,clientKey:t.clientKey,bill:S!=null&&S.address.show?{email:E.email,addressLine1:E.address.address1,addressLine2:E.address.address2,postalCode:E.address.postCode,country:E.address.country,district:E.address.area,state:E.address.province?s.getLabel(E.address.province,s.getProvinceOption())??E.address.province:void 0,city:E.address.city?s.getLabel(E.address.city,s.getCityOptions())??E.address.city:void 0}:{email:E.email},payment:{paymentMethod:G.ALI_PAY},browser:await Je({fraudDetectionId:await(f==null?void 0:f.getFraudDetectionId())})});async function ne(Q=!1,Y){var ee,re,ae,me,l,C,I,j,we;try{const pe={locale:u.locale,timeout:Y};let U=null;if(Q){const D=(re=(ee=r.config)._getExtraParams)==null?void 0:re.call(ee,"query",G.ALI_PAY);U=await f8({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.ALI_PAY},D,pe)}else{const D=(me=(ae=r.config)._getExtraParams)==null?void 0:me.call(ae,"payment",G.ALI_PAY);U=await m8(await q(),D,pe)}const{status:Z,orderStatus:B,errorMessage:M,errorCode:F,sessionId:L}=U;if(L&&(t.sessionId=L),!Q&&((l=e.onSubmitResponse)==null||l.call(e,U)),Z==="PROCESSING")if(B){if(B==="SUCCESS")return p(U),{end:!0};if(B==="FAILURE")return M&&d(M),w("unSubmit"),(C=e.onError)==null||C.call(e,new Ee("API_ERROR",M,{code:F})),{end:!0};if(B==="PROCESSING")return!Q&&K(),{end:!1};if(B==="CANCELED")return w("unSubmit"),(I=e.onTimeout)==null||I.call(e,"channel"),{end:!0}}else return w("unSubmit"),{end:!0};else{if(Z==="SUCCESS")return p(U),{end:!0};if(Z==="EXPIRED")return w("unSubmit"),(j=e.onExpired)==null||j.call(e),{end:!0}}return w("unSubmit"),{end:!0}}catch(pe){if(We(pe))return Q?{end:!1}:(x(),{end:!0});{const U=pe.i18nKey?u.get(pe.i18nKey):pe.message;return U&&d(U),(we=e.onError)==null||we.call(e,new Ee("API_ERROR",U,{code:pe.code,cause:pe})),w("unSubmit"),{end:!0}}}}async function W(){var Q;d(""),(Q=P.current)==null||Q.validate(async Y=>{var ee;if(S!=null&&S.address.show&&s.setValidateAllFields(!0),(ee=e.onSubmit)==null||ee.call(e,Y),Y){w("unSubmit");return}d(""),w("loading"),await ne()})}const J=()=>{const{transAmount:Q,channelParams:Y={}}=(t==null?void 0:t.checkout)??{},{totalAmount:ee}=Y.aliPay??{},re=(ee!=null&&ee.amount?ee:Q)||{},ae=re!=null&&re.amount?it(re).jointSymbol():"",me=u.get("common.pay")+(ae?` ${ae}`:"");return i(ut,{className:x1("button"),status:g,text:me,loadingText:u.get("common.payProcessing"),successText:u.get("common.paySuccess"),onClick:W,verified:b})},se=Q=>{P.current=Q,Q&&V()},z=()=>i(he,{children:(S==null?void 0:S.email.show)&&i("div",{className:ec,children:i(Ct,{ref:R,value:E.email,disabled:S==null?void 0:S.email.disabled})})}),X=()=>{var Q,Y;return i(he,{children:(S==null?void 0:S.address.show)&&i("div",{className:ec,children:i(ht,{ref:A,value:E.address,country:((Q=t==null?void 0:t.checkout)==null?void 0:Q.country)||((Y=t==null?void 0:t.checkout)==null?void 0:Y.bill.country),onAddressChange:ee=>v(Object.assign(E,{address:ee}))})})})};return i(ze.Provider,{value:{i18n:u,session:t,core:r},children:y&&u.ready.value&&i("div",{className:r.theme.className,children:i(dt,{form:E,ref:se,onFormChange:Q=>v(Q),children:i("div",{className:ye(ge,x1()),children:[z(),X(),(t==null?void 0:t.checkout.paymentType)===Nn.RECURRING&&So(),i("div",{className:x1("footer-wrapper"),children:[!!m&&i(nt,{className:x1("error"),content:m}),J()]})]})})})})}),{bem:tc}=_e("card-brands");function nc(e){const{supportedCardBrands:n,max:t=6,className:r,style:a}=e,o=$(null),[s,c]=O(0),d=tr(n).map(h=>Va(h)),f=d.length-t,u=d.slice(t-1),m=u[s];return Ce(()=>(o.current=window.setInterval(()=>{c(h=>{const g=h+1,w=u.length;return g===w?0:N1(g,0,w-1)})},3e3),()=>{o.current&&(window.clearInterval(o.current),o.current=null)}),[]),i("div",{className:ye(ge,tc(),r),style:a,children:[d.slice(0,t-1).map(h=>h.icon&&i(h.icon,{size:32},h.code)),!!(m!=null&&m.icon)&&i(m.icon,{size:32},m.code),f>0&&i("div",{className:tc("more"),children:["+",f]})]})}const rc=e=>{const{currentTarget:n,data:t}=e;let r=Xt(n.value);const a=r.length;return a===1&&Number(r)>1?r=`0${r}`:a===2&&Number(r)>12&&(r=`01${t}`),a>=2&&!r.includes("/")&&(r=r.slice(0,2)+"/"+r.slice(2,4)),r},ac=e=>{const{currentTarget:n}=e;let t=Xt(n.value);const r=t.length;if(r===0)return"";if(r===1&&Number(t)>1)t=`0${t}`;else if(r>=2){const a=t.slice(0,2);Number(a)>12?t=`0${t.slice(0,1)}/${t.slice(1,3)}`:t.includes("/")||(t=t.slice(0,2)+"/"+t.slice(2,4))}return t.length>5&&(t=t.slice(0,5)),t},Lo=Fe((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,s=$(null),c=$(null);Be(n,()=>({input:s.current,focus:()=>{var g;(g=s.current)==null||g.focus()},blur:()=>{var g;(g=s.current)==null||g.blur()},resetValidation:(g,w)=>{var P;(P=c.current)==null||P.resetValidation(g,[{message:w}])}}));const{i18n:d}=yt(),[f,u]=O(""),m={trigger:["blur","submit"],validator(g){if(a){const w=c.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Ie(g)||g.length!==5)throw new Error(d.get("card.cardExpireDate.incomplete"));if(n2(g))throw new Error(d.get("card.cardExpireDate.expired"));return!0}};function h(g){var b,N,S,T;const{inputType:w,currentTarget:P}=g,E=P.selectionStart;let v;if(w==="insertText")v=rc(g);else if(w==="insertFromPaste")v=ac(g);else{v=P.value;const A=f.slice(E,E+1),R=f.length;if(R>3&&A==="/"){u(P.value=f),P.setSelectionRange(E,E),(b=e.onInput)==null||b.call(e,g);return}else if(E===1){const y=f.slice(0,2);R>2&&+y>=10?v=`01${f.slice(2,R)}`:v=v.slice(0,1)}else if(E===0&&v.length>1){A==="0"?u(P.value=f):A==="1"&&u(P.value=`0${v}`),P.setSelectionRange(0,0),(N=e.onInput)==null||N.call(e,g);return}else if(E===3)if(R===4)v=v.slice(0,2);else{u(P.value=v),P.setSelectionRange(E-1,E-1),(S=e.onInput)==null||S.call(e,g);return}}u(P.value=v),w!=="insertText"&&P.setSelectionRange(E+1,E+1),(T=e.onInput)==null||T.call(e,g)}return i(At,{label:d.get("card.cardExpireDate.label"),showLabel:o,path:"expireDate",ref:c,rule:m,className:t,style:r,children:i(_t,{type:"text",inputmode:"numeric",ref:s,maxLength:5,value:f,onInput:h,placeholder:d.get("card.cardExpireDate.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.EXPIRE_DATE})})})});function oc(e){const{className:n,style:t,disabled:r}=e,{i18n:a}=yt(),o={trigger:["blur","submit"],validator(c){if(!c)throw new Error(a.get("card.cardHolderName.incomplete"));return!0}};function s(c){var d;(d=e.onInput)==null||d.call(e,c)}return i(At,{label:a.get("card.cardHolderName.label"),path:"holderName",rule:o,className:n,style:t,children:i(_t,{maxLength:100,placeholder:a.get("card.cardHolderName.placeholder"),onInput:s,disabled:r})})}const No=Fe((e,n)=>{const{supportedCardBrands:t=[],className:r,security:a,showLabel:o,onBinValue:s}=e,c=$(null),d=$(null);Be(n,()=>({input:c.current,focus:()=>{var _;(_=c.current)==null||_.focus()},blur:()=>{var _;(_=c.current)==null||_.blur()},resetValidation:(_,V)=>{var k;(k=d.current)==null||k.resetValidation(_,[{message:V}])},binValueChanged:_=>{m(_)},binValue:()=>u,brandChanged:_=>{if(_){const V=Da(_);v(()=>V==null?void 0:V.icon),N(V==null?void 0:V.code)}else v(void 0),N(void 0)},getCardBrand:()=>nr(Yt(u),w)||{code:b}}));const{i18n:f}=yt(),[u,m]=O(""),[h,g]=O(""),w=tr(t),P=zi(w),[E,v]=O(void 0),[b,N]=O(void 0),[S,T]=O("");Ce(()=>{const _=Yt(u);v(u?()=>{var k;return(k=nr(_,w))==null?void 0:k.icon}:void 0);const V=_.substring(0,6);T(V.length<6?"":V)},[u]),Ce(()=>{s==null||s(S)},[S]);const A={trigger:["blur","submit"],validator(_){if(a){const k=d.current.getValidateResult();if(k.status==="error")throw new Error(k.errors[0].message);if(k.status==="success")return!0}if(_=Yt(_??""),!P.includes(_.length))throw new Error(f.get("card.cardNumber.incomplete"));if(!nr(_,w))throw new Error(f.get("card.cardNumber.invalid"));return!0}};function R(_){var ie;const{currentTarget:V,inputType:k}=_,p=V.selectionStart;let x=Xt(V.value);x=x.replace(/(\d{4})(?=\d)/g,"$1 ");let K=p;K%5===0&&(K=N1(p+(k==="insertText"?1:-1),0)),m(V.value=x),V.setSelectionRange(K,K),(ie=e.onInput)==null||ie.call(e,_)}const y=()=>{if(h!=="error")return i(E??Ta,{size:32})};return i(At,{label:f.get("card.cardNumber.label"),showLabel:o,path:"number",ref:d,rule:A,onValidationStatusChange:g,className:r,children:i(_t,{type:"text",inputmode:"numeric",ref:c,maxLength:23,value:u,onInput:R,rightIcon:y(),placeholder:f.get("card.cardNumber.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.CARD_NUMBER})})})}),kr=Fe((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,s=$(null),c=$(null);Be(n,()=>({input:s.current,focus:()=>{var g;(g=s.current)==null||g.focus()},blur:()=>{var g;(g=s.current)==null||g.blur()},resetValidation:(g,w)=>{var P;(P=c.current)==null||P.resetValidation(g,[{message:w}])}}));const{i18n:d}=yt(),[f,u]=O(""),m={trigger:["blur","submit"],validator(g){if(a){const w=c.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Ie(g)||g.length<3)throw new Error(d.get("card.cardSecurityCode.incomplete"));return!0}};function h(g){var P;const w=Xt(g.currentTarget.value);u(g.currentTarget.value=w),(P=e.onInput)==null||P.call(e,g)}return i(At,{label:d.get("card.cardSecurityCode.label"),showLabel:o,path:"securityCode",ref:c,rule:m,className:t,style:r,children:i(_t,{type:"text",inputmode:"numeric",ref:s,maxLength:4,value:f,onInput:h,placeholder:d.get("card.cardSecurityCode.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.CVV})})})}),{bem:Mo}=_e("card-no"),ic=e=>{const{value:n,className:t,style:r}=e;return i("div",{className:ye(ge,Mo("wrapper"),t),style:r,children:[Array.from({length:4},(a,o)=>o).map(()=>i("span",{className:Mo("dot")})),i("span",{className:Mo("card-no"),children:n})]})},sc=e=>{const{cardList:n=[],onCardChange:t,onClickEdit:r,className:a,style:o,onClickChange:s,value:c}=e,{i18n:d}=yt(),{bem:f}=_e("card-selector"),u=$(null),m=$(null),h={trigger:["blur","submit"],validator(){return!0}},g=()=>n.map(S=>({label:"",value:S.token,...S})),[w,P]=O(c);Ce(()=>{if(c){const S=g().find(({token:T})=>c===T);E(c,S)}},[c]);const E=(S,T)=>{P(S),t==null||t(T)},v=S=>{var A;const T=((A=Da(S.cardBrand))==null?void 0:A.icon)??Ta;return i("div",{className:f("label"),children:[i(T,{size:32}),i("div",{className:f("card-no"),children:i(ic,{value:S.last4})}),i("span",{})]})},b=()=>i("div",{className:f("change"),onClick:s,children:[i(Yi,{}),i("span",{style:{marginLeft:"4px"},children:d.get("card.cardSelector.change")})]}),N=()=>{const S=()=>{var T;(T=u.current)==null||T.blur(),r==null||r()};return i("div",{className:f("action"),children:i(Io,{style:{borderRadius:"6px",fontSize:"14px"},dashed:!0,icon:i(_l,{}),onClick:S,children:d.get("card.cardSelector.useOtherCard")})})};return i(At,{label:d.get("card.cardNumber.label"),path:"token",rule:h,className:a,style:o,ref:m,children:i(Tr,{value:w,ref:u,options:g(),renderLabel:v,onSelect:E,noDataTip:d.get("common.noData"),action:N(),rightIcon:b()})})};function uu({size:e,style:n,className:t}){const r=Ie(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:ye(ge,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:cc}=_e("check-box"),mu=e=>{const{checked:n,onChange:t,label:r,style:a}=e,o=()=>{t==null||t(!n)};return i("div",{className:ye(ge,cc({checked:n})),onClick:o,style:a,children:[i("div",{className:cc("inner"),children:i(uu,{size:10})}),i("span",{children:r})]})},fu=e=>e?Array.prototype.slice.call(e.querySelectorAll(`[${Ws}]`)):[];class hu{constructor(n){Ae(this,"iframe");Ae(this,"iframeWindow");Ae(this,"hiddenIframe");Ae(this,"config");this.config=n,this.init()}init(){const{iframeSrc:n,iframeClassName:t,fieldNode:r,iframeName:a}=this.config,o=Ks(n);o.width="100%",o.height="100%",o.style.border="none",o.name=a,r.appendChild(o);const s=r.querySelector(`.${t}`);s&&(this.iframe=s,s.addEventListener("load",()=>this.onFieldIframeLoad()))}onFieldIframeLoad(){this.iframeWindow=this.iframe.contentWindow;const{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o,checkoutId:s}=this.config,c={action:Ve.INIT,checkoutId:s,config:{checkoutId:s,fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o},hidden:!1,cdnUrl:$n};mt(c,this.iframeWindow,jt)}}const Vr=Fe((e,n)=>{const{sessionMode:t,i18n:r,targetElement:a,checkoutId:o}=e,s=$(null),c=$(null),d=(v,b)=>{const N={action:Ve.PAYMENT,checkoutId:o,formData:v,extraParams:b,locale:e.i18n.locale};mt(N,c.current.contentWindow,jt)};if(Be(n,()=>({payment:d,reload:()=>{t!==Ue.HOSTED&&(window.removeEventListener("message",E),c.current&&document.body.removeChild(c.current),h())},encryptCard:v=>{const b={action:Ve.ENCRYPT_CARD,...v};mt(b,c.current.contentWindow,jt)},validate:()=>{Object.values(u.current).forEach(v=>{const b={action:Ve.VALIDATE,checkoutId:o};mt(b,v.iframe.contentWindow,jt)})},setConfig:v=>{e.style=v.style}})),!frames&&t===Ue.HOSTED)return e.children;let f=[];const u=$({}),m={[Oe.CARD_NUMBER]:r.get("card.cardNumber.placeholder"),[Oe.CVV]:r.get("card.cardSecurityCode.placeholder"),[Oe.EXPIRE_DATE]:r.get("card.cardExpireDate.placeholder"),[R1.CPF]:r.get("cpf.placeholder")};Ce(()=>{h()},[]);const h=async()=>{f=fu(a||s.current),f.length&&(await g(),w(),window.addEventListener("message",E))},g=async()=>{const v=Ks(`${$n}/secured-iframe.html`);v.name=`${Y4}-${o}-${Date.now()}`,v.width="0",v.height="0",v.style.border="none",c.current=v;const b={action:Ve.INIT,hidden:!0,checkoutId:o,apiUrl:io,cdnUrl:$n,apiPrefix:Re};v.addEventListener("load",()=>{mt(b,c.current.contentWindow,jt)}),window.document.body.appendChild(v)},w=()=>{f.forEach(v=>{const b=v.getAttribute(Ws);u.current[b]=new hu({fieldNode:v,hiddenIframe:c.current,hiddenIframeName:c.current.name,rootNode:s.current,iframeSrc:`${$n}/secured-iframe.html`,iframeName:`${j4}-${o}-${Date.now()}`,iframeClassName:Qs,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,checkoutId:o})})},P=v=>{var S;const b=Object.values(u.current).some(T=>T.iframe.contentWindow===v),N=((S=c.current)==null?void 0:S.contentWindow)===v;return b||N},E=qe(v=>{var A,R,y,_,V,k,p,x,K,ie,q,ne;const{data:b,origin:N,source:S}=v;if(N!==jt||!S||!P(S))return;const T=M1(b);if(Reflect.has(T,"action")&&T.checkoutId===o)switch(T.action){case Ve.FOCUS:(A=e.onFocus)==null||A.call(e,T);break;case Ve.BIN_VALUE:(R=e.onBinValue)==null||R.call(e,T);break;case Ve.BRAND:(y=e.onBrand)==null||y.call(e,T);break;case Ve.AFTER_PAYMENT:(_=e.onAfterPayment)==null||_.call(e,T);break;case Ve.PAYMENT_ERROR:(V=e.onPaymentError)==null||V.call(e,T);break;case Ve.PAYMENT_TIMEOUT:(k=e.onPaymentTimeout)==null||k.call(e,T);break;case Ve.VALID_STATUS_CHANGED:(p=e.onValidStatusChanged)==null||p.call(e,T);break;case Ve.AUTHORIZED:(x=e.onAuthorized)==null||x.call(e,T);break;case Ve.ACTIVATED:(K=e.onActivated)==null||K.call(e,T);break;case Ve.CARD_ENCRYPTED:(ie=e.onCardEncrypted)==null||ie.call(e,T);break;case Ve.CARD_ENCRYPTION_FAILED:(q=e.onCardEncryptionFailed)==null||q.call(e,T);break;case Ve.VALIDATED:(ne=e.onValidated)==null||ne.call(e,T);break}},[]);return i("div",{ref:s,children:!a&&e.children})}),{bem:r1}=_e("modal"),dc=Fe(e=>{const{show:n=!1,width:t,height:r,maskClosable:a,header:o,children:s,onChange:c,style:d,appendToBody:f=!1}=e,[u,m]=O(),[h,g]=O(),{i18n:w}=yt();Ht(()=>{m(typeof t=="number"?`${t}px`:t),g(typeof r=="number"?`${r}px`:r)},[t,r]);const P=()=>{a&&(c==null||c(!1))},E=()=>{c==null||c(!1)},v=i(he,{children:n&&i("div",{className:r1(),children:[i("div",{className:r1("mask"),onClick:P}),i("div",{className:r1("content"),style:{width:u,height:h,...d},children:[o||i("div",{className:r1("header"),children:i("div",{className:r1("close"),onClick:E,children:w.get("common.cancel")})}),i("div",{className:r1("body"),children:s})]})]})});return f?n?el(v,document.body):null:v}),{bem:O1}=_e("three-ds-auth"),lc=e=>{const{show:n=!1,onClose:t,url:r,incomplete:a=!0,width:o,height:s="72vh",theme:c,checkoutId:d}=e,f=T2(),[u,m]=O(!1),h=$(),g=$(null),[w]=O(`${q4}-${d}-${Date.now()}`),{i18n:P}=yt(),E=()=>{m(!0)},v=N=>{!N&&(t==null||t())},b=Ht(()=>n?o||(f.smaller("sm")?"90vw":"600px"):"0",[n,o,f.matches]);return Ce(()=>{n?(h.current&&window.removeEventListener("message",h.current),h.current=N=>{const{data:S,origin:T}=N;if(T!==jt)return;const A=M1(S);if(A.checkoutId===d)switch(A.action){case Ve.CHECK_THREE_DS:{v(!1);break}}},window.addEventListener("message",h.current)):h.current&&window.removeEventListener("message",h.current)},[n]),i(dc,{show:n,onChange:v,width:b,height:s,style:{maxWidth:"calc(100vw - 10px)",maxHeight:"calc(100vh - 100px)",minWidth:"300px"},children:i("div",{className:O1("content"),children:!a||u?i("iframe",{ref:g,name:w,class:O1("three-ds-iframe"),width:"100%",height:"100%",frameBorder:0,src:r}):i("div",{className:O1("last-three-ds"),children:[i(Rl,{className:O1("last-three-ds-icon"),size:60}),i("div",{className:O1("last-three-ds-title"),children:[i("div",{children:P.get("threeDS.paymentIncomplete")}),i("div",{children:P.get("threeDS.completeFirst")})]}),i("div",{children:i(Io,{style:{backgroundColor:c==null?void 0:c.payButtonBackgroundColor,color:c==null?void 0:c.payButtonTextColor},onClick:E,children:P.get("common.confirm")})})]})})})},{bem:F1}=_e("combined-card-info"),To=Fe((e,n)=>{const{supportedCardBrands:t=[],className:r,showLabel:a=!1,security:o}=e,s=$(null),c=$(null),{i18n:d}=yt();Be(n,()=>({input:s.current,focus:()=>{var P;(P=s.current)==null||P.focus()},blur:()=>{var P;(P=s.current)==null||P.blur()},resetValidation:(P,E)=>{var v;(v=c.current)==null||v.resetValidation(P,[{message:E}])},binValueChanged:P=>{m(P)},binValue:()=>u,brandChanged:P=>{if(P){const E=Da(P);g(()=>E==null?void 0:E.icon)}else g(void 0)},getCardBrand:()=>nr(Yt(u),tr(t))||{}}));const f={trigger:["submit"],validator(){if(o){const P=c.current.getValidateResult();if(P.status==="error")throw new Error(P.errors[0].message);if(P.status==="success")return!0}return!0}},[u,m]=O(""),[h,g]=O(void 0),w=()=>i(h??Ta,{size:32});return i(At,{showLabel:a,ref:c,label:d.get("card.info.label"),className:r,path:"cardInfo",rule:f,children:i(_t,{ref:s,leftIcon:w(),rightIcon:i("div",{className:F1("blank-icon")}),children:i("div",{className:F1(),children:[i("div",{className:F1("card-number"),"data-sf":Oe.CARD_NUMBER}),i("div",{className:F1("expire-date"),"data-sf":Oe.EXPIRE_DATE}),i("div",{className:F1("cvv"),"data-sf":Oe.CVV})]})})})}),{bem:wt}=_e("card"),a1=wt("field"),uc=Fe((e,n)=>{var Dd,xd;const{showCardBrands:t=!0,session:r,cardInfoLayout:a="split",showHolderName:o=!0,showEmail:s=!1,showAddress:c=!1,threeDSFrame:d,styles:f,enable3DSModal:u=!0,isDropIn:m,core:h,hidePaymentButton:g=!1}=e,w=h.getAddressCore(),P=lt(),{i18n:E,fraudDetection:v,sessionReady:b}=et(r,h),N=$(null),S=$(null),T=$(null),A=$(null),[R,y]=O({email:"",number:"",expireDate:"",securityCode:"",holderName:"",cardInfo:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[_,V]=O(!1),[k,p]=O("unSubmit"),[x,K]=O(""),[ie,q]=O(!1),[ne,W]=O(!1),[J,se]=O(!1),[z,X]=O([]),[Q,Y]=O(!1),[ee,re]=O(),[ae,me]=O(),[l,C]=O(!1),[I,j]=O(!0),[we,pe]=O({}),[U]=O(a==="split");Be(n,()=>({checkThreeDS:ei,updateAddress:()=>{var ue;if(!(ae!=null&&ae.address.show))return;const te=Object.assign(R,{address:w.getAddressState()});y(te),(ue=N.current)==null||ue.update(w.getAddressState()),Sn()},updateEmail:()=>{var ue;if(!(ae!=null&&ae.email.show))return;const te=Object.assign(R,{email:P.email});y(te),(ue=S.current)==null||ue.update(P.email),Sn()},payment:()=>{g&&ve()}}));const Z=()=>{const{field:te,sessionMode:ue}=r.checkout,{email:Pe,address:Le,holderName:Ze}=te;ue===Ue.COMPONENT&&(Pe.disabled&&(Pe.show=s),c&&!(Le!=null&&Le.show)&&(Le.show=!0),o&&!(Ze!=null&&Ze.show)&&(Ze.show=!0,Ze.disabled=!0)),me({...te})},B=()=>{if(!f)return;const{input:te}=qs(f);te&&pe(te)};Ce(()=>{var rt,at;if(!b)return;const{status:te,supportMethods:ue=[],bill:Pe={},sessionMode:Le,country:Ze}=(r==null?void 0:r.checkout)||{};if(Le===Ue.DROP_IN&&!m){(at=(rt=e.core.config).onInitError)==null||at.call(rt,new Ee("ERROR","Please send the correct session when creating the checkout"));return}Kn(ue,Ma).length&&(Z(),B(),C(Le!==Ue.HOSTED),Ze&&w.setCountry(Ze),R.email=Pe.email??"",R.address.country=Ze,X(Kn(Qi,ue||[])),se(!0),te==="SUCCESS"&&F(r==null?void 0:r.checkout))},[b]);const M=qe(te=>{var ue;K(te||E.get("common.payTimeout")),p("unSubmit"),(ue=e.onTimeout)==null||ue.call(e),h.resetEnablePaymentMethod()},[E,e.onTimeout]),F=te=>{var ue,Pe;p("success"),(Pe=e.onSuccess)==null||Pe.call(e,ft({...te,returnUrl:(ue=r==null?void 0:r.checkout)==null?void 0:ue.returnUrl}))},L=te=>{var ue;(ue=e.onError)==null||ue.call(e,te),h.resetEnablePaymentMethod()},{start:D}=Xe(te=>De(!0,te),{onTimeout:()=>M(E.get("common.queryTimeout"))}),H=$(kn()),oe=te=>{Hn.current[te.fieldType].status=te.status;const ue=Object.values(Hn.current);ue.includes(null)||(ue.every(Le=>Le.status==="success")?H.current.resolve(!0):H.current.reject(!1))},de=async()=>{var te;H.current=kn(),Object.keys(Hn.current).forEach(ue=>{Hn.current[ue]=null}),(te=ya.current)==null||te.validate();try{await H.current}catch{}};async function ve(){var te;K(""),!U&&l&&await de(),(te=A.current)==null||te.validate(async ue=>{var Pe;if(ae!=null&&ae.address.show&&w.setValidateAllFields(!0),(Pe=e.onSubmit)==null||Pe.call(e,ue),ue){p("unSubmit");return}K(""),p("loading"),await De()})}const le=async()=>{var Tt,ot,$e;const te=Yt(R.number),ue=Ki(te),[Pe,Le]=R.expireDate.split("/"),Ze=Ca&&!ne;let rt=null;Ca?rt=G.BANKCARD:l?rt=(Tt=(U?A1:T).current)==null?void 0:Tt.getCardBrand().code:rt=ue.code;let at;return l&&(at=U?(ot=A1.current)==null?void 0:ot.binValue():($e=T.current)==null?void 0:$e.binValue()),{sessionId:r.sessionId,clientKey:r.clientKey,payment:{paymentMethod:rt,cvv:R.securityCode,...Ze?{token:R.token}:{holderName:R.holderName,expYear:`20${Le}`,expMonth:Pe,cardNo:te,...Sd?{storePaymentMethod:ie}:null}},bill:ae!=null&&ae.address.show?{email:R.email,addressLine1:R.address.address1,addressLine2:R.address.address2,postalCode:R.address.postCode,country:R.address.country,district:R.address.area,state:R.address.province?w.getLabel(R.address.province,w.getProvinceOption())??R.address.province:void 0,city:R.address.city?w.getLabel(R.address.city,w.getCityOptions())??R.address.city:void 0}:{email:R.email},browser:await Je({fraudDetectionId:await(v==null?void 0:v.getFraudDetectionId({bin:te||at||""}))})}};async function De(te=!1,ue){var Pe,Le,Ze,rt,at;try{const Tt={locale:E.locale,timeout:ue};let ot=null;if(te){const $e=(Le=(Pe=h.config)._getExtraParams)==null?void 0:Le.call(Pe,"query",G.BANKCARD);ot=await x2({sessionId:r.sessionId,clientKey:r.clientKey},$e,Tt)}else{const $e=await le(),an=(rt=(Ze=h.config)._getExtraParams)==null?void 0:rt.call(Ze,"payment",G.BANKCARD);if(l)return(at=ya.current)==null||at.payment($e,an),{end:!0};ot=await D2($e,an,Tt)}return ke(ot,te)}catch(Tt){return We(Tt)?te?{end:!1}:(M(),{end:!0}):(Pn(Tt),b1(),{end:!0})}}const Te=(te,ue)=>{var Pe;u?(Y(!0),re({url:te,incomplete:ue,width:d==null?void 0:d.modalWidth,height:d==null?void 0:d.modalHeight})):(Pe=e.onThreeDS)==null||Pe.call(e,te,ue)},je=()=>{Y(!1),re(void 0),ei()},ke=(te,ue=!1)=>{var $e,an;const{status:Pe,orderStatus:Le,errorMessage:Ze,errorCode:rt,payInfo:at={},sessionId:Tt}=te,{threeDSUrl:ot}=at;if(Tt&&(r.sessionId=Tt),Pe==="PROCESSING"){if(!Le)p("unSubmit");else if(Le==="SUCCESS")F(te);else{if(Le==="PROCESSING")return!ue&&D(),{end:!1};Le==="FAILURE"?(Ze&&K(Ze),p("unSubmit"),L(new Ee("API_ERROR",Ze,{code:rt}))):Le==="AUTHORIZED"?(p("unSubmit"),($e=e.onAuthorized)==null||$e.call(e)):Le==="IN_THREED"?ot&&Te(ot,!1):Le==="IN_PREVIOUS_THREED"&&ot&&Te(ot,!0)}return{end:!0}}else{if(Pe==="SUCCESS")return F(te),{end:!0};if(Pe==="EXPIRED")return p("unSubmit"),(an=e.onExpired)==null||an.call(e),{end:!0}}return p("unSubmit"),{end:!0}},Pn=te=>{const ue=te.i18nKey?E.get(te.i18nKey):te.message;K(ue),p("unSubmit"),L(new Ee("API_ERROR",ue,{code:te.code,cause:te}))},Sn=()=>{var te;(te=A.current)==null||te.validate(void 0,!1).then(()=>{V(!0)}).catch(()=>{V(!1)})};Ce(()=>{Sn()},[R]);const ha=()=>{var Le;const te=(Le=r==null?void 0:r.checkout)==null?void 0:Le.transAmount,ue=te!=null&&te.amount?it(te).jointSymbol():"",Pe=E.get("common.pay")+(ue?` ${ue}`:"");return i(ut,{className:wt("button"),status:k,text:Pe,loadingText:E.get("common.payProcessing"),successText:E.get("common.paySuccess"),onClick:ve,verified:_})},{start:j1,stop:b1}=Xe(te=>ei(!0,te),{timeout:12*1e3,onTimeout:()=>M(E.get("common.queryTimeout"))});async function ei(te=!1,ue=2e4){var Pe,Le,Ze,rt;if(!r)return{end:!0};try{const at=(Le=(Pe=h.config)._getExtraParams)==null?void 0:Le.call(Pe,"query",G.BANKCARD),Tt=await x2({sessionId:r.sessionId,clientKey:r.clientKey},at,{locale:E.locale,timeout:ue}),{status:ot,orderStatus:$e,errorMessage:an,errorCode:i9}=Tt;if(ot==="PROCESSING"){if($e==="PROCESSING")D();else if($e==="FAILURE")an&&K(an),p("unSubmit"),L(new Ee("API_ERROR",an,{code:i9}));else if($e==="AUTHORIZED")p("unSubmit"),(Ze=e.onAuthorized)==null||Ze.call(e);else{if($e==="IN_THREED")return p("loading"),!te&&j1(),{end:!1};$e==="IN_PREVIOUS_THREED"?(K(E.get("common.pay3DSIncomplete")),p("unSubmit")):$e||p("unSubmit")}return b1(),{end:!0}}else{if(ot==="SUCCESS")return F(Tt),b1(),{end:!0};if(ot==="EXPIRED")return p("unSubmit"),(rt=e.onExpired)==null||rt.call(e),b1(),{end:!0}}return p("unSubmit"),b1(),{end:!0}}catch(at){return We(at)?te?{end:!1}:(M(E.get("common.queryTimeout")),{end:!0}):(Pn(at),b1(),{end:!0})}}const Ca=Ht(()=>{var Pe;if(!(r!=null&&r.checkout))return;const te=(r==null?void 0:r.checkout.paymentType)===Nn.PURCHASE,ue=!!((Pe=r==null?void 0:r.checkout.tokens)!=null&&Pe.length);return te&&ue},[r==null?void 0:r.checkout]),Sd=Ht(()=>{if(r!=null&&r.checkout)return(r==null?void 0:r.checkout.paymentType)===Nn.PURCHASE&&(r==null?void 0:r.checkout.storePaymentMethod)},[r==null?void 0:r.checkout]),W6=()=>{const te=ue=>{q(ue)};return i("div",{className:wt("store-checkbox"),children:i(mu,{label:E.get("card.storeInfo"),checked:ie,onChange:te})})},Q6=()=>{var Le,Ze,rt;const te=((Le=r==null?void 0:r.checkout)==null?void 0:Le.paymentType)===Nn.PURCHASE,ue=!!((rt=(Ze=r==null?void 0:r.checkout)==null?void 0:Ze.tokens)!=null&&rt.length),Pe=()=>{var at;(at=A.current)==null||at.resetValidation(),W(!1)};return te&&ue&&i("div",{className:wt("change-box"),onClick:Pe,children:[i(Yi,{}),i("span",{style:{marginLeft:"2px"},children:E.get("card.cardSelector.change")})]})},Id=()=>{var te;(te=A.current)==null||te.resetValidation(),W(!0)},K6=()=>{var ue;(((ue=r==null?void 0:r.checkout)==null?void 0:ue.tokens)||[]).length>1||Id()},z6=te=>{j(!1),y(Object.assign(R,{token:te==null?void 0:te.token}))},_d=te=>{A.current=te,te&&Sn()},A1=$(null),Rd=$(null),ti=$(null),ya=$(null),Ld=Ht(()=>Ca&&!ne,[Ca,ne]);Ce(()=>{var te;(te=ya.current)==null||te.reload()},[Ld]);const Nd={[Oe.CARD_NUMBER]:A1,[Oe.CVV]:ti,[Oe.EXPIRE_DATE]:Rd},J6=te=>{var Pe,Le;const ue=U?Nd[te.fieldType]:T;te.focus?(Pe=ue.current)==null||Pe.focus():(Le=ue.current)==null||Le.blur()},X6=[Oe.CARD_NUMBER,Oe.EXPIRE_DATE,Oe.CVV],Hn=$({[Oe.CARD_NUMBER]:null,[Oe.EXPIRE_DATE]:null,[Oe.CVV]:null}),$6=te=>{var Le,Ze,rt,at;const ue=U?Nd[te.fieldType]:T,Pe=te.errorTip&&E.get(te.errorTip);if(U)(at=ue.current)==null||at.resetValidation(te.status,Pe);else{Hn.current[te.fieldType]={status:te.status,errorTip:Pe};for(const ot of X6){const $e=Hn.current[ot];if(($e==null?void 0:$e.status)==="error"){(Le=ue.current)==null||Le.resetValidation($e.status,$e.errorTip);return}}Object.values(Hn.current).every(ot=>(ot==null?void 0:ot.status)==="success")?(Ze=ue.current)==null||Ze.resetValidation("success"):(rt=ue.current)==null||rt.resetValidation("unValidate")}setTimeout(()=>{Sn()},100)},e9=te=>{var Pe;(Pe=(U?A1:T).current)==null||Pe.brandChanged(te.brand)},Md=te=>{var Pe;let ue="";typeof te=="string"?ue=te:((Pe=(U?A1:T).current)==null||Pe.binValueChanged(te.binValue),ue=te.binValue),ue&&new Lr().init(ue)},t9=te=>{ke(te.response)},n9=te=>{Pn(te.error)},Td=()=>i(he,{children:(ae==null?void 0:ae.email.show)&&i("div",{className:a1,children:i(Ct,{ref:S,value:R.email,disabled:ae==null?void 0:ae.email.disabled})})}),kd=()=>{var te,ue;return i(he,{children:(ae==null?void 0:ae.address.show)&&i("div",{className:wt("address"),children:i(ht,{ref:N,value:R.address,country:((te=r==null?void 0:r.checkout)==null?void 0:te.country)||((ue=r==null?void 0:r.checkout)==null?void 0:ue.bill.country),onAddressChange:Pe=>y(Object.assign(R,{address:Pe}))})})})},Vd=()=>i(he,{children:!!x&&i(nt,{content:x})}),r9=qe(()=>{var te,ue,Pe,Le;return U?i(he,{children:[i("div",{className:a1,children:[i("div",{className:wt("card-number-wrapper"),children:[i(No,{supportedCardBrands:(ue=(te=r==null?void 0:r.checkout)==null?void 0:te.supportMethods)==null?void 0:ue.filter(Boolean),security:l,ref:A1,onBinValue:Md}),Q6()]}),t&&i(nc,{className:wt("card-brands"),supportedCardBrands:(Le=(Pe=r==null?void 0:r.checkout)==null?void 0:Pe.supportMethods)==null?void 0:Le.filter(Boolean)})]}),i("div",{className:wt("center"),children:[i(Lo,{security:l,className:a1,ref:Rd}),i(kr,{security:l,className:a1,ref:ti})]})]}):i("div",{className:wt("card-info"),children:i(To,{ref:T,supportedCardBrands:z,showLabel:!0,security:l})})},[U,l]),a9=()=>{var te;return i(dt,{form:R,ref:_d,onFormChange:ue=>y(ue),children:i("div",{className:ye(ge,wt()),children:[Td(),r9(),(ae==null?void 0:ae.holderName.show)&&i("div",{className:wt("holder-name"),children:i(oc,{disabled:ae==null?void 0:ae.holderName.disabled})}),kd(),((te=r==null?void 0:r.checkout)==null?void 0:te.paymentType)===Nn.RECURRING&&So(),i("div",{className:wt("footer-wrapper"),children:[Sd&&W6(),Vd(),!g&&ha()]})]})})},o9=()=>{var te,ue,Pe,Le;return i(dt,{form:R,ref:_d,onFormChange:Ze=>y(Ze),children:i("div",{className:ye(ge,wt()),children:[Td(),i("div",{className:wt("card-selector-wrapper"),children:[i(sc,{value:(Pe=(ue=(te=r==null?void 0:r.checkout)==null?void 0:te.tokens)==null?void 0:ue[0])==null?void 0:Pe.token,cardList:(Le=r==null?void 0:r.checkout)==null?void 0:Le.tokens,onClickEdit:Id,onClickChange:K6,onCardChange:z6,className:wt("card-selector",a1),style:{flex:2}}),i(kr,{className:wt("card-security-code",a1),style:{flex:1},security:l,ref:ti})]}),I&&kd(),i("div",{className:wt("footer-wrapper"),children:[Vd(),!g&&ha()]})]})})};return i(ze.Provider,{value:{i18n:E,core:h},children:J&&E.ready.value&&i("div",{className:h.theme.className,children:[i(Vr,{ref:ya,i18n:E,checkoutId:h.id,sessionMode:(Dd=r.checkout)==null?void 0:Dd.sessionMode,supportedCardBrands:z,style:we||S1,onFocus:J6,onBinValue:Md,onBrand:e9,onAfterPayment:t9,onPaymentError:n9,onPaymentTimeout:({message:te})=>M(E.get(te)),onValidStatusChanged:$6,onValidated:oe,children:Ld?o9():a9()}),i(lc,{show:Q,theme:(xd=r==null?void 0:r.checkout)==null?void 0:xd.theme,onClose:je,checkoutId:h.id,...ee})]})})}),{bem:B1}=_e("wechat-pay"),mc=B1("field"),Cu=Fe((e,n)=>{var Q;const{session:t,core:r,showEmail:a=!1,showAddress:o=!1}=e,s=r.getAddressCore(),c=lt(),d=$(null);Be(n,()=>({stopRetry:()=>{ie(),P("unSubmit")},startRetry:Y=>{P("loading"),K({timeout:Y})},updateAddress:()=>{var ee;if(!(T!=null&&T.address.show))return;const Y=Object.assign(v,{address:s.getAddressState()});b(Y),(ee=R.current)==null||ee.update(s.getAddressState()),V()},updateEmail:()=>{var ee;if(!(T!=null&&T.email.show))return;const Y=Object.assign(v,{email:c.email});b(Y),(ee=d.current)==null||ee.update(c.email),V()}}));const{setErrorMsg:f,fraudDetection:u,i18n:m,errorMsg:h,sessionReady:g}=et(t,e.core),[w,P]=O("unSubmit"),E=$(null),[v,b]=O({email:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[N,S]=O(!1),[T,A]=O(),R=$(null),[y,_]=O(!1);function V(){var Y;(Y=E.current)==null||Y.validate(void 0,!1).then(()=>{S(!0)}).catch(()=>{S(!1)})}const k=()=>{const{field:Y,sessionMode:ee}=t.checkout,{email:re,address:ae}=Y;ee===Ue.COMPONENT&&(re.disabled&&(re.show=a),o&&!(ae!=null&&ae.show)&&(ae.show=!0)),A({...Y})};Ce(()=>{V()},[v]);const p=Y=>{var ee,re;P("success"),(re=e.onSuccess)==null||re.call(e,ft({...Y,returnUrl:(ee=t==null?void 0:t.checkout)==null?void 0:ee.returnUrl}))};Ce(()=>{if(!g)return;const{bill:Y={},supportMethods:ee=[],country:re}=(t==null?void 0:t.checkout)||{};ee.includes(G.WECHAT_PAY)&&(k(),_(!0),re&&s.setCountry(re),v.email=Y.email??"",v.address.country=re)},[g]);const x=qe(Y=>{var ee;f(Y||m.get("common.payTimeout")),P("unSubmit"),(ee=e.onTimeout)==null||ee.call(e,"retry")},[m,e.onTimeout]),{start:K,stop:ie}=Xe(Y=>ne(!0,Y),{timeout:2*60*1e3,onTimeout:()=>x(m.get("common.queryTimeout"))}),q=async()=>{var Y;return{sessionId:t.sessionId,clientKey:t.clientKey,bill:T!=null&&T.address.show?{email:v.email,addressLine1:v.address.address1,addressLine2:v.address.address2,postalCode:v.address.postCode,country:v.address.country,district:v.address.area,state:v.address.province?s.getLabel(v.address.province,s.getProvinceOption())??v.address.province:void 0,city:v.address.city?s.getLabel(v.address.city,s.getCityOptions())??v.address.city:void 0}:{email:v.email},channelUserId:await((Y=e.onGetOpenId)==null?void 0:Y.call(e)),payment:{paymentMethod:G.WECHAT_PAY},browser:await Je({fraudDetectionId:await(u==null?void 0:u.getFraudDetectionId())})}};async function ne(Y=!1,ee){var re,ae,me,l,C,I,j,we,pe,U;try{const Z={locale:m.locale,timeout:ee};let B=null;if(Y){const de=(ae=(re=r.config)._getExtraParams)==null?void 0:ae.call(re,"query",G.WECHAT_PAY);B=await w8({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.WECHAT_PAY},de,Z)}else{const de=(l=(me=r.config)._getExtraParams)==null?void 0:l.call(me,"payment",G.WECHAT_PAY);B=await A8(await q(),de,Z)}const{status:M,orderStatus:F,errorMessage:L,payInfo:D,errorCode:H,sessionId:oe}=B;if(oe&&(t.sessionId=oe),!Y&&((C=e.onSubmitResponse)==null||C.call(e,B)),M==="PROCESSING")if(F){if(F==="SUCCESS")return p(B),{end:!0};if(F==="FAILURE")return L&&f(L),P("unSubmit"),(I=e.onError)==null||I.call(e,new Ee("API_ERROR",L,{code:H})),{end:!0};if(F==="PROCESSING")return Y||(await((j=e.onCallWxPayBox)==null?void 0:j.call(e,D)),K()),{end:!1};if(F==="CANCELED")return P("unSubmit"),(we=e.onTimeout)==null||we.call(e,"channel"),{end:!0}}else return P("unSubmit"),{end:!0};else{if(M==="SUCCESS")return p(B),{end:!0};if(M==="EXPIRED")return P("unSubmit"),(pe=e.onExpired)==null||pe.call(e),{end:!0}}return P("unSubmit"),{end:!0}}catch(Z){if(We(Z))return Y?{end:!1}:(x(),{end:!0});{const B=Z.i18nKey?m.get(Z.i18nKey):Z.message;return B&&f(B),(U=e.onError)==null||U.call(e,new Ee("API_ERROR",B,{code:Z.code,cause:Z})),P("unSubmit"),{end:!0}}}}async function W(){var Y;f(""),(Y=E.current)==null||Y.validate(async ee=>{var re;if(T!=null&&T.address.show&&s.setValidateAllFields(!0),(re=e.onSubmit)==null||re.call(e,ee),ee){P("unSubmit");return}f(""),P("loading"),await ne()})}const J=()=>{const{transAmount:Y,channelParams:ee={}}=(t==null?void 0:t.checkout)??{},{totalAmount:re}=ee.wechatPay??{},ae=(re!=null&&re.amount?re:Y)||{},me=ae!=null&&ae.amount?it(ae).jointSymbol():"",l=m.get("common.pay")+(me?` ${me}`:"");return i(ut,{className:B1("button"),status:w,text:l,loadingText:m.get("common.payProcessing"),successText:m.get("common.paySuccess"),onClick:W,verified:N})},se=Y=>{E.current=Y,Y&&V()},z=()=>i(he,{children:(T==null?void 0:T.email.show)&&i("div",{className:mc,children:i(Ct,{ref:d,value:v.email,disabled:T==null?void 0:T.email.disabled})})}),X=()=>{var Y,ee;return i(he,{children:(T==null?void 0:T.address.show)&&i("div",{className:mc,children:i(ht,{ref:R,value:v.address,country:((Y=t==null?void 0:t.checkout)==null?void 0:Y.country)||((ee=t==null?void 0:t.checkout)==null?void 0:ee.bill.country),onAddressChange:re=>b(Object.assign(v,{address:re}))})})})};return i(ze.Provider,{value:{i18n:m,session:t,core:r},children:y&&m.ready.value&&i("div",{className:r.theme.className,children:i(dt,{form:v,ref:se,onFormChange:Y=>b(Y),children:i("div",{className:ye(ge,B1()),children:[z(),X(),((Q=t==null?void 0:t.checkout)==null?void 0:Q.paymentType)===Nn.RECURRING&&So(),i("div",{className:B1("footer-wrapper"),children:[!!h&&i(nt,{className:B1("error"),content:h}),J()]})]})})})})}),yu={request:{requiredBillingContactFields:["name","email"],requiredShippingContactFields:["email"]},button:{buttonStyle:"black",buttonType:"plain"}},gu="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",pu=["paymentCredentialsAvailable","paymentCredentialStatusUnknown","paymentCredentialsUnavailable"],vu=3,fc=()=>{const e=navigator.userAgent;if(/Safari/.test(e)&&!/Chrome|Chromium|Edg|OPR|Android/.test(e)){const n=e.match(/Version\/(\d+\.\d+)/);return n?parseFloat(n[1])>=15:!1}if(/iPhone|iPad|iPod/.test(e)){const n=e.match(/OS (\d+)_(\d+)/);return n?parseInt(n[1],10)>=15:!1}return!0},bu=(e,n)=>{fc()?eo({src:gu,onload:e,onerror:n,extraOptions:{async:!0,crossOrigin:""}}):e==null||e()},Au=async e=>{var n,t;if(!e||!window.ApplePaySession||!((n=ApplePaySession.canMakePayments)!=null&&n.call(ApplePaySession)))return!1;if(ApplePaySession.applePayCapabilities){const r=await((t=ApplePaySession.applePayCapabilities)==null?void 0:t.call(ApplePaySession,e));return pu.includes(r.paymentCredentialStatus)}else return!!ApplePaySession.canMakePaymentsWithActiveCard},wu=()=>{const e=$(null);return{applePaySession:e,initApplePaySession:a=>{e.current=new ApplePaySession(vu,a.request),e.current.onvalidatemerchant=a.onValidate,e.current.onpaymentauthorized=a.onAuthorized,e.current.oncancel=a.onCancel},reportSuccess2ApplePay:()=>{var a;(a=e.current)==null||a.completePayment({status:ApplePaySession.STATUS_SUCCESS??0})},reportFailure2ApplePay:a=>{var o;(o=e.current)==null||o.completePayment({status:ApplePaySession.STATUS_FAILURE??1,errors:[new ApplePayError("unknown",void 0,a)]})}}},{bem:hc}=_e("apple-pay"),Cc=Fe(e=>{const{session:n,isDropIn:t,core:r,config:a}=e,{applePaySession:o,initApplePaySession:s,reportSuccess2ApplePay:c,reportFailure2ApplePay:d}=wu(),{i18n:f,sessionReady:u,fraudDetection:m}=et(n,e.core),[h,g]=O(""),[w,P]=O(!1),E=L1(yu,a||{}),v=fc(),b=V=>{var p,x;const k=ft({...V,returnUrl:(p=n==null?void 0:n.checkout)==null?void 0:p.returnUrl});(x=e.onSuccess)==null||x.call(e,k)};Ce(()=>{if(!u)return;const{supportMethods:V=[],sessionMode:k}=(n==null?void 0:n.checkout)||{},{onEvent:p,onInitError:x}=e.core.config;if(k===Ue.DROP_IN&&!t){x==null||x(new Ee("ERROR","Please send the correct session when creating the checkout"));return}V.includes(G.APPLE_PAY)&&bu(async()=>{var ie,q,ne,W,J;(ie=e.onLoad)==null||ie.call(e,!0);const K=await Au((W=(ne=(q=n==null?void 0:n.checkout)==null?void 0:q.channelParams)==null?void 0:ne.applePay)==null?void 0:W.merchantIdentifier);K||p==null||p(Cn.APPLE_PAY_CAN_NOT_USE),(J=e.onCanUse)==null||J.call(e,K),P(K)},()=>{var K;p==null||p(Cn.APPLE_PAY_LOAD_ERROR),(K=e.onLoad)==null||K.call(e,!1),P(!1)})},[u]);const N=qe(V=>{var p;const k=V||f.get("common.payTimeout");d(k),g(k),(p=e.onTimeout)==null||p.call(e,"retry")},[f,e.onTimeout]),{start:S}=Xe(V=>A(!0,V),{onTimeout:()=>N(f.get("common.queryTimeout"))}),T=async(V,k,p)=>{var K,ie;const x=Z4(k==null?void 0:k.phoneNumber);return{sessionId:n.sessionId,clientKey:n.clientKey,bill:{firstName:k==null?void 0:k.givenName,lastName:k==null?void 0:k.familyName,addressLine1:(K=k==null?void 0:k.addressLines)==null?void 0:K[0],addressLine2:(ie=k==null?void 0:k.addressLines)==null?void 0:ie[1],state:k==null?void 0:k.administrativeArea,city:k==null?void 0:k.locality,postalCode:k==null?void 0:k.postalCode,areaCode:x==null?void 0:x.areaCode,phoneNumber:x==null?void 0:x.phoneNumber,email:(k==null?void 0:k.emailAddress)||(p==null?void 0:p.emailAddress)||(n==null?void 0:n.checkout.bill.email),country:k==null?void 0:k.countryCode},payment:{paymentMethod:G.APPLE_PAY,tokenData:JSON.stringify({token:V})},browser:await Je({fraudDetectionId:await(m==null?void 0:m.getFraudDetectionId())})}};async function A(V=!1,k,p,x,K){var ie,q,ne,W,J,se,z,X,Q;g("");try{const Y={locale:f.locale,timeout:k};let ee=null;if(V){const I=(q=(ie=r.config)._getExtraParams)==null?void 0:q.call(ie,"query",G.APPLE_PAY);ee=await S8({sessionId:n.sessionId,clientKey:n.clientKey,paymentMethod:G.APPLE_PAY},I,Y)}else{const I=(W=(ne=r.config)._getExtraParams)==null?void 0:W.call(ne,"payment",G.APPLE_PAY);ee=await P8(await T(p,x,K),I,Y)}const{status:re,orderStatus:ae,errorMessage:me,errorCode:l,sessionId:C}=ee;return C&&(n.sessionId=C),re===on.PROCESSING?ae===on.SUCCESS?(c(),b(ee),{end:!0}):ae===on.PROCESSING?(!V&&await S(),{end:!V}):ae===on.FAILURE?(me&&g(me),(J=e.onError)==null||J.call(e,new Ee("API_ERROR",me,{code:l})),d(me),{end:!0}):ae===on.AUTHORIZED?(c(),(se=e.onAuthorized)==null||se.call(e),{end:!0}):(d(),{end:!0}):re===on.SUCCESS?(c(),b(ee),{end:!0}):re===on.EXPIRED?((z=e.onExpired)==null||z.call(e),(X=o.current)==null||X.abort(),{end:!0}):(d(),{end:!0})}catch(Y){if(We(Y))return V?{end:!1}:(N(),{end:!0});{const ee=Y.i18nKey?f.get(Y.i18nKey):Y.message;return ee&&g(ee),(Q=e.onError)==null||Q.call(e,new Ee("API_ERROR",ee,{code:Y.code,cause:Y})),d(ee),{end:!0}}}}const R=()=>{var x,K,ie,q,ne;const V=n==null?void 0:n.checkout,{applePay:k}=(V==null?void 0:V.channelParams)??{},p=[...((x=E.request)==null?void 0:x.requiredBillingContactFields)||[]];return((K=V==null?void 0:V.bill)==null?void 0:K.billingAddressCollection)==="REQUIRED"&&p.push("postalAddress"),{merchantCapabilities:["supports3DS"],countryCode:(k==null?void 0:k.countryCode)??"",requiredBillingContactFields:p,requiredShippingContactFields:(ie=E.request)==null?void 0:ie.requiredShippingContactFields,currencyCode:(V==null?void 0:V.transAmount.currency)??"",supportedNetworks:((ne=(q=k==null?void 0:k.supportedNetworks)==null?void 0:q.map)==null?void 0:ne.call(q,W=>H4(W)))??[],total:{label:(V==null?void 0:V.theme.merchantName)??"",type:"final",amount:String(V==null?void 0:V.transAmount.amount)}}},y=()=>{var p,x;const{onEvent:V}=e.core.config;if(V==null||V(Cn.APPLE_PAY_BUTTON_CLICKED),(p=e.onBtnClick)==null||p.call(e),!ApplePaySession)return;const k=R();console.warn("ApplePay Request",k),s({request:k,onValidate:async()=>{var ie;V==null||V(Cn.APPLE_PAY_VALIDATE_MERCHANT);const K=await E8();(ie=o.current)==null||ie.completeMerchantValidation(K)},onAuthorized:async K=>{var W;V==null||V(Cn.APPLE_PAY_AUTHORIZED),(W=e.onSubmit)==null||W.call(e);const{token:ie,billingContact:q,shippingContact:ne}=(K==null?void 0:K.payment)||{};console.warn("ApplePay Res",K==null?void 0:K.payment),A(!1,void 0,ie,q,ne)},onCancel:()=>{var K;V==null||V(Cn.APPLE_PAY_CANCELLED),(K=e.onCancel)==null||K.call(e)}}),(x=o.current)==null||x.begin()},_=()=>{var p,x;const V=(p=E.button)==null?void 0:p.buttonStyle,k=(x=E.button)==null?void 0:x.buttonType;return i("div",{className:hc("button"),children:v?i(he,{children:i("apple-pay-button",{buttonstyle:V,type:k,onClick:y})}):i("button",{onClick:y,style:{"-webkit-appearance":"-apple-pay-button","-apple-pay-button-style":V,"-apple-pay-button-type":k,width:"100%",height:"44px",minHeight:"44px",border:"none",borderRadius:"6px",cursor:"pointer"}})})};return i("div",{children:u&&w&&f.ready.value&&i(he,{children:[!!h&&i(nt,{className:hc("error"),content:h}),i(_,{})]})})});function Eu(e,n,t,r,a){const{transAmount:o,theme:{merchantName:s}}=e,{googlePay:c}=(e==null?void 0:e.channelParams)??{},d={apiVersion:2,apiVersionMinor:0},f={type:"PAYMENT_GATEWAY",parameters:{gateway:c==null?void 0:c.providerGatewayId,gatewayMerchantId:c==null?void 0:c.merchantGatewayId}},u=(c==null?void 0:c.allowedCardNetworks)??[],h={type:"CARD",parameters:{allowedAuthMethods:(c==null?void 0:c.allowedAuthMethods)??[],allowedCardNetworks:u,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}};function g(){return Object.assign({},d,{allowedPaymentMethods:[h]})}const w=Object.assign({tokenizationSpecification:f},h);function P(){return{countryCode:c==null?void 0:c.countryCode,currencyCode:o.currency,totalPriceStatus:"FINAL",totalPrice:String(o.amount),totalPriceLabel:"Total"}}let E;function v(){const R=Object.assign({},d);return R.emailRequired=!0,R.allowedPaymentMethods=[w],R.transactionInfo=P(),R.merchantInfo={merchantId:c==null?void 0:c.googlePayMerchantId,merchantName:s},R.callbackIntents=["PAYMENT_AUTHORIZATION"],R}function b(){return E||(E=new google.payments.api.PaymentsClient({environment:c==null?void 0:c.environment,paymentDataCallbacks:{onPaymentAuthorized:N}})),E}function N(R){return new Promise(function(y){var W,J;R.paymentMethodData.tokenizationData.token,(W=R.paymentMethodData.info)==null||W.billingAddress;const{name:_,address1:V,address2:k,address3:p,countryCode:x,administrativeArea:K,locality:ie,postalCode:q,phoneNumber:ne}=((J=R.paymentMethodData.info)==null?void 0:J.billingAddress)??{};console.warn("GooglePay Res",R.paymentMethodData),t(R.paymentMethodData.tokenizationData.token,{email:R.email,name:_,address1:V,address2:k,address3:p,countryCode:x??"",administrativeArea:K??"",locality:ie??"",postalCode:q??"",phoneNumber:ne??""}).then(se=>{y(se==null?void 0:se.res)})})}function S(R){b().isReadyToPay(g()).then(function(_){_.result?(T(R),a==null||a(!0)):a==null||a(!1)}).catch(function(_){console.error(_)})}function T(R){const _=b().createButton({...n==null?void 0:n.button,onClick:A,allowedPaymentMethods:[h]});R==null||R.appendChild(_)}function A(){r==null||r();const R=v();R.transactionInfo=P(),b().loadPaymentData(R)}return{onGooglePayLoaded:S}}const Pu=(e,n)=>{var t;if((t=window.google)!=null&&t.payments){e==null||e();return}eo({src:"https://pay.google.com/gp/p/js/pay.js",onload:e,onerror:n,extraOptions:{async:!0}})},{bem:Su}=_e("google-pay"),Iu={button:{buttonColor:"default",buttonType:"pay",buttonRadius:8,buttonSizeMode:"fill",buttonBorderType:"default_border"}},yc=Fe((e,n)=>{var q;const{session:t,threeDSFrame:r,isDropIn:a,core:o}=e,s=L1(Iu,e.config||{});Be(n,()=>({checkThreeDS:x}));const{sessionReady:c,i18n:d,fraudDetection:f}=et(t,e.core),[u,m]=O(""),[h,g]=O(!1),[w,P]=O(!1),[E,v]=O(),[b,N]=O(!0),S=qe(ne=>{var W;m(ne||d.get("common.payTimeout")),(W=e.onTimeout)==null||W.call(e,"retry")},[d,e.onTimeout]),T=ne=>{var W,J;(J=e.onSuccess)==null||J.call(e,ft({...ne,returnUrl:(W=t==null?void 0:t.checkout)==null?void 0:W.returnUrl}))};Ce(()=>{var se,z;if(!c)return;const{status:ne,supportMethods:W=[],sessionMode:J}=(t==null?void 0:t.checkout)||{};if(J===Ue.DROP_IN&&!a){(z=(se=e.core.config).onInitError)==null||z.call(se,new Ee("ERROR","Please send the correct session when creating the checkout"));return}W.includes(G.GOOGLE_PAY)&&(Pu(()=>{var X;g(!0),(X=e.onLoad)==null||X.call(e,!0)},()=>{var X;g(!1),(X=e.onLoad)==null||X.call(e,!1)}),N(J===Ue.HOSTED),ne==="SUCCESS"&&T(t==null?void 0:t.checkout))},[c]);const A=(ne,W)=>{var J;b?(J=e.onThreeDS)==null||J.call(e,ne,W):(P(!0),v({url:ne,incomplete:W,width:r==null?void 0:r.modalWidth,height:r==null?void 0:r.modalHeight}))},R=()=>{P(!1),v(void 0),x()},{start:y}=Xe(async ne=>await V(void 0,void 0,!0,ne),{onTimeout:()=>S(d.get("common.queryTimeout"))}),_=async(ne,W)=>{const J=U4(W==null?void 0:W.phoneNumber);return{sessionId:t.sessionId,clientKey:t.clientKey,payment:{paymentMethod:G.GOOGLE_PAY,tokenData:ne??""},bill:{firstName:W==null?void 0:W.name,addressLine1:W==null?void 0:W.address1,addressLine2:(W==null?void 0:W.address2)??""+(W==null?void 0:W.address3)??"",country:W==null?void 0:W.countryCode,state:W==null?void 0:W.administrativeArea,city:W==null?void 0:W.locality,email:W==null?void 0:W.email,postalCode:W==null?void 0:W.postalCode,phoneNumber:J==null?void 0:J.phoneNumber,areaCode:J==null?void 0:J.areaCode},browser:await Je({fraudDetectionId:await(f==null?void 0:f.getFraudDetectionId())})}};async function V(ne,W,J=!1,se){var z,X,Q,Y,ee,re,ae,me,l;m(""),J||(z=e.onSubmit)==null||z.call(e);try{const C={locale:d.locale,timeout:se};let I=null;if(J){const F=(Q=(X=o.config)._getExtraParams)==null?void 0:Q.call(X,"query",G.GOOGLE_PAY);I=await F2({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.GOOGLE_PAY},F,C)}else{const F=(ee=(Y=o.config)._getExtraParams)==null?void 0:ee.call(Y,"payment",G.GOOGLE_PAY);I=await I8(await _(ne,W),F,C)}const{status:j,orderStatus:we,errorMessage:pe,payInfo:U={},errorCode:Z,sessionId:B}=I,{threeDSUrl:M}=U;if(B&&(t.sessionId=B),j==="PROCESSING"){if(we==="SUCCESS")return T(I),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="PROCESSING"){const F=await y();return(F==null?void 0:F.end)===!0?{end:!0,res:F.res}:await y()}else{if(we==="FAILURE")return pe&&m(pe),(re=e.onError)==null||re.call(e,new Ee("API_ERROR",pe,{code:Z})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:pe||"",reason:"OTHER_ERROR"}}};if(we==="AUTHORIZED")return(ae=e.onAuthorized)==null||ae.call(e),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="IN_THREED")return M&&A(M,!1),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="IN_PREVIOUS_THREED")return M&&A(M,!0),{end:!0,res:{transactionState:"SUCCESS"}};if(!we)return{end:!0,res:{transactionState:"SUCCESS"}}}}else{if(j==="SUCCESS")return T(I),{end:!0,res:{transactionState:"SUCCESS"}};if(j==="EXPIRED")return(me=e.onExpired)==null||me.call(e),{end:!0,res:{transactionState:"SUCCESS"}}}return T(I),{end:!1,res:{transactionState:"SUCCESS"}}}catch(C){if(We(C))return J?{end:!1}:(S(),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:d.get("common.payTimeout"),reason:"OTHER_ERROR"}}});{const I=C.i18nKey?d.get(C.i18nKey):C.message;return m(I),(l=e.onError)==null||l.call(e,new Ee("API_ERROR",I,{code:C.code,cause:C})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:I,reason:"OTHER_ERROR"}}}}}}const{start:k,stop:p}=Xe(()=>x(!0),{timeout:12*1e3,onTimeout:()=>S(d.get("common.queryTimeout"))});async function x(ne=!1){var W,J,se,z,X;if(!t)return{end:!0};try{const Q=(J=(W=o.config)._getExtraParams)==null?void 0:J.call(W,"query",G.GOOGLE_PAY),Y=await F2({sessionId:t.sessionId,clientKey:t.clientKey},Q,{locale:d.locale}),{status:ee,orderStatus:re,errorMessage:ae}=Y;if(ee==="PROCESSING"){if(re==="PROCESSING")y();else if(re==="FAILURE")ae&&m(ae);else if(re==="AUTHORIZED")(se=e.onAuthorized)==null||se.call(e);else{if(re==="IN_THREED")return!ne&&k(),{end:!1};re==="IN_PREVIOUS_THREED"&&m(d.get("common.pay3DSIncomplete"))}return p(),{end:!0}}else{if(ee==="SUCCESS")return T(Y),p(),{end:!0};if(ee==="EXPIRED")return(z=e.onExpired)==null||z.call(e),p(),{end:!0}}return T(Y),p(),{end:!0}}catch(Q){if(We(Q))return ne?{end:!1}:(S(d.get("common.queryTimeout")),{end:!0});{const Y=Q.i18nKey?d.get(Q.i18nKey):Q.message;return m(Y),(X=e.onError)==null||X.call(e,new Ee("API_ERROR",Y,{code:Q.code,cause:Q})),{end:!0}}}}const K=$(null);Ce(()=>{if(K&&(t!=null&&t.checkout)&&h){const{onGooglePayLoaded:ne}=Eu(t==null?void 0:t.checkout,s,V,e.onBtnClick,e.onCanUse);ne(K.current)}},[c,K,d.ready.value,h]);const ie=()=>i("div",{style:"width: 100%; height: 44px",children:i("div",{id:"container",style:"width:100%; height: 44px",ref:K})});return i("div",{children:c&&h&&d.ready.value&&i(he,{children:[!!u&&i(nt,{className:Su("error"),content:u}),ie(),i(lc,{show:w,theme:(q=t==null?void 0:t.checkout)==null?void 0:q.theme,checkoutId:o.id,...E,onClose:R})]})})}),_u=11,ko=14,Dr=18,Ru=e=>e.length<=_u?e.replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"):e.replace(/^(\d{2})(\d)/,"$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3").replace(/\.(\d{3})(\d)/,".$1/$2").replace(/(\d{4})(\d{1,2})$/,"$1-$2"),gc=e=>{const{currentTarget:n}=e,t=n,r=t.selectionStart,a=t.value,o=Xt(a).slice(0,ko),s=Lu(a,r),c=Ru(o),d=Nu(c,s);return{value:c,cursorPosition:d}},Lu=(e,n)=>{let t=0;for(let r=0;r<n&&r<e.length;r++)/\d/.test(e[r])&&t++;return t},Nu=(e,n)=>{let t=0;for(let r=0;r<e.length;r++)if(/\d/.test(e[r])){if(t===n)return r;t++}return e.length},Mu=()=>{let e;const n=$(""),[t,r]=O("");let a,o;const[s,c]=O(void 0),d=N=>{e=N.fieldType,a=tr(N.supportedCardBrands),o=zi(a)},f=()=>{let N={maxLength:0,onInput:S=>{}};switch(e){case Oe.CVV:{N={maxLength:4,inputMode:"numeric",onInput:u,validator:w};break}case Oe.CARD_NUMBER:{N={maxLength:23,inputMode:"numeric",onInput:m,validator:P};break}case Oe.EXPIRE_DATE:{N={maxLength:5,inputMode:"numeric",onInput:h,validator:E};break}case R1.CPF:{N={maxLength:Dr,inputMode:"numeric",onInput:g,validator:v};break}}return N},u=N=>{const S=N.currentTarget,T=Xt(S.value);n.current=S.value=T},m=N=>{var V;const{inputType:S}=N,T=N.currentTarget,A=T.selectionStart;let R=Xt(T.value);R=R.replace(/(\d{4})(?=\d)/g,"$1 ");let y=A;y%5===0&&(y=N1(A+(S==="insertText"?1:-1),0)),n.current=T.value=R,T.setSelectionRange(y,y);const _=Yt(T.value).substring(0,6);r(_.length<6?"":_),c((V=b(Yt(T.value)))==null?void 0:V.code)},h=N=>{const{inputType:S}=N,T=N.currentTarget,A=T.selectionStart;let R;if(S==="insertText")R=rc(N);else if(S==="insertFromPaste")R=ac(N);else{R=T.value;const y=n.current.slice(A,A+1),_=n.current.length;if(_>3&&y==="/"){n.current=T.value=n.current,T.setSelectionRange(A,A);return}else if(A===1){const V=n.current.slice(0,2);_>2&&+V>=10?R=`01${n.current.slice(2,_)}`:R=R.slice(0,1)}else if(A===0&&R.length>1){y==="0"?n.current=T.value=n.current:y==="1"&&(n.current=T.value=`0${R}`),T.setSelectionRange(0,0);return}else if(A===3)if(_===4)R=R.slice(0,2);else{n.current=T.value=R,T.setSelectionRange(A-1,A-1);return}}n.current=T.value=R,S!=="insertText"&&T.setSelectionRange(A+1,A+1)},g=N=>{const S=N.currentTarget,{value:T,cursorPosition:A}=gc(N);n.current=S.value=T,S.setSelectionRange(A,A)},w=()=>{if(Ie(n.current)||n.current.length<3)throw new Error("card.cardSecurityCode.incomplete");return!0},P=()=>{const N=Yt(n.current??"");if(!o.includes(N.length))throw new Error("card.cardNumber.incomplete");if(!b(N))throw new Error("card.cardNumber.invalid");return!0},E=()=>{if(Ie(n.current)||n.current.length!==5)throw new Error("card.cardExpireDate.incomplete");if(n2(n.current))throw new Error("card.cardExpireDate.expired");return!0},v=()=>{if(Ie(n.current)||![ko,Dr].includes(n.current.length))throw new Error("cpf.incomplete");return!0},b=N=>Ki(N,a);return{value:n,cardBin:t,initSecuredInput:d,getConfigByFieldType:f,getCurrCardBrand:b,brand:s}},Lt=G4("input"),Tu=e=>{const{checkoutId:n}=e,t=window.parent.frames[e.hiddenIframeName],r=$(null),{initSecuredInput:a,getConfigByFieldType:o,getCurrCardBrand:s,cardBin:c,value:d,brand:f}=Mu(),[u,m]=O(!1),h="securedInput",g=()=>{a({fieldType:e.fieldType,supportedCardBrands:e.supportedCardBrands}),w(e.style)},w=(y={})=>{const{base:_,hover:V,focus:k,valid:p,invalid:x,placeholder:K}=y,ie=`input { ${Vn(_)} }`,q=`input.${Lt.hover} { ${Vn(V)} }`,ne=`input.${Lt.focus} { ${Vn(k)} }`,W=`input.${Lt.valid} { ${Vn(p)} }`,J=`input.${Lt.invalid} { ${Vn(x)} }`,se=js("input",K==null?void 0:K.base),z=js(`input.${Lt.focus}`,K==null?void 0:K.focus),X=`
14
+ `);var Oe=(e=>(e.CARD_NUMBER="CARD_NUMBER",e.CVV="CVV",e.EXPIRE_DATE="EXPIRE_DATE",e))(Oe||{}),R1=(e=>(e.CPF="CPF",e))(R1||{});const Ws="data-sf",Qs="secured-iframe",Y4="hidden-pay-iframe",j4="field-pay-iframe",q4="three-ds-iframe",Ks=e=>{const n=document.createElement("iframe");n.setAttribute("src",e),n.classList.add(Qs),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},mt=(e,n,t="*")=>{if(!n||n===window)return;const r=typeof e=="string"?e:JSON.stringify(e);n==null||n.postMessage(r,{targetOrigin:t})},W4=e=>typeof window>"u"?null:new URLSearchParams(window.location.search).get(e),Q4=(e,n)=>{const t=new URL(e);return Object.entries(n).forEach(([r,a])=>{t.searchParams.append(r,String(a))}),t.toString()},$a=e=>{try{const n=new URL(e),t={};return n.searchParams.forEach((a,o)=>{t[o]=a}),{baseUrl:n.origin+n.pathname,params:t,origin:n.origin}}catch{return{baseUrl:e,params:{},origin:""}}},It=e=>{const{requestMethod:n,targetUrl:t}=e;if(t)if(n==="GET")K4(t,{});else{const{baseUrl:r,params:a}=$a(t);z4(r,a)}},K4=(e,n)=>{const t=Q4(e,n);window.location.href=t},z4=(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()},zs=(e,n)=>{const t=e.indexOf(n);t!==-1&&e.splice(t,1)},J4=(e,n=document.createElement("div"))=>"on"+e in n,Js="MM/DD/YYYY",X4=`${Js} HH:mm:ss`,Xs={date:Js,datetime:X4},$4=(e,n="datetime")=>{if(!e&&e!==0)return"-";n in Xs&&(n=Xs[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()))},e5=e=>Ln(e)?e.split("."):e;function $s(e,n,t){const r=e5(n);if(!r.length)return;let a=e;const o=r.pop();for(let s=0,c=r.length;s<c;s++){const d=r[s];if(Dt(a[d])){const f=(r==null?void 0:r[s+1])??o;a[d]=hl(f)?[]:{}}a=a[d]}a[o]=t}const L1=(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]=L1(t[r],n[r]):t[r]=n[r];return t};function e2(e){const n={...e};for(const t of Object.keys(n))La(n[t])&&(n[t]=e2(n[t]));return Object.freeze(n)}const t5="^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$",yr=(e,n)=>{var a,o,s,c,d,f,u,m,h,g,w;const{status:t,orderStatus:r}=e;switch(t){case"PROCESSING":{switch(r){case"PROCESSING":{(a=n.onProcessing)==null||a.call(n);break}case"AUTHORIZED":{(o=n.onAuthorized)==null||o.call(n);break}case"IN_THREED":{(s=n.onInThreeDS)==null||s.call(n);break}case"IN_PREVIOUS_THREED":{(c=n.onInPreviousThreeDS)==null||c.call(n);break}case"CANCELED":{(d=n.onCanceled)==null||d.call(n);break}case"SUCCESS":{(f=n.onSuccess)==null||f.call(n);break}case"FAILURE":{(u=n.onFailure)==null||u.call(n);break}default:{(m=n.onDefault)==null||m.call(n);break}}break}case"SUCCESS":{(h=n.onSuccess)==null||h.call(n);break}case"EXPIRED":{(g=n.onExpired)==null||g.call(n);break}default:{(w=n.onDefault)==null||w.call(n);break}}},ft=e=>{var n,t,r;return{returnUrl:e==null?void 0:e.returnUrl,sessionId:e==null?void 0:e.sessionId,merchantId:e==null?void 0:e.merchantId,orderId:e==null?void 0:e.orderId,errorCode:e==null?void 0:e.errorCode,errorMessage:e==null?void 0:e.errorMessage,transAmount:e==null?void 0:e.transAmount,status:e==null?void 0:e.status,orderStatus:e==null?void 0:e.orderStatus,paymentMethod:e==null?void 0:e.paymentMethod,finishTime:e==null?void 0:e.finishTime,payInfo:{threeDSUrl:(n=e==null?void 0:e.payInfo)==null?void 0:n.threeDSUrl,paymentUrl:(t=e==null?void 0:e.payInfo)==null?void 0:t.paymentUrl,paymentExpiredAt:(r=e==null?void 0:e.payInfo)==null?void 0:r.paymentExpiredAt,...e==null?void 0:e.payInfo},rawResponse:e==null?void 0:e.rawResponse}},n5=(e={})=>Object.entries(e).map(([n,t])=>Dt(t)?"":`${n}: ${t};`).join(""),t2=(e=12)=>{let n="";for(;n.length<e;)n+=Math.random().toString(36).slice(2);return n.slice(0,e)},eo=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)};function r5(e,n){return n?e:void 0}function N1(e,n,t){return Ie(n)||(e=Math.max(e,n)),Ie(t)||(e=Math.min(e,t)),e}const M1=(e,n={})=>{try{return JSON.parse(e)}catch{return n}},a5=(e,n="")=>{try{return JSON.stringify(e)}catch{return n}};function n2(e){const[n,t]=e.split("/").map(Number);return new Date(+`20${t}`,n-1)<new Date}const Kn=(...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},o5=()=>Object.entries(Object.assign({"./de-DE.ts":()=>Promise.resolve().then(()=>x6),"./en-GB.ts":()=>Promise.resolve().then(()=>i5),"./es-ES.ts":()=>Promise.resolve().then(()=>O6),"./fr-FR.ts":()=>Promise.resolve().then(()=>F6),"./ja-JP.ts":()=>Promise.resolve().then(()=>B6),"./ko-KR.ts":()=>Promise.resolve().then(()=>H6),"./nl-NL.ts":()=>Promise.resolve().then(()=>U6),"./pt-PT.ts":()=>Promise.resolve().then(()=>Z6),"./ru-RU.ts":()=>Promise.resolve().then(()=>G6),"./zh-CN.ts":()=>Promise.resolve().then(()=>Y6),"./zh-HK.ts":()=>Promise.resolve().then(()=>j6),"./zh-TW.ts":()=>Promise.resolve().then(()=>q6)})).reduce((e,[n,t])=>{const r=n.match(/\.\/(.+)\./)[1];return e[r]=t,e},{});var Dn=(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))(Dn||{});const r2={"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":"Maya","dropIn.zalopay.label":"Zalopay","dropIn.vietqr.label":"VietQR","dropIn.pix.label":"Pix","dropIn.picPay.label":"PicPay","dropIn.opayWallet.label":"OPay Wallet","dropIn.pagaWallet.label":"Paga Wallet","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","qrCode.scanByZalopay":"Scan QR code with Zalopay","qrCode.scanByVietqr":"Scan QR code with VietQR","cpf.label":"CPF/CNPJ","cpf.incomplete":"Your CPF/CNPJ is incomplete","cpf.placeholder":"123.456.789-00",iofTip:"This is a International purchase. IOF fees may be charged by your card issuer. Final amount depends on your bank statement."},i5=Object.freeze(Object.defineProperty({__proto__:null,default:r2},Symbol.toStringTag,{value:"Module"}));function a2(e){return e.replaceAll("_","-").toLowerCase()}function o2(e){return e.split("-")[0]}const s5=()=>Object.entries(o5()).map(([e,n])=>({locale:a2(e),language:o2(e),translation:n}));function c5(e){return s5()}function i2(e,n){var a,o;const t=c5();e=a2(e);let r=(a=t.find(s=>s.locale===e))==null?void 0:a.translation;if(!r){const s=o2(e);r=(o=t.find(c=>c.language===s))==null?void 0:o.translation}return r}const d5=e=>{let n=s2(e);return n||(n=s2(gn().language)),n||Dn.enGB},s2=e=>{if(Object.values(Dn).includes(e))return e;if(e!=null&&e.toLowerCase().startsWith("en"))return Dn.enGB;if(e!=null&&e.toLowerCase().startsWith("zh"))return Dn.zhCN};async function l5(e,n){let t=i2(e);if(!t&&e!==gn().language&&(e=gn().language,t=i2(e)),Hi(t)){const r=await t();return{locale:e,translation:r.default}}return t?{locale:e,translation:t}:{locale:Dn.enGB,translation:r2}}var u5=Symbol.for("preact-signals");function to(){if(zn>1)zn--;else{for(var e,n=!1;T1!==void 0;){var t=T1;for(T1=void 0,no++;t!==void 0;){var r=t.o;if(t.o=void 0,t.f&=-3,!(8&t.f)&&d2(t))try{t.c()}catch(a){n||(e=a,n=!0)}t=r}}if(no=0,zn--,n)throw e}}var Ye=void 0,T1=void 0,zn=0,no=0,gr=0;function c2(e){if(Ye!==void 0){var n=e.n;if(n===void 0||n.t!==Ye)return n={i:0,S:e,p:Ye.s,n:void 0,t:Ye,e:void 0,x:void 0,r:n},Ye.s!==void 0&&(Ye.s.n=n),Ye.s=n,e.n=n,32&Ye.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=Ye.s,n.n=void 0,Ye.s.n=n,Ye.s=n),n}}function vt(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}vt.prototype.brand=u5,vt.prototype.h=function(){return!0},vt.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)},vt.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)}},vt.prototype.subscribe=function(e){var n=this;return ao(function(){var t=n.value,r=Ye;Ye=void 0;try{e(t)}finally{Ye=r}})},vt.prototype.valueOf=function(){return this.value},vt.prototype.toString=function(){return this.value+""},vt.prototype.toJSON=function(){return this.value},vt.prototype.peek=function(){var e=Ye;Ye=void 0;try{return this.value}finally{Ye=e}},Object.defineProperty(vt.prototype,"value",{get:function(){var e=c2(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(no>100)throw new Error("Cycle detected");this.v=e,this.i++,gr++,zn++;try{for(var n=this.t;n!==void 0;n=n.x)n.t.N()}finally{to()}}}});function k1(e){return new vt(e)}function d2(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 l2(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 u2(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 Jn(e){vt.call(this,void 0),this.x=e,this.s=void 0,this.g=gr-1,this.f=4}(Jn.prototype=new vt).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===gr))return!0;if(this.g=gr,this.f|=1,this.i>0&&!d2(this))return this.f&=-2,!0;var e=Ye;try{l2(this),Ye=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 Ye=e,u2(this),this.f&=-2,!0},Jn.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)}vt.prototype.S.call(this,e)},Jn.prototype.U=function(e){if(this.t!==void 0&&(vt.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)}},Jn.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(Jn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=c2(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function m2(e){return new Jn(e)}function f2(e){var n=e.u;if(e.u=void 0,typeof n=="function"){zn++;var t=Ye;Ye=void 0;try{n()}catch(r){throw e.f&=-2,e.f|=8,ro(e),r}finally{Ye=t,to()}}}function ro(e){for(var n=e.s;n!==void 0;n=n.n)n.S.U(n);e.x=void 0,e.s=void 0,f2(e)}function m5(e){if(Ye!==this)throw new Error("Out-of-order effect");u2(this),Ye=e,this.f&=-2,8&this.f&&ro(this),to()}function V1(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}V1.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()}},V1.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,f2(this),l2(this),zn++;var e=Ye;return Ye=this,m5.bind(this,e)},V1.prototype.N=function(){2&this.f||(this.f|=2,this.o=T1,T1=this)},V1.prototype.d=function(){this.f|=8,1&this.f||ro(this)};function ao(e){var n=new V1(e);try{n.c()}catch(t){throw n.d(),t}return n.d.bind(n)}var oo;function Xn(e,n){be[e]=n.bind(null,be[e]||function(){})}function pr(e){oo&&oo(),oo=e&&e.S()}function h2(e){var n=this,t=e.data,r=h5(t);r.value=t;var a=Ht(function(){for(var o=n.__v;o=o.__;)if(o.__c){o.__c.__$f|=4;break}return n.__$u.c=function(){var s;!ri(a.peek())&&((s=n.base)==null?void 0:s.nodeType)===3?n.base.data=a.peek():(n.__$f|=1,n.setState({}))},m2(function(){var s=r.value.value;return s===0?0:s===!0?"":s||""})},[]);return a.value}h2.displayName="_st",Object.defineProperties(vt.prototype,{constructor:{configurable:!0,value:void 0},type:{configurable:!0,value:h2},props:{configurable:!0,get:function(){return{data:this}}},__b:{configurable:!0,value:1}}),Xn("__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 vt&&(t||(n.__np=t={}),t[a]=o,r[a]=o.peek())}}e(n)}),Xn("__r",function(e,n){pr();var t,r=n.__c;r&&(r.__$f&=-2,(t=r.__$u)===void 0&&(r.__$u=t=function(a){var o;return ao(function(){o=this}),o.c=function(){r.__$f|=1,r.setState({})},o}())),pr(t),e(n)}),Xn("__e",function(e,n,t,r){pr(),e(n,t,r)}),Xn("diffed",function(e,n){pr();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 s in o){var c=o[s];c!==void 0&&!(s in r)&&(c.d(),o[s]=void 0)}else t.U=o={};for(var d in r){var f=o[d],u=r[d];f===void 0?(f=f5(t,d,u,a),o[d]=f):f.o(u,a)}}}e(n)});function f5(e,n,t,r){var a=n in e&&e.ownerSVGElement===void 0,o=k1(t);return{o:function(s,c){o.value=s,r=c},d:ao(function(){var s=o.value.value;r[n]!==s&&(r[n]=s,a?e[n]=s:s?e.setAttribute(n,s):e.removeAttribute(n))})}}Xn("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 s=n.__c;if(s){var c=s.__$u;c&&(s.__$u=void 0,c.d())}}e(n)}),Xn("__h",function(e,n,t,r){(r<3||r===9)&&(n.__$f|=2),e(n,t,r)}),en.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 h5(e){return Ht(function(){return k1(e)},[])}const l1=class l1{constructor(){Ae(this,"locale");Ae(this,"translation");Ae(this,"isReady",k1(!1));Ae(this,"currentLoadId",0);return l1.instance||(l1.instance=this),l1.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=gn().language){if(n===this.locale)return;this.locale=n;const t=++this.currentLoadId;this.isReady.value=!1,l5(this.locale).then(r=>{t===this.currentLoadId&&(this.isReady.value=!0,this.locale=r.locale,this.translation=r.translation)}).catch(()=>{this.isReady.value=!1})}};Ae(l1,"instance");let vr=l1,io="https://checkout.aq.paykka.com",jt="https://checkout.aq.paykka.com",br="/cp",$n=`${jt}${br}`,so,C2={},y2,Re="/session";const e1=e=>{io=e},t1=e=>{const n=new URL(e);jt=n.origin,br=n.pathname,$n=`${jt}${br==="/"?"":br}`},g2=e=>{so=e},C5=e=>{C2=e},p2=e=>{y2=e},co=e=>{Re=e},ze=X1(null),v2=new WeakMap,Ar=(e,n)=>{const t=Object.assign(v2.get(e)??{},n);return v2.set(e,t),t};function xn(e,n){const t={},r={updateProps:f,mount:u,unmount:m,get props(){return e2(o)},ref:t},a=e,o={...n},s=Ar(r,{vNode:c(),render:d});function c(){return Un(a,{...o,ref:h=>{Object.assign(t,h)}})}function d(){Ar(r,{vNode:c()}),s.dom&&J1(s.vNode,s.dom)}function f(h){Object.assign(o,h),d()}function u(h){const g=Ln(h)?document.querySelector(h):h;if(!g)throw new Error("Component could not mount. Root node was not found.");return m(),Ar(r,{dom:g}),d(),r}function m(){const{dom:h}=s;return h&&(J1(null,h),Ar(r,{dom:null})),r}return r}var n1=(e=>(e.ERROR="ERROR",e.API_ERROR="API_ERROR",e.TIMEOUT="TIMEOUT",e))(n1||{});class Ee extends Error{constructor(t,r,a){super(r);Ae(this,"type");Ae(this,"code");this.type=t,this.code=a==null?void 0:a.code,this.cause=a==null?void 0:a.cause}}const b2=async(e,n={},t)=>b8(e,n,t);class A2{constructor(n,t={}){Et(this,da);Et(this,la);Ae(this,"sessionId");Ae(this,"clientKey");Ae(this,"paykkaDetectionKey");Ae(this,"checkout");Ae(this,"theme",k1({}));Ae(this,"extraParams",{});Et(this,u1,kn());const{sessionId:r,clientKey:a}=n;this.sessionId=r,this.clientKey=a,this.extraParams=t,ga(this,da,Od).call(this)}ready(){return Ne(this,u1)}}u1=new WeakMap,da=new WeakSet,Od=async function(){try{await ga(this,la,Fd).call(this),Ne(this,u1).resolve(!0)}catch(n){const t=We(n)?n:new Ee("API_ERROR",n.message,{code:n.code});Ne(this,u1).reject(t)}},la=new WeakSet,Fd=async function(){this.checkout=await b2({sessionId:this.sessionId,clientKey:this.clientKey},this.extraParams);const{sessionId:n,clientKey:t}=this.checkout||{};this.sessionId=n,t&&(this.paykkaDetectionKey=t)};const w2={eu:"https://checkout.eu.paykka.com",hk:"https://checkout.aq.paykka.com",sandbox:"https://checkout-sandbox.aq.paykka.com",fat:"",dev:""},E2={eu:"https://checkout.eu.paykka.com/cp",hk:"https://checkout.aq.paykka.com/cp",sandbox:"https://checkout-sandbox.aq.paykka.com/cp",fat:"",dev:""},y5=e=>{let n="WEB";const t=window.navigator.userAgent.toLowerCase();return e==="MOBILE"&&(t.includes("miniprogram")?n="MINI_APP":t.includes("micromessenger")||t.includes("alipay")?n="IN_APP_WAP":p4(t)?n="APP":n="WAP"),n},g5=async(e={})=>{var o,s;const{fraudDetectionId:n,origin:t}=e,r=await b4(),a=y5(r.deviceType);return{origin:btoa(t||window.location.origin),referer:btoa(document.referrer||((s=(o=window.frames)==null?void 0:o.top)==null?void 0:s.document.referrer)||""),user_agent:r.userAgent,color_depth:r.colorDepth,language:r.language,java_enabled:r.javaEnabled,device_type:r.deviceType,timezone_offset:r.timezoneOffset,screen_height:r.screenHeight,screen_width:r.screenWidth,cookies:r.cookies,device_os:r.osName,terminal_type:a,fraud_detection_id:n,app_version:"0.13.14"}},Je=async(e={})=>({...await g5(e),device_finger_print_id:await _s()}),p5=async(e,n)=>{const{channel:t,browser:r}=e;return Se.post("/pub/channel/sdk/config",{browser:r,channel_code_list:[...t.map(a=>({channel_code:a}))]},n).then(a=>{const{stripe:o,world_pay:s}=a||{};return{stripe:{key:(o==null?void 0:o.public_key)||""},worldPay:{authCode:(s==null?void 0:s.auth_code)||"",ddcCollectUrl:(s==null?void 0:s.channel_collect_url)||""}}})},v5=async e=>Se.post("/pub/fraud-detection/report/urls",{client_key:e.clientKey,fraud_detection_mode:e.fraudDetectionMode,data:e.data}),b5={organizationId:"dzppsd1h",profilingDomain:"ddc.worldpay.com"},A5={organizationId:"afevfjm6",profilingDomain:"ddc-test.worldpay.com"},w5="https://js.stripe.com/v3/",E5=1e4;/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */function P5(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function S5(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function bt(e,n,t=""){const r=P5(e),a=e==null?void 0:e.length,o=n!==void 0;if(!r||o&&a!==n){const s=t&&`"${t}" `,c=o?` of length ${n}`:"",d=r?`length=${a}`:`type=${typeof e}`;throw new Error(s+"expected Uint8Array"+c+", got "+d)}return e}function wr(e,n=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(n&&e.finished)throw new Error("Hash#digest() has already been called")}function P2(e,n){bt(e,void 0,"output");const t=n.outputLen;if(e.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function I5(e){return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}function dn(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ln(...e){for(let n=0;n<e.length;n++)e[n].fill(0)}function Er(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}const _5=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function R5(...e){let n=0;for(let r=0;r<e.length;r++){const a=e[r];bt(a),n+=a.length}const t=new Uint8Array(n);for(let r=0,a=0;r<e.length;r++){const o=e[r];t.set(o,a),a+=o.length}return t}function L5(e,n){if(e.length!==n.length)return!1;let t=0;for(let r=0;r<e.length;r++)t|=e[r]^n[r];return t===0}const N5=(e,n)=>{function t(r,...a){if(bt(r,void 0,"key"),!_5)throw new Error("Non little-endian hardware is not yet supported");if(e.nonceLength!==void 0){const u=a[0];bt(u,e.varSizeNonce?void 0:e.nonceLength,"nonce")}const o=e.tagLength;o&&a[1]!==void 0&&bt(a[1],void 0,"AAD");const s=n(r,...a),c=(u,m)=>{if(m!==void 0){if(u!==2)throw new Error("cipher output not supported");bt(m,void 0,"output")}};let d=!1;return{encrypt(u,m){if(d)throw new Error("cannot encrypt() twice with same key + nonce");return d=!0,bt(u),c(s.encrypt.length,m),s.encrypt(u,m)},decrypt(u,m){if(bt(u),o&&u.length<o)throw new Error('"ciphertext" expected length bigger than tagLength='+o);return c(s.decrypt.length,m),s.decrypt(u,m)}}}return Object.assign(t,e),t};function M5(e,n,t=!0){if(n===void 0)return new Uint8Array(e);if(n.length!==e)throw new Error('"output" expected Uint8Array of length '+e+", got: "+n.length);if(t&&!Pr(n))throw new Error("invalid output, must be aligned");return n}function T5(e,n,t){const r=new Uint8Array(16),a=Er(r);return a.setBigUint64(0,BigInt(n),t),a.setBigUint64(8,BigInt(e),t),r}function Pr(e){return e.byteOffset%4===0}function On(e){return Uint8Array.from(e)}function k5(e=32){const n=typeof globalThis=="object"?globalThis.crypto:null;if(typeof(n==null?void 0:n.getRandomValues)!="function")throw new Error("crypto.getRandomValues must be defined");return n.getRandomValues(new Uint8Array(e))}function V5(e,n=k5){const{nonceLength:t}=e;S5(t);const r=(a,o)=>{const s=R5(a,o);return o.fill(0),s};return(a,...o)=>({encrypt(s){bt(s);const c=n(t),d=e(a,c,...o).encrypt(s);return d instanceof Promise?d.then(f=>r(c,f)):r(c,d)},decrypt(s){bt(s);const c=s.subarray(0,t),d=s.subarray(t);return e(a,c,...o).decrypt(d)}})}const un=16,lo=new Uint8Array(16),tn=dn(lo),D5=225,x5=(e,n,t,r)=>{const a=r&1;return{s3:t<<31|r>>>1,s2:n<<31|t>>>1,s1:e<<31|n>>>1,s0:e>>>1^D5<<24&-(a&1)}},qt=e=>(e>>>0&255)<<24|(e>>>8&255)<<16|(e>>>16&255)<<8|e>>>24&255|0;function O5(e){e.reverse();const n=e[15]&1;let t=0;for(let r=0;r<e.length;r++){const a=e[r];e[r]=a>>>1|t,t=(a&1)<<7}return e[0]^=-n&225,e}const F5=e=>e>64*1024?8:e>1024?4:2;class S2{constructor(n,t){Ae(this,"blockLen",un);Ae(this,"outputLen",un);Ae(this,"s0",0);Ae(this,"s1",0);Ae(this,"s2",0);Ae(this,"s3",0);Ae(this,"finished",!1);Ae(this,"t");Ae(this,"W");Ae(this,"windowSize");bt(n,16,"key"),n=On(n);const r=Er(n);let a=r.getUint32(0,!1),o=r.getUint32(4,!1),s=r.getUint32(8,!1),c=r.getUint32(12,!1);const d=[];for(let w=0;w<128;w++)d.push({s0:qt(a),s1:qt(o),s2:qt(s),s3:qt(c)}),{s0:a,s1:o,s2:s,s3:c}=x5(a,o,s,c);const f=F5(t||1024);if(![1,2,4,8].includes(f))throw new Error("ghash: invalid window size, expected 2, 4 or 8");this.W=f;const m=128/f,h=this.windowSize=2**f,g=[];for(let w=0;w<m;w++)for(let P=0;P<h;P++){let E=0,v=0,b=0,N=0;for(let S=0;S<f;S++){if(!(P>>>f-S-1&1))continue;const{s0:A,s1:R,s2:y,s3:_}=d[f*w+S];E^=A,v^=R,b^=y,N^=_}g.push({s0:E,s1:v,s2:b,s3:N})}this.t=g}_updateBlock(n,t,r,a){n^=this.s0,t^=this.s1,r^=this.s2,a^=this.s3;const{W:o,t:s,windowSize:c}=this;let d=0,f=0,u=0,m=0;const h=(1<<o)-1;let g=0;for(const w of[n,t,r,a])for(let P=0;P<4;P++){const E=w>>>8*P&255;for(let v=8/o-1;v>=0;v--){const b=E>>>o*v&h,{s0:N,s1:S,s2:T,s3:A}=s[g*c+b];d^=N,f^=S,u^=T,m^=A,g+=1}}this.s0=d,this.s1=f,this.s2=u,this.s3=m}update(n){wr(this),bt(n),n=On(n);const t=dn(n),r=Math.floor(n.length/un),a=n.length%un;for(let o=0;o<r;o++)this._updateBlock(t[o*4+0],t[o*4+1],t[o*4+2],t[o*4+3]);return a&&(lo.set(n.subarray(r*un)),this._updateBlock(tn[0],tn[1],tn[2],tn[3]),ln(tn)),this}destroy(){const{t:n}=this;for(const t of n)t.s0=0,t.s1=0,t.s2=0,t.s3=0}digestInto(n){wr(this),P2(n,this),this.finished=!0;const{s0:t,s1:r,s2:a,s3:o}=this,s=dn(n);return s[0]=t,s[1]=r,s[2]=a,s[3]=o,n}digest(){const n=new Uint8Array(un);return this.digestInto(n),this.destroy(),n}}class B5 extends S2{constructor(n,t){bt(n);const r=O5(On(n));super(r,t),ln(r)}update(n){wr(this),bt(n),n=On(n);const t=dn(n),r=n.length%un,a=Math.floor(n.length/un);for(let o=0;o<a;o++)this._updateBlock(qt(t[o*4+3]),qt(t[o*4+2]),qt(t[o*4+1]),qt(t[o*4+0]));return r&&(lo.set(n.subarray(a*un)),this._updateBlock(qt(tn[3]),qt(tn[2]),qt(tn[1]),qt(tn[0])),ln(tn)),this}digestInto(n){wr(this),P2(n,this),this.finished=!0;const{s0:t,s1:r,s2:a,s3:o}=this,s=dn(n);return s[0]=t,s[1]=r,s[2]=a,s[3]=o,n.reverse()}}function I2(e){const n=(r,a)=>e(a,r.length).update(r).digest(),t=e(new Uint8Array(16),0);return n.outputLen=t.outputLen,n.blockLen=t.blockLen,n.create=(r,a)=>e(r,a),n}const _2=I2((e,n)=>new S2(e,n));I2((e,n)=>new B5(e,n));const uo=16,H5=4,Sr=new Uint8Array(uo),U5=283;function Z5(e){if(![16,24,32].includes(e.length))throw new Error('"aes key" expected Uint8Array of length 16/24/32, got length='+e.length)}function mo(e){return e<<1^U5&-(e>>7)}function R2(e,n){let t=0;for(;n>0;n>>=1)t^=e&-(n&1),e=mo(e);return t}const G5=(()=>{const e=new Uint8Array(256);for(let t=0,r=1;t<256;t++,r^=mo(r))e[t]=r;const n=new Uint8Array(256);n[0]=99;for(let t=0;t<255;t++){let r=e[255-t];r|=r<<8,n[e[t]]=(r^r>>4^r>>5^r>>6^r>>7^99)&255}return ln(e),n})(),Y5=e=>e<<24|e>>>8,fo=e=>e<<8|e>>>24;function j5(e,n){if(e.length!==256)throw new Error("Wrong sbox length");const t=new Uint32Array(256).map((f,u)=>n(e[u])),r=t.map(fo),a=r.map(fo),o=a.map(fo),s=new Uint32Array(256*256),c=new Uint32Array(256*256),d=new Uint16Array(256*256);for(let f=0;f<256;f++)for(let u=0;u<256;u++){const m=f*256+u;s[m]=t[f]^r[u],c[m]=a[f]^o[u],d[m]=e[f]<<8|e[u]}return{sbox:e,sbox2:d,T0:t,T1:r,T2:a,T3:o,T01:s,T23:c}}const L2=j5(G5,e=>R2(e,3)<<24|e<<16|e<<8|R2(e,2)),q5=(()=>{const e=new Uint8Array(16);for(let n=0,t=1;n<16;n++,t=mo(t))e[n]=t;return e})();function W5(e){bt(e);const n=e.length;Z5(e);const{sbox2:t}=L2,r=[];Pr(e)||r.push(e=On(e));const a=dn(e),o=a.length,s=d=>D1(t,d,d,d,d),c=new Uint32Array(n+28);c.set(a);for(let d=o;d<c.length;d++){let f=c[d-1];d%o===0?f=s(Y5(f))^q5[d/o-1]:o>6&&d%o===4&&(f=s(f)),c[d]=c[d-o]^f}return ln(...r),c}function Ir(e,n,t,r,a,o){return e[t<<8&65280|r>>>8&255]^n[a>>>8&65280|o>>>24&255]}function D1(e,n,t,r,a){return e[n&255|t&65280]|e[r>>>16&255|a>>>16&65280]<<16}function N2(e,n,t,r,a){const{sbox2:o,T01:s,T23:c}=L2;let d=0;n^=e[d++],t^=e[d++],r^=e[d++],a^=e[d++];const f=e.length/4-2;for(let w=0;w<f;w++){const P=e[d++]^Ir(s,c,n,t,r,a),E=e[d++]^Ir(s,c,t,r,a,n),v=e[d++]^Ir(s,c,r,a,n,t),b=e[d++]^Ir(s,c,a,n,t,r);n=P,t=E,r=v,a=b}const u=e[d++]^D1(o,n,t,r,a),m=e[d++]^D1(o,t,r,a,n),h=e[d++]^D1(o,r,a,n,t),g=e[d++]^D1(o,a,n,t,r);return{s0:u,s1:m,s2:h,s3:g}}function _r(e,n,t,r,a){bt(t,uo,"nonce"),bt(r),a=M5(r.length,a);const o=t,s=dn(o),c=Er(o),d=dn(r),f=dn(a),u=n?0:12,m=r.length;let h=c.getUint32(u,n),{s0:g,s1:w,s2:P,s3:E}=N2(e,s[0],s[1],s[2],s[3]);for(let b=0;b+4<=d.length;b+=4)f[b+0]=d[b+0]^g,f[b+1]=d[b+1]^w,f[b+2]=d[b+2]^P,f[b+3]=d[b+3]^E,h=h+1>>>0,c.setUint32(u,h,n),{s0:g,s1:w,s2:P,s3:E}=N2(e,s[0],s[1],s[2],s[3]);const v=uo*Math.floor(d.length/H5);if(v<m){const b=new Uint32Array([g,w,P,E]),N=I5(b);for(let S=v,T=0;S<m;S++,T++)a[S]=r[S]^N[T];ln(b)}return a}function Q5(e,n,t,r,a){const o=a?a.length:0,s=e.create(t,r.length+o);a&&s.update(a);const c=T5(8*r.length,8*o,n);s.update(r),s.update(c);const d=s.digest();return ln(c),d}const K5=N5({blockSize:16,nonceLength:12,tagLength:16,varSizeNonce:!0},function(n,t,r){if(t.length<8)throw new Error("aes/gcm: invalid nonce length");const a=16;function o(c,d,f){const u=Q5(_2,!1,c,f,r);for(let m=0;m<d.length;m++)u[m]^=d[m];return u}function s(){const c=W5(n),d=Sr.slice(),f=Sr.slice();if(_r(c,!1,f,f,d),t.length===12)f.set(t);else{const m=Sr.slice();Er(m).setBigUint64(8,BigInt(t.length*8),!1);const g=_2.create(d).update(t).update(m);g.digestInto(f),g.destroy()}const u=_r(c,!1,f,Sr);return{xk:c,authKey:d,counter:f,tagMask:u}}return{encrypt(c){const{xk:d,authKey:f,counter:u,tagMask:m}=s(),h=new Uint8Array(c.length+a),g=[d,f,u,m];Pr(c)||g.push(c=On(c)),_r(d,!1,u,c,h.subarray(0,c.length));const w=o(f,m,h.subarray(0,h.length-a));return g.push(w),h.set(w,c.length),ln(...g),h},decrypt(c){const{xk:d,authKey:f,counter:u,tagMask:m}=s(),h=[d,f,m,u];Pr(c)||h.push(c=On(c));const g=c.subarray(0,-a),w=c.subarray(-a),P=o(f,m,g);if(h.push(P),!L5(P,w))throw new Error("aes/gcm: invalid ghash tag");const E=_r(d,!1,u,g);return ln(...h),E}}}),z5=async e=>{const n=typeof e=="string"?new TextEncoder().encode(e):e,t=await crypto.subtle.digest("SHA-256",n);return new Uint8Array(t)},J5=e=>btoa(String.fromCharCode(...e)),X5=async(e,n)=>{const t=V5(K5)(await z5(e)).encrypt(new TextEncoder().encode(n));return J5(t)};class Rr{constructor(n){Ae(this,"channel");Ae(this,"options");Ae(this,"fraudDetectionId","");Ae(this,"channelConfig");Ae(this,"timeout",null);Ae(this,"timer",null);Ae(this,"initPromise",null);this.channel=n.channel,this.channelConfig=n.channelConfig,this.timeout=n.timeout,this.options=n.options}validateChannelConfig(){return!0}load(){return Promise.resolve()}async init(...n){if(!this.fraudDetectionId)return this.initPromise?this.initPromise:(this.initPromise=new Promise(async t=>{var r;if(this.reportEvent(zt.FRAUD_DETECTION_START),!((r=this.validateChannelConfig)!=null&&r.call(this))){this.reportEvent(zt.FRAUD_DETECTION_CHANNEL_CONFIG_ERROR),t();return}try{await this.load()}catch{this.reportEvent(zt.FRAUD_DETECTION_LOAD_ERROR),t();return}try{if(this.clearTimer(),this.timeout){const a=await Promise.race([this.collect(...n),this.createTimeoutPromise()]);if(a instanceof Ee&&a.type===n1.TIMEOUT){this.reportEvent(zt.FRAUD_DETECTION_TIMEOUT),t();return}else this.fraudDetectionId=a}else this.fraudDetectionId=await this.collect(...n);this.clearTimer()}catch(a){this.clearTimer(),this.reportEvent(zt.FRAUD_DETECTION_ERROR,{message:a==null?void 0:a.message}),t();return}this.reportEvent(zt.FRAUD_DETECTION_SUCCESS),t()}),this.initPromise)}clearTimer(){this.timer&&clearTimeout(this.timer),this.timer=null}createTimeoutPromise(){return new Promise(n=>{this.timer=setTimeout(()=>{n(new Ee(n1.TIMEOUT))},this.timeout)})}getFraudDetectionId(){return this.fraudDetectionId}onError(n){this.reportEvent(zt.FRAUD_DETECTION_ERROR,{message:n==null?void 0:n.message})}onWarning(n){this.reportEvent(zt.FRAUD_DETECTION_WARNING,{message:n})}reportEvent(n,t){var r,a;(a=(r=this.options)==null?void 0:r.onEvent)==null||a.call(r,n,{...t||{},channel:this.channel})}}const m1=class m1 extends Rr{constructor(n,t){if(m1.instance)return m1.instance;super({channel:Mn.PAYKKA,channelConfig:t,options:n}),m1.instance=this}validateChannelConfig(){var r;const{clientKey:n,sessionMode:t}=((r=this.channelConfig)==null?void 0:r.paykka)||{};return!!n&&!!t}async collect(){var o;const{clientKey:n,sessionMode:t}=((o=this.channelConfig)==null?void 0:o.paykka)||{},r={originUrl:this.getOrigin(),refererUrl:this.getReferer()};return await v5({clientKey:n,fraudDetectionMode:t,data:await X5(n,JSON.stringify(r))})}getReferer(){var t,r;const n=document.referrer||((r=(t=window.frames)==null?void 0:t.top)==null?void 0:r.document.referrer)||"";return $a(n).origin}getOrigin(){return $a(window.location.href).origin}};Ae(m1,"instance",null);let ho=m1;const f1=class f1 extends Rr{constructor(n,t){if(f1.instance)return f1.instance;super({channel:Mn.STRIPE,channelConfig:t,options:n}),f1.instance=this}validateChannelConfig(){var n,t;return!!((t=(n=this.channelConfig)==null?void 0:n.stripe)!=null&&t.key)}async collect(){var o,s;const n=(s=(o=this.channelConfig)==null?void 0:o.stripe)==null?void 0:s.key,t=window.Stripe(n),{radarSession:r,error:a}=await t.createRadarSession();if(a)throw new Ee(n1.ERROR,a==null?void 0:a.message);return r==null?void 0:r.id}load(){return new Promise((n,t)=>{eo({src:w5,extraOptions:{async:!0,crossOrigin:""},onload:()=>{n()},onerror:()=>{t()}})})}};Ae(f1,"instance",null);let Co=f1;const h1=class h1 extends Rr{constructor(t,r){if(h1.instance)return h1.instance;super({channel:Mn.WORLDPAY,channelConfig:r,timeout:E5,options:t});Ae(this,"iframe",null);Ae(this,"listener",null);h1.instance=this}validateChannelConfig(){var a;const{authCode:t,ddcCollectUrl:r}=((a=this.channelConfig)==null?void 0:a.worldPay)||{};return!!t&&!!r}load(){if(this.iframe)return Promise.resolve();const t=document.createElement("iframe");return t.src=`${$n}/worldpay-ddc.html`,t.style.display="none",t.width="1",t.height="1",document.body.appendChild(t),this.iframe=t,new Promise(r=>{t.onload=()=>{r()}})}async collect(t){return this.sendJWTAndBin(t),new Promise(r=>{this.listenFraudDetectionId(a=>{this.fraudDetectionId=a,r(a)})})}sendJWTAndBin(t){var s;const{authCode:r,ddcCollectUrl:a}=((s=this.channelConfig)==null?void 0:s.worldPay)||{},o={action:Ve.DDC_JWT_BIN,jwt:r||"",bin:t,url:a||""};mt(o,this.iframe.contentWindow,jt)}listenFraudDetectionId(t){this.listener&&this.clearListener(),this.listener=r=>{var a,o,s;if(r.origin===((o=(a=this.channelConfig)==null?void 0:a.worldPay)==null?void 0:o.ddcOrigin)){const c=r.data;if(typeof c!="string")return;let d={};try{d=JSON.parse(c)}catch(f){console.error(f);return}if(console.warn("worldpay ddc data",d),d){const f=d.SessionId||((s=d.Payload)==null?void 0:s.SessionId)||"";t(f)}}},window.addEventListener("message",this.listener)}clearListener(){this.listener&&window.removeEventListener("message",this.listener),this.listener=null}};Ae(h1,"instance",null);let Lr=h1;window.worldpayJSCOrigin=window.worldpayJSCOrigin||{},window.worldpayJSCOrigin.version=4,window.worldpayJSCOrigin.create_url=function(e,n,t,r,a){function o(){return Math.floor(2742745743359*Math.random())}function s(){return c(o())}function c(g){return(g+78364164096).toString(36)}var d=o(),f=o(),u=885187064159;f=((f=f-f%256+window.worldpayJSCOrigin.version)+d)%2742745743359,u=(u+d)%2742745743359;var m="https://"+e+"/"+(d=s()+c(d))+n,h=[(f=c(u)+c(f))+"="+t,s()+s()+"="+r];return a!==void 0&&a.length>0&&h.push(s()+s()+"="+a),m+"?"+h.join("&")},window.worldpayJSCOrigin.beacon=function(e,n,t,r){var a="turn:aa.online-metrix.net?transport=",o="1:"+n+":"+t,s={iceServers:[{urls:a+"tcp",username:o,credential:t},{urls:a+"udp",username:o,credential:t}]};try{var c=new RTCPeerConnection(s);c.createDataChannel(Math.random().toString());var d=function(){},f=function(u){c.setLocalDescription(u,d,d)};typeof Promise>"u"||c.createOffer.length>0?c.createOffer(f,d):c.createOffer().then(f,d),setInterval(function(){c.close()},1e4)}catch{}},window.worldpayJSCOrigin.load_tags=function(e,n,t,r){window.worldpayJSCOrigin.beacon(e,n,t,r);var a=document.getElementsByTagName("head").item(0),o=document.createElement("script");o.id="tmx_tags_js",o.setAttribute("type","text/javascript");var s=window.worldpayJSCOrigin.create_url(e,".js",n,t,r);o.setAttribute("src",s),window.worldpayJSCOrigin.set_csp_nonce(o),a.appendChild(o)},window.worldpayJSCOrigin.csp_nonce=null,window.worldpayJSCOrigin.register_csp_nonce=function(e){if(e.currentScript!==void 0&&e.currentScript!==null){var n=e.currentScript.getAttribute("nonce");n!=null&&n!==""?window.worldpayJSCOrigin.csp_nonce=n:e.currentScript.nonce!==void 0&&e.currentScript.nonce!==null&&e.currentScript.nonce!==""&&(window.worldpayJSCOrigin.csp_nonce=e.currentScript.nonce)}},window.worldpayJSCOrigin.set_csp_nonce=function(e){window.worldpayJSCOrigin.csp_nonce!==null&&(e.setAttribute("nonce",window.worldpayJSCOrigin.csp_nonce),e.getAttribute("nonce")!==window.worldpayJSCOrigin.csp_nonce&&(e.nonce=window.worldpayJSCOrigin.csp_nonce))},window.worldpayJSCOrigin.cleanup=function(){let e=null,n=null,t=null;for(;(e=document.getElementById("tdz_ifrm"))!==null;)e.parentElement.removeChild(e);for(;(n=document.getElementById("tmx_tags_iframe"))!==null;)n.parentElement.removeChild(n);for(;(t=document.getElementById("tmx_tags_js"))!==null;)t.parentElement.removeChild(t)},window.worldpayJSCOrigin.load=function(e,n,t,r){e!==void 0&&n!==void 0&&t!==void 0&&n.length===8&&(window.worldpayJSCOrigin.cleanup(),window.worldpayJSCOrigin.register_csp_nonce(document),window.worldpayJSCOrigin.load_tags(e,n,t,r))};const C1=class C1 extends Rr{constructor(n,t){if(C1.instance)return C1.instance;super({channel:Mn.WORLDPAY_JSC,channelConfig:t,options:n}),C1.instance=this}validateChannelConfig(){var r;const{organizationId:n,profilingDomain:t}=((r=this.channelConfig)==null?void 0:r.worldPayJSC)||{};return!!n&&!!t}async collect(){var a,o;const n=this.getRandomId(),{organizationId:t,profilingDomain:r}=((a=this.channelConfig)==null?void 0:a.worldPayJSC)||{};return(o=window.worldpayJSCOrigin)==null||o.load(r,t,n),n}getRandomId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{const t=Math.random()*16|0;return(n==="x"?t:t&3|8).toString(16)})}};Ae(C1,"instance",null);let yo=C1;const $5="eu";let go=null;function e8(e,n,t){return go||(go=new t8(e,t,n)),go}class t8{constructor(n,t=[Kt.SR,Kt.WP,Kt.WJ],r){Ae(this,"options");Ae(this,"clientKey");Ae(this,"collMap",{[Kt.SR]:()=>this.stripeRadarColl(),[Kt.WP]:()=>this.worldpayDDCColl(),[Kt.WJ]:()=>this.worldpayJSCColl()});Ae(this,"p");Ae(this,"realMode",[]);Ae(this,"env");Ae(this,"channelConfig");Ae(this,"channelConfigPromise");Ae(this,"isIIFE",typeof __IS_IIFE__<"u"&&__IS_IIFE__);Et(this,Y1,void 0);const{env:a,clientKey:o}=n;this.realMode=t,this.options=r,this.env=a||$5,this.clientKey=o,Qt(this,Y1,this.isIIFE?"API":r==null?void 0:r.sessionMode),this.isIIFE&&(e1(w2[this.env]),t1(E2[this.env]),co("/session"))}async getFraudDetectionId(n){await this.setChannelSDKConfig(),await Promise.all([this.worldpayDDCColl().init((n==null?void 0:n.bin)||""),this.paykkaDetectionColl().init()]);const t=this.realMode;return this.formatFraudDetectionId({s:t.includes(Kt.SR)?this.stripeRadarColl().getFraudDetectionId():"",w:t.includes(Kt.WP)?this.worldpayDDCColl().getFraudDetectionId():"",wr:t.includes(Kt.WJ)?this.worldpayJSCColl().getFraudDetectionId():"",p:this.paykkaDetectionColl().getFraudDetectionId()})}async createFraudDetection(){await this.setChannelSDKConfig(),this.p||(this.p=Promise.all([...this.realMode.map(async n=>{if(this.collMap[n])return this.collMap[n]();throw new Error(`Unsupported collection mode: ${n}`)}),this.paykkaDetectionColl()])),await this.p}formatFraudDetectionId(n){var t,r;try{const a=JSON.stringify(n);return btoa(a)}catch{return(r=(t=this.options)==null?void 0:t.onEvent)==null||r.call(t,zt.FRAUD_DETECTION_TRANSFORM_ERROR),""}}async setChannelSDKConfig(){if(!this.channelConfig)return this.channelConfigPromise?this.channelConfigPromise:(this.channelConfigPromise=new Promise(async n=>{let t={},r={};try{t=await Je(),r=await p5({channel:[Mn.STRIPE,Mn.WORLDPAY],browser:t})}catch{}const{worldPay:a}=r||{};let o="";try{o=new URL((a==null?void 0:a.ddcCollectUrl)||"").origin}catch{o=""}this.channelConfig={...r,worldPay:{...a,ddcOrigin:o},worldPayJSC:["eu","hk"].includes(this.env)?b5:A5,paykka:{clientKey:this.clientKey,sessionMode:Ne(this,Y1)}},n()}),this.channelConfigPromise)}worldpayDDCColl(){return new Lr(this.options,this.channelConfig)}worldpayJSCColl(){const n=new yo(this.options,this.channelConfig);return n.init(),n}stripeRadarColl(){const n=new Co(this.options,this.channelConfig);return n.init(),n}paykkaDetectionColl(){const n=new ho(this.options,this.channelConfig);return n.init(),n}}Y1=new WeakMap;const Nr=new WeakMap;function M2(e,{time:n=70,argsResolver:t,resultResolver:r}){function a(...s){const c=Date.now();let d=Nr.get(e);d||Nr.set(e,d={items:[],firstInvokeTime:c});const f=kn();return d.items.push({args:s,invokeTime:c,promise:f}),d.items.length===1&&o(),f}function o(){setTimeout(()=>{const s=Nr.get(e);if(!s)return;Nr.delete(e);const c=t(s.items);e(...c).then(d=>{s.items.forEach((f,u)=>{f.promise.resolve(r(d,f,u,s.items))})}).catch(d=>{s.items.forEach(f=>{f.promise.reject(d)})})},n)}return a}function n8(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}}const r8=async e=>Se.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})))??[]}),a8=M2(async(e,n)=>Se.post(`/address/style/${e}`,void 0,n).then(({address_style_list:t})=>t.map(r=>n8(r))),{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}}),o8=M2(async(e,n)=>Se.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}))}),{argsResolver(e){return e==null?void 0:e[0].args},resultResolver(e){return e}}),i8=async e=>Se.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 s8{constructor(){Et(this,wn,void 0);Ae(this,"countryOptions");Ae(this,"provinceOptions");Ae(this,"cityOptions");Ae(this,"addressState");Ae(this,"i18n");Ae(this,"addressFormat");Ae(this,"validateAllFields",!1);this.addressState={country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0},this.countryOptions=[]}setI18n({i18n:n}){this.i18n=n}async requestCountryOption(){var n,t;if(!(this.countryOptions.length!==0||(n=Ne(this,wn))!=null&&n.isPending))try{Qt(this,wn,kn()),this.countryOptions=await r8({locale:this.i18n.locale}),Ne(this,wn).resolve(!0)}catch{(t=Ne(this,wn))==null||t.resolve(!1)}}async countryOptionReady(){return Ne(this,wn)}getCountryOption(){return this.countryOptions}async requestProvinceOption(n){return this.provinceOptions=await o8(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{[xe.ADDRESS_1]:n=>this.setAddress1(n),[xe.ADDRESS_2]:n=>this.setAddress2(n),[xe.CITY]:n=>this.setCity(n),[xe.AREA]:n=>this.setArea(n),[xe.POST_CODE]:n=>this.setPostCode(n),[xe.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:Rn(t)&&t.length>0?((r=t.find(a=>a.value===n))==null?void 0:r.label)??null:null}}wn=new WeakMap;function _e(e){return A4(`${Ui}-${e}`)}function yt(e){const n=Yn(ze),[t]=O((n==null?void 0:n.i18n)??new vr);return e&&t.load(e),{i18n:t}}function et(e,n){const[t,r]=O(!1),[a,o]=O(""),[s,c]=O(!1),[d,f]=O(null),{i18n:u}=yt();return Ce(()=>{e.ready().then(()=>{var g,w;c(!0);const m=d5(y2||((g=e.checkout)==null?void 0:g.locale)||gn().language);u.load(m);const h=e8({clientKey:e.paykkaDetectionKey,env:so},{sessionMode:(w=e.checkout)==null?void 0:w.sessionMode,onEvent:(P,E)=>{var v,b;(b=n==null?void 0:(v=n.config).onEvent)==null||b.call(v,P,E)}});f(h),h==null||h.createFraudDetection()})},[]),{validated:t,setValidated:r,errorMsg:a,setErrorMsg:o,i18n:u,fraudDetection:d,sessionReady:s}}function Xe(e,{timeout:n=2e4,interval:t=2e3,onTimeout:r,onEnd:a}){const o=$(null);Ce(()=>c,[]);function s(d={}){return new Promise(f=>{d={timeout:n,interval:t,...d};const u=Date.now(),m=async()=>{if(!o.current){c();return}const h=Date.now(),g=await e(N1(h-u,0,d.timeout));o.current&&(g.end?(a==null||a(g.res),f(g)):h-u>d.timeout?r==null||r():o.current=window.setTimeout(m,d.interval))};o.current=window.setTimeout(m,d.interval)})}function c(){o.current&&(clearTimeout(o.current),o.current=null)}return{start:s,stop:c}}const po={xs:480,sm:928,md:992,lg:1200,xl:1366,xxl:1600},T2=()=>{const[e,n]=O(()=>typeof window<"u"?window.innerWidth:0);Ce(()=>{if(typeof window>"u")return;const s=()=>{n(window.innerWidth)};return window.addEventListener("resize",s),()=>window.removeEventListener("resize",s)},[]);const t=Ht(()=>Object.entries(po).sort((s,c)=>s[1]-c[1]),[po]),{matches:r,current:a}=Ht(()=>{const s={xs:!1,sm:!1,md:!1,lg:!1,xl:!1,xxl:!1};let c=null;for(let d=t.length-1;d>=0;d--){const[f,u]=t[d],m=e>=u;s[f]=m,m&&!c&&(c=f)}return{matches:s,current:c}},[e,t]);return{matches:r,current:a,smaller:s=>{const c=po[s];return c===void 0?!1:e<c}}},k2=()=>{const[e,n]=O("unSubmit"),[t,r]=O("");return{paymentButtonStatus:e,setPaymentButtonStatus:n,errorMsg:t,setErrorMsg:r}};class c8{constructor(n){Et(this,y1,void 0);Et(this,En,{});Qt(this,y1,_e(`theme-${n}`).bem())}init(n){const{payButtonBackgroundColor:t,payButtonTextColor:r}=n||{};if(Qt(this,En,{...Ne(this,En),"--paykka-button-font-color":r}),t){const o=F4(t);Qt(this,En,{...Ne(this,En),"--paykka-button-bg-color":o[5],"--paykka-button-bg-color-hover":o[4],"--paykka-button-bg-color-active":o[6]})}const a=n5(Ne(this,En));Ja(`.${Ne(this,y1)}{${a}}`)}get className(){return Ne(this,y1)}}y1=new WeakMap,En=new WeakMap;const d8="m",l8={enableInitValidation:!0,apiPrefix:"/session",addressMode:"address"};class u8{constructor(n){Et(this,fa);Et(this,g1,void 0);Et(this,Mt,void 0);Et(this,ua,void 0);Et(this,rn,void 0);Et(this,p1,void 0);Et(this,ma,[]);Et(this,v1,void 0);Et(this,Bn,void 0);Ae(this,"processingPaymentMethod",null);Ae(this,"enablePaymentMethod",k1(null));Qt(this,g1,t2(6)),Qt(this,Mt,n),this.init()}async init(){return Ne(this,Bn)?Ne(this,Bn):(Qt(this,Bn,ga(this,fa,Bd).call(this)),Ne(this,Bn))}initCheckoutConfig(){Ne(this,Mt)._checkoutConfig=L1(l8,Ne(this,Mt)._checkoutConfig||{}),co(Ne(this,Mt)._checkoutConfig.apiPrefix)}async initSession(){var f,u;const{sessionId:n,clientKey:t,onPaymentMethodsReady:r,onInitError:a,onSuccess:o,_checkoutConfig:s={}}=Ne(this,Mt),{enableInitValidation:c}=s;if(c&&!n){a==null||a(new Ee("ERROR","SessionId is required"));return}const d=(u=(f=Ne(this,Mt))._getExtraParams)==null?void 0:u.call(f,"info");return Qt(this,rn,new A2({sessionId:n,clientKey:t},d)),Ne(this,rn).ready().then(()=>{var g,w;if(Cl((g=Ne(this,rn))==null?void 0:g.checkout)){a==null||a(new Ee("ERROR","Checkout is empty"));return}const{supportMethods:m=[],status:h}=((w=Ne(this,rn))==null?void 0:w.checkout)||{};if(h==="SUCCESS"){o==null||o({});return}r==null||r(m)}).catch(m=>{a==null||a(m)})}initEnv(){const{env:n,_envConfig:t,onInitError:r}=Ne(this,Mt);if(!n){r==null||r(new Ee("ERROR","Env is required"));return}e1((t==null?void 0:t.api)||w2[n]),t1((t==null?void 0:t.cdn)||E2[n]),g2((t==null?void 0:t.fraudDetection)||n||so)}initLocale(){const{locale:n}=Ne(this,Mt);n&&p2(n)}initTheme(){var n;Qt(this,p1,new c8(Ne(this,g1))),Ne(this,p1).init((n=Ne(this,rn).checkout)==null?void 0:n.theme)}initOtherData(){const n=W4(d8);n&&(this.processingPaymentMethod=n)}get session(){return Ne(this,rn)}get theme(){return Ne(this,p1)}get envConfig(){return Ne(this,ua)}get config(){return Ne(this,Mt)}get id(){return Ne(this,g1)}create(n,t){var m;const{onSubmit:r,onSuccess:a,onError:o,onTimeout:s,onExpired:c}=Ne(this,Mt),d=this.getCoreProps(),f={onSubmit:r,onSuccess:a,onError:o,onTimeout:s,onExpired:c,...d,...t},u=xn(n,{...f,onError:h=>{var g,w,P;(g=f.onError)==null||g.call(f,h),(P=(w=this.config).onEvent)==null||P.call(w,ka.PAYMENT_FAILURE,{message:h.message,code:h.code})}});return(m=Ne(this,ma))==null||m.push(u),u}getCoreProps(){return{session:Ne(this,rn),core:this,threeDSFrame:Ne(this,Mt).threeDSFrame,hidePaymentButton:Ne(this,Mt).hidePaymentButton}}resetEnablePaymentMethod(){this.enablePaymentMethod.value=null}getAddressCore(){return Ne(this,v1)||Qt(this,v1,new s8),Ne(this,v1)}}g1=new WeakMap,Mt=new WeakMap,ua=new WeakMap,rn=new WeakMap,p1=new WeakMap,ma=new WeakMap,v1=new WeakMap,Bn=new WeakMap,fa=new WeakSet,Bd=async function(){this.initCheckoutConfig(),this.initEnv(),this.initLocale(),await this.initSession(),this.initTheme(),this.initOtherData()};const V2=async(e,n,t,{timeout:r=2e4,headers:a,locale:o}={})=>{const s=new AbortController,c=setTimeout(()=>{s.abort()},r);try{const d=ml(),f=e==="post",u=await d(`${io}/bk${n}`,{method:e,mode:"cors",cache:"default",credentials:"same-origin",headers:{Accept:"application/json, text/plain, */*","Content-Type":f?"application/json":"text/plain","Accept-Language":o??gn().language,...C2,...a},redirect:"follow",referrerPolicy:"no-referrer-when-downgrade",body:f&&t?a5(t):void 0,signal:s.signal});clearTimeout(c);const m=String(u.status);let h;try{h=await u.json()}catch{h={i18nKey:"common.netError"}}if(m==="500")throw{code:m,...h.ret_msg?{message:h.ret_msg}:{i18nKey:"common.unknownError"}};if(/^(429|5\d{2})$/.test(m))throw{code:m,i18nKey:"common.netError"};if(h.ret_code!=="000000")throw{code:h.ret_code,message:h.ret_msg};return h.data}catch(d){throw d.name==="AbortError"?new Ee(n1.TIMEOUT):d.code?d:{i18nKey:"common.unknownError"}}},Se={get:(e,n,t)=>V2("get",e,n,t),post:(e,n,t)=>V2("post",e,n,t)},We=e=>e instanceof Ee&&e.type===n1.TIMEOUT,st=(e,n={})=>{const{bill:t,payment:r,customer:a}=e;return{...L1({bill:{first_name:t==null?void 0:t.firstName,middle_name:t==null?void 0:t.middleName,last_name:t==null?void 0:t.lastName,email:t==null?void 0:t.email,country:t==null?void 0:t.country,state:t==null?void 0:t.state,city:t==null?void 0:t.city,postal_code:t==null?void 0:t.postalCode,address_line1:t==null?void 0:t.addressLine1,address_line2:t==null?void 0:t.addressLine2,district:t==null?void 0:t.district,area_code:t==null?void 0:t.areaCode,phone_number:t==null?void 0:t.phoneNumber}},n||{}),session_id:e.sessionId,client_key:e.clientKey,channel_user_id:e.channelUserId,payment:{payment_method:r.paymentMethod,store_payment_method:r.storePaymentMethod,token_data:r.tokenData,iban:r.iban,token:r.token,card_no:r.cardNo,exp_year:r.expYear,exp_month:r.expMonth,cvv:r.cvv,holder_name:r.holderName},customer:{document:a==null?void 0:a.document},browser:e.browser}},ct=(e,n={})=>{const{sessionId:t,clientKey:r,paymentMethod:a,browser:o}=e;return{...n,session_id:t,client_key:r,payment_method:a,browser:o}},$t=e=>({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}),Me=e=>{var t;const n=e.pay_info||{};return{sessionId:e.session_id,merchantId:e.merchant_id,errorCode:e.error_code,errorMessage:e.error_description,orderId:e.order_id,transAmount:$t(e.trans_amount),status:e.status,orderStatus:e.order_status,paymentMethod:e.payment_method,finishTime:e.utc_finish_time,payInfo:{threeDSUrl:(t=e.authentication_result)==null?void 0:t.authentication_url,targetUrl:n.payment_url||n.request_url,requestMethod:n.request_method,paymentExpiredAt:e==null?void 0:e.payment_expire_time,...n},rawResponse:e}},m8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},f8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},D2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},x2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)};class h8{constructor(){Ae(this,"cache",new Map)}cacheRequest(n,t){const r=this.cache.get(n);if(r)return r;const o=t.catch(s=>{throw this.cache.delete(n),s});return this.cache.set(n,o),o}}const O2=(e=[])=>{const n=[],t={};return e.forEach(({value:r,configuration:a={}})=>{r===G.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===G.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===G.WECHAT_PAY?t.wechatPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:$t(a==null?void 0:a.fee),totalAmount:$t(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}:r===G.ALI_PAY&&(t.aliPay={neededToCompute:a==null?void 0:a.needed_to_compute,fee:$t(a==null?void 0:a.fee),totalAmount:$t(a==null?void 0:a.total_amount),percentageFee:a==null?void 0:a.percentage_fee,transactionFee:a==null?void 0:a.transaction_fee}),r===G.BANKCARD?n.push(...a.allowed_card_networks||[]):n.push(r)}),{supportMethods:n,channelParams:t}},C8=(e={})=>({goodsTax:$t(e.goods_tax),shippingAmount:$t(e.shipping_amount),shippingTax:$t(e.shipping_tax),discount:$t(e.discount),other:$t(e.other)}),y8=(e={})=>{var f,u;const{theme:n,field:t,support_methods:r={}}=e,{payment_methods:a,bill:o,tokens:s}=r,c=O2(a),d=e.session_mode==="HOST"?"HOSTED":e.session_mode;return{country:e.country,merchantId:e.merchant_id,sessionId:e.session_id,clientKey:e.client_key,status:e.status,transAmount:$t(e.trans_amount),expireTime:e.expire_time,paymentMethod:e.payment_method,sessionMode:d||"HOSTED",merchantName:(f=e.theme)==null?void 0:f.merchant_name,returnUrl:e.return_url,cancelUrl:e.cancel_url,locale:e.locale,paymentType:e.payment_type||"PURCHASE",orderId:e.order_id,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:o==null?void 0:o.billing_address_collection,addressLine1:o==null?void 0:o.address_line1,addressLine2:o==null?void 0:o.address_line2,email:o==null?void 0:o.email,descriptor:o==null?void 0:o.descriptor,country:o==null?void 0:o.country},tokens:s==null?void 0:s.map(m=>({token:m.token,last4:m.last4,cardBrand:m.card_brand,billingAddressFilled:m.billing_address_filled})),storePaymentMethod:(u=e.payment)==null?void 0:u.store_payment_method,field:{holderName:{show:!!(t!=null&&t.holder_name_display),required:!!(t!=null&&t.holder_name_required)},email:{show:!!(t!=null&&t.bill_email_display),required:!!(t!=null&&t.bill_email_required),disabled:!!(t!=null&&t.bill_email_disabled)},address:{show:!!(t!=null&&t.bill_address_display),required:!!(t!=null&&t.bill_address_required)}},amountBreakdown:C8(e.amount_breakdown),finishTime:e.utc_finish_time,...c,rawResponse:e}},g8=async(e,n={},t)=>Se.post(`${Re}/info`,{session_id:e.sessionId,client_key:e.clientKey,...n,browser:await Je()},t),p8=async(e,n={},t)=>{const r=await g8(e,n,t);return y8(r)},v8=new h8,b8=async(e,n={},t)=>{const r=p8(e,n,t);return v8.cacheRequest(JSON.stringify(e),r)},A8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},w8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},E8=async e=>Se.post(`${Re}/apple-pay/create-session`,e),P8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},S8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},I8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},F2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},_8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},R8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},L8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},N8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},M8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},T8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},k8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},V8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},D8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},x8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},O8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},F8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},B8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},H8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},U8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Z8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},G8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Y8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},j8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},q8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},B2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},H2=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},U2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},W8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},Z2=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},Q8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},K8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},z8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},J8=async(e,n,t)=>{const r=st(e,n);return Se.post(`${Re}/payments`,r,t).then(Me)},X8=async(e,n,t)=>{const r=ct(e,n);return Se.post(`${Re}/payments/query`,r,t).then(Me)},vo=_e("form-item"),mn=vo.bem("label"),G2=vo.bem("error-text"),Mr=X1(null),Y2=X1(null);function j2(e,n){return n?(Rn(e.trigger)?e.trigger:[e.trigger]).includes(n):!0}function $8(e,n){if(!e)return;if(Rn(e))return e.filter(r=>j2(r,n));const t=r5(e,j2(e,n));return t?[t]:[]}function q2(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 $s(n,r,t.fields[r]),n},{})}const eu=e=>Dt(e)||e==="",At=Fe((e,n)=>{const{label:t,path:r,children:a,triggersOfEmptyValue:o=["submit"],onValidationStatusChange:s,className:c,style:d,showErrorMessage:f=!0,showLabel:u=!0}=e;Be(n,()=>({validate:E,validateChange:N,getValidateResult:w,resetValidation:v}));const m=Yn(Y2),[h,g]=O({status:"unValidate",errors:[],fields:{}});function w(){return h}function P(A){g(A),A.status!==h.status&&(s==null||s(A.status))}async function E(A,{trigger:R,setResult:y=!0}){return eu(A)&&!o.includes(R)?v():new Promise(async _=>{const V=$8(e.rule,R);if(!r||!(V!=null&&V.length)){_(h);return}const k=[],p={};for(const K of V){const{validator:ie}=K;if(ie)try{await ie(A)||(k.push({message:void 0,fieldValue:A,field:r}),p[r]=k)}catch(q){k.push({message:q.message,fieldValue:A,field:r}),p[r]=k}}let x={status:"unValidate",errors:k,fields:p};k.length?(x.status="error",y&&P(x)):y?x=v("success"):x.status="success",_(x)})}function v(A="unValidate",R=[]){const y={status:A,errors:A==="error"?R:[],fields:{}};return P(y),y}async function b(A){return await E(A,{trigger:"blur"})}async function N(A){return await E(A,{trigger:"change"})}function S(A){r&&(m==null||m.setForm(R=>(R={...R},$s(R,r,A),R)))}function T(){var A;return(A=h.errors)==null?void 0:A[0]}return Ce(()=>{const A={internalValidate:E,path:r,resetValidation:v};return r&&(m==null||m.setFormItems(R=>[...R,A])),()=>{r&&(m==null||m.setFormItems(R=>R.filter(y=>y!==A)))}},[]),i("div",{className:ye(ge,vo.bem(),c),style:d,children:[u&&!Dt(t)&&i("div",{className:mn,children:t}),i(Mr.Provider,{value:{rule:e.rule,validateBlur:b,validateChange:N,resetValidation:v,validationResult:h,setValue:S},children:a}),f&&h.status==="error"&&i("div",{className:G2,children:T().message})]})}),dt=Fe((e,n)=>{const{children:t}=e;Be(n,()=>({validate:d,resetValidation:u,validateField:f}));const[r,a]=O(e.form),[o,s]=O([]);function c(m,h){if(!La(m)||!Ln(h))return;const g=h.split(".");return g.length===0?m[h]:g.reduce((w,P)=>w&&w[P],m)}async function d(m,h=!0){const g=await Promise.all(o.map(P=>{const E=c(r,P.path);return P.internalValidate(E,{trigger:"submit",setResult:h})})),w=q2(g);if(w)throw m&&(m==null||m(w)),w;m&&(m==null||m())}async function f(m,h,g=!0){const w=o.filter(v=>m.includes(v.path)),P=await Promise.all(w.map(v=>{const b=c(r,v.path);return v.internalValidate(b,{trigger:"submit",setResult:g})})),E=q2(P);if(E)throw h&&(h==null||h(E)),E;h&&(h==null||h())}function u(){o.forEach(m=>{var h;(h=m.resetValidation)==null||h.call(m)})}return Ce(()=>{var m;(m=e.onFormChange)==null||m.call(e,r)},[r]),i(Y2.Provider,{value:{form:r,setForm:a,formItems:o,setFormItems:s},children:t})}),Fn=_e("input"),vn=Fn.bem("input-wrapper"),tu={error:Zi,success:El},_t=Fe((e,n)=>{const{inputClassName:t,style:r,disabled:a,children:o,showStatus:s=!0}=e;Be(n,()=>({input:m.current,focus:()=>{f(!0)},blur:()=>{f(!1)},valid:()=>{c==null||c.resetValidation("success")},invalid:S=>{c==null||c.resetValidation("error",[{message:S}])}}));const c=Yn(Mr),[d,f]=O(!1);let u=!1;const m=$(null);let h=e.status??(c==null?void 0:c.validationResult.status);h==="unValidate"&&(h=void 0);let{rightIcon:g}=e;if(s&&h){const S=tu[h];g=i(S,{size:16})}function w(S){var T;f(!0),(T=e.onFocus)==null||T.call(e,S)}function P(S){var A;f(!1),(A=e.onBlur)==null||A.call(e,S);const{value:T}=S.currentTarget;c==null||c.validateBlur(T)}function E(S){var A;if(S instanceof InputEvent&&!S.isComposing&&(u=!1),u||S instanceof InputEvent&&S.inputType==="insertCompositionText")return;(A=e.onInput)==null||A.call(e,S);const{value:T}=S.target;c==null||c.setValue(T),c==null||c.validateChange(T)}const v=m2(()=>{const S=Fn.bem("input-wrapper",[h,{focus:d}]),T=Fn.bem("input-wrapper-disabled");return a?`${S} ${T}`:`${S}`});function b(S){var T;u=!0,(T=e.onCompositionStart)==null||T.call(e,S)}function N(S){u=!1,E(S)}return i("div",{className:ye(ge,Fn.bem(),t),onClick:()=>{var S;return(S=m.current)==null?void 0:S.focus()},children:i("div",{className:`${v}`,style:r,children:[!!e.leftIcon&&i("div",{class:Fn.bem("left-icon"),children:e.leftIcon}),o||i("input",{ref:m,...e,class:Fn.bem("input"),onFocus:w,onBlur:P,onInput:E,onCompositionStart:b,onCompositionEnd:N,autocomplete:"off"}),!!g&&i("div",{class:Fn.bem("right-icon"),children:g})]})})}),{bem:nu}=_e("select"),ru=e=>{const{style:n,children:t,...r}=e;return i("div",{style:n,class:nu("menu"),onMouseDown:a=>a.preventDefault(),...r,children:t})},{bem:W2}=_e("select");function au(e){const{onSelect:n,...t}=e,{label:r}=t;function a(o){o.preventDefault(),o.stopPropagation(),n==null||n({...t})}return i("div",{onClick:o=>a(o),class:W2("menu-item",[{selected:e.selected}]),children:[Hi(r)?r(e,e.selected):r,e.selected&&i("div",{class:W2("menu-item-icon"),children:Il({})})]})}const{bem:bo}=_e("select"),Tr=Fe((e,n)=>{const t=Yn(Mr);let r=e.status??(t==null?void 0:t.validationResult.status);r==="unValidate"&&(r=void 0);const[a,o]=O(!1),[s,c]=O(!1),[d,f]=O([]),[u,m]=O(),[h,g]=O(),[w,P]=O(),E=$(null),[v,b]=O(!1),[N,S]=O(!1);Ce(()=>{if(!N&&(f(e.options??[]),!Dt(e.value)&&e.options.length>0)){const J=T(e.value,e.options);J&&V(J,!1)}},[e.value,e.options]),Ce(()=>{if(e.renderLabel)return;const J=Dt(w)||w==="";if(S(!J),J)f(e.options);else{const se=e.options.filter(z=>z.label.toLowerCase().includes(w.toLowerCase()));f(se)}},[w]),Be(n,()=>({blur:()=>{var J,se;b(!1),c(!1),(se=(J=E.current)==null?void 0:J.input)==null||se.blur()}}));function T(J,se){for(let z=0;z<se.length;z++){const X=se[z];if(X.value===J)return X}}function A(J){var se;b(!0),o(!0),(se=e.onFocus)==null||se.call(e,J)}function R(){var J,se;(se=(J=E.current)==null?void 0:J.input)==null||se.focus()}function y(J){var se;o(!1),(se=e.onBlur)==null||se.call(e,J),P(""),c(!1),t==null||t.validateBlur(Dt(h)?"":String(h))}function _(J){c(!0),P(J.currentTarget.value)}function V(J,se=!0){var Q,Y,ee,re;const{value:z,label:X}=J;P(""),g(z),m(((Q=e.renderLabel)==null?void 0:Q.call(e,J))||X),b(!1),c(!1),(ee=(Y=E.current)==null?void 0:Y.input)==null||ee.blur(),se&&((re=e==null?void 0:e.onSelect)==null||re.call(e,z,J))}function k(J){c(!0),P(J.currentTarget.value)}let p,x;const K=qe(J=>{p=J},[]),ie=qe(J=>{x=J,q(x,p)},[]);Ce(()=>(document.addEventListener("mousedown",K),document.addEventListener("mouseup",ie),()=>{document.removeEventListener("mousedown",K),document.removeEventListener("mouseup",ie)}),[]);function q(J,se){var ee,re;if(!ne.current)return;const z=J==null?void 0:J.target,X=se==null?void 0:se.target,Q=((ee=ne.current)==null?void 0:ee.contains(z))||((re=ne.current)==null?void 0:re.contains(X)),Y=ne.current===z;Q||Y||b(!1)}const ne=$(null),W=Sl({style:{transform:v?"rotate(-180deg)":"rotate(0deg)",transition:"transform 0.3s ease"}});return i("div",{class:bo("wrapper"),ref:ne,onClick:()=>{var J,se;return(se=(J=E.current)==null?void 0:J.input)==null?void 0:se.focus()},children:[i(Mr.Provider,{value:null,children:i(_t,{ref:E,value:w,status:r,readOnly:!e.filterable,onInput:_,onFocus:A,onBlur:y,onChange:k,onCompositionStart:()=>c(!0),placeholder:a||s||!Dt(h)?"":e.placeholder,rightIcon:e.rightIcon||W,inputClassName:e.inputClassName})}),i("div",{class:bo("render-label",[{placeholder:a,hidden:s}]),onClick:R,children:u}),i(ru,{style:{display:v?"block":"none"},children:[N&&d.length===0?i("div",{class:bo("menu-no-data"),children:e.noDataTip}):d.map(J=>i(au,{onSelect:V,selected:h===J.value,...J,label:e.renderLabel?()=>{var se;return(se=e.renderLabel)==null?void 0:se.call(e,J)}:J.label},J.value)),e.action]})]})}),{bem:Ao}=_e("address-field"),Q2={country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0},ht=Fe((e,n)=>{const{onAddressChange:t}=e,{i18n:r}=yt(),a=Yn(ze);if(!(a!=null&&a.core))throw new Error("CoreContext is not found");const o=a.core.getAddressCore(),[s,c]=O({...o.getAddressState()}),[d,f]=O(o.getCountryOption()??[]),[u,m]=O(o.getProvinceOption()??[]),[h,g]=O([]),[w,P]=O(o.getAddressFormat()),E=$(null),v=$(null),b=$(null),N=$(null),S=$(null),T=$(null),A=$(null);Ht(()=>{r.ready.value&&(o.setI18n({i18n:r}),o.requestCountryOption(),o.countryOptionReady().then(()=>{p(),f(o.getCountryOption())}))},[r.ready.value]);const R={[xe.ADDRESS_1]:l=>{c(Object.assign(s,{address1:l}))},[xe.ADDRESS_2]:l=>{c(Object.assign(s,{address2:l}))},[xe.CITY]:l=>{c(Object.assign(s,{city:l}))},[xe.AREA]:l=>{c(Object.assign(s,{area:l}))},[xe.POST_CODE]:l=>{c(Object.assign(s,{postCode:l}))},[xe.PROVINCE]:l=>{c(Object.assign(s,{province:l}))},COUNTRY:l=>{c(Object.assign(s,{country:l}))}};function y(l,C){R[l](C)}function _(l,C){y(l,C),o.setAddressStateByKey(l,C)}function V(l){P(l),o.setAddressFormat(l)}Be(n,()=>({update:l=>{c(l),o.setAddressState(l),V(o.getAddressFormat()),m(o.getProvinceOption()??[]),g(o.getCityOptions()??[])}}));function k(l){l.map(C=>{y(C,""),o.setAddressStateByKey(C,"")})}async function p(){const C=navigator.language.split("-"),I=s.country||((C==null?void 0:C[1])??"US");ie(I||""),t({...s})}const x={[xe.ADDRESS_1]:X,[xe.ADDRESS_2]:Q,[xe.CITY]:re,[xe.AREA]:ee,[xe.POST_CODE]:Y,[xe.PROVINCE]:ae};function K(){return{trigger:["blur","submit"],validator(l){if(!l)throw new Error;return!0}}}async function ie(l){var pe,U;if(V([]),_("COUNTRY",l),((U=(pe=a==null?void 0:a.core)==null?void 0:pe.config._checkoutConfig)==null?void 0:U.addressMode)==="country"){t({...Q2,country:l});return}const I=await a8(l,{locale:r.locale}),j=[],we=I.map(({addressItem:Z,required:B,description:M})=>(j.push(Z),{addressItem:Z,required:B,description:M}));q(j,l),V(we),k([xe.PROVINCE,xe.CITY,xe.AREA,xe.POST_CODE,xe.ADDRESS_1,xe.ADDRESS_2]),g([]),o.setCityOptions([]),t({...Q2,country:l})}async function q(l,C){if(l.includes(xe.PROVINCE)){ne(C);return}if(!l.includes(xe.PROVINCE)&&l.includes(xe.CITY)){J(C);return}}async function ne(l){o.requestProvinceOption(l).then(C=>{m(C)})}async function W(l){var C;_(xe.PROVINCE,l),J(l),k([xe.CITY]),(C=b.current)==null||C.validateChange(""),t({...s,province:l,city:""})}async function J(l){const C=await i8(l);if(C)return g(C),o.setCityOptions(C),C}function se(l){_(xe.CITY,l),t({...s,city:l})}function z(){var C,I;const l=(I=(C=a==null?void 0:a.core)==null?void 0:C.config._checkoutConfig)==null?void 0:I.addressMode;return i(At,{ref:E,label:r.get("address.label"),path:"address.country",rule:K(),showErrorMessage:!1,children:i(Tr,{value:s.country,filterable:!0,options:d,onSelect:j=>ie(j),placeholder:r.get("address.country"),inputClassName:Ao("first-item",{"no-bottom-radius":l==="address"}),noDataTip:r.get("common.noData")})})}function X({description:l,className:C}){return i(At,{ref:T,path:"address.address1",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.address1,onInput:I=>_(xe.ADDRESS_1,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.address1")}function Q({description:l,className:C}){return i(At,{ref:A,path:"address.address2",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.address2,onInput:I=>_(xe.ADDRESS_2,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.address2")}function Y({description:l,className:C}){return i(At,{ref:S,path:"address.postCode",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.postCode,onInput:I=>_(xe.POST_CODE,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.postCode")}function ee({description:l,className:C}){return i(At,{ref:N,path:"address.area",rule:K(),showErrorMessage:!1,children:i(_t,{value:s.area,onInput:I=>_(xe.AREA,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.area")}function re({description:l,className:C}){return i(At,{ref:b,path:"address.city",rule:K(),showErrorMessage:!1,children:Rn(h)&&h.length>0?i(Tr,{value:s.city,filterable:!0,options:h,onSelect:I=>se(I),placeholder:l,inputClassName:C,noDataTip:r.get("common.noData")}):i(_t,{value:s.city,onInput:I=>_(xe.CITY,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.city")}function ae({description:l,className:C}){return i(At,{ref:v,path:"address.province",rule:K(),showErrorMessage:!1,children:Rn(u)&&u.length>0?i(Tr,{value:s.province,filterable:!0,options:u,onSelect:I=>W(I),placeholder:l,inputClassName:C,noDataTip:r.get("common.noData")}):i(_t,{value:s.province,onInput:I=>_(xe.PROVINCE,I.currentTarget.value),placeholder:l,inputClassName:C})},"address.province")}function me(l){const C=w==null?void 0:w.length;return Dt(C)||C===1?"":l===C-1?Ao("last-item"):Ao("mid-item")}return i("div",{style:"width: 100%",children:[z(),w==null?void 0:w.map((l,C)=>x[l.addressItem]({description:l.description,className:me(C)}))]})});class ou{constructor(n){Ae(this,"_email");Ae(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 wo;const lt=e=>wo||(wo=new ou(e)),Ct=Fe((e,n)=>{const{className:t,style:r,disabled:a}=e,{i18n:o}=yt(),[s,c]=O(""),d=$(null),f=lt(e.value??"");Be(n,()=>({update:g=>{var w;u(g),(f.isValid||yl(g))&&((w=d.current)==null||w.validate(g,{trigger:"submit",setResult:!0}))}})),Ce(()=>{u(e.value)},[e.value]);const u=g=>{f.email=g??"",c(g??"")},m={trigger:["blur","submit"],validator(g){if(!g)throw new Error(o.get("common.email.incomplete"));if(!new RegExp(t5).test(g))throw new Error(o.get("common.email.incorrect"));return!0}},h=g=>{var P;const{currentTarget:w}=g;u(w.value),(P=e.onInput)==null||P.call(e,g)};return i(At,{ref:d,label:o.get("common.email.label"),path:"email",rule:m,className:t,style:r,children:i(_t,{value:s,disabled:a,maxLength:100,onInput:h})})}),{bem:Eo}=_e("info"),iu={error:Zi};function nt(e){const{type:n="error",content:t,className:r,style:a}=e,o=iu[n];return i("div",{className:ye(ge,Eo([n]),r),style:a,children:[i("div",{className:Eo("icon"),children:i(o,{size:16})}),i("div",{className:Eo("content"),children:t})]})}const{bem:Po}=_e("recurring-tip");function So(){return i(ze.Consumer,{children:e=>{var n;return i("div",{className:Po(),children:[i("div",{className:Po("icon"),children:Gi({size:16})}),i("div",{className:Po("text"),children:(n=e==null?void 0:e.i18n)==null?void 0:n.get("common.recurringTip")})]})}})}const{bem:K2}=_e("button");function Io(e){const{style:n,className:t,children:r,icon:a,loading:o,disabled:s,dashed:c}=e;function d(f){var u;o||s||(u=e.onClick)==null||u.call(e,f)}return i("button",{className:ye(ge,K2({loading:o,disabled:s,dashed:c}),t),style:n,onClick:d,children:[!!a&&i("div",{className:K2("icon"),children:a}),r]})}const _o=40,su=`0 0 ${_o} ${_o}`,z2=3.3,J2=_o/2-z2-.5,X2=2*Math.PI*J2,cu=3.2,{bem:Ro}=_e("loading-check");function du({color:e="currentColor",checkedColor:n="currentColor",checked:t=!1,size:r,className:a,style:o,onCheckShow:s}){const[c,d]=O(75),[f,u]=O(!1),[m,h]=O(!1),g=Ie(r)?"1em":`${r}px`,P={strokeDasharray:`${X2*(c/100)} ${X2}`,animationPlayState:f?"running":"paused"};t?(d(100),u(!1)):(h(!0),u(!0),d(75));function E(){h(!1),s==null||s()}return i("div",{className:ye(ge,Ro(),a),style:B4({width:g,height:g},o),children:i("svg",{width:g,height:g,viewBox:su,children:[m&&i("circle",{className:Ro("circle",["loading"]),cx:"50%",cy:"50%",r:J2,fill:"none",stroke:e,"stroke-width":z2,"stroke-linecap":"round",style:P}),t&&i("polyline",{className:Ro("check"),points:"8.5,20 18.2,29.5 31.5,10.5",fill:"none",stroke:n,"stroke-width":cu,"stroke-linecap":"round","stroke-linejoin":"miter",onAnimationStart:E})]})})}const{bem:$2}=_e("submit-button"),ut=e=>{const{text:n,loadingText:t,successText:r,status:a="unSubmit",onClick:o,className:s,style:c,icon:d=wl}=e,[f,u]=O(n),{i18n:m}=yt(),h=()=>a==="unSubmit"?i(d,{size:20,disabled:!e.verified}):i(du,{checked:a==="success",size:20,onCheckShow:()=>u(r||m.get("common.paySuccess"))});return Ce(()=>{if(a==="success")return;const g=a==="loading"?t||m.get("common.payProcessing"):n||m.get("common.pay");u(g)},[a,n]),i(Io,{icon:h(),onClick:o,className:ye($2({success:a==="success"}),s),style:c,loading:a==="loading",disabled:e.disabled||a==="success",children:i("span",{class:$2("text",{"not-verified":!e.verified}),children:f})})},{bem:x1}=_e("ali-pay"),ec=x1("field"),lu=Fe((e,n)=>{const{session:t,core:r,showEmail:a=!1,showAddress:o=!1}=e,s=r.getAddressCore(),c=lt(),{setErrorMsg:d,fraudDetection:f,i18n:u,errorMsg:m,sessionReady:h}=et(t,e.core),[g,w]=O("unSubmit"),P=$(null),[E,v]=O({email:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[b,N]=O(!1),[S,T]=O(),A=$(null),R=$(null),[y,_]=O(!1);Be(n,()=>({stopRetry:()=>{ie(),w("unSubmit")},startRetry:Q=>{w("loading"),K({timeout:Q})},updateAddress:()=>{var Y;if(!(S!=null&&S.address.show))return;const Q=Object.assign(E,{address:s.getAddressState()});v(Q),(Y=A.current)==null||Y.update(s.getAddressState()),V()},updateEmail:()=>{var Y;if(!(S!=null&&S.email.show))return;const Q=Object.assign(E,{email:c.email});v(Q),(Y=R.current)==null||Y.update(c.email),V()}}));function V(){var Q;(Q=P.current)==null||Q.validate(void 0,!1).then(()=>{N(!0)}).catch(()=>{N(!1)})}const k=()=>{const{field:Q,sessionMode:Y}=t.checkout,{email:ee,address:re}=Q;Y===Ue.COMPONENT&&(ee.disabled&&(ee.show=a),o&&!(re!=null&&re.show)&&(re.show=!0)),T({...Q})};Ce(()=>{V()},[E]);const p=Q=>{var Y,ee;w("success"),(ee=e.onSuccess)==null||ee.call(e,ft({...Q,returnUrl:(Y=t==null?void 0:t.checkout)==null?void 0:Y.returnUrl}))};Ce(()=>{if(!h)return;const{bill:Q={},supportMethods:Y=[],country:ee}=(t==null?void 0:t.checkout)||{};Y.includes(G.ALI_PAY)&&(k(),_(!0),ee&&s.setCountry(ee),E.email=Q.email??"",E.address.country=ee)},[h]);const x=qe(Q=>{var Y;d(Q||u.get("common.payTimeout")),w("unSubmit"),(Y=e.onTimeout)==null||Y.call(e,"retry")},[u,e.onTimeout]),{start:K,stop:ie}=Xe(Q=>ne(!0,Q),{onTimeout:()=>x(u.get("common.queryTimeout"))}),q=async()=>({sessionId:t.sessionId,clientKey:t.clientKey,bill:S!=null&&S.address.show?{email:E.email,addressLine1:E.address.address1,addressLine2:E.address.address2,postalCode:E.address.postCode,country:E.address.country,district:E.address.area,state:E.address.province?s.getLabel(E.address.province,s.getProvinceOption())??E.address.province:void 0,city:E.address.city?s.getLabel(E.address.city,s.getCityOptions())??E.address.city:void 0}:{email:E.email},payment:{paymentMethod:G.ALI_PAY},browser:await Je({fraudDetectionId:await(f==null?void 0:f.getFraudDetectionId())})});async function ne(Q=!1,Y){var ee,re,ae,me,l,C,I,j,we;try{const pe={locale:u.locale,timeout:Y};let U=null;if(Q){const D=(re=(ee=r.config)._getExtraParams)==null?void 0:re.call(ee,"query",G.ALI_PAY);U=await f8({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.ALI_PAY},D,pe)}else{const D=(me=(ae=r.config)._getExtraParams)==null?void 0:me.call(ae,"payment",G.ALI_PAY);U=await m8(await q(),D,pe)}const{status:Z,orderStatus:B,errorMessage:M,errorCode:F,sessionId:L}=U;if(L&&(t.sessionId=L),!Q&&((l=e.onSubmitResponse)==null||l.call(e,U)),Z==="PROCESSING")if(B){if(B==="SUCCESS")return p(U),{end:!0};if(B==="FAILURE")return M&&d(M),w("unSubmit"),(C=e.onError)==null||C.call(e,new Ee("API_ERROR",M,{code:F})),{end:!0};if(B==="PROCESSING")return!Q&&K(),{end:!1};if(B==="CANCELED")return w("unSubmit"),(I=e.onTimeout)==null||I.call(e,"channel"),{end:!0}}else return w("unSubmit"),{end:!0};else{if(Z==="SUCCESS")return p(U),{end:!0};if(Z==="EXPIRED")return w("unSubmit"),(j=e.onExpired)==null||j.call(e),{end:!0}}return w("unSubmit"),{end:!0}}catch(pe){if(We(pe))return Q?{end:!1}:(x(),{end:!0});{const U=pe.i18nKey?u.get(pe.i18nKey):pe.message;return U&&d(U),(we=e.onError)==null||we.call(e,new Ee("API_ERROR",U,{code:pe.code,cause:pe})),w("unSubmit"),{end:!0}}}}async function W(){var Q;d(""),(Q=P.current)==null||Q.validate(async Y=>{var ee;if(S!=null&&S.address.show&&s.setValidateAllFields(!0),(ee=e.onSubmit)==null||ee.call(e,Y),Y){w("unSubmit");return}d(""),w("loading"),await ne()})}const J=()=>{const{transAmount:Q,channelParams:Y={}}=(t==null?void 0:t.checkout)??{},{totalAmount:ee}=Y.aliPay??{},re=(ee!=null&&ee.amount?ee:Q)||{},ae=re!=null&&re.amount?it(re).jointSymbol():"",me=u.get("common.pay")+(ae?` ${ae}`:"");return i(ut,{className:x1("button"),status:g,text:me,loadingText:u.get("common.payProcessing"),successText:u.get("common.paySuccess"),onClick:W,verified:b})},se=Q=>{P.current=Q,Q&&V()},z=()=>i(he,{children:(S==null?void 0:S.email.show)&&i("div",{className:ec,children:i(Ct,{ref:R,value:E.email,disabled:S==null?void 0:S.email.disabled})})}),X=()=>{var Q,Y;return i(he,{children:(S==null?void 0:S.address.show)&&i("div",{className:ec,children:i(ht,{ref:A,value:E.address,country:((Q=t==null?void 0:t.checkout)==null?void 0:Q.country)||((Y=t==null?void 0:t.checkout)==null?void 0:Y.bill.country),onAddressChange:ee=>v(Object.assign(E,{address:ee}))})})})};return i(ze.Provider,{value:{i18n:u,session:t,core:r},children:y&&u.ready.value&&i("div",{className:r.theme.className,children:i(dt,{form:E,ref:se,onFormChange:Q=>v(Q),children:i("div",{className:ye(ge,x1()),children:[z(),X(),(t==null?void 0:t.checkout.paymentType)===Nn.RECURRING&&So(),i("div",{className:x1("footer-wrapper"),children:[!!m&&i(nt,{className:x1("error"),content:m}),J()]})]})})})})}),{bem:tc}=_e("card-brands");function nc(e){const{supportedCardBrands:n,max:t=6,className:r,style:a}=e,o=$(null),[s,c]=O(0),d=tr(n).map(h=>Va(h)),f=d.length-t,u=d.slice(t-1),m=u[s];return Ce(()=>(o.current=window.setInterval(()=>{c(h=>{const g=h+1,w=u.length;return g===w?0:N1(g,0,w-1)})},3e3),()=>{o.current&&(window.clearInterval(o.current),o.current=null)}),[]),i("div",{className:ye(ge,tc(),r),style:a,children:[d.slice(0,t-1).map(h=>h.icon&&i(h.icon,{size:32},h.code)),!!(m!=null&&m.icon)&&i(m.icon,{size:32},m.code),f>0&&i("div",{className:tc("more"),children:["+",f]})]})}const rc=e=>{const{currentTarget:n,data:t}=e;let r=Xt(n.value);const a=r.length;return a===1&&Number(r)>1?r=`0${r}`:a===2&&Number(r)>12&&(r=`01${t}`),a>=2&&!r.includes("/")&&(r=r.slice(0,2)+"/"+r.slice(2,4)),r},ac=e=>{const{currentTarget:n}=e;let t=Xt(n.value);const r=t.length;if(r===0)return"";if(r===1&&Number(t)>1)t=`0${t}`;else if(r>=2){const a=t.slice(0,2);Number(a)>12?t=`0${t.slice(0,1)}/${t.slice(1,3)}`:t.includes("/")||(t=t.slice(0,2)+"/"+t.slice(2,4))}return t.length>5&&(t=t.slice(0,5)),t},Lo=Fe((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,s=$(null),c=$(null);Be(n,()=>({input:s.current,focus:()=>{var g;(g=s.current)==null||g.focus()},blur:()=>{var g;(g=s.current)==null||g.blur()},resetValidation:(g,w)=>{var P;(P=c.current)==null||P.resetValidation(g,[{message:w}])}}));const{i18n:d}=yt(),[f,u]=O(""),m={trigger:["blur","submit"],validator(g){if(a){const w=c.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Ie(g)||g.length!==5)throw new Error(d.get("card.cardExpireDate.incomplete"));if(n2(g))throw new Error(d.get("card.cardExpireDate.expired"));return!0}};function h(g){var b,N,S,T;const{inputType:w,currentTarget:P}=g,E=P.selectionStart;let v;if(w==="insertText")v=rc(g);else if(w==="insertFromPaste")v=ac(g);else{v=P.value;const A=f.slice(E,E+1),R=f.length;if(R>3&&A==="/"){u(P.value=f),P.setSelectionRange(E,E),(b=e.onInput)==null||b.call(e,g);return}else if(E===1){const y=f.slice(0,2);R>2&&+y>=10?v=`01${f.slice(2,R)}`:v=v.slice(0,1)}else if(E===0&&v.length>1){A==="0"?u(P.value=f):A==="1"&&u(P.value=`0${v}`),P.setSelectionRange(0,0),(N=e.onInput)==null||N.call(e,g);return}else if(E===3)if(R===4)v=v.slice(0,2);else{u(P.value=v),P.setSelectionRange(E-1,E-1),(S=e.onInput)==null||S.call(e,g);return}}u(P.value=v),w!=="insertText"&&P.setSelectionRange(E+1,E+1),(T=e.onInput)==null||T.call(e,g)}return i(At,{label:d.get("card.cardExpireDate.label"),showLabel:o,path:"expireDate",ref:c,rule:m,className:t,style:r,children:i(_t,{type:"text",inputmode:"numeric",ref:s,maxLength:5,value:f,onInput:h,placeholder:d.get("card.cardExpireDate.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.EXPIRE_DATE})})})});function oc(e){const{className:n,style:t,disabled:r}=e,{i18n:a}=yt(),o={trigger:["blur","submit"],validator(c){if(!c)throw new Error(a.get("card.cardHolderName.incomplete"));return!0}};function s(c){var d;(d=e.onInput)==null||d.call(e,c)}return i(At,{label:a.get("card.cardHolderName.label"),path:"holderName",rule:o,className:n,style:t,children:i(_t,{maxLength:100,placeholder:a.get("card.cardHolderName.placeholder"),onInput:s,disabled:r})})}const No=Fe((e,n)=>{const{supportedCardBrands:t=[],className:r,security:a,showLabel:o,onBinValue:s}=e,c=$(null),d=$(null);Be(n,()=>({input:c.current,focus:()=>{var _;(_=c.current)==null||_.focus()},blur:()=>{var _;(_=c.current)==null||_.blur()},resetValidation:(_,V)=>{var k;(k=d.current)==null||k.resetValidation(_,[{message:V}])},binValueChanged:_=>{m(_)},binValue:()=>u,brandChanged:_=>{if(_){const V=Da(_);v(()=>V==null?void 0:V.icon),N(V==null?void 0:V.code)}else v(void 0),N(void 0)},getCardBrand:()=>nr(Yt(u),w)||{code:b}}));const{i18n:f}=yt(),[u,m]=O(""),[h,g]=O(""),w=tr(t),P=zi(w),[E,v]=O(void 0),[b,N]=O(void 0),[S,T]=O("");Ce(()=>{const _=Yt(u);v(u?()=>{var k;return(k=nr(_,w))==null?void 0:k.icon}:void 0);const V=_.substring(0,6);T(V.length<6?"":V)},[u]),Ce(()=>{s==null||s(S)},[S]);const A={trigger:["blur","submit"],validator(_){if(a){const k=d.current.getValidateResult();if(k.status==="error")throw new Error(k.errors[0].message);if(k.status==="success")return!0}if(_=Yt(_??""),!P.includes(_.length))throw new Error(f.get("card.cardNumber.incomplete"));if(!nr(_,w))throw new Error(f.get("card.cardNumber.invalid"));return!0}};function R(_){var ie;const{currentTarget:V,inputType:k}=_,p=V.selectionStart;let x=Xt(V.value);x=x.replace(/(\d{4})(?=\d)/g,"$1 ");let K=p;K%5===0&&(K=N1(p+(k==="insertText"?1:-1),0)),m(V.value=x),V.setSelectionRange(K,K),(ie=e.onInput)==null||ie.call(e,_)}const y=()=>{if(h!=="error")return i(E??Ta,{size:32})};return i(At,{label:f.get("card.cardNumber.label"),showLabel:o,path:"number",ref:d,rule:A,onValidationStatusChange:g,className:r,children:i(_t,{type:"text",inputmode:"numeric",ref:c,maxLength:23,value:u,onInput:R,rightIcon:y(),placeholder:f.get("card.cardNumber.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.CARD_NUMBER})})})}),kr=Fe((e,n)=>{const{className:t,style:r,security:a,showLabel:o}=e,s=$(null),c=$(null);Be(n,()=>({input:s.current,focus:()=>{var g;(g=s.current)==null||g.focus()},blur:()=>{var g;(g=s.current)==null||g.blur()},resetValidation:(g,w)=>{var P;(P=c.current)==null||P.resetValidation(g,[{message:w}])}}));const{i18n:d}=yt(),[f,u]=O(""),m={trigger:["blur","submit"],validator(g){if(a){const w=c.current.getValidateResult();if(w.status==="error")throw new Error(w.errors[0].message);if(w.status==="success")return!0}if(Ie(g)||g.length<3)throw new Error(d.get("card.cardSecurityCode.incomplete"));return!0}};function h(g){var P;const w=Xt(g.currentTarget.value);u(g.currentTarget.value=w),(P=e.onInput)==null||P.call(e,g)}return i(At,{label:d.get("card.cardSecurityCode.label"),showLabel:o,path:"securityCode",ref:c,rule:m,className:t,style:r,children:i(_t,{type:"text",inputmode:"numeric",ref:s,maxLength:4,value:f,onInput:h,placeholder:d.get("card.cardSecurityCode.placeholder"),children:a&&i("div",{style:"width:100%;height:100%","data-sf":Oe.CVV})})})}),{bem:Mo}=_e("card-no"),ic=e=>{const{value:n,className:t,style:r}=e;return i("div",{className:ye(ge,Mo("wrapper"),t),style:r,children:[Array.from({length:4},(a,o)=>o).map(()=>i("span",{className:Mo("dot")})),i("span",{className:Mo("card-no"),children:n})]})},sc=e=>{const{cardList:n=[],onCardChange:t,onClickEdit:r,className:a,style:o,onClickChange:s,value:c}=e,{i18n:d}=yt(),{bem:f}=_e("card-selector"),u=$(null),m=$(null),h={trigger:["blur","submit"],validator(){return!0}},g=()=>n.map(S=>({label:"",value:S.token,...S})),[w,P]=O(c);Ce(()=>{if(c){const S=g().find(({token:T})=>c===T);E(c,S)}},[c]);const E=(S,T)=>{P(S),t==null||t(T)},v=S=>{var A;const T=((A=Da(S.cardBrand))==null?void 0:A.icon)??Ta;return i("div",{className:f("label"),children:[i(T,{size:32}),i("div",{className:f("card-no"),children:i(ic,{value:S.last4})}),i("span",{})]})},b=()=>i("div",{className:f("change"),onClick:s,children:[i(Yi,{}),i("span",{style:{marginLeft:"4px"},children:d.get("card.cardSelector.change")})]}),N=()=>{const S=()=>{var T;(T=u.current)==null||T.blur(),r==null||r()};return i("div",{className:f("action"),children:i(Io,{style:{borderRadius:"6px",fontSize:"14px"},dashed:!0,icon:i(_l,{}),onClick:S,children:d.get("card.cardSelector.useOtherCard")})})};return i(At,{label:d.get("card.cardNumber.label"),path:"token",rule:h,className:a,style:o,ref:m,children:i(Tr,{value:w,ref:u,options:g(),renderLabel:v,onSelect:E,noDataTip:d.get("common.noData"),action:N(),rightIcon:b()})})};function uu({size:e,style:n,className:t}){const r=Ie(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:ye(ge,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:cc}=_e("check-box"),mu=e=>{const{checked:n,onChange:t,label:r,style:a}=e,o=()=>{t==null||t(!n)};return i("div",{className:ye(ge,cc({checked:n})),onClick:o,style:a,children:[i("div",{className:cc("inner"),children:i(uu,{size:10})}),i("span",{children:r})]})},fu=e=>e?Array.prototype.slice.call(e.querySelectorAll(`[${Ws}]`)):[];class hu{constructor(n){Ae(this,"iframe");Ae(this,"iframeWindow");Ae(this,"hiddenIframe");Ae(this,"config");this.config=n,this.init()}init(){const{iframeSrc:n,iframeClassName:t,fieldNode:r,iframeName:a}=this.config,o=Ks(n);o.width="100%",o.height="100%",o.style.border="none",o.name=a,r.appendChild(o);const s=r.querySelector(`.${t}`);s&&(this.iframe=s,s.addEventListener("load",()=>this.onFieldIframeLoad()))}onFieldIframeLoad(){this.iframeWindow=this.iframe.contentWindow;const{fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o,checkoutId:s}=this.config,c={action:Ve.INIT,checkoutId:s,config:{checkoutId:s,fieldType:n,placeholder:t,style:r,hiddenIframeName:a,supportedCardBrands:o},hidden:!1,cdnUrl:$n};mt(c,this.iframeWindow,jt)}}const Vr=Fe((e,n)=>{const{sessionMode:t,i18n:r,targetElement:a,checkoutId:o}=e,s=$(null),c=$(null),d=(v,b)=>{const N={action:Ve.PAYMENT,checkoutId:o,formData:v,extraParams:b,locale:e.i18n.locale};mt(N,c.current.contentWindow,jt)};if(Be(n,()=>({payment:d,reload:()=>{t!==Ue.HOSTED&&(window.removeEventListener("message",E),c.current&&document.body.removeChild(c.current),h())},encryptCard:v=>{const b={action:Ve.ENCRYPT_CARD,...v};mt(b,c.current.contentWindow,jt)},validate:()=>{Object.values(u.current).forEach(v=>{const b={action:Ve.VALIDATE,checkoutId:o};mt(b,v.iframe.contentWindow,jt)})},setConfig:v=>{e.style=v.style}})),!frames&&t===Ue.HOSTED)return e.children;let f=[];const u=$({}),m={[Oe.CARD_NUMBER]:r.get("card.cardNumber.placeholder"),[Oe.CVV]:r.get("card.cardSecurityCode.placeholder"),[Oe.EXPIRE_DATE]:r.get("card.cardExpireDate.placeholder"),[R1.CPF]:r.get("cpf.placeholder")};Ce(()=>{h()},[]);const h=async()=>{f=fu(a||s.current),f.length&&(await g(),w(),window.addEventListener("message",E))},g=async()=>{const v=Ks(`${$n}/secured-iframe.html`);v.name=`${Y4}-${o}-${Date.now()}`,v.width="0",v.height="0",v.style.border="none",c.current=v;const b={action:Ve.INIT,hidden:!0,checkoutId:o,apiUrl:io,cdnUrl:$n,apiPrefix:Re};v.addEventListener("load",()=>{mt(b,c.current.contentWindow,jt)}),window.document.body.appendChild(v)},w=()=>{f.forEach(v=>{const b=v.getAttribute(Ws);u.current[b]=new hu({fieldNode:v,hiddenIframe:c.current,hiddenIframeName:c.current.name,rootNode:s.current,iframeSrc:`${$n}/secured-iframe.html`,iframeName:`${j4}-${o}-${Date.now()}`,iframeClassName:Qs,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,checkoutId:o})})},P=v=>{var S;const b=Object.values(u.current).some(T=>T.iframe.contentWindow===v),N=((S=c.current)==null?void 0:S.contentWindow)===v;return b||N},E=qe(v=>{var A,R,y,_,V,k,p,x,K,ie,q,ne;const{data:b,origin:N,source:S}=v;if(N!==jt||!S||!P(S))return;const T=M1(b);if(Reflect.has(T,"action")&&T.checkoutId===o)switch(T.action){case Ve.FOCUS:(A=e.onFocus)==null||A.call(e,T);break;case Ve.BIN_VALUE:(R=e.onBinValue)==null||R.call(e,T);break;case Ve.BRAND:(y=e.onBrand)==null||y.call(e,T);break;case Ve.AFTER_PAYMENT:(_=e.onAfterPayment)==null||_.call(e,T);break;case Ve.PAYMENT_ERROR:(V=e.onPaymentError)==null||V.call(e,T);break;case Ve.PAYMENT_TIMEOUT:(k=e.onPaymentTimeout)==null||k.call(e,T);break;case Ve.VALID_STATUS_CHANGED:(p=e.onValidStatusChanged)==null||p.call(e,T);break;case Ve.AUTHORIZED:(x=e.onAuthorized)==null||x.call(e,T);break;case Ve.ACTIVATED:(K=e.onActivated)==null||K.call(e,T);break;case Ve.CARD_ENCRYPTED:(ie=e.onCardEncrypted)==null||ie.call(e,T);break;case Ve.CARD_ENCRYPTION_FAILED:(q=e.onCardEncryptionFailed)==null||q.call(e,T);break;case Ve.VALIDATED:(ne=e.onValidated)==null||ne.call(e,T);break}},[]);return i("div",{ref:s,children:!a&&e.children})}),{bem:r1}=_e("modal"),dc=Fe(e=>{const{show:n=!1,width:t,height:r,maskClosable:a,header:o,children:s,onChange:c,style:d,appendToBody:f=!1}=e,[u,m]=O(),[h,g]=O(),{i18n:w}=yt();Ht(()=>{m(typeof t=="number"?`${t}px`:t),g(typeof r=="number"?`${r}px`:r)},[t,r]);const P=()=>{a&&(c==null||c(!1))},E=()=>{c==null||c(!1)},v=i(he,{children:n&&i("div",{className:r1(),children:[i("div",{className:r1("mask"),onClick:P}),i("div",{className:r1("content"),style:{width:u,height:h,...d},children:[o||i("div",{className:r1("header"),children:i("div",{className:r1("close"),onClick:E,children:w.get("common.cancel")})}),i("div",{className:r1("body"),children:s})]})]})});return f?n?el(v,document.body):null:v}),{bem:O1}=_e("three-ds-auth"),lc=e=>{const{show:n=!1,onClose:t,url:r,incomplete:a=!0,width:o,height:s="72vh",theme:c,checkoutId:d}=e,f=T2(),[u,m]=O(!1),h=$(),g=$(null),[w]=O(`${q4}-${d}-${Date.now()}`),{i18n:P}=yt(),E=()=>{m(!0)},v=N=>{!N&&(t==null||t())},b=Ht(()=>n?o||(f.smaller("sm")?"90vw":"600px"):"0",[n,o,f.matches]);return Ce(()=>{n?(h.current&&window.removeEventListener("message",h.current),h.current=N=>{const{data:S,origin:T}=N;if(T!==jt)return;const A=M1(S);if(A.checkoutId===d)switch(A.action){case Ve.CHECK_THREE_DS:{v(!1);break}}},window.addEventListener("message",h.current)):h.current&&window.removeEventListener("message",h.current)},[n]),i(dc,{show:n,onChange:v,width:b,height:s,style:{maxWidth:"calc(100vw - 10px)",maxHeight:"calc(100vh - 100px)",minWidth:"300px"},children:i("div",{className:O1("content"),children:!a||u?i("iframe",{ref:g,name:w,class:O1("three-ds-iframe"),width:"100%",height:"100%",frameBorder:0,src:r}):i("div",{className:O1("last-three-ds"),children:[i(Rl,{className:O1("last-three-ds-icon"),size:60}),i("div",{className:O1("last-three-ds-title"),children:[i("div",{children:P.get("threeDS.paymentIncomplete")}),i("div",{children:P.get("threeDS.completeFirst")})]}),i("div",{children:i(Io,{style:{backgroundColor:c==null?void 0:c.payButtonBackgroundColor,color:c==null?void 0:c.payButtonTextColor},onClick:E,children:P.get("common.confirm")})})]})})})},{bem:F1}=_e("combined-card-info"),To=Fe((e,n)=>{const{supportedCardBrands:t=[],className:r,showLabel:a=!1,security:o}=e,s=$(null),c=$(null),{i18n:d}=yt();Be(n,()=>({input:s.current,focus:()=>{var P;(P=s.current)==null||P.focus()},blur:()=>{var P;(P=s.current)==null||P.blur()},resetValidation:(P,E)=>{var v;(v=c.current)==null||v.resetValidation(P,[{message:E}])},binValueChanged:P=>{m(P)},binValue:()=>u,brandChanged:P=>{if(P){const E=Da(P);g(()=>E==null?void 0:E.icon)}else g(void 0)},getCardBrand:()=>nr(Yt(u),tr(t))||{}}));const f={trigger:["submit"],validator(){if(o){const P=c.current.getValidateResult();if(P.status==="error")throw new Error(P.errors[0].message);if(P.status==="success")return!0}return!0}},[u,m]=O(""),[h,g]=O(void 0),w=()=>i(h??Ta,{size:32});return i(At,{showLabel:a,ref:c,label:d.get("card.info.label"),className:r,path:"cardInfo",rule:f,children:i(_t,{ref:s,leftIcon:w(),rightIcon:i("div",{className:F1("blank-icon")}),children:i("div",{className:F1(),children:[i("div",{className:F1("card-number"),"data-sf":Oe.CARD_NUMBER}),i("div",{className:F1("expire-date"),"data-sf":Oe.EXPIRE_DATE}),i("div",{className:F1("cvv"),"data-sf":Oe.CVV})]})})})}),{bem:wt}=_e("card"),a1=wt("field"),uc=Fe((e,n)=>{var Dd,xd;const{showCardBrands:t=!0,session:r,cardInfoLayout:a="split",showHolderName:o=!0,showEmail:s=!1,showAddress:c=!1,threeDSFrame:d,styles:f,enable3DSModal:u=!0,isDropIn:m,core:h,hidePaymentButton:g=!1}=e,w=h.getAddressCore(),P=lt(),{i18n:E,fraudDetection:v,sessionReady:b}=et(r,h),N=$(null),S=$(null),T=$(null),A=$(null),[R,y]=O({email:"",number:"",expireDate:"",securityCode:"",holderName:"",cardInfo:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[_,V]=O(!1),[k,p]=O("unSubmit"),[x,K]=O(""),[ie,q]=O(!1),[ne,W]=O(!1),[J,se]=O(!1),[z,X]=O([]),[Q,Y]=O(!1),[ee,re]=O(),[ae,me]=O(),[l,C]=O(!1),[I,j]=O(!0),[we,pe]=O({}),[U]=O(a==="split");Be(n,()=>({checkThreeDS:ei,updateAddress:()=>{var ue;if(!(ae!=null&&ae.address.show))return;const te=Object.assign(R,{address:w.getAddressState()});y(te),(ue=N.current)==null||ue.update(w.getAddressState()),Sn()},updateEmail:()=>{var ue;if(!(ae!=null&&ae.email.show))return;const te=Object.assign(R,{email:P.email});y(te),(ue=S.current)==null||ue.update(P.email),Sn()},payment:()=>{g&&ve()}}));const Z=()=>{const{field:te,sessionMode:ue}=r.checkout,{email:Pe,address:Le,holderName:Ze}=te;ue===Ue.COMPONENT&&(Pe.disabled&&(Pe.show=s),c&&!(Le!=null&&Le.show)&&(Le.show=!0),o&&!(Ze!=null&&Ze.show)&&(Ze.show=!0,Ze.disabled=!0)),me({...te})},B=()=>{if(!f)return;const{input:te}=qs(f);te&&pe(te)};Ce(()=>{var rt,at;if(!b)return;const{status:te,supportMethods:ue=[],bill:Pe={},sessionMode:Le,country:Ze}=(r==null?void 0:r.checkout)||{};if(Le===Ue.DROP_IN&&!m){(at=(rt=e.core.config).onInitError)==null||at.call(rt,new Ee("ERROR","Please send the correct session when creating the checkout"));return}Kn(ue,Ma).length&&(Z(),B(),C(Le!==Ue.HOSTED),Ze&&w.setCountry(Ze),R.email=Pe.email??"",R.address.country=Ze,X(Kn(Qi,ue||[])),se(!0),te==="SUCCESS"&&F(r==null?void 0:r.checkout))},[b]);const M=qe(te=>{var ue;K(te||E.get("common.payTimeout")),p("unSubmit"),(ue=e.onTimeout)==null||ue.call(e),h.resetEnablePaymentMethod()},[E,e.onTimeout]),F=te=>{var ue,Pe;p("success"),(Pe=e.onSuccess)==null||Pe.call(e,ft({...te,returnUrl:(ue=r==null?void 0:r.checkout)==null?void 0:ue.returnUrl}))},L=te=>{var ue;(ue=e.onError)==null||ue.call(e,te),h.resetEnablePaymentMethod()},{start:D}=Xe(te=>De(!0,te),{onTimeout:()=>M(E.get("common.queryTimeout"))}),H=$(kn()),oe=te=>{Hn.current[te.fieldType].status=te.status;const ue=Object.values(Hn.current);ue.includes(null)||(ue.every(Le=>Le.status==="success")?H.current.resolve(!0):H.current.reject(!1))},de=async()=>{var te;H.current=kn(),Object.keys(Hn.current).forEach(ue=>{Hn.current[ue]=null}),(te=ya.current)==null||te.validate();try{await H.current}catch{}};async function ve(){var te;K(""),!U&&l&&await de(),(te=A.current)==null||te.validate(async ue=>{var Pe;if(ae!=null&&ae.address.show&&w.setValidateAllFields(!0),(Pe=e.onSubmit)==null||Pe.call(e,ue),ue){p("unSubmit");return}K(""),p("loading"),await De()})}const le=async()=>{var Tt,ot,$e;const te=Yt(R.number),ue=Ki(te),[Pe,Le]=R.expireDate.split("/"),Ze=Ca&&!ne;let rt=null;Ca?rt=G.BANKCARD:l?rt=(Tt=(U?A1:T).current)==null?void 0:Tt.getCardBrand().code:rt=ue.code;let at;return l&&(at=U?(ot=A1.current)==null?void 0:ot.binValue():($e=T.current)==null?void 0:$e.binValue()),{sessionId:r.sessionId,clientKey:r.clientKey,payment:{paymentMethod:rt,cvv:R.securityCode,...Ze?{token:R.token}:{holderName:R.holderName,expYear:`20${Le}`,expMonth:Pe,cardNo:te,...Sd?{storePaymentMethod:ie}:null}},bill:ae!=null&&ae.address.show?{email:R.email,addressLine1:R.address.address1,addressLine2:R.address.address2,postalCode:R.address.postCode,country:R.address.country,district:R.address.area,state:R.address.province?w.getLabel(R.address.province,w.getProvinceOption())??R.address.province:void 0,city:R.address.city?w.getLabel(R.address.city,w.getCityOptions())??R.address.city:void 0}:{email:R.email},browser:await Je({fraudDetectionId:await(v==null?void 0:v.getFraudDetectionId({bin:te||at||""}))})}};async function De(te=!1,ue){var Pe,Le,Ze,rt,at;try{const Tt={locale:E.locale,timeout:ue};let ot=null;if(te){const $e=(Le=(Pe=h.config)._getExtraParams)==null?void 0:Le.call(Pe,"query",G.BANKCARD);ot=await x2({sessionId:r.sessionId,clientKey:r.clientKey},$e,Tt)}else{const $e=await le(),an=(rt=(Ze=h.config)._getExtraParams)==null?void 0:rt.call(Ze,"payment",G.BANKCARD);if(l)return(at=ya.current)==null||at.payment($e,an),{end:!0};ot=await D2($e,an,Tt)}return ke(ot,te)}catch(Tt){return We(Tt)?te?{end:!1}:(M(),{end:!0}):(Pn(Tt),b1(),{end:!0})}}const Te=(te,ue)=>{var Pe;u?(Y(!0),re({url:te,incomplete:ue,width:d==null?void 0:d.modalWidth,height:d==null?void 0:d.modalHeight})):(Pe=e.onThreeDS)==null||Pe.call(e,te,ue)},je=()=>{Y(!1),re(void 0),ei()},ke=(te,ue=!1)=>{var $e,an;const{status:Pe,orderStatus:Le,errorMessage:Ze,errorCode:rt,payInfo:at={},sessionId:Tt}=te,{threeDSUrl:ot}=at;if(Tt&&(r.sessionId=Tt),Pe==="PROCESSING"){if(!Le)p("unSubmit");else if(Le==="SUCCESS")F(te);else{if(Le==="PROCESSING")return!ue&&D(),{end:!1};Le==="FAILURE"?(Ze&&K(Ze),p("unSubmit"),L(new Ee("API_ERROR",Ze,{code:rt}))):Le==="AUTHORIZED"?(p("unSubmit"),($e=e.onAuthorized)==null||$e.call(e)):Le==="IN_THREED"?ot&&Te(ot,!1):Le==="IN_PREVIOUS_THREED"&&ot&&Te(ot,!0)}return{end:!0}}else{if(Pe==="SUCCESS")return F(te),{end:!0};if(Pe==="EXPIRED")return p("unSubmit"),(an=e.onExpired)==null||an.call(e),{end:!0}}return p("unSubmit"),{end:!0}},Pn=te=>{const ue=te.i18nKey?E.get(te.i18nKey):te.message;K(ue),p("unSubmit"),L(new Ee("API_ERROR",ue,{code:te.code,cause:te}))},Sn=()=>{var te;(te=A.current)==null||te.validate(void 0,!1).then(()=>{V(!0)}).catch(()=>{V(!1)})};Ce(()=>{Sn()},[R]);const ha=()=>{var Le;const te=(Le=r==null?void 0:r.checkout)==null?void 0:Le.transAmount,ue=te!=null&&te.amount?it(te).jointSymbol():"",Pe=E.get("common.pay")+(ue?` ${ue}`:"");return i(ut,{className:wt("button"),status:k,text:Pe,loadingText:E.get("common.payProcessing"),successText:E.get("common.paySuccess"),onClick:ve,verified:_})},{start:j1,stop:b1}=Xe(te=>ei(!0,te),{timeout:12*1e3,onTimeout:()=>M(E.get("common.queryTimeout"))});async function ei(te=!1,ue=2e4){var Pe,Le,Ze,rt;if(!r)return{end:!0};try{const at=(Le=(Pe=h.config)._getExtraParams)==null?void 0:Le.call(Pe,"query",G.BANKCARD),Tt=await x2({sessionId:r.sessionId,clientKey:r.clientKey},at,{locale:E.locale,timeout:ue}),{status:ot,orderStatus:$e,errorMessage:an,errorCode:i9}=Tt;if(ot==="PROCESSING"){if($e==="PROCESSING")D();else if($e==="FAILURE")an&&K(an),p("unSubmit"),L(new Ee("API_ERROR",an,{code:i9}));else if($e==="AUTHORIZED")p("unSubmit"),(Ze=e.onAuthorized)==null||Ze.call(e);else{if($e==="IN_THREED")return p("loading"),!te&&j1(),{end:!1};$e==="IN_PREVIOUS_THREED"?(K(E.get("common.pay3DSIncomplete")),p("unSubmit")):$e||p("unSubmit")}return b1(),{end:!0}}else{if(ot==="SUCCESS")return F(Tt),b1(),{end:!0};if(ot==="EXPIRED")return p("unSubmit"),(rt=e.onExpired)==null||rt.call(e),b1(),{end:!0}}return p("unSubmit"),b1(),{end:!0}}catch(at){return We(at)?te?{end:!1}:(M(E.get("common.queryTimeout")),{end:!0}):(Pn(at),b1(),{end:!0})}}const Ca=Ht(()=>{var Pe;if(!(r!=null&&r.checkout))return;const te=(r==null?void 0:r.checkout.paymentType)===Nn.PURCHASE,ue=!!((Pe=r==null?void 0:r.checkout.tokens)!=null&&Pe.length);return te&&ue},[r==null?void 0:r.checkout]),Sd=Ht(()=>{if(r!=null&&r.checkout)return(r==null?void 0:r.checkout.paymentType)===Nn.PURCHASE&&(r==null?void 0:r.checkout.storePaymentMethod)},[r==null?void 0:r.checkout]),W6=()=>{const te=ue=>{q(ue)};return i("div",{className:wt("store-checkbox"),children:i(mu,{label:E.get("card.storeInfo"),checked:ie,onChange:te})})},Q6=()=>{var Le,Ze,rt;const te=((Le=r==null?void 0:r.checkout)==null?void 0:Le.paymentType)===Nn.PURCHASE,ue=!!((rt=(Ze=r==null?void 0:r.checkout)==null?void 0:Ze.tokens)!=null&&rt.length),Pe=()=>{var at;(at=A.current)==null||at.resetValidation(),W(!1)};return te&&ue&&i("div",{className:wt("change-box"),onClick:Pe,children:[i(Yi,{}),i("span",{style:{marginLeft:"2px"},children:E.get("card.cardSelector.change")})]})},Id=()=>{var te;(te=A.current)==null||te.resetValidation(),W(!0)},K6=()=>{var ue;(((ue=r==null?void 0:r.checkout)==null?void 0:ue.tokens)||[]).length>1||Id()},z6=te=>{j(!1),y(Object.assign(R,{token:te==null?void 0:te.token}))},_d=te=>{A.current=te,te&&Sn()},A1=$(null),Rd=$(null),ti=$(null),ya=$(null),Ld=Ht(()=>Ca&&!ne,[Ca,ne]);Ce(()=>{var te;(te=ya.current)==null||te.reload()},[Ld]);const Nd={[Oe.CARD_NUMBER]:A1,[Oe.CVV]:ti,[Oe.EXPIRE_DATE]:Rd},J6=te=>{var Pe,Le;const ue=U?Nd[te.fieldType]:T;te.focus?(Pe=ue.current)==null||Pe.focus():(Le=ue.current)==null||Le.blur()},X6=[Oe.CARD_NUMBER,Oe.EXPIRE_DATE,Oe.CVV],Hn=$({[Oe.CARD_NUMBER]:null,[Oe.EXPIRE_DATE]:null,[Oe.CVV]:null}),$6=te=>{var Le,Ze,rt,at;const ue=U?Nd[te.fieldType]:T,Pe=te.errorTip&&E.get(te.errorTip);if(U)(at=ue.current)==null||at.resetValidation(te.status,Pe);else{Hn.current[te.fieldType]={status:te.status,errorTip:Pe};for(const ot of X6){const $e=Hn.current[ot];if(($e==null?void 0:$e.status)==="error"){(Le=ue.current)==null||Le.resetValidation($e.status,$e.errorTip);return}}Object.values(Hn.current).every(ot=>(ot==null?void 0:ot.status)==="success")?(Ze=ue.current)==null||Ze.resetValidation("success"):(rt=ue.current)==null||rt.resetValidation("unValidate")}setTimeout(()=>{Sn()},100)},e9=te=>{var Pe;(Pe=(U?A1:T).current)==null||Pe.brandChanged(te.brand)},Md=te=>{var Pe;let ue="";typeof te=="string"?ue=te:((Pe=(U?A1:T).current)==null||Pe.binValueChanged(te.binValue),ue=te.binValue),ue&&new Lr().init(ue)},t9=te=>{ke(te.response)},n9=te=>{Pn(te.error)},Td=()=>i(he,{children:(ae==null?void 0:ae.email.show)&&i("div",{className:a1,children:i(Ct,{ref:S,value:R.email,disabled:ae==null?void 0:ae.email.disabled})})}),kd=()=>{var te,ue;return i(he,{children:(ae==null?void 0:ae.address.show)&&i("div",{className:wt("address"),children:i(ht,{ref:N,value:R.address,country:((te=r==null?void 0:r.checkout)==null?void 0:te.country)||((ue=r==null?void 0:r.checkout)==null?void 0:ue.bill.country),onAddressChange:Pe=>y(Object.assign(R,{address:Pe}))})})})},Vd=()=>i(he,{children:!!x&&i(nt,{content:x})}),r9=qe(()=>{var te,ue,Pe,Le;return U?i(he,{children:[i("div",{className:a1,children:[i("div",{className:wt("card-number-wrapper"),children:[i(No,{supportedCardBrands:(ue=(te=r==null?void 0:r.checkout)==null?void 0:te.supportMethods)==null?void 0:ue.filter(Boolean),security:l,ref:A1,onBinValue:Md}),Q6()]}),t&&i(nc,{className:wt("card-brands"),supportedCardBrands:(Le=(Pe=r==null?void 0:r.checkout)==null?void 0:Pe.supportMethods)==null?void 0:Le.filter(Boolean)})]}),i("div",{className:wt("center"),children:[i(Lo,{security:l,className:a1,ref:Rd}),i(kr,{security:l,className:a1,ref:ti})]})]}):i("div",{className:wt("card-info"),children:i(To,{ref:T,supportedCardBrands:z,showLabel:!0,security:l})})},[U,l]),a9=()=>{var te;return i(dt,{form:R,ref:_d,onFormChange:ue=>y(ue),children:i("div",{className:ye(ge,wt()),children:[Td(),r9(),(ae==null?void 0:ae.holderName.show)&&i("div",{className:wt("holder-name"),children:i(oc,{disabled:ae==null?void 0:ae.holderName.disabled})}),kd(),((te=r==null?void 0:r.checkout)==null?void 0:te.paymentType)===Nn.RECURRING&&So(),i("div",{className:wt("footer-wrapper"),children:[Sd&&W6(),Vd(),!g&&ha()]})]})})},o9=()=>{var te,ue,Pe,Le;return i(dt,{form:R,ref:_d,onFormChange:Ze=>y(Ze),children:i("div",{className:ye(ge,wt()),children:[Td(),i("div",{className:wt("card-selector-wrapper"),children:[i(sc,{value:(Pe=(ue=(te=r==null?void 0:r.checkout)==null?void 0:te.tokens)==null?void 0:ue[0])==null?void 0:Pe.token,cardList:(Le=r==null?void 0:r.checkout)==null?void 0:Le.tokens,onClickEdit:Id,onClickChange:K6,onCardChange:z6,className:wt("card-selector",a1),style:{flex:2}}),i(kr,{className:wt("card-security-code",a1),style:{flex:1},security:l,ref:ti})]}),I&&kd(),i("div",{className:wt("footer-wrapper"),children:[Vd(),!g&&ha()]})]})})};return i(ze.Provider,{value:{i18n:E,core:h},children:J&&E.ready.value&&i("div",{className:h.theme.className,children:[i(Vr,{ref:ya,i18n:E,checkoutId:h.id,sessionMode:(Dd=r.checkout)==null?void 0:Dd.sessionMode,supportedCardBrands:z,style:we||S1,onFocus:J6,onBinValue:Md,onBrand:e9,onAfterPayment:t9,onPaymentError:n9,onPaymentTimeout:({message:te})=>M(E.get(te)),onValidStatusChanged:$6,onValidated:oe,children:Ld?o9():a9()}),i(lc,{show:Q,theme:(xd=r==null?void 0:r.checkout)==null?void 0:xd.theme,onClose:je,checkoutId:h.id,...ee})]})})}),{bem:B1}=_e("wechat-pay"),mc=B1("field"),Cu=Fe((e,n)=>{var Q;const{session:t,core:r,showEmail:a=!1,showAddress:o=!1}=e,s=r.getAddressCore(),c=lt(),d=$(null);Be(n,()=>({stopRetry:()=>{ie(),P("unSubmit")},startRetry:Y=>{P("loading"),K({timeout:Y})},updateAddress:()=>{var ee;if(!(T!=null&&T.address.show))return;const Y=Object.assign(v,{address:s.getAddressState()});b(Y),(ee=R.current)==null||ee.update(s.getAddressState()),V()},updateEmail:()=>{var ee;if(!(T!=null&&T.email.show))return;const Y=Object.assign(v,{email:c.email});b(Y),(ee=d.current)==null||ee.update(c.email),V()}}));const{setErrorMsg:f,fraudDetection:u,i18n:m,errorMsg:h,sessionReady:g}=et(t,e.core),[w,P]=O("unSubmit"),E=$(null),[v,b]=O({email:"",address:{country:void 0,province:void 0,city:void 0,area:void 0,postCode:void 0,address1:void 0,address2:void 0}}),[N,S]=O(!1),[T,A]=O(),R=$(null),[y,_]=O(!1);function V(){var Y;(Y=E.current)==null||Y.validate(void 0,!1).then(()=>{S(!0)}).catch(()=>{S(!1)})}const k=()=>{const{field:Y,sessionMode:ee}=t.checkout,{email:re,address:ae}=Y;ee===Ue.COMPONENT&&(re.disabled&&(re.show=a),o&&!(ae!=null&&ae.show)&&(ae.show=!0)),A({...Y})};Ce(()=>{V()},[v]);const p=Y=>{var ee,re;P("success"),(re=e.onSuccess)==null||re.call(e,ft({...Y,returnUrl:(ee=t==null?void 0:t.checkout)==null?void 0:ee.returnUrl}))};Ce(()=>{if(!g)return;const{bill:Y={},supportMethods:ee=[],country:re}=(t==null?void 0:t.checkout)||{};ee.includes(G.WECHAT_PAY)&&(k(),_(!0),re&&s.setCountry(re),v.email=Y.email??"",v.address.country=re)},[g]);const x=qe(Y=>{var ee;f(Y||m.get("common.payTimeout")),P("unSubmit"),(ee=e.onTimeout)==null||ee.call(e,"retry")},[m,e.onTimeout]),{start:K,stop:ie}=Xe(Y=>ne(!0,Y),{timeout:2*60*1e3,onTimeout:()=>x(m.get("common.queryTimeout"))}),q=async()=>{var Y;return{sessionId:t.sessionId,clientKey:t.clientKey,bill:T!=null&&T.address.show?{email:v.email,addressLine1:v.address.address1,addressLine2:v.address.address2,postalCode:v.address.postCode,country:v.address.country,district:v.address.area,state:v.address.province?s.getLabel(v.address.province,s.getProvinceOption())??v.address.province:void 0,city:v.address.city?s.getLabel(v.address.city,s.getCityOptions())??v.address.city:void 0}:{email:v.email},channelUserId:await((Y=e.onGetOpenId)==null?void 0:Y.call(e)),payment:{paymentMethod:G.WECHAT_PAY},browser:await Je({fraudDetectionId:await(u==null?void 0:u.getFraudDetectionId())})}};async function ne(Y=!1,ee){var re,ae,me,l,C,I,j,we,pe,U;try{const Z={locale:m.locale,timeout:ee};let B=null;if(Y){const de=(ae=(re=r.config)._getExtraParams)==null?void 0:ae.call(re,"query",G.WECHAT_PAY);B=await w8({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.WECHAT_PAY},de,Z)}else{const de=(l=(me=r.config)._getExtraParams)==null?void 0:l.call(me,"payment",G.WECHAT_PAY);B=await A8(await q(),de,Z)}const{status:M,orderStatus:F,errorMessage:L,payInfo:D,errorCode:H,sessionId:oe}=B;if(oe&&(t.sessionId=oe),!Y&&((C=e.onSubmitResponse)==null||C.call(e,B)),M==="PROCESSING")if(F){if(F==="SUCCESS")return p(B),{end:!0};if(F==="FAILURE")return L&&f(L),P("unSubmit"),(I=e.onError)==null||I.call(e,new Ee("API_ERROR",L,{code:H})),{end:!0};if(F==="PROCESSING")return Y||(await((j=e.onCallWxPayBox)==null?void 0:j.call(e,D)),K()),{end:!1};if(F==="CANCELED")return P("unSubmit"),(we=e.onTimeout)==null||we.call(e,"channel"),{end:!0}}else return P("unSubmit"),{end:!0};else{if(M==="SUCCESS")return p(B),{end:!0};if(M==="EXPIRED")return P("unSubmit"),(pe=e.onExpired)==null||pe.call(e),{end:!0}}return P("unSubmit"),{end:!0}}catch(Z){if(We(Z))return Y?{end:!1}:(x(),{end:!0});{const B=Z.i18nKey?m.get(Z.i18nKey):Z.message;return B&&f(B),(U=e.onError)==null||U.call(e,new Ee("API_ERROR",B,{code:Z.code,cause:Z})),P("unSubmit"),{end:!0}}}}async function W(){var Y;f(""),(Y=E.current)==null||Y.validate(async ee=>{var re;if(T!=null&&T.address.show&&s.setValidateAllFields(!0),(re=e.onSubmit)==null||re.call(e,ee),ee){P("unSubmit");return}f(""),P("loading"),await ne()})}const J=()=>{const{transAmount:Y,channelParams:ee={}}=(t==null?void 0:t.checkout)??{},{totalAmount:re}=ee.wechatPay??{},ae=(re!=null&&re.amount?re:Y)||{},me=ae!=null&&ae.amount?it(ae).jointSymbol():"",l=m.get("common.pay")+(me?` ${me}`:"");return i(ut,{className:B1("button"),status:w,text:l,loadingText:m.get("common.payProcessing"),successText:m.get("common.paySuccess"),onClick:W,verified:N})},se=Y=>{E.current=Y,Y&&V()},z=()=>i(he,{children:(T==null?void 0:T.email.show)&&i("div",{className:mc,children:i(Ct,{ref:d,value:v.email,disabled:T==null?void 0:T.email.disabled})})}),X=()=>{var Y,ee;return i(he,{children:(T==null?void 0:T.address.show)&&i("div",{className:mc,children:i(ht,{ref:R,value:v.address,country:((Y=t==null?void 0:t.checkout)==null?void 0:Y.country)||((ee=t==null?void 0:t.checkout)==null?void 0:ee.bill.country),onAddressChange:re=>b(Object.assign(v,{address:re}))})})})};return i(ze.Provider,{value:{i18n:m,session:t,core:r},children:y&&m.ready.value&&i("div",{className:r.theme.className,children:i(dt,{form:v,ref:se,onFormChange:Y=>b(Y),children:i("div",{className:ye(ge,B1()),children:[z(),X(),((Q=t==null?void 0:t.checkout)==null?void 0:Q.paymentType)===Nn.RECURRING&&So(),i("div",{className:B1("footer-wrapper"),children:[!!h&&i(nt,{className:B1("error"),content:h}),J()]})]})})})})}),yu={request:{requiredBillingContactFields:["name","email"],requiredShippingContactFields:["email"]},button:{buttonStyle:"black",buttonType:"plain"}},gu="https://applepay.cdn-apple.com/jsapi/1.latest/apple-pay-sdk.js",pu=["paymentCredentialsAvailable","paymentCredentialStatusUnknown","paymentCredentialsUnavailable"],vu=3,fc=()=>{const e=navigator.userAgent;if(/Safari/.test(e)&&!/Chrome|Chromium|Edg|OPR|Android/.test(e)){const n=e.match(/Version\/(\d+\.\d+)/);return n?parseFloat(n[1])>=15:!1}if(/iPhone|iPad|iPod/.test(e)){const n=e.match(/OS (\d+)_(\d+)/);return n?parseInt(n[1],10)>=15:!1}return!0},bu=(e,n)=>{fc()?eo({src:gu,onload:e,onerror:n,extraOptions:{async:!0,crossOrigin:""}}):e==null||e()},Au=async e=>{var n,t;if(!e||!window.ApplePaySession||!((n=ApplePaySession.canMakePayments)!=null&&n.call(ApplePaySession)))return!1;if(ApplePaySession.applePayCapabilities){const r=await((t=ApplePaySession.applePayCapabilities)==null?void 0:t.call(ApplePaySession,e));return pu.includes(r.paymentCredentialStatus)}else return!!ApplePaySession.canMakePaymentsWithActiveCard},wu=()=>{const e=$(null);return{applePaySession:e,initApplePaySession:a=>{e.current=new ApplePaySession(vu,a.request),e.current.onvalidatemerchant=a.onValidate,e.current.onpaymentauthorized=a.onAuthorized,e.current.oncancel=a.onCancel},reportSuccess2ApplePay:()=>{var a;(a=e.current)==null||a.completePayment({status:ApplePaySession.STATUS_SUCCESS??0})},reportFailure2ApplePay:a=>{var o;(o=e.current)==null||o.completePayment({status:ApplePaySession.STATUS_FAILURE??1,errors:[new ApplePayError("unknown",void 0,a)]})}}},{bem:hc}=_e("apple-pay"),Cc=Fe(e=>{const{session:n,isDropIn:t,core:r,config:a}=e,{applePaySession:o,initApplePaySession:s,reportSuccess2ApplePay:c,reportFailure2ApplePay:d}=wu(),{i18n:f,sessionReady:u,fraudDetection:m}=et(n,e.core),[h,g]=O(""),[w,P]=O(!1),E=L1(yu,a||{}),v=fc(),b=V=>{var p,x;const k=ft({...V,returnUrl:(p=n==null?void 0:n.checkout)==null?void 0:p.returnUrl});(x=e.onSuccess)==null||x.call(e,k)};Ce(()=>{if(!u)return;const{supportMethods:V=[],sessionMode:k}=(n==null?void 0:n.checkout)||{},{onEvent:p,onInitError:x}=e.core.config;if(k===Ue.DROP_IN&&!t){x==null||x(new Ee("ERROR","Please send the correct session when creating the checkout"));return}V.includes(G.APPLE_PAY)&&bu(async()=>{var ie,q,ne,W,J;(ie=e.onLoad)==null||ie.call(e,!0);const K=await Au((W=(ne=(q=n==null?void 0:n.checkout)==null?void 0:q.channelParams)==null?void 0:ne.applePay)==null?void 0:W.merchantIdentifier);K||p==null||p(Cn.APPLE_PAY_CAN_NOT_USE),(J=e.onCanUse)==null||J.call(e,K),P(K)},()=>{var K;p==null||p(Cn.APPLE_PAY_LOAD_ERROR),(K=e.onLoad)==null||K.call(e,!1),P(!1)})},[u]);const N=qe(V=>{var p;const k=V||f.get("common.payTimeout");d(k),g(k),(p=e.onTimeout)==null||p.call(e,"retry")},[f,e.onTimeout]),{start:S}=Xe(V=>A(!0,V),{onTimeout:()=>N(f.get("common.queryTimeout"))}),T=async(V,k,p)=>{var K,ie;const x=Z4(k==null?void 0:k.phoneNumber);return{sessionId:n.sessionId,clientKey:n.clientKey,bill:{firstName:k==null?void 0:k.givenName,lastName:k==null?void 0:k.familyName,addressLine1:(K=k==null?void 0:k.addressLines)==null?void 0:K[0],addressLine2:(ie=k==null?void 0:k.addressLines)==null?void 0:ie[1],state:k==null?void 0:k.administrativeArea,city:k==null?void 0:k.locality,postalCode:k==null?void 0:k.postalCode,areaCode:x==null?void 0:x.areaCode,phoneNumber:x==null?void 0:x.phoneNumber,email:(k==null?void 0:k.emailAddress)||(p==null?void 0:p.emailAddress)||(n==null?void 0:n.checkout.bill.email),country:k==null?void 0:k.countryCode},payment:{paymentMethod:G.APPLE_PAY,tokenData:JSON.stringify({token:V})},browser:await Je({fraudDetectionId:await(m==null?void 0:m.getFraudDetectionId())})}};async function A(V=!1,k,p,x,K){var ie,q,ne,W,J,se,z,X,Q;g("");try{const Y={locale:f.locale,timeout:k};let ee=null;if(V){const I=(q=(ie=r.config)._getExtraParams)==null?void 0:q.call(ie,"query",G.APPLE_PAY);ee=await S8({sessionId:n.sessionId,clientKey:n.clientKey,paymentMethod:G.APPLE_PAY},I,Y)}else{const I=(W=(ne=r.config)._getExtraParams)==null?void 0:W.call(ne,"payment",G.APPLE_PAY);ee=await P8(await T(p,x,K),I,Y)}const{status:re,orderStatus:ae,errorMessage:me,errorCode:l,sessionId:C}=ee;return C&&(n.sessionId=C),re===on.PROCESSING?ae===on.SUCCESS?(c(),b(ee),{end:!0}):ae===on.PROCESSING?(!V&&await S(),{end:!V}):ae===on.FAILURE?(me&&g(me),(J=e.onError)==null||J.call(e,new Ee("API_ERROR",me,{code:l})),d(me),{end:!0}):ae===on.AUTHORIZED?(c(),(se=e.onAuthorized)==null||se.call(e),{end:!0}):(d(),{end:!0}):re===on.SUCCESS?(c(),b(ee),{end:!0}):re===on.EXPIRED?((z=e.onExpired)==null||z.call(e),(X=o.current)==null||X.abort(),{end:!0}):(d(),{end:!0})}catch(Y){if(We(Y))return V?{end:!1}:(N(),{end:!0});{const ee=Y.i18nKey?f.get(Y.i18nKey):Y.message;return ee&&g(ee),(Q=e.onError)==null||Q.call(e,new Ee("API_ERROR",ee,{code:Y.code,cause:Y})),d(ee),{end:!0}}}}const R=()=>{var x,K,ie,q,ne;const V=n==null?void 0:n.checkout,{applePay:k}=(V==null?void 0:V.channelParams)??{},p=[...((x=E.request)==null?void 0:x.requiredBillingContactFields)||[]];return((K=V==null?void 0:V.bill)==null?void 0:K.billingAddressCollection)==="REQUIRED"&&p.push("postalAddress"),{merchantCapabilities:["supports3DS"],countryCode:(k==null?void 0:k.countryCode)??"",requiredBillingContactFields:p,requiredShippingContactFields:(ie=E.request)==null?void 0:ie.requiredShippingContactFields,currencyCode:(V==null?void 0:V.transAmount.currency)??"",supportedNetworks:((ne=(q=k==null?void 0:k.supportedNetworks)==null?void 0:q.map)==null?void 0:ne.call(q,W=>H4(W)))??[],total:{label:(V==null?void 0:V.theme.merchantName)??"",type:"final",amount:String(V==null?void 0:V.transAmount.amount)}}},y=()=>{var p,x;const{onEvent:V}=e.core.config;if(V==null||V(Cn.APPLE_PAY_BUTTON_CLICKED),(p=e.onBtnClick)==null||p.call(e),!ApplePaySession)return;const k=R();console.warn("ApplePay Request",k),s({request:k,onValidate:async()=>{var ie;V==null||V(Cn.APPLE_PAY_VALIDATE_MERCHANT);const K=await E8();(ie=o.current)==null||ie.completeMerchantValidation(K)},onAuthorized:async K=>{var W;V==null||V(Cn.APPLE_PAY_AUTHORIZED),(W=e.onSubmit)==null||W.call(e);const{token:ie,billingContact:q,shippingContact:ne}=(K==null?void 0:K.payment)||{};console.warn("ApplePay Res",K==null?void 0:K.payment),A(!1,void 0,ie,q,ne)},onCancel:()=>{var K;V==null||V(Cn.APPLE_PAY_CANCELLED),(K=e.onCancel)==null||K.call(e)}}),(x=o.current)==null||x.begin()},_=()=>{var p,x;const V=(p=E.button)==null?void 0:p.buttonStyle,k=(x=E.button)==null?void 0:x.buttonType;return i("div",{className:hc("button"),children:v?i(he,{children:i("apple-pay-button",{buttonstyle:V,type:k,onClick:y})}):i("button",{onClick:y,style:{"-webkit-appearance":"-apple-pay-button","-apple-pay-button-style":V,"-apple-pay-button-type":k,width:"100%",height:"44px",minHeight:"44px",border:"none",borderRadius:"6px",cursor:"pointer"}})})};return i("div",{children:u&&w&&f.ready.value&&i(he,{children:[!!h&&i(nt,{className:hc("error"),content:h}),i(_,{})]})})});function Eu(e,n,t,r,a){const{transAmount:o,theme:{merchantName:s}}=e,{googlePay:c}=(e==null?void 0:e.channelParams)??{},d={apiVersion:2,apiVersionMinor:0},f={type:"PAYMENT_GATEWAY",parameters:{gateway:c==null?void 0:c.providerGatewayId,gatewayMerchantId:c==null?void 0:c.merchantGatewayId}},u=(c==null?void 0:c.allowedCardNetworks)??[],h={type:"CARD",parameters:{allowedAuthMethods:(c==null?void 0:c.allowedAuthMethods)??[],allowedCardNetworks:u,billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}};function g(){return Object.assign({},d,{allowedPaymentMethods:[h]})}const w=Object.assign({tokenizationSpecification:f},h);function P(){return{countryCode:c==null?void 0:c.countryCode,currencyCode:o.currency,totalPriceStatus:"FINAL",totalPrice:String(o.amount),totalPriceLabel:"Total"}}let E;function v(){const R=Object.assign({},d);return R.emailRequired=!0,R.allowedPaymentMethods=[w],R.transactionInfo=P(),R.merchantInfo={merchantId:c==null?void 0:c.googlePayMerchantId,merchantName:s},R.callbackIntents=["PAYMENT_AUTHORIZATION"],R}function b(){return E||(E=new google.payments.api.PaymentsClient({environment:c==null?void 0:c.environment,paymentDataCallbacks:{onPaymentAuthorized:N}})),E}function N(R){return new Promise(function(y){var W,J;R.paymentMethodData.tokenizationData.token,(W=R.paymentMethodData.info)==null||W.billingAddress;const{name:_,address1:V,address2:k,address3:p,countryCode:x,administrativeArea:K,locality:ie,postalCode:q,phoneNumber:ne}=((J=R.paymentMethodData.info)==null?void 0:J.billingAddress)??{};console.warn("GooglePay Res",R.paymentMethodData),t(R.paymentMethodData.tokenizationData.token,{email:R.email,name:_,address1:V,address2:k,address3:p,countryCode:x??"",administrativeArea:K??"",locality:ie??"",postalCode:q??"",phoneNumber:ne??""}).then(se=>{y(se==null?void 0:se.res)})})}function S(R){b().isReadyToPay(g()).then(function(_){_.result?(T(R),a==null||a(!0)):a==null||a(!1)}).catch(function(_){console.error(_)})}function T(R){const _=b().createButton({...n==null?void 0:n.button,onClick:A,allowedPaymentMethods:[h]});R==null||R.appendChild(_)}function A(){r==null||r();const R=v();R.transactionInfo=P(),b().loadPaymentData(R)}return{onGooglePayLoaded:S}}const Pu=(e,n)=>{var t;if((t=window.google)!=null&&t.payments){e==null||e();return}eo({src:"https://pay.google.com/gp/p/js/pay.js",onload:e,onerror:n,extraOptions:{async:!0}})},{bem:Su}=_e("google-pay"),Iu={button:{buttonColor:"default",buttonType:"pay",buttonRadius:8,buttonSizeMode:"fill",buttonBorderType:"default_border"}},yc=Fe((e,n)=>{var q;const{session:t,threeDSFrame:r,isDropIn:a,core:o}=e,s=L1(Iu,e.config||{});Be(n,()=>({checkThreeDS:x}));const{sessionReady:c,i18n:d,fraudDetection:f}=et(t,e.core),[u,m]=O(""),[h,g]=O(!1),[w,P]=O(!1),[E,v]=O(),[b,N]=O(!0),S=qe(ne=>{var W;m(ne||d.get("common.payTimeout")),(W=e.onTimeout)==null||W.call(e,"retry")},[d,e.onTimeout]),T=ne=>{var W,J;(J=e.onSuccess)==null||J.call(e,ft({...ne,returnUrl:(W=t==null?void 0:t.checkout)==null?void 0:W.returnUrl}))};Ce(()=>{var se,z;if(!c)return;const{status:ne,supportMethods:W=[],sessionMode:J}=(t==null?void 0:t.checkout)||{};if(J===Ue.DROP_IN&&!a){(z=(se=e.core.config).onInitError)==null||z.call(se,new Ee("ERROR","Please send the correct session when creating the checkout"));return}W.includes(G.GOOGLE_PAY)&&(Pu(()=>{var X;g(!0),(X=e.onLoad)==null||X.call(e,!0)},()=>{var X;g(!1),(X=e.onLoad)==null||X.call(e,!1)}),N(J===Ue.HOSTED),ne==="SUCCESS"&&T(t==null?void 0:t.checkout))},[c]);const A=(ne,W)=>{var J;b?(J=e.onThreeDS)==null||J.call(e,ne,W):(P(!0),v({url:ne,incomplete:W,width:r==null?void 0:r.modalWidth,height:r==null?void 0:r.modalHeight}))},R=()=>{P(!1),v(void 0),x()},{start:y}=Xe(async ne=>await V(void 0,void 0,!0,ne),{onTimeout:()=>S(d.get("common.queryTimeout"))}),_=async(ne,W)=>{const J=U4(W==null?void 0:W.phoneNumber);return{sessionId:t.sessionId,clientKey:t.clientKey,payment:{paymentMethod:G.GOOGLE_PAY,tokenData:ne??""},bill:{firstName:W==null?void 0:W.name,addressLine1:W==null?void 0:W.address1,addressLine2:(W==null?void 0:W.address2)??""+(W==null?void 0:W.address3)??"",country:W==null?void 0:W.countryCode,state:W==null?void 0:W.administrativeArea,city:W==null?void 0:W.locality,email:W==null?void 0:W.email,postalCode:W==null?void 0:W.postalCode,phoneNumber:J==null?void 0:J.phoneNumber,areaCode:J==null?void 0:J.areaCode},browser:await Je({fraudDetectionId:await(f==null?void 0:f.getFraudDetectionId())})}};async function V(ne,W,J=!1,se){var z,X,Q,Y,ee,re,ae,me,l;m(""),J||(z=e.onSubmit)==null||z.call(e);try{const C={locale:d.locale,timeout:se};let I=null;if(J){const F=(Q=(X=o.config)._getExtraParams)==null?void 0:Q.call(X,"query",G.GOOGLE_PAY);I=await F2({sessionId:t.sessionId,clientKey:t.clientKey,paymentMethod:G.GOOGLE_PAY},F,C)}else{const F=(ee=(Y=o.config)._getExtraParams)==null?void 0:ee.call(Y,"payment",G.GOOGLE_PAY);I=await I8(await _(ne,W),F,C)}const{status:j,orderStatus:we,errorMessage:pe,payInfo:U={},errorCode:Z,sessionId:B}=I,{threeDSUrl:M}=U;if(B&&(t.sessionId=B),j==="PROCESSING"){if(we==="SUCCESS")return T(I),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="PROCESSING"){const F=await y();return(F==null?void 0:F.end)===!0?{end:!0,res:F.res}:await y()}else{if(we==="FAILURE")return pe&&m(pe),(re=e.onError)==null||re.call(e,new Ee("API_ERROR",pe,{code:Z})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:pe||"",reason:"OTHER_ERROR"}}};if(we==="AUTHORIZED")return(ae=e.onAuthorized)==null||ae.call(e),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="IN_THREED")return M&&A(M,!1),{end:!0,res:{transactionState:"SUCCESS"}};if(we==="IN_PREVIOUS_THREED")return M&&A(M,!0),{end:!0,res:{transactionState:"SUCCESS"}};if(!we)return{end:!0,res:{transactionState:"SUCCESS"}}}}else{if(j==="SUCCESS")return T(I),{end:!0,res:{transactionState:"SUCCESS"}};if(j==="EXPIRED")return(me=e.onExpired)==null||me.call(e),{end:!0,res:{transactionState:"SUCCESS"}}}return T(I),{end:!1,res:{transactionState:"SUCCESS"}}}catch(C){if(We(C))return J?{end:!1}:(S(),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:d.get("common.payTimeout"),reason:"OTHER_ERROR"}}});{const I=C.i18nKey?d.get(C.i18nKey):C.message;return m(I),(l=e.onError)==null||l.call(e,new Ee("API_ERROR",I,{code:C.code,cause:C})),{end:!0,res:{transactionState:"ERROR",error:{intent:"PAYMENT_AUTHORIZATION",message:I,reason:"OTHER_ERROR"}}}}}}const{start:k,stop:p}=Xe(()=>x(!0),{timeout:12*1e3,onTimeout:()=>S(d.get("common.queryTimeout"))});async function x(ne=!1){var W,J,se,z,X;if(!t)return{end:!0};try{const Q=(J=(W=o.config)._getExtraParams)==null?void 0:J.call(W,"query",G.GOOGLE_PAY),Y=await F2({sessionId:t.sessionId,clientKey:t.clientKey},Q,{locale:d.locale}),{status:ee,orderStatus:re,errorMessage:ae}=Y;if(ee==="PROCESSING"){if(re==="PROCESSING")y();else if(re==="FAILURE")ae&&m(ae);else if(re==="AUTHORIZED")(se=e.onAuthorized)==null||se.call(e);else{if(re==="IN_THREED")return!ne&&k(),{end:!1};re==="IN_PREVIOUS_THREED"&&m(d.get("common.pay3DSIncomplete"))}return p(),{end:!0}}else{if(ee==="SUCCESS")return T(Y),p(),{end:!0};if(ee==="EXPIRED")return(z=e.onExpired)==null||z.call(e),p(),{end:!0}}return T(Y),p(),{end:!0}}catch(Q){if(We(Q))return ne?{end:!1}:(S(d.get("common.queryTimeout")),{end:!0});{const Y=Q.i18nKey?d.get(Q.i18nKey):Q.message;return m(Y),(X=e.onError)==null||X.call(e,new Ee("API_ERROR",Y,{code:Q.code,cause:Q})),{end:!0}}}}const K=$(null);Ce(()=>{if(K&&(t!=null&&t.checkout)&&h){const{onGooglePayLoaded:ne}=Eu(t==null?void 0:t.checkout,s,V,e.onBtnClick,e.onCanUse);ne(K.current)}},[c,K,d.ready.value,h]);const ie=()=>i("div",{style:"width: 100%; height: 44px",children:i("div",{id:"container",style:"width:100%; height: 44px",ref:K})});return i("div",{children:c&&h&&d.ready.value&&i(he,{children:[!!u&&i(nt,{className:Su("error"),content:u}),ie(),i(lc,{show:w,theme:(q=t==null?void 0:t.checkout)==null?void 0:q.theme,checkoutId:o.id,...E,onClose:R})]})})}),_u=11,ko=14,Dr=18,Ru=e=>e.length<=_u?e.replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d)/,"$1.$2").replace(/(\d{3})(\d{1,2})$/,"$1-$2"):e.replace(/^(\d{2})(\d)/,"$1.$2").replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3").replace(/\.(\d{3})(\d)/,".$1/$2").replace(/(\d{4})(\d{1,2})$/,"$1-$2"),gc=e=>{const{currentTarget:n}=e,t=n,r=t.selectionStart,a=t.value,o=Xt(a).slice(0,ko),s=Lu(a,r),c=Ru(o),d=Nu(c,s);return{value:c,cursorPosition:d}},Lu=(e,n)=>{let t=0;for(let r=0;r<n&&r<e.length;r++)/\d/.test(e[r])&&t++;return t},Nu=(e,n)=>{let t=0;for(let r=0;r<e.length;r++)if(/\d/.test(e[r])){if(t===n)return r;t++}return e.length},Mu=()=>{let e;const n=$(""),[t,r]=O("");let a,o;const[s,c]=O(void 0),d=N=>{e=N.fieldType,a=tr(N.supportedCardBrands),o=zi(a)},f=()=>{let N={maxLength:0,onInput:S=>{}};switch(e){case Oe.CVV:{N={maxLength:4,inputMode:"numeric",onInput:u,validator:w};break}case Oe.CARD_NUMBER:{N={maxLength:23,inputMode:"numeric",onInput:m,validator:P};break}case Oe.EXPIRE_DATE:{N={maxLength:5,inputMode:"numeric",onInput:h,validator:E};break}case R1.CPF:{N={maxLength:Dr,inputMode:"numeric",onInput:g,validator:v};break}}return N},u=N=>{const S=N.currentTarget,T=Xt(S.value);n.current=S.value=T},m=N=>{var V;const{inputType:S}=N,T=N.currentTarget,A=T.selectionStart;let R=Xt(T.value);R=R.replace(/(\d{4})(?=\d)/g,"$1 ");let y=A;y%5===0&&(y=N1(A+(S==="insertText"?1:-1),0)),n.current=T.value=R,T.setSelectionRange(y,y);const _=Yt(T.value).substring(0,6);r(_.length<6?"":_),c((V=b(Yt(T.value)))==null?void 0:V.code)},h=N=>{const{inputType:S}=N,T=N.currentTarget,A=T.selectionStart;let R;if(S==="insertText")R=rc(N);else if(S==="insertFromPaste")R=ac(N);else{R=T.value;const y=n.current.slice(A,A+1),_=n.current.length;if(_>3&&y==="/"){n.current=T.value=n.current,T.setSelectionRange(A,A);return}else if(A===1){const V=n.current.slice(0,2);_>2&&+V>=10?R=`01${n.current.slice(2,_)}`:R=R.slice(0,1)}else if(A===0&&R.length>1){y==="0"?n.current=T.value=n.current:y==="1"&&(n.current=T.value=`0${R}`),T.setSelectionRange(0,0);return}else if(A===3)if(_===4)R=R.slice(0,2);else{n.current=T.value=R,T.setSelectionRange(A-1,A-1);return}}n.current=T.value=R,S!=="insertText"&&T.setSelectionRange(A+1,A+1)},g=N=>{const S=N.currentTarget,{value:T,cursorPosition:A}=gc(N);n.current=S.value=T,S.setSelectionRange(A,A)},w=()=>{if(Ie(n.current)||n.current.length<3)throw new Error("card.cardSecurityCode.incomplete");return!0},P=()=>{const N=Yt(n.current??"");if(!o.includes(N.length))throw new Error("card.cardNumber.incomplete");if(!b(N))throw new Error("card.cardNumber.invalid");return!0},E=()=>{if(Ie(n.current)||n.current.length!==5)throw new Error("card.cardExpireDate.incomplete");if(n2(n.current))throw new Error("card.cardExpireDate.expired");return!0},v=()=>{if(Ie(n.current)||![ko,Dr].includes(n.current.length))throw new Error("cpf.incomplete");return!0},b=N=>Ki(N,a);return{value:n,cardBin:t,initSecuredInput:d,getConfigByFieldType:f,getCurrCardBrand:b,brand:s}},Lt=G4("input"),Tu=e=>{const{checkoutId:n}=e,t=window.parent.frames[e.hiddenIframeName],r=$(null),{initSecuredInput:a,getConfigByFieldType:o,getCurrCardBrand:s,cardBin:c,value:d,brand:f}=Mu(),[u,m]=O(!1),h="securedInput",g=()=>{a({fieldType:e.fieldType,supportedCardBrands:e.supportedCardBrands}),w(e.style)},w=(y={})=>{const{base:_,hover:V,focus:k,valid:p,invalid:x,placeholder:K}=y,ie=`input { ${Vn(_)} }`,q=`input.${Lt.hover} { ${Vn(V)} }`,ne=`input.${Lt.focus} { ${Vn(k)} }`,W=`input.${Lt.valid} { ${Vn(p)} }`,J=`input.${Lt.invalid} { ${Vn(x)} }`,se=js("input",K==null?void 0:K.base),z=js(`input.${Lt.focus}`,K==null?void 0:K.focus),X=`
15
15
  ${ie}
16
16
  ${q}
17
17
  ${ne}