Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@moneyhash/js-sdk

Package Overview
Dependencies
Maintainers
0
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@moneyhash/js-sdk - npm Package Compare versions

Comparing version 1.9.0 to 1.9.1-beta.0

dist/warnIf-31e89941.js

2

dist/headless.cjs.js

@@ -1,1 +0,1 @@

"use strict";var fe=Object.defineProperty,we=Object.defineProperties;var Pe=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var O=(o,e,t)=>e in o?fe(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t,w=(o,e)=>{for(var t in e||(e={}))ne.call(e,t)&&O(o,t,e[t]);if(_)for(var t of _(e))se.call(e,t)&&O(o,t,e[t]);return o},q=(o,e)=>we(o,Pe(e));var ie=(o,e)=>{var t={};for(var s in o)ne.call(o,s)&&e.indexOf(s)<0&&(t[s]=o[s]);if(o!=null&&_)for(var s of _(o))e.indexOf(s)<0&&se.call(o,s)&&(t[s]=o[s]);return t};var f=(o,e,t)=>(O(o,typeof e!="symbol"?e+"":e,t),t),be=(o,e,t)=>{if(!e.has(o))throw TypeError("Cannot "+t)};var P=(o,e,t)=>{if(e.has(o))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(o):e.set(o,t)};var y=(o,e,t)=>(be(o,e,"access private method"),t);var m=(o,e,t)=>new Promise((s,a)=>{var i=n=>{try{r(t.next(n))}catch(l){a(l)}},d=n=>{try{r(t.throw(n))}catch(l){a(l)}},r=n=>n.done?s(n.value):Promise.resolve(n.value).then(i,d);r((t=t.apply(o,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("./warnIf-e80a4672.cjs");function ke(){return typeof window!="undefined"}const b=class{constructor(){ke()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=p.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.9.0");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),b.messagingService=new p.MessagingService({target:s.contentWindow,targetOrigin:e}),b.isCommunicationReady=new Promise(a=>{var d;const i=r=>{var n;r.data.type==="headlessSDK:init"&&(a(),(n=b.messagingService)==null||n.removeListener(i))};(d=b.messagingService)==null||d.onReceive(i)})}request(s){return m(this,arguments,function*({api:e,payload:t}){return yield b.isCommunicationReady,new Promise((a,i)=>{var r,n;(r=b.messagingService)==null||r.send({type:e,data:t});const d=l=>{var g;const{type:c,data:h}=l.data;c===e&&(h.status==="resolved"?a(h.payload):i(h.payload),(g=b.messagingService)==null||g.removeListener(d))};(n=b.messagingService)==null||n.onReceive(d)})})}postMessage(e){var t;(t=b.messagingService)==null||t.send({type:e})}};let C=b;f(C,"messagingService",null),f(C,"isCommunicationReady");class B{constructor(){f(this,"promise");f(this,"resolve");f(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Ae(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function S(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function Ee(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function re(o){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!o.includes(t))return t;return null}function oe(o){return(Array.isArray(o)?o.length:Object.keys(o).length)===0}function de(o,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const i=document.createElement("script");i.src=o,i.id=e,i.addEventListener("load",()=>{t(void 0)}),i.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(i)})}function ve(o){return new Promise(e=>{setTimeout(()=>{e("done")},o*1e3)})}const le=new Set(["method","customerBalance","savedCard"]);var L,G,M,K,F,ce,$,pe,H,he,R,Y,N,ue,D,me,V,ge,W,ye;class Ie{constructor(e){P(this,L);P(this,M);P(this,F);P(this,$);P(this,H);P(this,R);P(this,N);P(this,D);P(this,V);P(this,W);f(this,"options");f(this,"sdkApiHandler",new C);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);f(this,"googlePaymentsClient",null);f(this,"cardForm",{collect:()=>m(this,null,function*(){p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=re(this.mountedCardElements);p.throwIf(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return y(this,M,K).call(this,{accessToken:t})}),pay:r=>m(this,[r],function*({intentId:e,cardData:t,saveCard:s,billingData:a,shippingData:i,installmentPlanData:d}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:a,shippingData:i,cardEmbed:t,saveCard:s,installmentPlanData:d}})}),createCardToken:s=>m(this,[s],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new p.SDKEmbed(q(w({},e),{headless:!0})),y(this,D,me).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),p.throwIf(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:w({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:s,useWalletBalance:a,metaData:i}){return p.throwIf(!le.has(t),`type must be a valid one (${[...le].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,lang:this.sdkEmbed.lang,useWalletBalance:a,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return p.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return m(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:a,onCancel:i=()=>{},onError:d,onComplete:r,billingData:n={}}){if(yield de("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const c=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${s}`},requiredShippingContactFields:["email"]}),{state:h,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(h==="FORM_FIELDS"){if(oe(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(E){throw yield this.resetSelectedMethod(e),E}const A=new B;return c.onvalidatemerchant=E=>{fetch(`${Ee()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:g.secret,validation_url:E.validationURL})}).then(k=>k.ok?k.json():Promise.reject()).then(k=>c.completeMerchantValidation(k)).catch(d)},c.onpaymentauthorized=E=>{var k;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:E.payment.token}),receiptBillingData:{email:(k=E.payment.shippingContact)==null?void 0:k.emailAddress}}}).then(U=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),A.resolve(U)}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),d==null||d(),A.reject(void 0)})},c.oncancel=i,c.begin(),A.promise})}renderGooglePayButton(s){return m(this,null,function*(){var a=s,{onClick:e}=a,t=ie(a,["onClick"]);var r;const i=document.getElementById("moneyHash-google-pay-button");p.throwIf(!i,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield de("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const d=y(this,L,G).call(this);this.googlePaymentsClient.isReadyToPay(d).then(n=>{if(n.result){const l=this.googlePaymentsClient.createButton(q(w({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:d.allowedPaymentMethods,onClick:e}));i==null||i.replaceChildren(l)}else throw new Error("Google Pay is not ready to pay!")}).catch(n=>{console.dir(n)})})}payWithGooglePay(a){return m(this,arguments,function*({intentId:e,billingData:t={},onCancel:s}){p.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let i=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(i.state==="FORM_FIELDS"){if(oe(t))throw new Error("Billing data is missing while calling payWithGooglePay");i=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:d}=i;return d?this.googlePaymentsClient.loadPaymentData(q(w({},y(this,L,G).call(this,d)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${d.amount}`,currencyCode:d.currency_code,countryCode:d.country_code},merchantInfo:{merchantName:d==null?void 0:d.merchant_name,merchantId:d==null?void 0:d.merchant_id},emailRequired:!0})).then(r=>{const n=r.paymentMethodData.tokenizationData.token;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:n,receiptBillingData:{email:r.email}}})}).catch(r=>(r.statusCode==="CANCELED"?s==null||s():console.dir(r),Promise.reject(r))):i})}renderForm(e){return p.throwIf(!e.selector,"selector is required for renderForm"),p.throwIf(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){p.warnIf(!!e&&!p.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...p.supportedLanguages].join(" | ")})`);const t=p.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return p.throwIf(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(s=>{p.throwIf(!s.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:s}){const a=[],i={},d=new Map;let r=!1;return y(this,N,ue).call(this,a),{create:({elementType:n,elementOptions:l})=>{var k,U;const c=new Map;let h=null;const g=w(w({},t),l.classes),A=((k=g==null?void 0:g.focus)==null?void 0:k.split(" "))||["MoneyHashElement--focus"],E=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const u=document.querySelector(l.selector);p.throwIf(!u,`Couldn't find an element with selector ${l.selector}!`),u.classList.add("MoneyHashElement"),a.push(T=>{var x,z,J,X,Q,Z,ee,te,ae;const{type:v,data:I}=T.data;if(v===`${n}@mount`&&(i[n]=I.isValid,(x=c.get(`${n}@mount`))==null||x()),v===`${n}@focus`){u.classList.add(...A),(z=c.get(`${n}@focus`))==null||z();return}if(v===`${n}@blur`){u.classList.remove(...A),(J=c.get(`${n}@blur`))==null||J();return}if(v===`${n}@error`){I.isValid?u.classList.remove(...E):u.classList.add(...E),(X=c.get(`${n}@error`))==null||X(I);return}if(v===`${n}@changeInput`){if((Q=c.get(`${n}@changeInput`))==null||Q({isValid:I.isValid,length:I.length}),i[n]=I.isValid,d.get("validityChange")){const j=Object.values(i).every(Boolean);j!==r&&((Z=d.get("validityChange"))==null||Z(j),r=j)}return}if(v===`${n}@cardNumberChange`){(ee=c.get(`${n}@cardNumberChange`))==null||ee(I);return}if(v===`${n}@key:Backspace`){(te=c.get(`${n}@key:Backspace`))==null||te();return}v===`${n}@key:Enter`&&((ae=c.get(`${n}@key:Enter`))==null||ae())}),h=y(this,V,ge).call(this,{container:u,elementType:n,elementOptions:l,styles:w(w({},e),l.styles),fontSourceCss:s}),this.mountedCardElements.push(n)},on:(u,T)=>{c.set(`${n}@${u}`,T)},off:u=>c.delete(`${n}@${u}`),focus:()=>{var u;(u=h==null?void 0:h.contentWindow)==null||u.postMessage({type:"focus"},S())},blur:()=>{var u;(u=h==null?void 0:h.contentWindow)==null||u.postMessage({type:"blur"},S())},clear:()=>{var u;(u=h==null?void 0:h.contentWindow)==null||u.postMessage({type:"clear"},S())}}},on:(n,l)=>{d.set(n,l)}}}submitForm(n){return m(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:a,saveCard:i,paymentMethod:d="CARD",installmentPlanData:r}){let l;if(t){const h=re(this.mountedCardElements);p.throwIf(!!h,`You must mount ${h} element!`),l=yield y(this,M,K).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:d,lang:this.sdkEmbed.lang,billingData:s,shippingData:a,cardEmbed:l,saveCard:i,installmentPlanData:r}})})}selectInstallmentPlan(a){return m(this,arguments,function*({intentId:e,planId:t,issuerCode:s}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:s,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(a){return m(this,arguments,function*({first6Digits:e,amount:t,currency:s}){return p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:s,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(a){return m(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:s}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:s,lang:this.sdkEmbed.lang}})})}renderUrl(i){return m(this,arguments,function*({intentId:e,url:t,renderStrategy:s,options:a}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),s){case"IFRAME":return y(this,F,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return y(this,$,pe).call(this,{url:t,intentId:e,options:a});case"REDIRECT":return y(this,H,he).call(this,{url:t,options:a});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const s=new Date(e),a=setInterval(()=>m(this,null,function*(){const i=new Date;s<i&&(clearInterval(a),t())}),1e3);return()=>clearInterval(a)}}L=new WeakSet,G=function(e){var s,a;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[w({type:"CARD",parameters:{allowedAuthMethods:((s=this.options.googlePay)==null?void 0:s.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((a=this.options.googlePay)==null?void 0:a.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},M=new WeakSet,K=function(t){return m(this,arguments,function*({accessToken:e}){const s=new B;this.vaultSubmitListener.current=d=>{const{type:r,data:n}=d.data;r==="vaultSubmit:success"&&s.resolve(n),r==="vaultSubmit:error"&&s.reject(n)};const a=y(this,W,ye).call(this,{accessToken:e}),i=yield s.promise;return a.remove(),i})},F=new WeakSet,ce=function(s){return m(this,arguments,function*({intentId:e,url:t}){const a=document.querySelector("#rendered-url-iframe-container");p.throwIf(!a,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const i=document.createElement("iframe");i.src=t,i.style.setProperty("border","0","important"),i.style.setProperty("width","100%","important"),i.style.setProperty("height","100%","important"),a==null||a.replaceChildren(i),yield y(this,R,Y).call(this,{intentId:e}),i.remove()})},$=new WeakSet,pe=function(a){return m(this,arguments,function*({intentId:e,url:t,options:s={}}){const{width:i=600,height:d=400,left:r=200,top:n=200}=s.window||{},l=window.open(t,"",`width=${i},height=${d},left=${r},top=${n}`);p.throwIf(!l,"Popup blocked by browser!"),yield y(this,R,Y).call(this,{intentId:e,isUsingPopUp:!0}),l==null||l.close()})},H=new WeakSet,he=function(s){return m(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},R=new WeakSet,Y=function(s){return m(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const a=new B,i=d=>m(this,null,function*(){var n,l,c,h;if(d.origin!==p.getIframeUrl())return;const{type:r}=d.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),ve(2)]),A=g.transaction.status.split(".")[1];A==="successful"||A.startsWith("pending")?(l=(n=this.options).onComplete)==null||l.call(n,w({type:this.options.type},g)):(h=(c=this.options).onFail)==null||h.call(c,w({type:this.options.type},g)),a.resolve(()=>null),window.removeEventListener("message",i)}});return window.addEventListener("message",i),a.promise})},N=new WeakSet,ue=function(e){const t=s=>{s.origin===S()&&e.forEach(a=>{a(s)})};window.addEventListener("message",t)},D=new WeakSet,me=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},V=new WeakSet,ge=function({container:e,elementType:t,elementOptions:s,styles:a,fontSourceCss:i}){var l,c,h,g;const d=S(),r=new URL(`${d}/vaultField/vaultField.html`);i&&r.searchParams.set("fontSourceCss",i),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((l=s.validation)==null?void 0:l.required)!==void 0&&r.searchParams.set("required",`${(c=s.validation)==null?void 0:c.required}`),r.searchParams.set("placeholder",(h=s.placeholder)!=null?h:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(a==null?void 0:a.direction)||""),r.searchParams.set("color",JSON.stringify(a!=null&&a.color?a.color:"#000")),r.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),r.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),r.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),r.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),r.searchParams.set("padding",(a==null?void 0:a.padding)||"");const n=document.createElement("iframe");return n.src=r.toString(),n.style.height=(g=a==null?void 0:a.height)!=null?g:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},W=new WeakSet,ye=function({accessToken:e}){const t=S(),s=Ae(),a=new URL(`${t}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${s}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang);const i=document.createElement("iframe");return i.id="moneyhash-submit-iframe",i.src=a.toString(),i.hidden=!0,document.body.appendChild(i),i};exports.IFrameSandboxOptions=p.IFrameSandboxOptions;exports.default=Ie;
"use strict";var fe=Object.defineProperty,we=Object.defineProperties;var be=Object.getOwnPropertyDescriptors;var _=Object.getOwnPropertySymbols;var ne=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var j=(d,e,t)=>e in d?fe(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t,w=(d,e)=>{for(var t in e||(e={}))ne.call(e,t)&&j(d,t,e[t]);if(_)for(var t of _(e))se.call(e,t)&&j(d,t,e[t]);return d},q=(d,e)=>we(d,be(e));var ie=(d,e)=>{var t={};for(var s in d)ne.call(d,s)&&e.indexOf(s)<0&&(t[s]=d[s]);if(d!=null&&_)for(var s of _(d))e.indexOf(s)<0&&se.call(d,s)&&(t[s]=d[s]);return t};var f=(d,e,t)=>(j(d,typeof e!="symbol"?e+"":e,t),t),Pe=(d,e,t)=>{if(!e.has(d))throw TypeError("Cannot "+t)};var b=(d,e,t)=>{if(e.has(d))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(d):e.set(d,t)};var y=(d,e,t)=>(Pe(d,e,"access private method"),t);var m=(d,e,t)=>new Promise((s,a)=>{var i=n=>{try{r(t.next(n))}catch(l){a(l)}},o=n=>{try{r(t.throw(n))}catch(l){a(l)}},r=n=>n.done?s(n.value):Promise.resolve(n.value).then(i,o);r((t=t.apply(d,e)).next())});Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const p=require("./warnIf-a2f49315.cjs");function ke(){return typeof window!="undefined"}const P=class{constructor(){ke()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=p.getIframeUrl(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.9.1-beta.0");const s=document.createElement("iframe");s.id="moneyhash-headless-sdk",s.src=t.toString(),s.hidden=!0,document.body.appendChild(s),P.messagingService=new p.MessagingService({target:s.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(a=>{var o;const i=r=>{var n;r.data.type==="headlessSDK:init"&&(a(),(n=P.messagingService)==null||n.removeListener(i))};(o=P.messagingService)==null||o.onReceive(i)})}request(s){return m(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((a,i)=>{var r,n;(r=P.messagingService)==null||r.send({type:e,data:t});const o=l=>{var g;const{type:c,data:u}=l.data;c===e&&(u.status==="resolved"?a(u.payload):i(u.payload),(g=P.messagingService)==null||g.removeListener(o))};(n=P.messagingService)==null||n.onReceive(o)})})}postMessage(e){var t;(t=P.messagingService)==null||t.send({type:e})}};let C=P;f(C,"messagingService",null),f(C,"isCommunicationReady");class B{constructor(){f(this,"promise");f(this,"resolve");f(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Ee(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function S(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function re(d){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!d.includes(t))return t;return null}function oe(d){return(Array.isArray(d)?d.length:Object.keys(d).length)===0}function de(d,e){return new Promise((t,s)=>{if(document.getElementById(e)){t(void 0);return}const i=document.createElement("script");i.src=d,i.id=e,i.addEventListener("load",()=>{t(void 0)}),i.addEventListener("error",()=>{s(new Error("Script failed to load"))}),document.body.appendChild(i)})}function Ae(d){return new Promise(e=>{setTimeout(()=>{e("done")},d*1e3)})}const le=new Set(["method","customerBalance","savedCard"]);var M,G,L,K,F,ce,$,pe,H,ue,R,Y,D,he,N,me,V,ge,W,ye;class ve{constructor(e){b(this,M);b(this,L);b(this,F);b(this,$);b(this,H);b(this,R);b(this,D);b(this,N);b(this,V);b(this,W);f(this,"options");f(this,"sdkApiHandler",new C);f(this,"sdkEmbed");f(this,"vaultSubmitListener",{current:null});f(this,"mountedCardElements",[]);f(this,"googlePaymentsClient",null);f(this,"cardForm",{collect:()=>m(this,null,function*(){p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=re(this.mountedCardElements);p.throwIf(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return y(this,L,K).call(this,{accessToken:t})}),pay:r=>m(this,[r],function*({intentId:e,cardData:t,saveCard:s,billingData:a,shippingData:i,installmentPlanData:o}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:a,shippingData:i,cardEmbed:t,saveCard:s,installmentPlanData:o}})}),createCardToken:s=>m(this,[s],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new p.SDKEmbed(q(w({},e),{headless:!0})),y(this,N,me).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),p.throwIf(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:w({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:s,useWalletBalance:a,metaData:i}){return p.throwIf(!le.has(t),`type must be a valid one (${[...le].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:s,lang:this.sdkEmbed.lang,useWalletBalance:a,metaData:i}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return p.throwIf(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(l){return m(this,arguments,function*({intentId:e,currency:t,amount:s,countryCode:a,onCancel:i=()=>{},onError:o,onComplete:r,billingData:n={}}){if(yield de("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const c=new ApplePaySession(3,{countryCode:a,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${s}`},requiredShippingContactFields:["email"]}),{state:u,intent:g}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="FORM_FIELDS"){if(oe(n))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:n}})}}catch(E){throw yield this.resetSelectedMethod(e),E}const k=new B;return c.onvalidatemerchant=E=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:g.secret,validationUrl:E.validationURL}}).then(v=>c.completeMerchantValidation(v)).catch(o),c.onpaymentauthorized=E=>{var v;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:E.payment.token}),receiptBillingData:{email:(v=E.payment.shippingContact)==null?void 0:v.emailAddress}}}).then(U=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),k.resolve(U)}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),o==null||o(),k.reject(void 0)})},c.oncancel=i,c.begin(),k.promise})}renderGooglePayButton(s){return m(this,null,function*(){var a=s,{onClick:e}=a,t=ie(a,["onClick"]);var r;const i=document.getElementById("moneyHash-google-pay-button");p.throwIf(!i,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield de("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const o=y(this,M,G).call(this);this.googlePaymentsClient.isReadyToPay(o).then(n=>{if(n.result){const l=this.googlePaymentsClient.createButton(q(w({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:o.allowedPaymentMethods,onClick:e}));i==null||i.replaceChildren(l)}else throw new Error("Google Pay is not ready to pay!")}).catch(n=>{console.dir(n)})})}payWithGooglePay(a){return m(this,arguments,function*({intentId:e,billingData:t={},onCancel:s}){p.throwIf(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let i=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(i.state==="FORM_FIELDS"){if(oe(t))throw new Error("Billing data is missing while calling payWithGooglePay");i=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:o}=i;return o?this.googlePaymentsClient.loadPaymentData(q(w({},y(this,M,G).call(this,o)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${o.amount}`,currencyCode:o.currency_code,countryCode:o.country_code},merchantInfo:{merchantName:o==null?void 0:o.merchant_name,merchantId:o==null?void 0:o.merchant_id},emailRequired:!0})).then(r=>{const n=r.paymentMethodData.tokenizationData.token;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:n,receiptBillingData:{email:r.email}}})}).catch(r=>(r.statusCode==="CANCELED"?s==null||s():console.dir(r),Promise.reject(r))):i})}renderForm(e){return p.throwIf(!e.selector,"selector is required for renderForm"),p.throwIf(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){p.warnIf(!!e&&!p.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...p.supportedLanguages].join(" | ")})`);const t=p.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return p.throwIf(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(s=>{p.throwIf(!s.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:s}){const a=[],i={},o=new Map;let r=!1;return y(this,D,he).call(this,a),{create:({elementType:n,elementOptions:l})=>{var v,U;const c=new Map;let u=null;const g=w(w({},t),l.classes),k=((v=g==null?void 0:g.focus)==null?void 0:v.split(" "))||["MoneyHashElement--focus"],E=((U=g==null?void 0:g.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const h=document.querySelector(l.selector);p.throwIf(!h,`Couldn't find an element with selector ${l.selector}!`),h.classList.add("MoneyHashElement"),a.push(T=>{var x,z,J,X,Q,Z,ee,te,ae;const{type:A,data:I}=T.data;if(A===`${n}@mount`&&(i[n]=I.isValid,(x=c.get(`${n}@mount`))==null||x()),A===`${n}@focus`){h.classList.add(...k),(z=c.get(`${n}@focus`))==null||z();return}if(A===`${n}@blur`){h.classList.remove(...k),(J=c.get(`${n}@blur`))==null||J();return}if(A===`${n}@error`){I.isValid?h.classList.remove(...E):h.classList.add(...E),(X=c.get(`${n}@error`))==null||X(I);return}if(A===`${n}@changeInput`){if((Q=c.get(`${n}@changeInput`))==null||Q({isValid:I.isValid,length:I.length}),i[n]=I.isValid,o.get("validityChange")){const O=Object.values(i).every(Boolean);O!==r&&((Z=o.get("validityChange"))==null||Z(O),r=O)}return}if(A===`${n}@cardNumberChange`){(ee=c.get(`${n}@cardNumberChange`))==null||ee(I);return}if(A===`${n}@key:Backspace`){(te=c.get(`${n}@key:Backspace`))==null||te();return}A===`${n}@key:Enter`&&((ae=c.get(`${n}@key:Enter`))==null||ae())}),u=y(this,V,ge).call(this,{container:h,elementType:n,elementOptions:l,styles:w(w({},e),l.styles),fontSourceCss:s}),this.mountedCardElements.push(n)},on:(h,T)=>{c.set(`${n}@${h}`,T)},off:h=>c.delete(`${n}@${h}`),focus:()=>{var h;(h=u==null?void 0:u.contentWindow)==null||h.postMessage({type:"focus"},S())},blur:()=>{var h;(h=u==null?void 0:u.contentWindow)==null||h.postMessage({type:"blur"},S())},clear:()=>{var h;(h=u==null?void 0:u.contentWindow)==null||h.postMessage({type:"clear"},S())}}},on:(n,l)=>{o.set(n,l)}}}submitForm(n){return m(this,arguments,function*({intentId:e,accessToken:t,billingData:s,shippingData:a,saveCard:i,paymentMethod:o="CARD",installmentPlanData:r}){let l;if(t){const u=re(this.mountedCardElements);p.throwIf(!!u,`You must mount ${u} element!`),l=yield y(this,L,K).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:o,lang:this.sdkEmbed.lang,billingData:s,shippingData:a,cardEmbed:l,saveCard:i,installmentPlanData:r}})})}selectInstallmentPlan(a){return m(this,arguments,function*({intentId:e,planId:t,issuerCode:s}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:s,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(a){return m(this,arguments,function*({first6Digits:e,amount:t,currency:s}){return p.throwIf(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:s,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(a){return m(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:s}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:s,lang:this.sdkEmbed.lang}})})}renderUrl(i){return m(this,arguments,function*({intentId:e,url:t,renderStrategy:s,options:a}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),s){case"IFRAME":return y(this,F,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return y(this,$,pe).call(this,{url:t,intentId:e,options:a});case"REDIRECT":return y(this,H,ue).call(this,{url:t,options:a});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const s=new Date(e),a=setInterval(()=>m(this,null,function*(){const i=new Date;s<i&&(clearInterval(a),t())}),1e3);return()=>clearInterval(a)}}M=new WeakSet,G=function(e){var s,a;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[w({type:"CARD",parameters:{allowedAuthMethods:((s=this.options.googlePay)==null?void 0:s.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((a=this.options.googlePay)==null?void 0:a.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},L=new WeakSet,K=function(t){return m(this,arguments,function*({accessToken:e}){const s=new B;this.vaultSubmitListener.current=o=>{const{type:r,data:n}=o.data;r==="vaultSubmit:success"&&s.resolve(n),r==="vaultSubmit:error"&&s.reject(n)};const a=y(this,W,ye).call(this,{accessToken:e}),i=yield s.promise;return a.remove(),i})},F=new WeakSet,ce=function(s){return m(this,arguments,function*({intentId:e,url:t}){const a=document.querySelector("#rendered-url-iframe-container");p.throwIf(!a,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const i=document.createElement("iframe");i.src=t,i.style.setProperty("border","0","important"),i.style.setProperty("width","100%","important"),i.style.setProperty("height","100%","important"),a==null||a.replaceChildren(i),yield y(this,R,Y).call(this,{intentId:e}),i.remove()})},$=new WeakSet,pe=function(a){return m(this,arguments,function*({intentId:e,url:t,options:s={}}){const{width:i=600,height:o=400,left:r=200,top:n=200}=s.window||{},l=window.open(t,"",`width=${i},height=${o},left=${r},top=${n}`);p.throwIf(!l,"Popup blocked by browser!"),yield y(this,R,Y).call(this,{intentId:e,isUsingPopUp:!0}),l==null||l.close()})},H=new WeakSet,ue=function(s){return m(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},R=new WeakSet,Y=function(s){return m(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const a=new B,i=o=>m(this,null,function*(){var n,l,c,u;if(o.origin!==p.getIframeUrl())return;const{type:r}=o.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[g]=yield Promise.all([this.getIntentDetails(e),Ae(2)]),k=g.transaction.status.split(".")[1];k==="successful"||k.startsWith("pending")?(l=(n=this.options).onComplete)==null||l.call(n,w({type:this.options.type},g)):(u=(c=this.options).onFail)==null||u.call(c,w({type:this.options.type},g)),a.resolve(()=>null),window.removeEventListener("message",i)}});return window.addEventListener("message",i),a.promise})},D=new WeakSet,he=function(e){const t=s=>{s.origin===S()&&e.forEach(a=>{a(s)})};window.addEventListener("message",t)},N=new WeakSet,me=function(e){const t=s=>{e.current&&e.current(s)};window.addEventListener("message",t)},V=new WeakSet,ge=function({container:e,elementType:t,elementOptions:s,styles:a,fontSourceCss:i}){var l,c,u,g;const o=S(),r=new URL(`${o}/vaultField/vaultField.html`);i&&r.searchParams.set("fontSourceCss",i),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((l=s.validation)==null?void 0:l.required)!==void 0&&r.searchParams.set("required",`${(c=s.validation)==null?void 0:c.required}`),r.searchParams.set("placeholder",(u=s.placeholder)!=null?u:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(a==null?void 0:a.direction)||""),r.searchParams.set("color",JSON.stringify(a!=null&&a.color?a.color:"#000")),r.searchParams.set("placeholderColor",(a==null?void 0:a.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(a==null?void 0:a.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(a==null?void 0:a.fontSize)||""),r.searchParams.set("fontFamily",(a==null?void 0:a.fontFamily)||""),r.searchParams.set("fontWeight",`${a==null?void 0:a.fontWeight}`),r.searchParams.set("fontStyle",(a==null?void 0:a.fontStyle)||""),r.searchParams.set("padding",(a==null?void 0:a.padding)||"");const n=document.createElement("iframe");return n.src=r.toString(),n.style.height=(g=a==null?void 0:a.height)!=null?g:"40px",n.style.setProperty("overflow","hidden","important"),n.style.setProperty("display","block","important"),n.style.setProperty("width","100%","important"),n.style.setProperty("maxWidth","100%","important"),n.style.setProperty("border","0","important"),n.style.setProperty("margin","0","important"),n.style.setProperty("padding","0","important"),n.style.setProperty("userSelect","none","important"),n.style.setProperty("colorScheme","light only","important"),e.replaceChildren(n),n},W=new WeakSet,ye=function({accessToken:e}){const t=S(),s=Ee(),a=new URL(`${t}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${s}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang);const i=document.createElement("iframe");return i.id="moneyhash-submit-iframe",i.src=a.toString(),i.hidden=!0,document.body.appendChild(i),i};exports.IFrameSandboxOptions=p.IFrameSandboxOptions;exports.default=ve;
var Pe = Object.defineProperty, be = Object.defineProperties;
var ke = Object.getOwnPropertyDescriptors;
var _ = Object.getOwnPropertySymbols;
var se = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
var B = (o, e, t) => e in o ? Pe(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, w = (o, e) => {
var ne = Object.prototype.hasOwnProperty, ie = Object.prototype.propertyIsEnumerable;
var j = (d, e, t) => e in d ? Pe(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t, w = (d, e) => {
for (var t in e || (e = {}))
se.call(e, t) && B(o, t, e[t]);
ne.call(e, t) && j(d, t, e[t]);
if (_)
for (var t of _(e))
ie.call(e, t) && B(o, t, e[t]);
return o;
}, q = (o, e) => be(o, ke(e));
var re = (o, e) => {
ie.call(e, t) && j(d, t, e[t]);
return d;
}, q = (d, e) => be(d, ke(e));
var re = (d, e) => {
var t = {};
for (var s in o)
se.call(o, s) && e.indexOf(s) < 0 && (t[s] = o[s]);
if (o != null && _)
for (var s of _(o))
e.indexOf(s) < 0 && ie.call(o, s) && (t[s] = o[s]);
for (var n in d)
ne.call(d, n) && e.indexOf(n) < 0 && (t[n] = d[n]);
if (d != null && _)
for (var n of _(d))
e.indexOf(n) < 0 && ie.call(d, n) && (t[n] = d[n]);
return t;
};
var f = (o, e, t) => (B(o, typeof e != "symbol" ? e + "" : e, t), t), Ae = (o, e, t) => {
if (!e.has(o))
var f = (d, e, t) => (j(d, typeof e != "symbol" ? e + "" : e, t), t), Ee = (d, e, t) => {
if (!e.has(d))
throw TypeError("Cannot " + t);
};
var P = (o, e, t) => {
if (e.has(o))
var P = (d, e, t) => {
if (e.has(d))
throw TypeError("Cannot add the same private member more than once");
e instanceof WeakSet ? e.add(o) : e.set(o, t);
e instanceof WeakSet ? e.add(d) : e.set(d, t);
};
var y = (o, e, t) => (Ae(o, e, "access private method"), t);
var h = (o, e, t) => new Promise((s, a) => {
var i = (n) => {
var y = (d, e, t) => (Ee(d, e, "access private method"), t);
var h = (d, e, t) => new Promise((n, a) => {
var i = (s) => {
try {
r(t.next(n));
r(t.next(s));
} catch (l) {
a(l);
}
}, d = (n) => {
}, o = (s) => {
try {
r(t.throw(n));
r(t.throw(s));
} catch (l) {
a(l);
}
}, r = (n) => n.done ? s(n.value) : Promise.resolve(n.value).then(i, d);
r((t = t.apply(o, e)).next());
}, r = (s) => s.done ? n(s.value) : Promise.resolve(s.value).then(i, o);
r((t = t.apply(d, e)).next());
});
import { M as Ee, g as pe, S as ve, t as g, w as Se, s as O } from "./warnIf-41c60067.js";
import { I as He } from "./warnIf-41c60067.js";
import { M as Ae, g as pe, S as ve, t as g, w as Se, s as G } from "./warnIf-31e89941.js";
import { I as $e } from "./warnIf-31e89941.js";
function Ce() {

@@ -61,17 +61,17 @@ return typeof window != "undefined";

const e = pe(), t = new URL(`${e}/embed/headless-sdk`);
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.9.0");
const s = document.createElement("iframe");
s.id = "moneyhash-headless-sdk", s.src = t.toString(), s.hidden = !0, document.body.appendChild(s), b.messagingService = new Ee({
target: s.contentWindow,
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.9.1-beta.0");
const n = document.createElement("iframe");
n.id = "moneyhash-headless-sdk", n.src = t.toString(), n.hidden = !0, document.body.appendChild(n), b.messagingService = new Ae({
target: n.contentWindow,
targetOrigin: e
}), b.isCommunicationReady = new Promise((a) => {
var d;
var o;
const i = (r) => {
var n;
r.data.type === "headlessSDK:init" && (a(), (n = b.messagingService) == null || n.removeListener(i));
var s;
r.data.type === "headlessSDK:init" && (a(), (s = b.messagingService) == null || s.removeListener(i));
};
(d = b.messagingService) == null || d.onReceive(i);
(o = b.messagingService) == null || o.onReceive(i);
});
}
request(s) {
request(n) {
return h(this, arguments, function* ({

@@ -82,3 +82,3 @@ api: e,

return yield b.isCommunicationReady, new Promise((a, i) => {
var r, n;
var r, s;
(r = b.messagingService) == null || r.send({

@@ -88,8 +88,8 @@ type: e,

});
const d = (l) => {
const o = (l) => {
var m;
const { type: c, data: p } = l.data;
c === e && (p.status === "resolved" ? a(p.payload) : i(p.payload), (m = b.messagingService) == null || m.removeListener(d));
c === e && (p.status === "resolved" ? a(p.payload) : i(p.payload), (m = b.messagingService) == null || m.removeListener(o));
};
(n = b.messagingService) == null || n.onReceive(d);
(s = b.messagingService) == null || s.onReceive(o);
});

@@ -105,3 +105,3 @@ });

f(I, "messagingService", null), f(I, "isCommunicationReady");
class G {
class K {
constructor() {

@@ -124,7 +124,3 @@ f(this, "promise");

}
function Le() {
var e;
return (e = window.API_URL) != null ? e : "https://web.moneyhash.io";
}
function oe(o) {
function oe(d) {
const e = [

@@ -137,11 +133,11 @@ "cardNumber",

for (const t of e)
if (!o.includes(t))
if (!d.includes(t))
return t;
return null;
}
function de(o) {
return (Array.isArray(o) ? o.length : Object.keys(o).length) === 0;
function de(d) {
return (Array.isArray(d) ? d.length : Object.keys(d).length) === 0;
}
function le(o, e) {
return new Promise((t, s) => {
function le(d, e) {
return new Promise((t, n) => {
if (document.getElementById(e)) {

@@ -152,14 +148,14 @@ t(void 0);

const i = document.createElement("script");
i.src = o, i.id = e, i.addEventListener("load", () => {
i.src = d, i.id = e, i.addEventListener("load", () => {
t(void 0);
}), i.addEventListener("error", () => {
s(new Error("Script failed to load"));
n(new Error("Script failed to load"));
}), document.body.appendChild(i);
});
}
function Me(o) {
function Me(d) {
return new Promise((e) => {
setTimeout(() => {
e("done");
}, o * 1e3);
}, d * 1e3);
});

@@ -172,7 +168,7 @@ }

]);
var L, K, M, Y, F, ue, $, he, H, me, R, x, N, ge, D, ye, V, fe, W, we;
class qe {
var M, O, L, Y, F, ue, $, he, H, me, R, x, D, ge, N, ye, V, fe, W, we;
class _e {
constructor(e) {
P(this, M);
P(this, L);
P(this, M);
P(this, F);

@@ -182,4 +178,4 @@ P(this, $);

P(this, R);
P(this, D);
P(this, N);
P(this, D);
P(this, V);

@@ -214,3 +210,3 @@ P(this, W);

});
return y(this, M, Y).call(this, { accessToken: t });
return y(this, L, Y).call(this, { accessToken: t });
}),

@@ -220,6 +216,6 @@ pay: (r) => h(this, [r], function* ({

cardData: t,
saveCard: s,
saveCard: n,
billingData: a,
shippingData: i,
installmentPlanData: d
installmentPlanData: o
}) {

@@ -235,8 +231,8 @@ return this.sdkApiHandler.request({

cardEmbed: t,
saveCard: s,
installmentPlanData: d
saveCard: n,
installmentPlanData: o
}
});
}),
createCardToken: (s) => h(this, [s], function* ({
createCardToken: (n) => h(this, [n], function* ({
cardIntentId: e,

@@ -256,3 +252,3 @@ cardData: t

});
this.options = e, this.sdkEmbed = new ve(q(w({}, e), { headless: !0 })), y(this, D, ye).call(this, this.vaultSubmitListener);
this.options = e, this.sdkEmbed = new ve(q(w({}, e), { headless: !0 })), y(this, N, ye).call(this, this.vaultSubmitListener);
}

@@ -365,3 +361,3 @@ /**

type: t,
id: s,
id: n,
useWalletBalance: a,

@@ -381,3 +377,3 @@ metaData: i

intentId: e,
id: s,
id: n,
lang: this.sdkEmbed.lang,

@@ -482,9 +478,9 @@ useWalletBalance: a,

currency: t,
amount: s,
amount: n,
countryCode: a,
onCancel: i = () => {
},
onError: d,
onError: o,
onComplete: r,
billingData: n = {}
billingData: s = {}
}) {

@@ -504,3 +500,3 @@ if (yield le(

type: "final",
amount: `${s}`
amount: `${n}`
},

@@ -515,3 +511,3 @@ requiredShippingContactFields: ["email"]

if (p === "FORM_FIELDS") {
if (de(n))
if (de(s))
throw new Error(

@@ -526,3 +522,3 @@ "Billing data is missing while calling payWithApplePay"

lang: this.sdkEmbed.lang,
billingData: n
billingData: s
}

@@ -534,18 +530,13 @@ });

}
const A = new G();
return c.onvalidatemerchant = (E) => {
fetch(`${Le()}/api/v1/providers/applepay/session/`, {
method: "post",
headers: {
"Content-Type": "application/json"
},
body: JSON.stringify({
secret: m.secret,
validation_url: E.validationURL
})
}).then((k) => k.ok ? k.json() : Promise.reject()).then(
(k) => c.completeMerchantValidation(k)
).catch(d);
}, c.onpaymentauthorized = (E) => {
var k;
const k = new K();
return c.onvalidatemerchant = (E) => this.sdkApiHandler.request({
api: "sdk:applePaySession",
payload: {
secret: m.secret,
validationUrl: E.validationURL
}
}).then(
(v) => c.completeMerchantValidation(v)
).catch(o), c.onpaymentauthorized = (E) => {
var v;
return this.sdkApiHandler.request({

@@ -558,11 +549,11 @@ api: "sdk:submitReceipt",

receiptBillingData: {
email: (k = E.payment.shippingContact) == null ? void 0 : k.emailAddress
email: (v = E.payment.shippingContact) == null ? void 0 : v.emailAddress
}
}
}).then((U) => {
c.completePayment(ApplePaySession.STATUS_SUCCESS), r == null || r(), A.resolve(U);
c.completePayment(ApplePaySession.STATUS_SUCCESS), r == null || r(), k.resolve(U);
}).catch(() => {
c.completePayment(ApplePaySession.STATUS_FAILURE), d == null || d(), A.reject(void 0);
c.completePayment(ApplePaySession.STATUS_FAILURE), o == null || o(), k.reject(void 0);
});
}, c.oncancel = i, c.begin(), A.promise;
}, c.oncancel = i, c.begin(), k.promise;
});

@@ -593,5 +584,5 @@ }

*/
renderGooglePayButton(s) {
renderGooglePayButton(n) {
return h(this, null, function* () {
var a = s, {
var a = n, {
onClick: e

@@ -612,5 +603,5 @@ } = a, t = re(a, [

});
const d = y(this, L, K).call(this);
this.googlePaymentsClient.isReadyToPay(d).then((n) => {
if (n.result) {
const o = y(this, M, O).call(this);
this.googlePaymentsClient.isReadyToPay(o).then((s) => {
if (s.result) {
const l = this.googlePaymentsClient.createButton(q(w({

@@ -620,3 +611,3 @@ buttonSizeMode: "fill",

}, t), {
allowedPaymentMethods: d.allowedPaymentMethods,
allowedPaymentMethods: o.allowedPaymentMethods,
onClick: e

@@ -627,4 +618,4 @@ }));

throw new Error("Google Pay is not ready to pay!");
}).catch((n) => {
console.dir(n);
}).catch((s) => {
console.dir(s);
});

@@ -662,3 +653,3 @@ });

billingData: t = {},
onCancel: s
onCancel: n
}) {

@@ -693,18 +684,18 @@ g(

}
const { __nativePayData__: d } = i;
return d ? this.googlePaymentsClient.loadPaymentData(q(w({}, y(this, L, K).call(this, d)), {
const { __nativePayData__: o } = i;
return o ? this.googlePaymentsClient.loadPaymentData(q(w({}, y(this, M, O).call(this, o)), {
transactionInfo: {
totalPriceStatus: "FINAL",
totalPriceLabel: "Total",
totalPrice: `${d.amount}`,
currencyCode: d.currency_code,
countryCode: d.country_code
totalPrice: `${o.amount}`,
currencyCode: o.currency_code,
countryCode: o.country_code
},
merchantInfo: {
merchantName: d == null ? void 0 : d.merchant_name,
merchantId: d == null ? void 0 : d.merchant_id
merchantName: o == null ? void 0 : o.merchant_name,
merchantId: o == null ? void 0 : o.merchant_id
},
emailRequired: !0
})).then((r) => {
const n = r.paymentMethodData.tokenizationData.token;
const s = r.paymentMethodData.tokenizationData.token;
return this.sdkApiHandler.request({

@@ -715,3 +706,3 @@ api: "sdk:submitReceipt",

lang: this.sdkEmbed.lang,
receipt: n,
receipt: s,
receiptBillingData: {

@@ -722,3 +713,3 @@ email: r.email

});
}).catch((r) => (r.statusCode === "CANCELED" ? s == null || s() : console.dir(r), Promise.reject(r))) : i;
}).catch((r) => (r.statusCode === "CANCELED" ? n == null || n() : console.dir(r), Promise.reject(r))) : i;
});

@@ -760,8 +751,8 @@ }

Se(
!!e && !O.has(e),
`Invalid locale. Supported languages (${[...O].join(
!!e && !G.has(e),
`Invalid locale. Supported languages (${[...G].join(
" | "
)})`
);
const t = O.has(e) ? e : "en";
const t = G.has(e) ? e : "en";
return this.sdkEmbed.setLocale(t);

@@ -820,4 +811,4 @@ }

updateIntentFees({ intentId: e, fees: t }) {
return t.forEach((s) => {
g(!s.title.en, "English fee title is required!");
return t.forEach((n) => {
g(!n.title.en, "English fee title is required!");
}), this.sdkApiHandler.request({

@@ -844,6 +835,6 @@ api: "sdk:updateIntentFees",

*/
elements({ styles: e, classes: t, fontSourceCss: s }) {
const a = [], i = {}, d = /* @__PURE__ */ new Map();
elements({ styles: e, classes: t, fontSourceCss: n }) {
const a = [], i = {}, o = /* @__PURE__ */ new Map();
let r = !1;
return y(this, N, ge).call(this, a), {
return y(this, D, ge).call(this, a), {
/**

@@ -870,7 +861,7 @@ * Creates card field element

*/
create: ({ elementType: n, elementOptions: l }) => {
var k, U;
create: ({ elementType: s, elementOptions: l }) => {
var v, U;
const c = /* @__PURE__ */ new Map();
let p = null;
const m = w(w({}, t), l.classes), A = ((k = m == null ? void 0 : m.focus) == null ? void 0 : k.split(" ")) || [
const m = w(w({}, t), l.classes), k = ((v = m == null ? void 0 : m.focus) == null ? void 0 : v.split(" ")) || [
"MoneyHashElement--focus"

@@ -889,30 +880,30 @@ ], E = ((U = m == null ? void 0 : m.error) == null ? void 0 : U.split(" ")) || [

), u.classList.add("MoneyHashElement"), a.push((T) => {
var z, J, X, Q, Z, ee, te, ae, ne;
const { type: v, data: S } = T.data;
if (v === `${n}@mount` && (i[n] = S.isValid, (z = c.get(`${n}@mount`)) == null || z()), v === `${n}@focus`) {
u.classList.add(...A), (J = c.get(`${n}@focus`)) == null || J();
var z, J, X, Q, Z, ee, te, ae, se;
const { type: A, data: S } = T.data;
if (A === `${s}@mount` && (i[s] = S.isValid, (z = c.get(`${s}@mount`)) == null || z()), A === `${s}@focus`) {
u.classList.add(...k), (J = c.get(`${s}@focus`)) == null || J();
return;
}
if (v === `${n}@blur`) {
u.classList.remove(...A), (X = c.get(`${n}@blur`)) == null || X();
if (A === `${s}@blur`) {
u.classList.remove(...k), (X = c.get(`${s}@blur`)) == null || X();
return;
}
if (v === `${n}@error`) {
S.isValid ? u.classList.remove(...E) : u.classList.add(...E), (Q = c.get(`${n}@error`)) == null || Q(S);
if (A === `${s}@error`) {
S.isValid ? u.classList.remove(...E) : u.classList.add(...E), (Q = c.get(`${s}@error`)) == null || Q(S);
return;
}
if (v === `${n}@changeInput`) {
if ((Z = c.get(`${n}@changeInput`)) == null || Z({
if (A === `${s}@changeInput`) {
if ((Z = c.get(`${s}@changeInput`)) == null || Z({
isValid: S.isValid,
length: S.length
}), i[n] = S.isValid, d.get("validityChange")) {
const j = Object.values(i).every(Boolean);
j !== r && ((ee = d.get("validityChange")) == null || ee(
j
), r = j);
}), i[s] = S.isValid, o.get("validityChange")) {
const B = Object.values(i).every(Boolean);
B !== r && ((ee = o.get("validityChange")) == null || ee(
B
), r = B);
}
return;
}
if (v === `${n}@cardNumberChange`) {
(te = c.get(`${n}@cardNumberChange`)) == null || te(
if (A === `${s}@cardNumberChange`) {
(te = c.get(`${s}@cardNumberChange`)) == null || te(
S

@@ -922,19 +913,19 @@ );

}
if (v === `${n}@key:Backspace`) {
(ae = c.get(`${n}@key:Backspace`)) == null || ae();
if (A === `${s}@key:Backspace`) {
(ae = c.get(`${s}@key:Backspace`)) == null || ae();
return;
}
v === `${n}@key:Enter` && ((ne = c.get(`${n}@key:Enter`)) == null || ne());
A === `${s}@key:Enter` && ((se = c.get(`${s}@key:Enter`)) == null || se());
}), p = y(this, V, fe).call(this, {
container: u,
elementType: n,
elementType: s,
elementOptions: l,
styles: w(w({}, e), l.styles),
fontSourceCss: s
}), this.mountedCardElements.push(n);
fontSourceCss: n
}), this.mountedCardElements.push(s);
},
on: (u, T) => {
c.set(`${n}@${u}`, T);
c.set(`${s}@${u}`, T);
},
off: (u) => c.delete(`${n}@${u}`),
off: (u) => c.delete(`${s}@${u}`),
focus: () => {

@@ -963,4 +954,4 @@ var u;

},
on: (n, l) => {
d.set(n, l);
on: (s, l) => {
o.set(s, l);
}

@@ -983,10 +974,10 @@ };

*/
submitForm(n) {
submitForm(s) {
return h(this, arguments, function* ({
intentId: e,
accessToken: t,
billingData: s,
billingData: n,
shippingData: a,
saveCard: i,
paymentMethod: d = "CARD",
paymentMethod: o = "CARD",
installmentPlanData: r

@@ -1002,3 +993,3 @@ }) {

`You must mount ${p} element!`
), l = yield y(this, M, Y).call(this, {
), l = yield y(this, L, Y).call(this, {
accessToken: t

@@ -1011,5 +1002,5 @@ });

intentId: e,
paymentMethod: d,
paymentMethod: o,
lang: this.sdkEmbed.lang,
billingData: s,
billingData: n,
shippingData: a,

@@ -1035,3 +1026,3 @@ cardEmbed: l,

planId: t,
issuerCode: s
issuerCode: n
}) {

@@ -1043,3 +1034,3 @@ return this.sdkApiHandler.request({

intentId: e,
issuerCode: s,
issuerCode: n,
lang: this.sdkEmbed.lang

@@ -1062,3 +1053,3 @@ }

amount: t,
currency: s
currency: n
}) {

@@ -1073,3 +1064,3 @@ return g(

amount: t,
currency: s,
currency: n,
publicApiKey: this.options.publicApiKey,

@@ -1095,3 +1086,3 @@ lang: this.sdkEmbed.lang

cvv: t,
installmentPlanData: s
installmentPlanData: n
}) {

@@ -1103,3 +1094,3 @@ return this.sdkApiHandler.request({

cvv: t,
installmentPlanData: s,
installmentPlanData: n,
lang: this.sdkEmbed.lang

@@ -1123,6 +1114,6 @@ }

url: t,
renderStrategy: s,
renderStrategy: n,
options: a
}) {
switch (this.sdkApiHandler.postMessage("SDKRenderUrl"), s) {
switch (this.sdkApiHandler.postMessage("SDKRenderUrl"), n) {
case "IFRAME":

@@ -1154,5 +1145,5 @@ return y(this, F, ue).call(this, { url: t, intentId: e });

};
const s = new Date(e), a = setInterval(() => h(this, null, function* () {
const n = new Date(e), a = setInterval(() => h(this, null, function* () {
const i = new Date();
s < i && (clearInterval(a), t());
n < i && (clearInterval(a), t());
}), 1e3);

@@ -1162,4 +1153,4 @@ return () => clearInterval(a);

}
L = new WeakSet(), K = function(e) {
var s, a;
M = new WeakSet(), O = function(e) {
var n, a;
return {

@@ -1172,3 +1163,3 @@ apiVersion: 2,

parameters: {
allowedAuthMethods: ((s = this.options.googlePay) == null ? void 0 : s.allowedAuthMethods) || [
allowedAuthMethods: ((n = this.options.googlePay) == null ? void 0 : n.allowedAuthMethods) || [
"PAN_ONLY",

@@ -1196,15 +1187,15 @@ "CRYPTOGRAM_3DS"

};
}, M = new WeakSet(), Y = function(t) {
}, L = new WeakSet(), Y = function(t) {
return h(this, arguments, function* ({ accessToken: e }) {
const s = new G();
this.vaultSubmitListener.current = (d) => {
const { type: r, data: n } = d.data;
r === "vaultSubmit:success" && s.resolve(n), r === "vaultSubmit:error" && s.reject(n);
const n = new K();
this.vaultSubmitListener.current = (o) => {
const { type: r, data: s } = o.data;
r === "vaultSubmit:success" && n.resolve(s), r === "vaultSubmit:error" && n.reject(s);
};
const a = y(this, W, we).call(this, {
accessToken: e
}), i = yield s.promise;
}), i = yield n.promise;
return a.remove(), i;
});
}, F = new WeakSet(), ue = function(s) {
}, F = new WeakSet(), ue = function(n) {
return h(this, arguments, function* ({

@@ -1226,17 +1217,17 @@ intentId: e,

url: t,
options: s = {}
options: n = {}
}) {
const {
width: i = 600,
height: d = 400,
height: o = 400,
left: r = 200,
top: n = 200
} = s.window || {}, l = window.open(
top: s = 200
} = n.window || {}, l = window.open(
t,
"",
`width=${i},height=${d},left=${r},top=${n}`
`width=${i},height=${o},left=${r},top=${s}`
);
g(!l, "Popup blocked by browser!"), yield y(this, R, x).call(this, { intentId: e, isUsingPopUp: !0 }), l == null || l.close();
});
}, H = new WeakSet(), me = function(s) {
}, H = new WeakSet(), me = function(n) {
return h(this, arguments, function* ({

@@ -1252,3 +1243,3 @@ url: e,

});
}, R = new WeakSet(), x = function(s) {
}, R = new WeakSet(), x = function(n) {
return h(this, arguments, function* ({

@@ -1258,7 +1249,7 @@ intentId: e,

}) {
const a = new G(), i = (d) => h(this, null, function* () {
var n, l, c, p;
if (d.origin !== pe())
const a = new K(), i = (o) => h(this, null, function* () {
var s, l, c, p;
if (o.origin !== pe())
return;
const { type: r } = d.data;
const { type: r } = o.data;
if (r === "intentResult") {

@@ -1269,4 +1260,4 @@ t && this.sdkApiHandler.postMessage("EmbedResultClose");

Me(2)
]), A = m.transaction.status.split(".")[1];
A === "successful" || A.startsWith("pending") ? (l = (n = this.options).onComplete) == null || l.call(n, w({
]), k = m.transaction.status.split(".")[1];
k === "successful" || k.startsWith("pending") ? (l = (s = this.options).onComplete) == null || l.call(s, w({
type: this.options.type

@@ -1280,12 +1271,12 @@ }, m)) : (p = (c = this.options).onFail) == null || p.call(c, w({

});
}, N = new WeakSet(), ge = function(e) {
const t = (s) => {
s.origin === C() && e.forEach((a) => {
a(s);
}, D = new WeakSet(), ge = function(e) {
const t = (n) => {
n.origin === C() && e.forEach((a) => {
a(n);
});
};
window.addEventListener("message", t);
}, D = new WeakSet(), ye = function(e) {
const t = (s) => {
e.current && e.current(s);
}, N = new WeakSet(), ye = function(e) {
const t = (n) => {
e.current && e.current(n);
};

@@ -1296,3 +1287,3 @@ window.addEventListener("message", t);

elementType: t,
elementOptions: s,
elementOptions: n,
styles: a,

@@ -1302,7 +1293,7 @@ fontSourceCss: i

var l, c, p, m;
const d = C(), r = new URL(`${d}/vaultField/vaultField.html`);
i && r.searchParams.set("fontSourceCss", i), r.searchParams.set("host", btoa(window.location.origin)), r.searchParams.set("type", t), ((l = s.validation) == null ? void 0 : l.required) !== void 0 && r.searchParams.set(
const o = C(), r = new URL(`${o}/vaultField/vaultField.html`);
i && r.searchParams.set("fontSourceCss", i), r.searchParams.set("host", btoa(window.location.origin)), r.searchParams.set("type", t), ((l = n.validation) == null ? void 0 : l.required) !== void 0 && r.searchParams.set(
"required",
`${(c = s.validation) == null ? void 0 : c.required}`
), r.searchParams.set("placeholder", (p = s.placeholder) != null ? p : ""), r.searchParams.set("lang", this.sdkEmbed.lang), r.searchParams.set("direction", (a == null ? void 0 : a.direction) || ""), r.searchParams.set(
`${(c = n.validation) == null ? void 0 : c.required}`
), r.searchParams.set("placeholder", (p = n.placeholder) != null ? p : ""), r.searchParams.set("lang", this.sdkEmbed.lang), r.searchParams.set("direction", (a == null ? void 0 : a.direction) || ""), r.searchParams.set(
"color",

@@ -1317,9 +1308,9 @@ JSON.stringify(a != null && a.color ? a.color : "#000")

), r.searchParams.set("fontSize", (a == null ? void 0 : a.fontSize) || ""), r.searchParams.set("fontFamily", (a == null ? void 0 : a.fontFamily) || ""), r.searchParams.set("fontWeight", `${a == null ? void 0 : a.fontWeight}`), r.searchParams.set("fontStyle", (a == null ? void 0 : a.fontStyle) || ""), r.searchParams.set("padding", (a == null ? void 0 : a.padding) || "");
const n = document.createElement("iframe");
return n.src = r.toString(), n.style.height = (m = a == null ? void 0 : a.height) != null ? m : "40px", n.style.setProperty("overflow", "hidden", "important"), n.style.setProperty("display", "block", "important"), n.style.setProperty("width", "100%", "important"), n.style.setProperty("maxWidth", "100%", "important"), n.style.setProperty("border", "0", "important"), n.style.setProperty("margin", "0", "important"), n.style.setProperty("padding", "0", "important"), n.style.setProperty("userSelect", "none", "important"), n.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(n), n;
const s = document.createElement("iframe");
return s.src = r.toString(), s.style.height = (m = a == null ? void 0 : a.height) != null ? m : "40px", s.style.setProperty("overflow", "hidden", "important"), s.style.setProperty("display", "block", "important"), s.style.setProperty("width", "100%", "important"), s.style.setProperty("maxWidth", "100%", "important"), s.style.setProperty("border", "0", "important"), s.style.setProperty("margin", "0", "important"), s.style.setProperty("padding", "0", "important"), s.style.setProperty("userSelect", "none", "important"), s.style.setProperty("colorScheme", "light only", "important"), e.replaceChildren(s), s;
}, W = new WeakSet(), we = function({ accessToken: e }) {
const t = C(), s = Ie(), a = new URL(
const t = C(), n = Ie(), a = new URL(
`${t}/vaultSubmit/vaultSubmit.html`
);
a.searchParams.set("host", btoa(window.location.origin)), a.searchParams.set("vault_api_url", `${s}/api/v1/tokens/`), a.searchParams.set("access_token", e), a.searchParams.set("lang", this.sdkEmbed.lang);
a.searchParams.set("host", btoa(window.location.origin)), a.searchParams.set("vault_api_url", `${n}/api/v1/tokens/`), a.searchParams.set("access_token", e), a.searchParams.set("lang", this.sdkEmbed.lang);
const i = document.createElement("iframe");

@@ -1329,4 +1320,4 @@ return i.id = "moneyhash-submit-iframe", i.src = a.toString(), i.hidden = !0, document.body.appendChild(i), i;

export {
He as IFrameSandboxOptions,
qe as default
$e as IFrameSandboxOptions,
_e as default
};

@@ -1,1 +0,1 @@

(function(d,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(d=typeof globalThis!="undefined"?globalThis:d||self,l(d.MoneyHash={}))})(this,function(d){var N,Z,D,ee,T,we,W,be,j,Pe,V,te,B,ke,G,ve,K,Ee,Y,Ae;"use strict";var Le=Object.defineProperty,Ue=Object.defineProperties;var _e=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var Q=(d,l,c)=>l in d?Le(d,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[l]=c,E=(d,l)=>{for(var c in l||(l={}))ge.call(l,c)&&Q(d,c,l[c]);if(x)for(var c of x(l))ye.call(l,c)&&Q(d,c,l[c]);return d},z=(d,l)=>Ue(d,_e(l));var fe=(d,l)=>{var c={};for(var S in d)ge.call(d,S)&&l.indexOf(S)<0&&(c[S]=d[S]);if(d!=null&&x)for(var S of x(d))l.indexOf(S)<0&&ye.call(d,S)&&(c[S]=d[S]);return c};var b=(d,l,c)=>(Q(d,typeof l!="symbol"?l+"":l,c),c),Fe=(d,l,c)=>{if(!l.has(d))throw TypeError("Cannot "+c)};var I=(d,l,c)=>{if(l.has(d))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(d):l.set(d,c)};var A=(d,l,c)=>(Fe(d,l,"access private method"),c);var y=(d,l,c)=>new Promise((S,M)=>{var O=R=>{try{F(c.next(R))}catch(H){M(H)}},f=R=>{try{F(c.throw(R))}catch(H){M(H)}},F=R=>R.done?S(R.value):Promise.resolve(R.value).then(O,f);F((c=c.apply(d,l)).next())});class l{constructor(e){b(this,"target");b(this,"targetOrigin");b(this,"listeners");b(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function c(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function S(){return typeof window!="undefined"}const C=class{constructor(){S()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.9.0");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),C.messagingService=new l({target:n.contentWindow,targetOrigin:e}),C.isCommunicationReady=new Promise(i=>{var o;const a=r=>{var s;r.data.type==="headlessSDK:init"&&(i(),(s=C.messagingService)==null||s.removeListener(a))};(o=C.messagingService)==null||o.onReceive(a)})}request(n){return y(this,arguments,function*({api:e,payload:t}){return yield C.isCommunicationReady,new Promise((i,a)=>{var r,s;(r=C.messagingService)==null||r.send({type:e,data:t});const o=m=>{var u;const{type:p,data:h}=m.data;p===e&&(h.status==="resolved"?i(h.payload):a(h.payload),(u=C.messagingService)==null||u.removeListener(o))};(s=C.messagingService)==null||s.onReceive(o)})})}postMessage(e){var t;(t=C.messagingService)==null||t.send({type:e})}};let M=C;b(M,"messagingService",null),b(M,"isCommunicationReady");const O=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];function f(w,e){if(w)throw new Error(e)}const F=new Set(["payment","payout"]),R=new Set(["en","fr","ar"]);class H{constructor(e){b(this,"options");b(this,"messagingService",null);b(this,"iframe",null);b(this,"isCommunicationReady",null);f(!F.has(e.type),`MoneyHash constructor must be called with valid type (${[...F].join(" | ")})!`),this.options=e}get lang(){var t;return((t=this.options.locale)==null?void 0:t.split("-")[0])||"en"}render({selector:e,intentId:t,sandbox:n,onHeightChange:i}){var m,p;(m=this.messagingService)==null||m.abortService();const a=c(),o=new URL(`${a}/embed/${this.options.type}/${t}`);o.searchParams.set("sdk","true"),o.searchParams.set("parent",window.location.origin),o.searchParams.set("version","js@1.9.0"),i&&o.searchParams.set("onDimensionsChange","true");const r=(p=this.options.locale)==null?void 0:p.split("-")[0];r&&o.searchParams.set("lang",r),this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",n&&n.forEach(h=>{var u;O.includes(h)&&((u=this.iframe)==null||u.sandbox.add(h))});const s=document.querySelector(e);return f(!s,`Couldn't find an element with selector ${e}!`),s.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:a}),this.isCommunicationReady=new Promise(h=>{var v;const u=k=>{var P;k.data.type==="sdk:init"&&(h(),(P=this.messagingService)==null||P.removeListener(u))};(v=this.messagingService)==null||v.onReceive(u)}),this.messagingService.onReceive((h,u)=>{var P,U,g,q;const{type:v,data:k}=h.data;switch(v){case"sdk:init":{u({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(U=(P=this.options).onComplete)==null||U.call(P,E({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(q=(g=this.options).onFail)==null||q.call(g,E({type:this.options.type},k)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{i==null||i(k.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return y(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return y(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class J{constructor(){b(this,"promise");b(this,"resolve");b(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Se(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function $(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function Re(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function ie(w){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!w.includes(t))return t;return null}function se(w){return(Array.isArray(w)?w.length:Object.keys(w).length)===0}function ae(w,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=w,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(a)})}function Ce(w){return new Promise(e=>{setTimeout(()=>{e("done")},w*1e3)})}function Ie(w,e){w&&console.warn(e)}const ne=new Set(["method","customerBalance","savedCard"]);class Me{constructor(e){I(this,N);I(this,D);I(this,T);I(this,W);I(this,j);I(this,V);I(this,B);I(this,G);I(this,K);I(this,Y);b(this,"options");b(this,"sdkApiHandler",new M);b(this,"sdkEmbed");b(this,"vaultSubmitListener",{current:null});b(this,"mountedCardElements",[]);b(this,"googlePaymentsClient",null);b(this,"cardForm",{collect:()=>y(this,null,function*(){f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=ie(this.mountedCardElements);f(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return A(this,D,ee).call(this,{accessToken:t})}),pay:r=>y(this,[r],function*({intentId:e,cardData:t,saveCard:n,billingData:i,shippingData:a,installmentPlanData:o}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:i,shippingData:a,cardEmbed:t,saveCard:n,installmentPlanData:o}})}),createCardToken:n=>y(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new H(z(E({},e),{headless:!0})),A(this,G,ve).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),f(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:E({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:i,metaData:a}){return f(!ne.has(t),`type must be a valid one (${[...ne].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:i,metaData:a}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return f(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(m){return y(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:i,onCancel:a=()=>{},onError:o,onComplete:r,billingData:s={}}){if(yield ae("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const p=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:h,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(h==="FORM_FIELDS"){if(se(s))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:s}})}}catch(k){throw yield this.resetSelectedMethod(e),k}const v=new J;return p.onvalidatemerchant=k=>{fetch(`${Re()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:u.secret,validation_url:k.validationURL})}).then(P=>P.ok?P.json():Promise.reject()).then(P=>p.completeMerchantValidation(P)).catch(o)},p.onpaymentauthorized=k=>{var P;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:k.payment.token}),receiptBillingData:{email:(P=k.payment.shippingContact)==null?void 0:P.emailAddress}}}).then(U=>{p.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),v.resolve(U)}).catch(()=>{p.completePayment(ApplePaySession.STATUS_FAILURE),o==null||o(),v.reject(void 0)})},p.oncancel=a,p.begin(),v.promise})}renderGooglePayButton(n){return y(this,null,function*(){var i=n,{onClick:e}=i,t=fe(i,["onClick"]);var r;const a=document.getElementById("moneyHash-google-pay-button");f(!a,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield ae("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const o=A(this,N,Z).call(this);this.googlePaymentsClient.isReadyToPay(o).then(s=>{if(s.result){const m=this.googlePaymentsClient.createButton(z(E({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:o.allowedPaymentMethods,onClick:e}));a==null||a.replaceChildren(m)}else throw new Error("Google Pay is not ready to pay!")}).catch(s=>{console.dir(s)})})}payWithGooglePay(i){return y(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){f(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let a=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(a.state==="FORM_FIELDS"){if(se(t))throw new Error("Billing data is missing while calling payWithGooglePay");a=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:o}=a;return o?this.googlePaymentsClient.loadPaymentData(z(E({},A(this,N,Z).call(this,o)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${o.amount}`,currencyCode:o.currency_code,countryCode:o.country_code},merchantInfo:{merchantName:o==null?void 0:o.merchant_name,merchantId:o==null?void 0:o.merchant_id},emailRequired:!0})).then(r=>{const s=r.paymentMethodData.tokenizationData.token;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:s,receiptBillingData:{email:r.email}}})}).catch(r=>(r.statusCode==="CANCELED"?n==null||n():console.dir(r),Promise.reject(r))):a})}renderForm(e){return f(!e.selector,"selector is required for renderForm"),f(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){Ie(!!e&&!R.has(e),`Invalid locale. Supported languages (${[...R].join(" | ")})`);const t=R.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return f(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(n=>{f(!n.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:n}){const i=[],a={},o=new Map;let r=!1;return A(this,B,ke).call(this,i),{create:({elementType:s,elementOptions:m})=>{var P,U;const p=new Map;let h=null;const u=E(E({},t),m.classes),v=((P=u==null?void 0:u.focus)==null?void 0:P.split(" "))||["MoneyHashElement--focus"],k=((U=u==null?void 0:u.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const g=document.querySelector(m.selector);f(!g,`Couldn't find an element with selector ${m.selector}!`),g.classList.add("MoneyHashElement"),i.push(q=>{var re,oe,de,le,ce,he,pe,me,ue;const{type:L,data:_}=q.data;if(L===`${s}@mount`&&(a[s]=_.isValid,(re=p.get(`${s}@mount`))==null||re()),L===`${s}@focus`){g.classList.add(...v),(oe=p.get(`${s}@focus`))==null||oe();return}if(L===`${s}@blur`){g.classList.remove(...v),(de=p.get(`${s}@blur`))==null||de();return}if(L===`${s}@error`){_.isValid?g.classList.remove(...k):g.classList.add(...k),(le=p.get(`${s}@error`))==null||le(_);return}if(L===`${s}@changeInput`){if((ce=p.get(`${s}@changeInput`))==null||ce({isValid:_.isValid,length:_.length}),a[s]=_.isValid,o.get("validityChange")){const X=Object.values(a).every(Boolean);X!==r&&((he=o.get("validityChange"))==null||he(X),r=X)}return}if(L===`${s}@cardNumberChange`){(pe=p.get(`${s}@cardNumberChange`))==null||pe(_);return}if(L===`${s}@key:Backspace`){(me=p.get(`${s}@key:Backspace`))==null||me();return}L===`${s}@key:Enter`&&((ue=p.get(`${s}@key:Enter`))==null||ue())}),h=A(this,K,Ee).call(this,{container:g,elementType:s,elementOptions:m,styles:E(E({},e),m.styles),fontSourceCss:n}),this.mountedCardElements.push(s)},on:(g,q)=>{p.set(`${s}@${g}`,q)},off:g=>p.delete(`${s}@${g}`),focus:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"focus"},$())},blur:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"blur"},$())},clear:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"clear"},$())}}},on:(s,m)=>{o.set(s,m)}}}submitForm(s){return y(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:i,saveCard:a,paymentMethod:o="CARD",installmentPlanData:r}){let m;if(t){const h=ie(this.mountedCardElements);f(!!h,`You must mount ${h} element!`),m=yield A(this,D,ee).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:o,lang:this.sdkEmbed.lang,billingData:n,shippingData:i,cardEmbed:m,saveCard:a,installmentPlanData:r}})})}selectInstallmentPlan(i){return y(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(i){return y(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(i){return y(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(a){return y(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:i}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return A(this,T,we).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return A(this,W,be).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return A(this,j,Pe).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),i=setInterval(()=>y(this,null,function*(){const a=new Date;n<a&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}N=new WeakSet,Z=function(e){var n,i;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[E({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((i=this.options.googlePay)==null?void 0:i.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},D=new WeakSet,ee=function(t){return y(this,arguments,function*({accessToken:e}){const n=new J;this.vaultSubmitListener.current=o=>{const{type:r,data:s}=o.data;r==="vaultSubmit:success"&&n.resolve(s),r==="vaultSubmit:error"&&n.reject(s)};const i=A(this,Y,Ae).call(this,{accessToken:e}),a=yield n.promise;return i.remove(),a})},T=new WeakSet,we=function(n){return y(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");f(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const a=document.createElement("iframe");a.src=t,a.style.setProperty("border","0","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("height","100%","important"),i==null||i.replaceChildren(a),yield A(this,V,te).call(this,{intentId:e}),a.remove()})},W=new WeakSet,be=function(i){return y(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:a=600,height:o=400,left:r=200,top:s=200}=n.window||{},m=window.open(t,"",`width=${a},height=${o},left=${r},top=${s}`);f(!m,"Popup blocked by browser!"),yield A(this,V,te).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},j=new WeakSet,Pe=function(n){return y(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},V=new WeakSet,te=function(n){return y(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new J,a=o=>y(this,null,function*(){var s,m,p,h;if(o.origin!==c())return;const{type:r}=o.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[u]=yield Promise.all([this.getIntentDetails(e),Ce(2)]),v=u.transaction.status.split(".")[1];v==="successful"||v.startsWith("pending")?(m=(s=this.options).onComplete)==null||m.call(s,E({type:this.options.type},u)):(h=(p=this.options).onFail)==null||h.call(p,E({type:this.options.type},u)),i.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),i.promise})},B=new WeakSet,ke=function(e){const t=n=>{n.origin===$()&&e.forEach(i=>{i(n)})};window.addEventListener("message",t)},G=new WeakSet,ve=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},K=new WeakSet,Ee=function({container:e,elementType:t,elementOptions:n,styles:i,fontSourceCss:a}){var m,p,h,u;const o=$(),r=new URL(`${o}/vaultField/vaultField.html`);a&&r.searchParams.set("fontSourceCss",a),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((m=n.validation)==null?void 0:m.required)!==void 0&&r.searchParams.set("required",`${(p=n.validation)==null?void 0:p.required}`),r.searchParams.set("placeholder",(h=n.placeholder)!=null?h:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(i==null?void 0:i.direction)||""),r.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),r.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),r.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),r.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),r.searchParams.set("padding",(i==null?void 0:i.padding)||"");const s=document.createElement("iframe");return s.src=r.toString(),s.style.height=(u=i==null?void 0:i.height)!=null?u:"40px",s.style.setProperty("overflow","hidden","important"),s.style.setProperty("display","block","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("maxWidth","100%","important"),s.style.setProperty("border","0","important"),s.style.setProperty("margin","0","important"),s.style.setProperty("padding","0","important"),s.style.setProperty("userSelect","none","important"),s.style.setProperty("colorScheme","light only","important"),e.replaceChildren(s),s},Y=new WeakSet,Ae=function({accessToken:e}){const t=$(),n=Se(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),i.searchParams.set("access_token",e),i.searchParams.set("lang",this.sdkEmbed.lang);const a=document.createElement("iframe");return a.id="moneyhash-submit-iframe",a.src=i.toString(),a.hidden=!0,document.body.appendChild(a),a},d.IFrameSandboxOptions=O,d.default=Me,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
(function(d,l){typeof exports=="object"&&typeof module!="undefined"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(d=typeof globalThis!="undefined"?globalThis:d||self,l(d.MoneyHash={}))})(this,function(d){var D,Z,N,ee,W,we,T,be,B,Pe,V,te,j,ke,G,ve,K,Ee,Y,Ae;"use strict";var Ie=Object.defineProperty,Le=Object.defineProperties;var Ue=Object.getOwnPropertyDescriptors;var x=Object.getOwnPropertySymbols;var ge=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var Q=(d,l,c)=>l in d?Ie(d,l,{enumerable:!0,configurable:!0,writable:!0,value:c}):d[l]=c,v=(d,l)=>{for(var c in l||(l={}))ge.call(l,c)&&Q(d,c,l[c]);if(x)for(var c of x(l))ye.call(l,c)&&Q(d,c,l[c]);return d},z=(d,l)=>Le(d,Ue(l));var fe=(d,l)=>{var c={};for(var A in d)ge.call(d,A)&&l.indexOf(A)<0&&(c[A]=d[A]);if(d!=null&&x)for(var A of x(d))l.indexOf(A)<0&&ye.call(d,A)&&(c[A]=d[A]);return c};var w=(d,l,c)=>(Q(d,typeof l!="symbol"?l+"":l,c),c),_e=(d,l,c)=>{if(!l.has(d))throw TypeError("Cannot "+c)};var M=(d,l,c)=>{if(l.has(d))throw TypeError("Cannot add the same private member more than once");l instanceof WeakSet?l.add(d):l.set(d,c)};var E=(d,l,c)=>(_e(d,l,"access private method"),c);var y=(d,l,c)=>new Promise((A,I)=>{var O=R=>{try{F(c.next(R))}catch(H){I(H)}},f=R=>{try{F(c.throw(R))}catch(H){I(H)}},F=R=>R.done?A(R.value):Promise.resolve(R.value).then(O,f);F((c=c.apply(d,l)).next())});class l{constructor(e){w(this,"target");w(this,"targetOrigin");w(this,"listeners");w(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(t=>t!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(t=>{t(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function c(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function A(){return typeof window!="undefined"}const C=class{constructor(){A()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=c(),t=new URL(`${e}/embed/headless-sdk`);t.searchParams.set("sdk","true"),t.searchParams.set("parent",window.location.origin),t.searchParams.set("version","js@1.9.1-beta.0");const n=document.createElement("iframe");n.id="moneyhash-headless-sdk",n.src=t.toString(),n.hidden=!0,document.body.appendChild(n),C.messagingService=new l({target:n.contentWindow,targetOrigin:e}),C.isCommunicationReady=new Promise(i=>{var o;const a=r=>{var s;r.data.type==="headlessSDK:init"&&(i(),(s=C.messagingService)==null||s.removeListener(a))};(o=C.messagingService)==null||o.onReceive(a)})}request(n){return y(this,arguments,function*({api:e,payload:t}){return yield C.isCommunicationReady,new Promise((i,a)=>{var r,s;(r=C.messagingService)==null||r.send({type:e,data:t});const o=m=>{var u;const{type:p,data:h}=m.data;p===e&&(h.status==="resolved"?i(h.payload):a(h.payload),(u=C.messagingService)==null||u.removeListener(o))};(s=C.messagingService)==null||s.onReceive(o)})})}postMessage(e){var t;(t=C.messagingService)==null||t.send({type:e})}};let I=C;w(I,"messagingService",null),w(I,"isCommunicationReady");const O=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];function f(b,e){if(b)throw new Error(e)}const F=new Set(["payment","payout"]),R=new Set(["en","fr","ar"]);class H{constructor(e){w(this,"options");w(this,"messagingService",null);w(this,"iframe",null);w(this,"isCommunicationReady",null);f(!F.has(e.type),`MoneyHash constructor must be called with valid type (${[...F].join(" | ")})!`),this.options=e}get lang(){var t;return((t=this.options.locale)==null?void 0:t.split("-")[0])||"en"}render({selector:e,intentId:t,sandbox:n,onHeightChange:i}){var m,p;(m=this.messagingService)==null||m.abortService();const a=c(),o=new URL(`${a}/embed/${this.options.type}/${t}`);o.searchParams.set("sdk","true"),o.searchParams.set("parent",window.location.origin),o.searchParams.set("version","js@1.9.1-beta.0"),i&&o.searchParams.set("onDimensionsChange","true");const r=(p=this.options.locale)==null?void 0:p.split("-")[0];r&&o.searchParams.set("lang",r),this.iframe=document.createElement("iframe"),this.iframe.src=o.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",n&&n.forEach(h=>{var u;O.includes(h)&&((u=this.iframe)==null||u.sandbox.add(h))});const s=document.querySelector(e);return f(!s,`Couldn't find an element with selector ${e}!`),s.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:a}),this.isCommunicationReady=new Promise(h=>{var k;const u=P=>{var S;P.data.type==="sdk:init"&&(h(),(S=this.messagingService)==null||S.removeListener(u))};(k=this.messagingService)==null||k.onReceive(u)}),this.messagingService.onReceive((h,u)=>{var S,U,g,q;const{type:k,data:P}=h.data;switch(k){case"sdk:init":{u({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(U=(S=this.options).onComplete)==null||U.call(S,v({type:this.options.type},P)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(q=(g=this.options).onFail)==null||q.call(g,v({type:this.options.type},P)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{i==null||i(P.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return y(this,null,function*(){var t;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(t=this.messagingService)==null||t.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return y(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class J{constructor(){w(this,"promise");w(this,"resolve");w(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function Se(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function $(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function ie(b){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!b.includes(t))return t;return null}function se(b){return(Array.isArray(b)?b.length:Object.keys(b).length)===0}function ae(b,e){return new Promise((t,n)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=b,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{n(new Error("Script failed to load"))}),document.body.appendChild(a)})}function Re(b){return new Promise(e=>{setTimeout(()=>{e("done")},b*1e3)})}function Ce(b,e){b&&console.warn(e)}const ne=new Set(["method","customerBalance","savedCard"]);class Me{constructor(e){M(this,D);M(this,N);M(this,W);M(this,T);M(this,B);M(this,V);M(this,j);M(this,G);M(this,K);M(this,Y);w(this,"options");w(this,"sdkApiHandler",new I);w(this,"sdkEmbed");w(this,"vaultSubmitListener",{current:null});w(this,"mountedCardElements",[]);w(this,"googlePaymentsClient",null);w(this,"cardForm",{collect:()=>y(this,null,function*(){f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to collect card!");const e=ie(this.mountedCardElements);f(!!e,`You must mount ${e} element!`);const t=yield this.sdkApiHandler.request({api:"sdk:generateAccessToken",payload:{publicApiKey:this.options.publicApiKey}});return E(this,N,ee).call(this,{accessToken:t})}),pay:r=>y(this,[r],function*({intentId:e,cardData:t,saveCard:n,billingData:i,shippingData:a,installmentPlanData:o}){return this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",billingData:i,shippingData:a,cardEmbed:t,saveCard:n,installmentPlanData:o}})}),createCardToken:n=>y(this,[n],function*({cardIntentId:e,cardData:t}){return this.sdkApiHandler.request({api:"sdk:createCardToken",payload:{cardIntentId:e,lang:this.sdkEmbed.lang,paymentMethod:"CARD",cardEmbed:t}})})});this.options=e,this.sdkEmbed=new H(z(v({},e),{headless:!0})),E(this,G,ve).call(this,this.vaultSubmitListener)}getIntentDetails(e){return this.sdkApiHandler.request({api:"sdk:getIntentDetails",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getIntentMethods(e){return this.sdkApiHandler.request({api:"sdk:getIntentMethods",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}getMethods(e){return"intentId"in e?this.getIntentMethods(e.intentId):(f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get methods!"),f(this.options.type==="payout","getMethods is not allowed for payout!"),this.sdkApiHandler.request({api:"sdk:getMethods",payload:v({intentType:this.options.type,lang:this.sdkEmbed.lang,publicApiKey:this.options.publicApiKey},e)}))}proceedWith({intentId:e,type:t,id:n,useWalletBalance:i,metaData:a}){return f(!ne.has(t),`type must be a valid one (${[...ne].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:n,lang:this.sdkEmbed.lang,useWalletBalance:i,metaData:a}})}resetSelectedMethod(e){return this.sdkApiHandler.request({api:"sdk:resetSelectedMethod",payload:{intentType:this.options.type,intentId:e,lang:this.sdkEmbed.lang}})}deleteCard({cardId:e,intentSecret:t}){return f(this.options.type==="payout","deleteCard is allowed only for payment intent!"),this.sdkApiHandler.request({api:"sdk:deleteCard",payload:{cardId:e,intentSecret:t,lang:this.sdkEmbed.lang}})}payWithApplePay(m){return y(this,arguments,function*({intentId:e,currency:t,amount:n,countryCode:i,onCancel:a=()=>{},onError:o,onComplete:r,billingData:s={}}){if(yield ae("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)throw new Error("Apple Pay is not supported!");const p=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${n}`},requiredShippingContactFields:["email"]}),{state:h,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(h==="FORM_FIELDS"){if(se(s))throw new Error("Billing data is missing while calling payWithApplePay");yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"APPLE_PAY",lang:this.sdkEmbed.lang,billingData:s}})}}catch(P){throw yield this.resetSelectedMethod(e),P}const k=new J;return p.onvalidatemerchant=P=>this.sdkApiHandler.request({api:"sdk:applePaySession",payload:{secret:u.secret,validationUrl:P.validationURL}}).then(S=>p.completeMerchantValidation(S)).catch(o),p.onpaymentauthorized=P=>{var S;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:JSON.stringify({token:P.payment.token}),receiptBillingData:{email:(S=P.payment.shippingContact)==null?void 0:S.emailAddress}}}).then(U=>{p.completePayment(ApplePaySession.STATUS_SUCCESS),r==null||r(),k.resolve(U)}).catch(()=>{p.completePayment(ApplePaySession.STATUS_FAILURE),o==null||o(),k.reject(void 0)})},p.oncancel=a,p.begin(),k.promise})}renderGooglePayButton(n){return y(this,null,function*(){var i=n,{onClick:e}=i,t=fe(i,["onClick"]);var r;const a=document.getElementById("moneyHash-google-pay-button");f(!a,"Couldn't find an element with id moneyHash-google-pay-button to render the google pay button!"),yield ae("https://pay.google.com/gp/p/js/pay.js","moneyHash-google-pay-sdk"),this.googlePaymentsClient=new window.google.payments.api.PaymentsClient({environment:((r=this.options.googlePay)==null?void 0:r.environment)||"PRODUCTION"});const o=E(this,D,Z).call(this);this.googlePaymentsClient.isReadyToPay(o).then(s=>{if(s.result){const m=this.googlePaymentsClient.createButton(z(v({buttonSizeMode:"fill",buttonType:"pay"},t),{allowedPaymentMethods:o.allowedPaymentMethods,onClick:e}));a==null||a.replaceChildren(m)}else throw new Error("Google Pay is not ready to pay!")}).catch(s=>{console.dir(s)})})}payWithGooglePay(i){return y(this,arguments,function*({intentId:e,billingData:t={},onCancel:n}){f(!this.googlePaymentsClient,'Google Payments Client is not initialized! Make sure to call "renderGooglePay" before calling "payWithGooglePay"');let a=yield this.proceedWith({intentId:e,type:"method",id:"GOOGLE_PAY"});try{if(a.state==="FORM_FIELDS"){if(se(t))throw new Error("Billing data is missing while calling payWithGooglePay");a=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"GOOGLE_PAY",lang:this.sdkEmbed.lang,billingData:t}})}}catch(r){throw yield this.resetSelectedMethod(e),r}const{__nativePayData__:o}=a;return o?this.googlePaymentsClient.loadPaymentData(z(v({},E(this,D,Z).call(this,o)),{transactionInfo:{totalPriceStatus:"FINAL",totalPriceLabel:"Total",totalPrice:`${o.amount}`,currencyCode:o.currency_code,countryCode:o.country_code},merchantInfo:{merchantName:o==null?void 0:o.merchant_name,merchantId:o==null?void 0:o.merchant_id},emailRequired:!0})).then(r=>{const s=r.paymentMethodData.tokenizationData.token;return this.sdkApiHandler.request({api:"sdk:submitReceipt",payload:{intentId:e,lang:this.sdkEmbed.lang,receipt:s,receiptBillingData:{email:r.email}}})}).catch(r=>(r.statusCode==="CANCELED"?n==null||n():console.dir(r),Promise.reject(r))):a})}renderForm(e){return f(!e.selector,"selector is required for renderForm"),f(!e.intentId,"intentId is required for renderForm"),this.sdkEmbed.render(e)}setLocale(e){Ce(!!e&&!R.has(e),`Invalid locale. Supported languages (${[...R].join(" | ")})`);const t=R.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return f(!t.title.en,"English discount title is required!"),this.sdkApiHandler.request({api:"sdk:updateIntentDiscount",payload:{intentId:e,discount:t,lang:this.sdkEmbed.lang}})}updateIntentFees({intentId:e,fees:t}){return t.forEach(n=>{f(!n.title.en,"English fee title is required!")}),this.sdkApiHandler.request({api:"sdk:updateIntentFees",payload:{intentId:e,fees:t,lang:this.sdkEmbed.lang}})}elements({styles:e,classes:t,fontSourceCss:n}){const i=[],a={},o=new Map;let r=!1;return E(this,j,ke).call(this,i),{create:({elementType:s,elementOptions:m})=>{var S,U;const p=new Map;let h=null;const u=v(v({},t),m.classes),k=((S=u==null?void 0:u.focus)==null?void 0:S.split(" "))||["MoneyHashElement--focus"],P=((U=u==null?void 0:u.error)==null?void 0:U.split(" "))||["MoneyHashElement--error"];return{mount:()=>{const g=document.querySelector(m.selector);f(!g,`Couldn't find an element with selector ${m.selector}!`),g.classList.add("MoneyHashElement"),i.push(q=>{var re,oe,de,le,ce,he,pe,me,ue;const{type:L,data:_}=q.data;if(L===`${s}@mount`&&(a[s]=_.isValid,(re=p.get(`${s}@mount`))==null||re()),L===`${s}@focus`){g.classList.add(...k),(oe=p.get(`${s}@focus`))==null||oe();return}if(L===`${s}@blur`){g.classList.remove(...k),(de=p.get(`${s}@blur`))==null||de();return}if(L===`${s}@error`){_.isValid?g.classList.remove(...P):g.classList.add(...P),(le=p.get(`${s}@error`))==null||le(_);return}if(L===`${s}@changeInput`){if((ce=p.get(`${s}@changeInput`))==null||ce({isValid:_.isValid,length:_.length}),a[s]=_.isValid,o.get("validityChange")){const X=Object.values(a).every(Boolean);X!==r&&((he=o.get("validityChange"))==null||he(X),r=X)}return}if(L===`${s}@cardNumberChange`){(pe=p.get(`${s}@cardNumberChange`))==null||pe(_);return}if(L===`${s}@key:Backspace`){(me=p.get(`${s}@key:Backspace`))==null||me();return}L===`${s}@key:Enter`&&((ue=p.get(`${s}@key:Enter`))==null||ue())}),h=E(this,K,Ee).call(this,{container:g,elementType:s,elementOptions:m,styles:v(v({},e),m.styles),fontSourceCss:n}),this.mountedCardElements.push(s)},on:(g,q)=>{p.set(`${s}@${g}`,q)},off:g=>p.delete(`${s}@${g}`),focus:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"focus"},$())},blur:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"blur"},$())},clear:()=>{var g;(g=h==null?void 0:h.contentWindow)==null||g.postMessage({type:"clear"},$())}}},on:(s,m)=>{o.set(s,m)}}}submitForm(s){return y(this,arguments,function*({intentId:e,accessToken:t,billingData:n,shippingData:i,saveCard:a,paymentMethod:o="CARD",installmentPlanData:r}){let m;if(t){const h=ie(this.mountedCardElements);f(!!h,`You must mount ${h} element!`),m=yield E(this,N,ee).call(this,{accessToken:t})}return yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:o,lang:this.sdkEmbed.lang,billingData:n,shippingData:i,cardEmbed:m,saveCard:a,installmentPlanData:r}})})}selectInstallmentPlan(i){return y(this,arguments,function*({intentId:e,planId:t,issuerCode:n}){return this.sdkApiHandler.request({api:"sdk:selectInstallmentPlan",payload:{planId:t,intentId:e,issuerCode:n,lang:this.sdkEmbed.lang}})})}getInstallmentPlans(i){return y(this,arguments,function*({first6Digits:e,amount:t,currency:n}){return f(!this.options.publicApiKey,"publicApiKey on MoneyHash instance is required to get installment plans!"),this.sdkApiHandler.request({api:"sdk:getInstallmentPlans",payload:{first6Digits:e,amount:t,currency:n,publicApiKey:this.options.publicApiKey,lang:this.sdkEmbed.lang}})})}submitCvv(i){return y(this,arguments,function*({intentId:e,cvv:t,installmentPlanData:n}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,installmentPlanData:n,lang:this.sdkEmbed.lang}})})}renderUrl(a){return y(this,arguments,function*({intentId:e,url:t,renderStrategy:n,options:i}){switch(this.sdkApiHandler.postMessage("SDKRenderUrl"),n){case"IFRAME":return E(this,W,we).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return E(this,T,be).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return E(this,B,Pe).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return()=>{};const n=new Date(e),i=setInterval(()=>y(this,null,function*(){const a=new Date;n<a&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}D=new WeakSet,Z=function(e){var n,i;return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:[v({type:"CARD",parameters:{allowedAuthMethods:((n=this.options.googlePay)==null?void 0:n.allowedAuthMethods)||["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:((i=this.options.googlePay)==null?void 0:i.allowedCardNetworks)||["AMEX","DISCOVER","JCB","MASTERCARD","VISA"]}},e?{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:e.gateway,gatewayMerchantId:e.gateway_merchant_id}}}:{})]}},N=new WeakSet,ee=function(t){return y(this,arguments,function*({accessToken:e}){const n=new J;this.vaultSubmitListener.current=o=>{const{type:r,data:s}=o.data;r==="vaultSubmit:success"&&n.resolve(s),r==="vaultSubmit:error"&&n.reject(s)};const i=E(this,Y,Ae).call(this,{accessToken:e}),a=yield n.promise;return i.remove(),a})},W=new WeakSet,we=function(n){return y(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");f(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const a=document.createElement("iframe");a.src=t,a.style.setProperty("border","0","important"),a.style.setProperty("width","100%","important"),a.style.setProperty("height","100%","important"),i==null||i.replaceChildren(a),yield E(this,V,te).call(this,{intentId:e}),a.remove()})},T=new WeakSet,be=function(i){return y(this,arguments,function*({intentId:e,url:t,options:n={}}){const{width:a=600,height:o=400,left:r=200,top:s=200}=n.window||{},m=window.open(t,"",`width=${a},height=${o},left=${r},top=${s}`);f(!m,"Popup blocked by browser!"),yield E(this,V,te).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},B=new WeakSet,Pe=function(n){return y(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},V=new WeakSet,te=function(n){return y(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new J,a=o=>y(this,null,function*(){var s,m,p,h;if(o.origin!==c())return;const{type:r}=o.data;if(r==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[u]=yield Promise.all([this.getIntentDetails(e),Re(2)]),k=u.transaction.status.split(".")[1];k==="successful"||k.startsWith("pending")?(m=(s=this.options).onComplete)==null||m.call(s,v({type:this.options.type},u)):(h=(p=this.options).onFail)==null||h.call(p,v({type:this.options.type},u)),i.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),i.promise})},j=new WeakSet,ke=function(e){const t=n=>{n.origin===$()&&e.forEach(i=>{i(n)})};window.addEventListener("message",t)},G=new WeakSet,ve=function(e){const t=n=>{e.current&&e.current(n)};window.addEventListener("message",t)},K=new WeakSet,Ee=function({container:e,elementType:t,elementOptions:n,styles:i,fontSourceCss:a}){var m,p,h,u;const o=$(),r=new URL(`${o}/vaultField/vaultField.html`);a&&r.searchParams.set("fontSourceCss",a),r.searchParams.set("host",btoa(window.location.origin)),r.searchParams.set("type",t),((m=n.validation)==null?void 0:m.required)!==void 0&&r.searchParams.set("required",`${(p=n.validation)==null?void 0:p.required}`),r.searchParams.set("placeholder",(h=n.placeholder)!=null?h:""),r.searchParams.set("lang",this.sdkEmbed.lang),r.searchParams.set("direction",(i==null?void 0:i.direction)||""),r.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),r.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),r.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),r.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),r.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),r.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),r.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),r.searchParams.set("padding",(i==null?void 0:i.padding)||"");const s=document.createElement("iframe");return s.src=r.toString(),s.style.height=(u=i==null?void 0:i.height)!=null?u:"40px",s.style.setProperty("overflow","hidden","important"),s.style.setProperty("display","block","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("maxWidth","100%","important"),s.style.setProperty("border","0","important"),s.style.setProperty("margin","0","important"),s.style.setProperty("padding","0","important"),s.style.setProperty("userSelect","none","important"),s.style.setProperty("colorScheme","light only","important"),e.replaceChildren(s),s},Y=new WeakSet,Ae=function({accessToken:e}){const t=$(),n=Se(),i=new URL(`${t}/vaultSubmit/vaultSubmit.html`);i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("vault_api_url",`${n}/api/v1/tokens/`),i.searchParams.set("access_token",e),i.searchParams.set("lang",this.sdkEmbed.lang);const a=document.createElement("iframe");return a.id="moneyhash-submit-iframe",a.src=i.toString(),a.hidden=!0,document.body.appendChild(a),a},d.IFrameSandboxOptions=O,d.default=Me,Object.defineProperties(d,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});

@@ -1,1 +0,1 @@

"use strict";var d=Object.defineProperty;var a=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var n=(t,e,s)=>(a(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-e80a4672.cjs");class o{constructor(e){n(this,"options");n(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start(e){return r.throwIf(!e.selector,"selector is required for start"),r.throwIf(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){r.warnIf(!!e&&!r.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...r.supportedLanguages].join(" | ")})`);const s=r.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(s)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=o;
"use strict";var d=Object.defineProperty;var a=(t,e,s)=>e in t?d(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var n=(t,e,s)=>(a(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-a2f49315.cjs");class o{constructor(e){n(this,"options");n(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start(e){return r.throwIf(!e.selector,"selector is required for start"),r.throwIf(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){r.warnIf(!!e&&!r.supportedLanguages.has(e),`Invalid locale. Supported languages (${[...r.supportedLanguages].join(" | ")})`);const s=r.supportedLanguages.has(e)?e:"en";return this.sdkEmbed.setLocale(s)}removeEventListeners(){return this.sdkEmbed.abortService()}}module.exports=o;
var n = Object.defineProperty;
var i = (t, e, s) => e in t ? n(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
var r = (t, e, s) => (i(t, typeof e != "symbol" ? e + "" : e, s), s);
import { S as o, t as d, w as u, s as a } from "./warnIf-41c60067.js";
import { S as o, t as d, w as u, s as a } from "./warnIf-31e89941.js";
class c {

@@ -6,0 +6,0 @@ constructor(e) {

@@ -1,1 +0,1 @@

(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=s())})(this,function(){"use strict";var $=Object.defineProperty;var U=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var b=(i,s,t)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,S=(i,s)=>{for(var t in s||(s={}))A.call(s,t)&&b(i,t,s[t]);if(U)for(var t of U(s))_.call(s,t)&&b(i,t,s[t]);return i};var o=(i,s,t)=>(b(i,typeof s!="symbol"?s+"":s,t),t);var E=(i,s,t)=>new Promise((l,m)=>{var g=r=>{try{u(t.next(r))}catch(a){m(a)}},v=r=>{try{u(t.throw(r))}catch(a){m(a)}},u=r=>r.done?l(r.value):Promise.resolve(r.value).then(g,v);u((t=t.apply(i,s)).next())});const i=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];class s{constructor(e){o(this,"target");o(this,"targetOrigin");o(this,"listeners");o(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(n=>n!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(n=>{n(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(a,e){if(a)throw new Error(e)}const m=new Set(["payment","payout"]),g=new Set(["en","fr","ar"]);class v{constructor(e){o(this,"options");o(this,"messagingService",null);o(this,"iframe",null);o(this,"isCommunicationReady",null);l(!m.has(e.type),`MoneyHash constructor must be called with valid type (${[...m].join(" | ")})!`),this.options=e}get lang(){var n;return((n=this.options.locale)==null?void 0:n.split("-")[0])||"en"}render({selector:e,intentId:n,sandbox:R,onHeightChange:w}){var M,O;(M=this.messagingService)==null||M.abortService();const I=t(),d=new URL(`${I}/embed/${this.options.type}/${n}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@1.9.0"),w&&d.searchParams.set("onDimensionsChange","true");const L=(O=this.options.locale)==null?void 0:O.split("-")[0];L&&d.searchParams.set("lang",L),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",R&&R.forEach(h=>{var c;i.includes(h)&&((c=this.iframe)==null||c.sandbox.add(h))});const k=document.querySelector(e);return l(!k,`Couldn't find an element with selector ${e}!`),k.replaceChildren(this.iframe),this.messagingService=new s({target:this.iframe.contentWindow,targetOrigin:I}),this.isCommunicationReady=new Promise(h=>{var y;const c=p=>{var f;p.data.type==="sdk:init"&&(h(),(f=this.messagingService)==null||f.removeListener(c))};(y=this.messagingService)==null||y.onReceive(c)}),this.messagingService.onReceive((h,c)=>{var f,F,C,P;const{type:y,data:p}=h.data;switch(y){case"sdk:init":{c({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(F=(f=this.options).onComplete)==null||F.call(f,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(P=(C=this.options).onFail)==null||P.call(C,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{w==null||w(p.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return E(this,null,function*(){var n;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(n=this.messagingService)==null||n.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function u(a,e){a&&console.warn(e)}class r{constructor(e){o(this,"options");o(this,"sdkEmbed");this.options=e,this.sdkEmbed=new v(e)}start(e){return l(!e.selector,"selector is required for start"),l(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){u(!!e&&!g.has(e),`Invalid locale. Supported languages (${[...g].join(" | ")})`);const n=g.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return r});
(function(i,s){typeof exports=="object"&&typeof module!="undefined"?module.exports=s():typeof define=="function"&&define.amd?define(s):(i=typeof globalThis!="undefined"?globalThis:i||self,i.MoneyHash=s())})(this,function(){"use strict";var $=Object.defineProperty;var U=Object.getOwnPropertySymbols;var A=Object.prototype.hasOwnProperty,_=Object.prototype.propertyIsEnumerable;var b=(i,s,t)=>s in i?$(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,S=(i,s)=>{for(var t in s||(s={}))A.call(s,t)&&b(i,t,s[t]);if(U)for(var t of U(s))_.call(s,t)&&b(i,t,s[t]);return i};var o=(i,s,t)=>(b(i,typeof s!="symbol"?s+"":s,t),t);var E=(i,s,t)=>new Promise((l,m)=>{var g=r=>{try{u(t.next(r))}catch(a){m(a)}},v=r=>{try{u(t.throw(r))}catch(a){m(a)}},u=r=>r.done?l(r.value):Promise.resolve(r.value).then(g,v);u((t=t.apply(i,s)).next())});const i=["allow-downloads","allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-storage-access-by-user-activation","allow-top-navigation","allow-top-navigation-by-user-activation"];class s{constructor(e){o(this,"target");o(this,"targetOrigin");o(this,"listeners");o(this,"onIncomingMessageBind",this.onIncomingMessage.bind(this));this.target=e.target,this.targetOrigin=e.targetOrigin,this.listeners=[],window.addEventListener("message",this.onIncomingMessageBind)}send(e){this.target.postMessage(e,this.targetOrigin)}onReceive(e){this.listeners.push(e)}removeListener(e){this.listeners=this.listeners.filter(n=>n!==e)}onIncomingMessage(e){e.origin===this.targetOrigin&&this.listeners.forEach(n=>{n(e,this.send.bind(this))})}abortService(){window.removeEventListener("message",this.onIncomingMessageBind)}}function t(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function l(a,e){if(a)throw new Error(e)}const m=new Set(["payment","payout"]),g=new Set(["en","fr","ar"]);class v{constructor(e){o(this,"options");o(this,"messagingService",null);o(this,"iframe",null);o(this,"isCommunicationReady",null);l(!m.has(e.type),`MoneyHash constructor must be called with valid type (${[...m].join(" | ")})!`),this.options=e}get lang(){var n;return((n=this.options.locale)==null?void 0:n.split("-")[0])||"en"}render({selector:e,intentId:n,sandbox:R,onHeightChange:w}){var M,O;(M=this.messagingService)==null||M.abortService();const I=t(),d=new URL(`${I}/embed/${this.options.type}/${n}`);d.searchParams.set("sdk","true"),d.searchParams.set("parent",window.location.origin),d.searchParams.set("version","js@1.9.1-beta.0"),w&&d.searchParams.set("onDimensionsChange","true");const L=(O=this.options.locale)==null?void 0:O.split("-")[0];L&&d.searchParams.set("lang",L),this.iframe=document.createElement("iframe"),this.iframe.src=d.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0",R&&R.forEach(h=>{var c;i.includes(h)&&((c=this.iframe)==null||c.sandbox.add(h))});const k=document.querySelector(e);return l(!k,`Couldn't find an element with selector ${e}!`),k.replaceChildren(this.iframe),this.messagingService=new s({target:this.iframe.contentWindow,targetOrigin:I}),this.isCommunicationReady=new Promise(h=>{var y;const c=p=>{var f;p.data.type==="sdk:init"&&(h(),(f=this.messagingService)==null||f.removeListener(c))};(y=this.messagingService)==null||y.onReceive(c)}),this.messagingService.onReceive((h,c)=>{var f,F,C,P;const{type:y,data:p}=h.data;switch(y){case"sdk:init":{c({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(F=(f=this.options).onComplete)==null||F.call(f,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(P=(C=this.options).onFail)==null||P.call(C,S({type:this.options.type},p)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"dimensionsChange":{w==null||w(p.iframeHeight);break}}}),this.isCommunicationReady}setLocale(e){return E(this,null,function*(){var n;yield this==null?void 0:this.isCommunicationReady,this.options.locale=e,(n=this.messagingService)==null||n.send({type:"changeLanguage",data:{locale:e}})})}abortService(){return E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function u(a,e){a&&console.warn(e)}class r{constructor(e){o(this,"options");o(this,"sdkEmbed");this.options=e,this.sdkEmbed=new v(e)}start(e){return l(!e.selector,"selector is required for start"),l(!e.intentId,"intentId is required for start"),this.sdkEmbed.render(e)}setLocale(e){u(!!e&&!g.has(e),`Invalid locale. Supported languages (${[...g].join(" | ")})`);const n=g.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return r});
{
"name": "@moneyhash/js-sdk",
"version": "1.9.0",
"version": "1.9.1-beta.0",
"description": "MoneyHash JavaScript SDK",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc