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
63
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.5.2-beta.2 to 1.5.2-beta.3

dist/warnIf-389f3200.js

4

dist/headless.cjs.js

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

"use strict";var de=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?de(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e)=>{for(var t in e||(e={}))ue.call(e,t)&&q(s,t,e[t]);if(G)for(var t of G(e))he.call(e,t)&&q(s,t,e[t]);return s},Q=(s,e)=>ce(s,le(e));var v=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),pe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var b=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)};var E=(s,e,t)=>(pe(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((o,r)=>{var a=n=>{try{i(t.next(n))}catch(l){r(l)}},c=n=>{try{i(t.throw(n))}catch(l){r(l)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(a,c);i((t=t.apply(s,e)).next())});const p=require("./warnIf-cc60367b.cjs");function me(){return typeof window!="undefined"}const y=class{constructor(){me()&&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.5.2-beta.2");const o=document.createElement("iframe");o.id="moneyhash-headless-sdk",o.src=t.toString(),o.hidden=!0,document.body.appendChild(o),y.messagingService=new p.MessagingService({target:o.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(r=>{var c;const a=i=>{var n;i.data.type==="headlessSDK:init"&&(r(),(n=y.messagingService)==null||n.removeListener(a))};(c=y.messagingService)==null||c.onReceive(a)})}request(o){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((r,a)=>{var i,n;(i=y.messagingService)==null||i.send({type:e,data:t});const c=l=>{var h;const{type:d,data:u}=l.data;d===e&&(u.status==="resolved"?r(u.payload):a(u.payload),(h=y.messagingService)==null||h.removeListener(c))};(n=y.messagingService)==null||n.onReceive(c)})})}postMessage(e){var t;(t=y.messagingService)==null||t.send({type:e})}};let L=y;v(L,"messagingService",null),v(L,"isCommunicationReady");class X{constructor(){v(this,"promise");v(this,"resolve");v(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function ge(){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 Z(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function fe(s){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!s.includes(t))return t;return null}function we(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function ve(s,e){return new Promise((t,o)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=s,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{o(new Error("Script failed to load"))}),document.body.appendChild(a)})}function ye(s){return new Promise(e=>{setTimeout(()=>{e("done")},s*1e3)})}const ee=new Set(["method","customerBalance","savedCard"]);var C,te,U,re,R,ne,A,N,$,ae,M,ie,_,se,F,oe;class Pe{constructor(e){b(this,C);b(this,U);b(this,R);b(this,A);b(this,$);b(this,M);b(this,_);b(this,F);v(this,"options");v(this,"sdkApiHandler",new L);v(this,"sdkEmbed");v(this,"vaultSubmitListener",{current:null});v(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new p.SDKEmbed(Q(k({},e),{headless:!0})),E(this,M,ie).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}})}proceedWith({intentId:e,type:t,id:o,metaData:r}){return p.throwIf(!ee.has(t),`type must be a valid one (${[...ee].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:o,lang:this.sdkEmbed.lang,metaData:r}})}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 w(this,arguments,function*({intentId:e,currency:t,amount:o,countryCode:r,onCancel:a=()=>{},onError:c,onComplete:i,billingData:n={}}){if(yield ve("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:r,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${o}`}}),{state:u,intent:h}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="INTENT_FORM"){if(we(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(m){throw yield this.resetSelectedMethod(e),m}d.onvalidatemerchant=m=>{fetch(`${Z()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:h.secret,validation_url:m.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>d.completeMerchantValidation(f)).catch(c)},d.onpaymentauthorized=m=>{fetch(`${Z()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:m.payment.token,secret:h.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),c()})},d.oncancel=a,d.begin()})}renderForm({selector:e,intentId:t}){return p.throwIf(!e,"selector is required for renderForm"),p.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}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(o=>{p.throwIf(!o.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:o}){const r=[],a={},c=new Map;let i=!1;return E(this,$,ae).call(this,r),{create:({elementType:n,elementOptions:l})=>{var D,W;const d=new Map;let u=null,h;const m=k(k({},t),l.classes),f=((D=m==null?void 0:m.focus)==null?void 0:D.split(" "))||["MoneyHashElement--focus"],H=((W=m==null?void 0:m.error)==null?void 0:W.split(" "))||["MoneyHashElement--error"];return{mount:()=>{h=document.querySelector(l.selector),p.throwIf(!h,`Couldn't find an element with selector ${l.selector}!`),h.classList.add("MoneyHashElement"),r.push(g=>{var j,x,B,T,Y,O,z,J,K;const{type:P,data:I}=g.data;if(P===`${n}@mount`&&(a[n]=I.isValid,(j=d.get(`${n}@mount`))==null||j()),P===`${n}@focus`){h.classList.add(...f),(x=d.get(`${n}@focus`))==null||x();return}if(P===`${n}@blur`){h.classList.remove(...f),(B=d.get(`${n}@blur`))==null||B();return}if(P===`${n}@error`){I.isValid?h.classList.remove(...H):h.classList.add(...H),(T=d.get(`${n}@error`))==null||T(I);return}if(P===`${n}@changeInput`){if((Y=d.get(`${n}@changeInput`))==null||Y({isValid:I.isValid,length:I.length}),a[n]=I.isValid,c.get("validityChange")){const V=Object.values(a).every(Boolean);V!==i&&((O=c.get("validityChange"))==null||O(V),i=V)}return}if(P===`${n}@cardNumberChange`){(z=d.get(`${n}@cardNumberChange`))==null||z(I);return}if(P===`${n}@key:Backspace`){(J=d.get(`${n}@key:Backspace`))==null||J();return}P===`${n}@key:Enter`&&((K=d.get(`${n}@key:Enter`))==null||K())}),u=E(this,_,se).call(this,{container:h,elementType:n,elementOptions:l,styles:k(k({},e),l.styles),fontSourceCss:o}),this.mountedCardElements.push(n)},on:(g,P)=>{d.set(`${n}@${g}`,P)},off:g=>d.delete(`${n}@${g}`),focus:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"focus"},S())},blur:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"blur"},S())},clear:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"clear"},S())}}},on:(n,l)=>{c.set(n,l)}}}submitForm(c){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:o,shippingData:r,saveCard:a}){const i=fe(this.mountedCardElements);p.throwIf(!!i,`You must mount ${i} element!`);const n=new X;let l,d;t&&(this.vaultSubmitListener.current=h=>{const{type:m,data:f}=h.data;m==="vaultSubmit:success"&&n.resolve(f),m==="vaultSubmit:error"&&n.reject(f)},d=E(this,F,oe).call(this,{accessToken:t,saveCard:a}),l=yield n.promise);const u=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:o,shippingData:r,cardEmbed:l}});return d&&d.remove(),u})}submitCvv(o){return w(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(a){return w(this,arguments,function*({intentId:e,url:t,renderStrategy:o,options:r}){switch(o){case"IFRAME":return E(this,C,te).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return E(this,U,re).call(this,{url:t,intentId:e,options:r});case"REDIRECT":return E(this,R,ne).call(this,{url:t,options:r});default:return null}})}onExpiration(e,t){if(!e)return p.warnIf(!0,`No expiration date provided!, make sure to check for it before usage
"use strict";var de=Object.defineProperty,ce=Object.defineProperties;var le=Object.getOwnPropertyDescriptors;var G=Object.getOwnPropertySymbols;var ue=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable;var q=(s,e,t)=>e in s?de(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,k=(s,e)=>{for(var t in e||(e={}))ue.call(e,t)&&q(s,t,e[t]);if(G)for(var t of G(e))he.call(e,t)&&q(s,t,e[t]);return s},Q=(s,e)=>ce(s,le(e));var v=(s,e,t)=>(q(s,typeof e!="symbol"?e+"":e,t),t),pe=(s,e,t)=>{if(!e.has(s))throw TypeError("Cannot "+t)};var b=(s,e,t)=>{if(e.has(s))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(s):e.set(s,t)};var E=(s,e,t)=>(pe(s,e,"access private method"),t);var w=(s,e,t)=>new Promise((o,r)=>{var a=n=>{try{i(t.next(n))}catch(d){r(d)}},l=n=>{try{i(t.throw(n))}catch(d){r(d)}},i=n=>n.done?o(n.value):Promise.resolve(n.value).then(a,l);i((t=t.apply(s,e)).next())});const p=require("./warnIf-a8bc2152.cjs");function me(){return typeof window!="undefined"}const y=class{constructor(){me()&&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.5.2-beta.3");const o=document.createElement("iframe");o.id="moneyhash-headless-sdk",o.src=t.toString(),o.hidden=!0,document.body.appendChild(o),y.messagingService=new p.MessagingService({target:o.contentWindow,targetOrigin:e}),y.isCommunicationReady=new Promise(r=>{var l;const a=i=>{var n;i.data.type==="headlessSDK:init"&&(r(),(n=y.messagingService)==null||n.removeListener(a))};(l=y.messagingService)==null||l.onReceive(a)})}request(o){return w(this,arguments,function*({api:e,payload:t}){return yield y.isCommunicationReady,new Promise((r,a)=>{var i,n;(i=y.messagingService)==null||i.send({type:e,data:t});const l=d=>{var h;const{type:c,data:u}=d.data;c===e&&(u.status==="resolved"?r(u.payload):a(u.payload),(h=y.messagingService)==null||h.removeListener(l))};(n=y.messagingService)==null||n.onReceive(l)})})}postMessage(e){var t;(t=y.messagingService)==null||t.send({type:e})}};let L=y;v(L,"messagingService",null),v(L,"isCommunicationReady");class X{constructor(){v(this,"promise");v(this,"resolve");v(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function ge(){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 Z(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function fe(s){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!s.includes(t))return t;return null}function we(s){return(Array.isArray(s)?s.length:Object.keys(s).length)===0}function ve(s,e){return new Promise((t,o)=>{if(document.getElementById(e)){t(void 0);return}const a=document.createElement("script");a.src=s,a.id=e,a.addEventListener("load",()=>{t(void 0)}),a.addEventListener("error",()=>{o(new Error("Script failed to load"))}),document.body.appendChild(a)})}function ye(s){return new Promise(e=>{setTimeout(()=>{e("done")},s*1e3)})}const ee=new Set(["method","customerBalance","savedCard"]);var C,te,U,re,R,ne,A,N,$,ae,M,ie,_,se,F,oe;class Pe{constructor(e){b(this,C);b(this,U);b(this,R);b(this,A);b(this,$);b(this,M);b(this,_);b(this,F);v(this,"options");v(this,"sdkApiHandler",new L);v(this,"sdkEmbed");v(this,"vaultSubmitListener",{current:null});v(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new p.SDKEmbed(Q(k({},e),{headless:!0})),E(this,M,ie).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}})}proceedWith({intentId:e,type:t,id:o,metaData:r}){return p.throwIf(!ee.has(t),`type must be a valid one (${[...ee].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:o,lang:this.sdkEmbed.lang,metaData:r}})}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(d){return w(this,arguments,function*({intentId:e,currency:t,amount:o,countryCode:r,onCancel:a=()=>{},onError:l,onComplete:i,billingData:n={}}){if(yield ve("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const c=new ApplePaySession(3,{countryCode:r,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${o}`}}),{state:u,intent:h}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(u==="INTENT_FORM"){if(we(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(m){throw yield this.resetSelectedMethod(e),m}c.onvalidatemerchant=m=>{fetch(`${Z()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:h.secret,validation_url:m.validationURL})}).then(f=>f.ok?f.json():Promise.reject()).then(f=>c.completeMerchantValidation(f)).catch(l)},c.onpaymentauthorized=m=>{fetch(`${Z()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:m.payment.token,secret:h.secret})}).then(f=>f.ok?f.json():Promise.reject()).then(()=>{c.completePayment(ApplePaySession.STATUS_SUCCESS),i()}).catch(()=>{c.completePayment(ApplePaySession.STATUS_FAILURE),l()})},c.oncancel=a,c.begin()})}renderForm({selector:e,intentId:t}){return p.throwIf(!e,"selector is required for renderForm"),p.throwIf(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}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(o=>{p.throwIf(!o.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:o}){const r=[],a={},l=new Map;let i=!1;return E(this,$,ae).call(this,r),{create:({elementType:n,elementOptions:d})=>{var D,W;const c=new Map;let u=null,h;const m=k(k({},t),d.classes),f=((D=m==null?void 0:m.focus)==null?void 0:D.split(" "))||["MoneyHashElement--focus"],H=((W=m==null?void 0:m.error)==null?void 0:W.split(" "))||["MoneyHashElement--error"];return{mount:()=>{h=document.querySelector(d.selector),p.throwIf(!h,`Couldn't find an element with selector ${d.selector}!`),h.classList.add("MoneyHashElement"),r.push(g=>{var j,x,B,T,Y,O,z,J,K;const{type:P,data:I}=g.data;if(P===`${n}@mount`&&(a[n]=I.isValid,(j=c.get(`${n}@mount`))==null||j()),P===`${n}@focus`){h.classList.add(...f),(x=c.get(`${n}@focus`))==null||x();return}if(P===`${n}@blur`){h.classList.remove(...f),(B=c.get(`${n}@blur`))==null||B();return}if(P===`${n}@error`){I.isValid?h.classList.remove(...H):h.classList.add(...H),(T=c.get(`${n}@error`))==null||T(I);return}if(P===`${n}@changeInput`){if((Y=c.get(`${n}@changeInput`))==null||Y({isValid:I.isValid,length:I.length}),a[n]=I.isValid,l.get("validityChange")){const V=Object.values(a).every(Boolean);V!==i&&((O=l.get("validityChange"))==null||O(V),i=V)}return}if(P===`${n}@cardNumberChange`){(z=c.get(`${n}@cardNumberChange`))==null||z(I);return}if(P===`${n}@key:Backspace`){(J=c.get(`${n}@key:Backspace`))==null||J();return}P===`${n}@key:Enter`&&((K=c.get(`${n}@key:Enter`))==null||K())}),u=E(this,_,se).call(this,{container:h,elementType:n,elementOptions:d,styles:k(k({},e),d.styles),fontSourceCss:o}),this.mountedCardElements.push(n)},on:(g,P)=>{c.set(`${n}@${g}`,P)},off:g=>c.delete(`${n}@${g}`),focus:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"focus"},S())},blur:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"blur"},S())},clear:()=>{var g;(g=u==null?void 0:u.contentWindow)==null||g.postMessage({type:"clear"},S())}}},on:(n,d)=>{l.set(n,d)}}}submitForm(l){return w(this,arguments,function*({intentId:e,accessToken:t,billingData:o,shippingData:r,saveCard:a}){const i=new X;let n,d;if(t){const u=fe(this.mountedCardElements);p.throwIf(!!u,`You must mount ${u} element!`),this.vaultSubmitListener.current=h=>{const{type:m,data:f}=h.data;m==="vaultSubmit:success"&&i.resolve(f),m==="vaultSubmit:error"&&i.reject(f)},d=E(this,F,oe).call(this,{accessToken:t,saveCard:a}),n=yield i.promise}const c=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:o,shippingData:r,cardEmbed:n}});return d&&d.remove(),c})}submitCvv(o){return w(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(a){return w(this,arguments,function*({intentId:e,url:t,renderStrategy:o,options:r}){switch(o){case"IFRAME":return E(this,C,te).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return E(this,U,re).call(this,{url:t,intentId:e,options:r});case"REDIRECT":return E(this,R,ne).call(this,{url:t,options:r});default:return null}})}onExpiration(e,t){if(!e)return p.warnIf(!0,`No expiration date provided!, make sure to check for it before usage

@@ -7,2 +7,2 @@ if (intentDetails.intent.expirationDate) {

})
}`),()=>{};const o=new Date(e),r=setInterval(()=>w(this,null,function*(){const a=new Date;o<a&&(clearInterval(r),t())}),1e3);return()=>clearInterval(r)}}C=new WeakSet,te=function(o){return w(this,arguments,function*({intentId:e,url:t}){const r=document.querySelector("#rendered-url-iframe-container");p.throwIf(!r,"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"),r==null||r.replaceChildren(a),yield E(this,A,N).call(this,{intentId:e}),a.remove()})},U=new WeakSet,re=function(r){return w(this,arguments,function*({intentId:e,url:t,options:o={}}){const{width:a=600,height:c=400,left:i=200,top:n=200}=o.window||{},l=window.open(t,"",`width=${a},height=${c},left=${i},top=${n}`);p.throwIf(!l,"Popup blocked by browser!"),yield E(this,A,N).call(this,{intentId:e,isUsingPopUp:!0}),l==null||l.close()})},R=new WeakSet,ne=function(o){return w(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},A=new WeakSet,N=function(o){return w(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const r=new X,a=c=>w(this,null,function*(){var n,l,d,u;if(c.origin!==p.getIframeUrl())return;const{type:i}=c.data;if(i==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[h]=yield Promise.all([this.getIntentDetails(e),ye(2)]),m=h.transaction.status.split(".")[1];m==="successful"||m.startsWith("pending")?(l=(n=this.options).onComplete)==null||l.call(n,k({type:this.options.type},h)):(u=(d=this.options).onFail)==null||u.call(d,k({type:this.options.type},h)),r.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),r.promise})},$=new WeakSet,ae=function(e){const t=o=>{o.origin===S()&&e.forEach(r=>{r(o)})};window.addEventListener("message",t)},M=new WeakSet,ie=function(e){const t=o=>{e.current&&e.current(o)};window.addEventListener("message",t)},_=new WeakSet,se=function({container:e,elementType:t,elementOptions:o,styles:r,fontSourceCss:a}){var l,d,u,h;const c=S(),i=new URL(`${c}/vaultField/vaultField.html`);a&&i.searchParams.set("fontSourceCss",a),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((l=o.validation)==null?void 0:l.required)!==void 0&&i.searchParams.set("required",`${(d=o.validation)==null?void 0:d.required}`),i.searchParams.set("placeholder",(u=o.placeholder)!=null?u:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(r==null?void 0:r.direction)||""),i.searchParams.set("color",JSON.stringify(r!=null&&r.color?r.color:"#000")),i.searchParams.set("placeholderColor",(r==null?void 0:r.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(r==null?void 0:r.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(r==null?void 0:r.fontSize)||""),i.searchParams.set("fontFamily",(r==null?void 0:r.fontFamily)||""),i.searchParams.set("fontWeight",`${r==null?void 0:r.fontWeight}`),i.searchParams.set("fontStyle",(r==null?void 0:r.fontStyle)||""),i.searchParams.set("padding",(r==null?void 0:r.padding)||"");const n=document.createElement("iframe");return n.src=i.toString(),n.style.height=(h=r==null?void 0:r.height)!=null?h:"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},F=new WeakSet,oe=function({accessToken:e,saveCard:t}){const o=S(),r=ge(),a=new URL(`${o}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&a.searchParams.set("save_card",`${t}`);const c=document.createElement("iframe");return c.id="moneyhash-submit-iframe",c.src=a.toString(),c.hidden=!0,document.body.appendChild(c),c};module.exports=Pe;
}`),()=>{};const o=new Date(e),r=setInterval(()=>w(this,null,function*(){const a=new Date;o<a&&(clearInterval(r),t())}),1e3);return()=>clearInterval(r)}}C=new WeakSet,te=function(o){return w(this,arguments,function*({intentId:e,url:t}){const r=document.querySelector("#rendered-url-iframe-container");p.throwIf(!r,"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"),r==null||r.replaceChildren(a),yield E(this,A,N).call(this,{intentId:e}),a.remove()})},U=new WeakSet,re=function(r){return w(this,arguments,function*({intentId:e,url:t,options:o={}}){const{width:a=600,height:l=400,left:i=200,top:n=200}=o.window||{},d=window.open(t,"",`width=${a},height=${l},left=${i},top=${n}`);p.throwIf(!d,"Popup blocked by browser!"),yield E(this,A,N).call(this,{intentId:e,isUsingPopUp:!0}),d==null||d.close()})},R=new WeakSet,ne=function(o){return w(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},A=new WeakSet,N=function(o){return w(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const r=new X,a=l=>w(this,null,function*(){var n,d,c,u;if(l.origin!==p.getIframeUrl())return;const{type:i}=l.data;if(i==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[h]=yield Promise.all([this.getIntentDetails(e),ye(2)]),m=h.transaction.status.split(".")[1];m==="successful"||m.startsWith("pending")?(d=(n=this.options).onComplete)==null||d.call(n,k({type:this.options.type},h)):(u=(c=this.options).onFail)==null||u.call(c,k({type:this.options.type},h)),r.resolve(()=>null),window.removeEventListener("message",a)}});return window.addEventListener("message",a),r.promise})},$=new WeakSet,ae=function(e){const t=o=>{o.origin===S()&&e.forEach(r=>{r(o)})};window.addEventListener("message",t)},M=new WeakSet,ie=function(e){const t=o=>{e.current&&e.current(o)};window.addEventListener("message",t)},_=new WeakSet,se=function({container:e,elementType:t,elementOptions:o,styles:r,fontSourceCss:a}){var d,c,u,h;const l=S(),i=new URL(`${l}/vaultField/vaultField.html`);a&&i.searchParams.set("fontSourceCss",a),i.searchParams.set("host",btoa(window.location.origin)),i.searchParams.set("type",t),((d=o.validation)==null?void 0:d.required)!==void 0&&i.searchParams.set("required",`${(c=o.validation)==null?void 0:c.required}`),i.searchParams.set("placeholder",(u=o.placeholder)!=null?u:""),i.searchParams.set("lang",this.sdkEmbed.lang),i.searchParams.set("direction",(r==null?void 0:r.direction)||""),i.searchParams.set("color",JSON.stringify(r!=null&&r.color?r.color:"#000")),i.searchParams.set("placeholderColor",(r==null?void 0:r.placeholderColor)||"#ccc"),i.searchParams.set("backgroundColor",(r==null?void 0:r.backgroundColor)||"transparent"),i.searchParams.set("fontSize",(r==null?void 0:r.fontSize)||""),i.searchParams.set("fontFamily",(r==null?void 0:r.fontFamily)||""),i.searchParams.set("fontWeight",`${r==null?void 0:r.fontWeight}`),i.searchParams.set("fontStyle",(r==null?void 0:r.fontStyle)||""),i.searchParams.set("padding",(r==null?void 0:r.padding)||"");const n=document.createElement("iframe");return n.src=i.toString(),n.style.height=(h=r==null?void 0:r.height)!=null?h:"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},F=new WeakSet,oe=function({accessToken:e,saveCard:t}){const o=S(),r=ge(),a=new URL(`${o}/vaultSubmit/vaultSubmit.html`);a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("vault_api_url",`${r}/api/v1/tokens/`),a.searchParams.set("access_token",e),a.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&a.searchParams.set("save_card",`${t}`);const l=document.createElement("iframe");return l.id="moneyhash-submit-iframe",l.src=a.toString(),l.hidden=!0,document.body.appendChild(l),l};module.exports=Pe;

@@ -27,15 +27,15 @@ var ue = Object.defineProperty, pe = Object.defineProperties;

i(t.next(a));
} catch (l) {
r(l);
} catch (d) {
r(d);
}
}, c = (a) => {
}, l = (a) => {
try {
i(t.throw(a));
} catch (l) {
r(l);
} catch (d) {
r(d);
}
}, i = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(n, c);
}, i = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(n, l);
i((t = t.apply(s, e)).next());
});
import { M as ve, g as ae, S as we, t as E, w as Z, s as q } from "./warnIf-94e30d35.js";
import { M as ve, g as ae, S as we, t as E, w as Z, s as q } from "./warnIf-389f3200.js";
function ye() {

@@ -52,3 +52,3 @@ return typeof window != "undefined";

const e = ae(), 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.5.2-beta.2");
t.searchParams.set("sdk", "true"), t.searchParams.set("parent", window.location.origin), t.searchParams.set("version", "js@1.5.2-beta.3");
const o = document.createElement("iframe");

@@ -59,3 +59,3 @@ o.id = "moneyhash-headless-sdk", o.src = t.toString(), o.hidden = !0, document.body.appendChild(o), w.messagingService = new ve({

}), w.isCommunicationReady = new Promise((r) => {
var c;
var l;
const n = (i) => {

@@ -65,3 +65,3 @@ var a;

};
(c = w.messagingService) == null || c.onReceive(n);
(l = w.messagingService) == null || l.onReceive(n);
});

@@ -80,8 +80,8 @@ }

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

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

*/
payWithApplePay(l) {
payWithApplePay(d) {
return f(this, arguments, function* ({

@@ -390,3 +390,3 @@ intentId: e,

},
onError: c,
onError: l,
onComplete: i,

@@ -400,3 +400,3 @@ billingData: a = {}

return;
const d = new ApplePaySession(3, {
const c = new ApplePaySession(3, {
countryCode: r,

@@ -435,3 +435,3 @@ currencyCode: t,

}
d.onvalidatemerchant = (h) => {
c.onvalidatemerchant = (h) => {
fetch(`${te()}/api/v1/providers/applepay/session/`, {

@@ -447,5 +447,5 @@ method: "post",

}).then((g) => g.ok ? g.json() : Promise.reject()).then(
(g) => d.completeMerchantValidation(g)
).catch(c);
}, d.onpaymentauthorized = (h) => {
(g) => c.completeMerchantValidation(g)
).catch(l);
}, c.onpaymentauthorized = (h) => {
fetch(`${te()}/api/v1/providers/applepay/token/`, {

@@ -461,7 +461,7 @@ method: "post",

}).then((g) => g.ok ? g.json() : Promise.reject()).then(() => {
d.completePayment(ApplePaySession.STATUS_SUCCESS), i();
c.completePayment(ApplePaySession.STATUS_SUCCESS), i();
}).catch(() => {
d.completePayment(ApplePaySession.STATUS_FAILURE), c();
c.completePayment(ApplePaySession.STATUS_FAILURE), l();
});
}, d.oncancel = n, d.begin();
}, c.oncancel = n, c.begin();
});

@@ -585,3 +585,3 @@ }

elements({ styles: e, classes: t, fontSourceCss: o }) {
const r = [], n = {}, c = /* @__PURE__ */ new Map();
const r = [], n = {}, l = /* @__PURE__ */ new Map();
let i = !1;

@@ -610,7 +610,7 @@ return P(this, $, oe).call(this, r), {

*/
create: ({ elementType: a, elementOptions: l }) => {
create: ({ elementType: a, elementOptions: d }) => {
var W, j;
const d = /* @__PURE__ */ new Map();
const c = /* @__PURE__ */ new Map();
let u = null, p;
const h = k(k({}, t), l.classes), g = ((W = h == null ? void 0 : h.focus) == null ? void 0 : W.split(" ")) || [
const h = k(k({}, t), d.classes), g = ((W = h == null ? void 0 : h.focus) == null ? void 0 : W.split(" ")) || [
"MoneyHashElement--focus"

@@ -623,28 +623,28 @@ ], D = ((j = h == null ? void 0 : h.error) == null ? void 0 : j.split(" ")) || [

p = document.querySelector(
l.selector
d.selector
), E(
!p,
`Couldn't find an element with selector ${l.selector}!`
`Couldn't find an element with selector ${d.selector}!`
), p.classList.add("MoneyHashElement"), r.push((m) => {
var x, B, T, Y, O, z, J, K, G;
const { type: y, data: S } = m.data;
if (y === `${a}@mount` && (n[a] = S.isValid, (x = d.get(`${a}@mount`)) == null || x()), y === `${a}@focus`) {
p.classList.add(...g), (B = d.get(`${a}@focus`)) == null || B();
if (y === `${a}@mount` && (n[a] = S.isValid, (x = c.get(`${a}@mount`)) == null || x()), y === `${a}@focus`) {
p.classList.add(...g), (B = c.get(`${a}@focus`)) == null || B();
return;
}
if (y === `${a}@blur`) {
p.classList.remove(...g), (T = d.get(`${a}@blur`)) == null || T();
p.classList.remove(...g), (T = c.get(`${a}@blur`)) == null || T();
return;
}
if (y === `${a}@error`) {
S.isValid ? p.classList.remove(...D) : p.classList.add(...D), (Y = d.get(`${a}@error`)) == null || Y(S);
S.isValid ? p.classList.remove(...D) : p.classList.add(...D), (Y = c.get(`${a}@error`)) == null || Y(S);
return;
}
if (y === `${a}@changeInput`) {
if ((O = d.get(`${a}@changeInput`)) == null || O({
if ((O = c.get(`${a}@changeInput`)) == null || O({
isValid: S.isValid,
length: S.length
}), n[a] = S.isValid, c.get("validityChange")) {
}), n[a] = S.isValid, l.get("validityChange")) {
const V = Object.values(n).every(Boolean);
V !== i && ((z = c.get("validityChange")) == null || z(
V !== i && ((z = l.get("validityChange")) == null || z(
V

@@ -656,3 +656,3 @@ ), i = V);

if (y === `${a}@cardNumberChange`) {
(J = d.get(`${a}@cardNumberChange`)) == null || J(
(J = c.get(`${a}@cardNumberChange`)) == null || J(
S

@@ -663,11 +663,11 @@ );

if (y === `${a}@key:Backspace`) {
(K = d.get(`${a}@key:Backspace`)) == null || K();
(K = c.get(`${a}@key:Backspace`)) == null || K();
return;
}
y === `${a}@key:Enter` && ((G = d.get(`${a}@key:Enter`)) == null || G());
y === `${a}@key:Enter` && ((G = c.get(`${a}@key:Enter`)) == null || G());
}), u = P(this, _, ce).call(this, {
container: p,
elementType: a,
elementOptions: l,
styles: k(k({}, e), l.styles),
elementOptions: d,
styles: k(k({}, e), d.styles),
fontSourceCss: o

@@ -677,5 +677,5 @@ }), this.mountedCardElements.push(a);

on: (m, y) => {
d.set(`${a}@${m}`, y);
c.set(`${a}@${m}`, y);
},
off: (m) => d.delete(`${a}@${m}`),
off: (m) => c.delete(`${a}@${m}`),
focus: () => {

@@ -704,4 +704,4 @@ var m;

},
on: (a, l) => {
c.set(a, l);
on: (a, d) => {
l.set(a, d);
}

@@ -724,3 +724,3 @@ };

*/
submitForm(c) {
submitForm(l) {
return f(this, arguments, function* ({

@@ -733,14 +733,17 @@ intentId: e,

}) {
const i = Ee(this.mountedCardElements);
E(
!!i,
`You must mount ${i} element!`
);
const a = new ee();
let l, d;
t && (this.vaultSubmitListener.current = (p) => {
const { type: h, data: g } = p.data;
h === "vaultSubmit:success" && a.resolve(g), h === "vaultSubmit:error" && a.reject(g);
}, d = P(this, F, le).call(this, { accessToken: t, saveCard: n }), l = yield a.promise);
const u = yield this.sdkApiHandler.request({
const i = new ee();
let a, d;
if (t) {
const u = Ee(
this.mountedCardElements
);
E(
!!u,
`You must mount ${u} element!`
), this.vaultSubmitListener.current = (p) => {
const { type: h, data: g } = p.data;
h === "vaultSubmit:success" && i.resolve(g), h === "vaultSubmit:error" && i.reject(g);
}, d = P(this, F, le).call(this, { accessToken: t, saveCard: n }), a = yield i.promise;
}
const c = yield this.sdkApiHandler.request({
api: "sdk:submitNativeForm",

@@ -753,6 +756,6 @@ payload: {

shippingData: r,
cardEmbed: l
cardEmbed: a
}
});
return d && d.remove(), u;
return d && d.remove(), c;
});

@@ -865,11 +868,11 @@ }

width: n = 600,
height: c = 400,
height: l = 400,
left: i = 200,
top: a = 200
} = o.window || {}, l = window.open(
} = o.window || {}, d = window.open(
t,
"",
`width=${n},height=${c},left=${i},top=${a}`
`width=${n},height=${l},left=${i},top=${a}`
);
E(!l, "Popup blocked by browser!"), yield P(this, I, H).call(this, { intentId: e, isUsingPopUp: !0 }), l == null || l.close();
E(!d, "Popup blocked by browser!"), yield P(this, I, H).call(this, { intentId: e, isUsingPopUp: !0 }), d == null || d.close();
});

@@ -892,7 +895,7 @@ }, R = new WeakSet(), se = function(o) {

}) {
const r = new ee(), n = (c) => f(this, null, function* () {
var a, l, d, u;
if (c.origin !== ae())
const r = new ee(), n = (l) => f(this, null, function* () {
var a, d, c, u;
if (l.origin !== ae())
return;
const { type: i } = c.data;
const { type: i } = l.data;
if (i === "intentResult") {

@@ -904,5 +907,5 @@ t && this.sdkApiHandler.postMessage("EmbedResultClose");

]), h = p.transaction.status.split(".")[1];
h === "successful" || h.startsWith("pending") ? (l = (a = this.options).onComplete) == null || l.call(a, k({
h === "successful" || h.startsWith("pending") ? (d = (a = this.options).onComplete) == null || d.call(a, k({
type: this.options.type
}, p)) : (u = (d = this.options).onFail) == null || u.call(d, k({
}, p)) : (u = (c = this.options).onFail) == null || u.call(c, k({
type: this.options.type

@@ -933,7 +936,7 @@ }, p)), r.resolve(() => null), window.removeEventListener("message", n);

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

@@ -959,4 +962,4 @@ "color",

n.searchParams.set("host", btoa(window.location.origin)), n.searchParams.set("vault_api_url", `${r}/api/v1/tokens/`), n.searchParams.set("access_token", e), n.searchParams.set("lang", this.sdkEmbed.lang), t !== void 0 && n.searchParams.set("save_card", `${t}`);
const c = document.createElement("iframe");
return c.id = "moneyhash-submit-iframe", c.src = n.toString(), c.hidden = !0, document.body.appendChild(c), c;
const l = document.createElement("iframe");
return l.id = "moneyhash-submit-iframe", l.src = n.toString(), l.hidden = !0, document.body.appendChild(l), l;
};

@@ -963,0 +966,0 @@ export {

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

(function(l,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o():typeof define=="function"&&define.amd?define(o):(l=typeof globalThis!="undefined"?globalThis:l||self,l.MoneyHash=o())})(this,function(){var q,ce,j,le,D,he,F,z,W,me,x,ue,B,pe,O,ge;"use strict";var Ee=Object.defineProperty,Pe=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var Y=(l,o,p)=>o in l?Ee(l,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[o]=p,L=(l,o)=>{for(var p in o||(o={}))Se.call(o,p)&&Y(l,p,o[p]);if(oe)for(var p of oe(o))Le.call(o,p)&&Y(l,p,o[p]);return l},de=(l,o)=>Pe(l,ke(o));var y=(l,o,p)=>(Y(l,typeof o!="symbol"?o+"":o,p),p),Ae=(l,o,p)=>{if(!o.has(l))throw TypeError("Cannot "+p)};var R=(l,o,p)=>{if(o.has(l))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(l):o.set(l,p)};var A=(l,o,p)=>(Ae(l,o,"access private method"),p);var E=(l,o,p)=>new Promise((I,w)=>{var V=k=>{try{$(p.next(k))}catch(_){w(_)}},M=k=>{try{$(p.throw(k))}catch(_){w(_)}},$=k=>k.done?I(k.value):Promise.resolve(k.value).then(V,M);$((p=p.apply(l,o)).next())});class l{constructor(e){y(this,"target");y(this,"targetOrigin");y(this,"listeners");y(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 o(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function p(){return typeof window!="undefined"}const P=class{constructor(){p()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=o(),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.5.2-beta.2");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),P.messagingService=new l({target:r.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const s=a=>{var n;a.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(s))};(h=P.messagingService)==null||h.onReceive(s)})}request(r){return E(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,s)=>{var a,n;(a=P.messagingService)==null||a.send({type:e,data:t});const h=u=>{var m;const{type:d,data:c}=u.data;d===e&&(c.status==="resolved"?i(c.payload):s(c.payload),(m=P.messagingService)==null||m.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}postMessage(e){var t;(t=P.messagingService)==null||t.send({type:e})}};let I=P;y(I,"messagingService",null),y(I,"isCommunicationReady");function w(f,e){if(f)throw new Error(e)}const V=new Set(["payment","payout"]),M=new Set(["en","fr","ar"]);class ${constructor(e){y(this,"options");y(this,"messagingService",null);y(this,"iframe",null);y(this,"isCommunicationReady",null);w(!V.has(e.type),`MoneyHash constructor must be called with valid type (${[...V].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}){var a,n;(a=this.messagingService)==null||a.abortService();const r=o(),i=new URL(`${r}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.5.2-beta.2");const s=(n=this.options.locale)==null?void 0:n.split("-")[0];s&&i.searchParams.set("lang",s),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const h=document.querySelector(e);return w(!h,`Couldn't find an element with selector ${e}!`),h.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:r}),this.isCommunicationReady=new Promise(u=>{var c;const d=m=>{var g;m.data.type==="sdk:init"&&(u(),(g=this.messagingService)==null||g.removeListener(d))};(c=this.messagingService)==null||c.onReceive(d)}),this.messagingService.onReceive((u,d)=>{var g,v,H,N;const{type:c,data:m}=u.data;switch(c){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(v=(g=this.options).onComplete)==null||v.call(g,L({type:this.options.type},m)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(N=(H=this.options).onFail)==null||N.call(H,L({type:this.options.type},m)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return E(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 E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class k{constructor(){y(this,"promise");y(this,"resolve");y(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function _(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function U(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function J(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function fe(f){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!f.includes(t))return t;return null}function ye(f){return(Array.isArray(f)?f.length:Object.keys(f).length)===0}function ve(f,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const s=document.createElement("script");s.src=f,s.id=e,s.addEventListener("load",()=>{t(void 0)}),s.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(s)})}function we(f){return new Promise(e=>{setTimeout(()=>{e("done")},f*1e3)})}function K(f,e){f&&console.warn(e)}const G=new Set(["method","customerBalance","savedCard"]);class be{constructor(e){R(this,q);R(this,j);R(this,D);R(this,F);R(this,W);R(this,x);R(this,B);R(this,O);y(this,"options");y(this,"sdkApiHandler",new I);y(this,"sdkEmbed");y(this,"vaultSubmitListener",{current:null});y(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new $(de(L({},e),{headless:!0})),A(this,x,ue).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}})}proceedWith({intentId:e,type:t,id:r,metaData:i}){return w(!G.has(t),`type must be a valid one (${[...G].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,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 w(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(u){return E(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:i,onCancel:s=()=>{},onError:h,onComplete:a,billingData:n={}}){if(yield ve("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{state:c,intent:m}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(c==="INTENT_FORM"){if(ye(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(g){throw yield this.resetSelectedMethod(e),g}d.onvalidatemerchant=g=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:m.secret,validation_url:g.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>d.completeMerchantValidation(v)).catch(h)},d.onpaymentauthorized=g=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:m.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=s,d.begin()})}renderForm({selector:e,intentId:t}){return w(!e,"selector is required for renderForm"),w(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){K(!!e&&!M.has(e),`Invalid locale. Supported languages (${[...M].join(" | ")})`);const t=M.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return w(!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(r=>{w(!r.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:r}){const i=[],s={},h=new Map;let a=!1;return A(this,W,me).call(this,i),{create:({elementType:n,elementOptions:u})=>{var N,Q;const d=new Map;let c=null,m;const g=L(L({},t),u.classes),v=((N=g==null?void 0:g.focus)==null?void 0:N.split(" "))||["MoneyHashElement--focus"],H=((Q=g==null?void 0:g.error)==null?void 0:Q.split(" "))||["MoneyHashElement--error"];return{mount:()=>{m=document.querySelector(u.selector),w(!m,`Couldn't find an element with selector ${u.selector}!`),m.classList.add("MoneyHashElement"),i.push(b=>{var X,Z,ee,te,ie,ne,se,re,ae;const{type:S,data:C}=b.data;if(S===`${n}@mount`&&(s[n]=C.isValid,(X=d.get(`${n}@mount`))==null||X()),S===`${n}@focus`){m.classList.add(...v),(Z=d.get(`${n}@focus`))==null||Z();return}if(S===`${n}@blur`){m.classList.remove(...v),(ee=d.get(`${n}@blur`))==null||ee();return}if(S===`${n}@error`){C.isValid?m.classList.remove(...H):m.classList.add(...H),(te=d.get(`${n}@error`))==null||te(C);return}if(S===`${n}@changeInput`){if((ie=d.get(`${n}@changeInput`))==null||ie({isValid:C.isValid,length:C.length}),s[n]=C.isValid,h.get("validityChange")){const T=Object.values(s).every(Boolean);T!==a&&((ne=h.get("validityChange"))==null||ne(T),a=T)}return}if(S===`${n}@cardNumberChange`){(se=d.get(`${n}@cardNumberChange`))==null||se(C);return}if(S===`${n}@key:Backspace`){(re=d.get(`${n}@key:Backspace`))==null||re();return}S===`${n}@key:Enter`&&((ae=d.get(`${n}@key:Enter`))==null||ae())}),c=A(this,B,pe).call(this,{container:m,elementType:n,elementOptions:u,styles:L(L({},e),u.styles),fontSourceCss:r}),this.mountedCardElements.push(n)},on:(b,S)=>{d.set(`${n}@${b}`,S)},off:b=>d.delete(`${n}@${b}`),focus:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"focus"},U())},blur:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"blur"},U())},clear:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"clear"},U())}}},on:(n,u)=>{h.set(n,u)}}}submitForm(h){return E(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:i,saveCard:s}){const a=fe(this.mountedCardElements);w(!!a,`You must mount ${a} element!`);const n=new k;let u,d;t&&(this.vaultSubmitListener.current=m=>{const{type:g,data:v}=m.data;g==="vaultSubmit:success"&&n.resolve(v),g==="vaultSubmit:error"&&n.reject(v)},d=A(this,O,ge).call(this,{accessToken:t,saveCard:s}),u=yield n.promise);const c=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:i,cardEmbed:u}});return d&&d.remove(),c})}submitCvv(r){return E(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(s){return E(this,arguments,function*({intentId:e,url:t,renderStrategy:r,options:i}){switch(r){case"IFRAME":return A(this,q,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return A(this,j,le).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return A(this,D,he).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return K(!0,`No expiration date provided!, make sure to check for it before usage
(function(l,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o():typeof define=="function"&&define.amd?define(o):(l=typeof globalThis!="undefined"?globalThis:l||self,l.MoneyHash=o())})(this,function(){var q,ce,j,le,D,he,F,z,W,me,x,ue,B,pe,O,ge;"use strict";var Ee=Object.defineProperty,Pe=Object.defineProperties;var ke=Object.getOwnPropertyDescriptors;var oe=Object.getOwnPropertySymbols;var Se=Object.prototype.hasOwnProperty,Le=Object.prototype.propertyIsEnumerable;var Y=(l,o,p)=>o in l?Ee(l,o,{enumerable:!0,configurable:!0,writable:!0,value:p}):l[o]=p,L=(l,o)=>{for(var p in o||(o={}))Se.call(o,p)&&Y(l,p,o[p]);if(oe)for(var p of oe(o))Le.call(o,p)&&Y(l,p,o[p]);return l},de=(l,o)=>Pe(l,ke(o));var y=(l,o,p)=>(Y(l,typeof o!="symbol"?o+"":o,p),p),Ae=(l,o,p)=>{if(!o.has(l))throw TypeError("Cannot "+p)};var R=(l,o,p)=>{if(o.has(l))throw TypeError("Cannot add the same private member more than once");o instanceof WeakSet?o.add(l):o.set(l,p)};var A=(l,o,p)=>(Ae(l,o,"access private method"),p);var E=(l,o,p)=>new Promise((I,w)=>{var V=k=>{try{$(p.next(k))}catch(_){w(_)}},M=k=>{try{$(p.throw(k))}catch(_){w(_)}},$=k=>k.done?I(k.value):Promise.resolve(k.value).then(V,M);$((p=p.apply(l,o)).next())});class l{constructor(e){y(this,"target");y(this,"targetOrigin");y(this,"listeners");y(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 o(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function p(){return typeof window!="undefined"}const P=class{constructor(){p()&&this.initSDKCommunicationIframe()}initSDKCommunicationIframe(){if(document.getElementById("moneyhash-headless-sdk"))return;const e=o(),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.5.2-beta.3");const r=document.createElement("iframe");r.id="moneyhash-headless-sdk",r.src=t.toString(),r.hidden=!0,document.body.appendChild(r),P.messagingService=new l({target:r.contentWindow,targetOrigin:e}),P.isCommunicationReady=new Promise(i=>{var h;const s=a=>{var n;a.data.type==="headlessSDK:init"&&(i(),(n=P.messagingService)==null||n.removeListener(s))};(h=P.messagingService)==null||h.onReceive(s)})}request(r){return E(this,arguments,function*({api:e,payload:t}){return yield P.isCommunicationReady,new Promise((i,s)=>{var a,n;(a=P.messagingService)==null||a.send({type:e,data:t});const h=m=>{var u;const{type:d,data:c}=m.data;d===e&&(c.status==="resolved"?i(c.payload):s(c.payload),(u=P.messagingService)==null||u.removeListener(h))};(n=P.messagingService)==null||n.onReceive(h)})})}postMessage(e){var t;(t=P.messagingService)==null||t.send({type:e})}};let I=P;y(I,"messagingService",null),y(I,"isCommunicationReady");function w(f,e){if(f)throw new Error(e)}const V=new Set(["payment","payout"]),M=new Set(["en","fr","ar"]);class ${constructor(e){y(this,"options");y(this,"messagingService",null);y(this,"iframe",null);y(this,"isCommunicationReady",null);w(!V.has(e.type),`MoneyHash constructor must be called with valid type (${[...V].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}){var a,n;(a=this.messagingService)==null||a.abortService();const r=o(),i=new URL(`${r}/embed/${this.options.type}/${t}`);i.searchParams.set("sdk","true"),i.searchParams.set("parent",window.location.origin),i.searchParams.set("version","js@1.5.2-beta.3");const s=(n=this.options.locale)==null?void 0:n.split("-")[0];s&&i.searchParams.set("lang",s),this.iframe=document.createElement("iframe"),this.iframe.src=i.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const h=document.querySelector(e);return w(!h,`Couldn't find an element with selector ${e}!`),h.replaceChildren(this.iframe),this.messagingService=new l({target:this.iframe.contentWindow,targetOrigin:r}),this.isCommunicationReady=new Promise(m=>{var c;const d=u=>{var g;u.data.type==="sdk:init"&&(m(),(g=this.messagingService)==null||g.removeListener(d))};(c=this.messagingService)==null||c.onReceive(d)}),this.messagingService.onReceive((m,d)=>{var g,v,H,N;const{type:c,data:u}=m.data;switch(c){case"sdk:init":{d({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(v=(g=this.options).onComplete)==null||v.call(g,L({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(N=(H=this.options).onFail)==null||N.call(H,L({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return E(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 E(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}class k{constructor(){y(this,"promise");y(this,"resolve");y(this,"reject");this.promise=new Promise((e,t)=>{this.resolve=e,this.reject=t})}}function _(){var e;return(e=window.MONEYHASH_VAULT_API_URL)!=null?e:"https://vault.moneyhash.io"}function U(){var e;return(e=window.MONEYHASH_VAULT_INPUT_IFRAME_URL)!=null?e:"https://vault-form.moneyhash.io"}function J(){var e;return(e=window.API_URL)!=null?e:"https://web.moneyhash.io"}function fe(f){const e=["cardNumber","cardCvv","cardExpiryMonth","cardExpiryYear"];for(const t of e)if(!f.includes(t))return t;return null}function ye(f){return(Array.isArray(f)?f.length:Object.keys(f).length)===0}function ve(f,e){return new Promise((t,r)=>{if(document.getElementById(e)){t(void 0);return}const s=document.createElement("script");s.src=f,s.id=e,s.addEventListener("load",()=>{t(void 0)}),s.addEventListener("error",()=>{r(new Error("Script failed to load"))}),document.body.appendChild(s)})}function we(f){return new Promise(e=>{setTimeout(()=>{e("done")},f*1e3)})}function K(f,e){f&&console.warn(e)}const G=new Set(["method","customerBalance","savedCard"]);class be{constructor(e){R(this,q);R(this,j);R(this,D);R(this,F);R(this,W);R(this,x);R(this,B);R(this,O);y(this,"options");y(this,"sdkApiHandler",new I);y(this,"sdkEmbed");y(this,"vaultSubmitListener",{current:null});y(this,"mountedCardElements",[]);this.options=e,this.sdkEmbed=new $(de(L({},e),{headless:!0})),A(this,x,ue).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}})}proceedWith({intentId:e,type:t,id:r,metaData:i}){return w(!G.has(t),`type must be a valid one (${[...G].join(" | ")})`),this.sdkApiHandler.request({api:"sdk:proceedWith",payload:{proceedWith:t,intentType:this.options.type,intentId:e,id:r,lang:this.sdkEmbed.lang,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 w(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 E(this,arguments,function*({intentId:e,currency:t,amount:r,countryCode:i,onCancel:s=()=>{},onError:h,onComplete:a,billingData:n={}}){if(yield ve("https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js","moneyHash-apple-pay-sdk"),!ApplePaySession)return;const d=new ApplePaySession(3,{countryCode:i,currencyCode:t,supportedNetworks:["visa","masterCard","amex","discover","mada"],merchantCapabilities:["supports3DS"],total:{label:"Apple Pay",type:"final",amount:`${r}`}}),{state:c,intent:u}=yield this.proceedWith({intentId:e,type:"method",id:"APPLE_PAY"});try{if(c==="INTENT_FORM"){if(ye(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(g){throw yield this.resetSelectedMethod(e),g}d.onvalidatemerchant=g=>{fetch(`${J()}/api/v1/providers/applepay/session/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({secret:u.secret,validation_url:g.validationURL})}).then(v=>v.ok?v.json():Promise.reject()).then(v=>d.completeMerchantValidation(v)).catch(h)},d.onpaymentauthorized=g=>{fetch(`${J()}/api/v1/providers/applepay/token/`,{method:"post",headers:{"Content-Type":"application/json"},body:JSON.stringify({token_data:g.payment.token,secret:u.secret})}).then(v=>v.ok?v.json():Promise.reject()).then(()=>{d.completePayment(ApplePaySession.STATUS_SUCCESS),a()}).catch(()=>{d.completePayment(ApplePaySession.STATUS_FAILURE),h()})},d.oncancel=s,d.begin()})}renderForm({selector:e,intentId:t}){return w(!e,"selector is required for renderForm"),w(!t,"intentId is required for renderForm"),this.sdkEmbed.render({selector:e,intentId:t})}setLocale(e){K(!!e&&!M.has(e),`Invalid locale. Supported languages (${[...M].join(" | ")})`);const t=M.has(e)?e:"en";return this.sdkEmbed.setLocale(t)}removeEventListeners(){return this.sdkEmbed.abortService()}updateIntentDiscount({intentId:e,discount:t}){return w(!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(r=>{w(!r.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:r}){const i=[],s={},h=new Map;let a=!1;return A(this,W,me).call(this,i),{create:({elementType:n,elementOptions:m})=>{var N,Q;const d=new Map;let c=null,u;const g=L(L({},t),m.classes),v=((N=g==null?void 0:g.focus)==null?void 0:N.split(" "))||["MoneyHashElement--focus"],H=((Q=g==null?void 0:g.error)==null?void 0:Q.split(" "))||["MoneyHashElement--error"];return{mount:()=>{u=document.querySelector(m.selector),w(!u,`Couldn't find an element with selector ${m.selector}!`),u.classList.add("MoneyHashElement"),i.push(b=>{var X,Z,ee,te,ie,ne,se,re,ae;const{type:S,data:C}=b.data;if(S===`${n}@mount`&&(s[n]=C.isValid,(X=d.get(`${n}@mount`))==null||X()),S===`${n}@focus`){u.classList.add(...v),(Z=d.get(`${n}@focus`))==null||Z();return}if(S===`${n}@blur`){u.classList.remove(...v),(ee=d.get(`${n}@blur`))==null||ee();return}if(S===`${n}@error`){C.isValid?u.classList.remove(...H):u.classList.add(...H),(te=d.get(`${n}@error`))==null||te(C);return}if(S===`${n}@changeInput`){if((ie=d.get(`${n}@changeInput`))==null||ie({isValid:C.isValid,length:C.length}),s[n]=C.isValid,h.get("validityChange")){const T=Object.values(s).every(Boolean);T!==a&&((ne=h.get("validityChange"))==null||ne(T),a=T)}return}if(S===`${n}@cardNumberChange`){(se=d.get(`${n}@cardNumberChange`))==null||se(C);return}if(S===`${n}@key:Backspace`){(re=d.get(`${n}@key:Backspace`))==null||re();return}S===`${n}@key:Enter`&&((ae=d.get(`${n}@key:Enter`))==null||ae())}),c=A(this,B,pe).call(this,{container:u,elementType:n,elementOptions:m,styles:L(L({},e),m.styles),fontSourceCss:r}),this.mountedCardElements.push(n)},on:(b,S)=>{d.set(`${n}@${b}`,S)},off:b=>d.delete(`${n}@${b}`),focus:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"focus"},U())},blur:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"blur"},U())},clear:()=>{var b;(b=c==null?void 0:c.contentWindow)==null||b.postMessage({type:"clear"},U())}}},on:(n,m)=>{h.set(n,m)}}}submitForm(h){return E(this,arguments,function*({intentId:e,accessToken:t,billingData:r,shippingData:i,saveCard:s}){const a=new k;let n,m;if(t){const c=fe(this.mountedCardElements);w(!!c,`You must mount ${c} element!`),this.vaultSubmitListener.current=u=>{const{type:g,data:v}=u.data;g==="vaultSubmit:success"&&a.resolve(v),g==="vaultSubmit:error"&&a.reject(v)},m=A(this,O,ge).call(this,{accessToken:t,saveCard:s}),n=yield a.promise}const d=yield this.sdkApiHandler.request({api:"sdk:submitNativeForm",payload:{intentId:e,paymentMethod:"CARD",lang:this.sdkEmbed.lang,billingData:r,shippingData:i,cardEmbed:n}});return m&&m.remove(),d})}submitCvv(r){return E(this,arguments,function*({intentId:e,cvv:t}){return this.sdkApiHandler.request({api:"sdk:submitCardCvv",payload:{intentId:e,cvv:t,lang:this.sdkEmbed.lang}})})}renderUrl(s){return E(this,arguments,function*({intentId:e,url:t,renderStrategy:r,options:i}){switch(r){case"IFRAME":return A(this,q,ce).call(this,{url:t,intentId:e});case"POPUP_IFRAME":return A(this,j,le).call(this,{url:t,intentId:e,options:i});case"REDIRECT":return A(this,D,he).call(this,{url:t,options:i});default:return null}})}onExpiration(e,t){if(!e)return K(!0,`No expiration date provided!, make sure to check for it before usage

@@ -7,2 +7,2 @@ if (intentDetails.intent.expirationDate) {

})
}`),()=>{};const r=new Date(e),i=setInterval(()=>E(this,null,function*(){const s=new Date;r<s&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}return q=new WeakSet,ce=function(r){return E(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");w(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=t,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),i==null||i.replaceChildren(s),yield A(this,F,z).call(this,{intentId:e}),s.remove()})},j=new WeakSet,le=function(i){return E(this,arguments,function*({intentId:e,url:t,options:r={}}){const{width:s=600,height:h=400,left:a=200,top:n=200}=r.window||{},u=window.open(t,"",`width=${s},height=${h},left=${a},top=${n}`);w(!u,"Popup blocked by browser!"),yield A(this,F,z).call(this,{intentId:e,isUsingPopUp:!0}),u==null||u.close()})},D=new WeakSet,he=function(r){return E(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},F=new WeakSet,z=function(r){return E(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new k,s=h=>E(this,null,function*(){var n,u,d,c;if(h.origin!==o())return;const{type:a}=h.data;if(a==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[m]=yield Promise.all([this.getIntentDetails(e),we(2)]),g=m.transaction.status.split(".")[1];g==="successful"||g.startsWith("pending")?(u=(n=this.options).onComplete)==null||u.call(n,L({type:this.options.type},m)):(c=(d=this.options).onFail)==null||c.call(d,L({type:this.options.type},m)),i.resolve(()=>null),window.removeEventListener("message",s)}});return window.addEventListener("message",s),i.promise})},W=new WeakSet,me=function(e){const t=r=>{r.origin===U()&&e.forEach(i=>{i(r)})};window.addEventListener("message",t)},x=new WeakSet,ue=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},B=new WeakSet,pe=function({container:e,elementType:t,elementOptions:r,styles:i,fontSourceCss:s}){var u,d,c,m;const h=U(),a=new URL(`${h}/vaultField/vaultField.html`);s&&a.searchParams.set("fontSourceCss",s),a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("type",t),((u=r.validation)==null?void 0:u.required)!==void 0&&a.searchParams.set("required",`${(d=r.validation)==null?void 0:d.required}`),a.searchParams.set("placeholder",(c=r.placeholder)!=null?c:""),a.searchParams.set("lang",this.sdkEmbed.lang),a.searchParams.set("direction",(i==null?void 0:i.direction)||""),a.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),a.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),a.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),a.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),a.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),a.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),a.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),a.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");return n.src=a.toString(),n.style.height=(m=i==null?void 0:i.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},O=new WeakSet,ge=function({accessToken:e,saveCard:t}){const r=U(),i=_(),s=new URL(`${r}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),s.searchParams.set("access_token",e),s.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&s.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=s.toString(),h.hidden=!0,document.body.appendChild(h),h},be});
}`),()=>{};const r=new Date(e),i=setInterval(()=>E(this,null,function*(){const s=new Date;r<s&&(clearInterval(i),t())}),1e3);return()=>clearInterval(i)}}return q=new WeakSet,ce=function(r){return E(this,arguments,function*({intentId:e,url:t}){const i=document.querySelector("#rendered-url-iframe-container");w(!i,"Couldn't find an element with id rendered-url-iframe-container to render the iframe!");const s=document.createElement("iframe");s.src=t,s.style.setProperty("border","0","important"),s.style.setProperty("width","100%","important"),s.style.setProperty("height","100%","important"),i==null||i.replaceChildren(s),yield A(this,F,z).call(this,{intentId:e}),s.remove()})},j=new WeakSet,le=function(i){return E(this,arguments,function*({intentId:e,url:t,options:r={}}){const{width:s=600,height:h=400,left:a=200,top:n=200}=r.window||{},m=window.open(t,"",`width=${s},height=${h},left=${a},top=${n}`);w(!m,"Popup blocked by browser!"),yield A(this,F,z).call(this,{intentId:e,isUsingPopUp:!0}),m==null||m.close()})},D=new WeakSet,he=function(r){return E(this,arguments,function*({url:e,options:t}){if(!t||!t.redirectToNewWindow){window.location.href=e;return}window.open(e,"_blank")})},F=new WeakSet,z=function(r){return E(this,arguments,function*({intentId:e,isUsingPopUp:t=!1}){const i=new k,s=h=>E(this,null,function*(){var n,m,d,c;if(h.origin!==o())return;const{type:a}=h.data;if(a==="intentResult"){t&&this.sdkApiHandler.postMessage("EmbedResultClose");const[u]=yield Promise.all([this.getIntentDetails(e),we(2)]),g=u.transaction.status.split(".")[1];g==="successful"||g.startsWith("pending")?(m=(n=this.options).onComplete)==null||m.call(n,L({type:this.options.type},u)):(c=(d=this.options).onFail)==null||c.call(d,L({type:this.options.type},u)),i.resolve(()=>null),window.removeEventListener("message",s)}});return window.addEventListener("message",s),i.promise})},W=new WeakSet,me=function(e){const t=r=>{r.origin===U()&&e.forEach(i=>{i(r)})};window.addEventListener("message",t)},x=new WeakSet,ue=function(e){const t=r=>{e.current&&e.current(r)};window.addEventListener("message",t)},B=new WeakSet,pe=function({container:e,elementType:t,elementOptions:r,styles:i,fontSourceCss:s}){var m,d,c,u;const h=U(),a=new URL(`${h}/vaultField/vaultField.html`);s&&a.searchParams.set("fontSourceCss",s),a.searchParams.set("host",btoa(window.location.origin)),a.searchParams.set("type",t),((m=r.validation)==null?void 0:m.required)!==void 0&&a.searchParams.set("required",`${(d=r.validation)==null?void 0:d.required}`),a.searchParams.set("placeholder",(c=r.placeholder)!=null?c:""),a.searchParams.set("lang",this.sdkEmbed.lang),a.searchParams.set("direction",(i==null?void 0:i.direction)||""),a.searchParams.set("color",JSON.stringify(i!=null&&i.color?i.color:"#000")),a.searchParams.set("placeholderColor",(i==null?void 0:i.placeholderColor)||"#ccc"),a.searchParams.set("backgroundColor",(i==null?void 0:i.backgroundColor)||"transparent"),a.searchParams.set("fontSize",(i==null?void 0:i.fontSize)||""),a.searchParams.set("fontFamily",(i==null?void 0:i.fontFamily)||""),a.searchParams.set("fontWeight",`${i==null?void 0:i.fontWeight}`),a.searchParams.set("fontStyle",(i==null?void 0:i.fontStyle)||""),a.searchParams.set("padding",(i==null?void 0:i.padding)||"");const n=document.createElement("iframe");return n.src=a.toString(),n.style.height=(u=i==null?void 0:i.height)!=null?u:"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},O=new WeakSet,ge=function({accessToken:e,saveCard:t}){const r=U(),i=_(),s=new URL(`${r}/vaultSubmit/vaultSubmit.html`);s.searchParams.set("host",btoa(window.location.origin)),s.searchParams.set("vault_api_url",`${i}/api/v1/tokens/`),s.searchParams.set("access_token",e),s.searchParams.set("lang",this.sdkEmbed.lang),t!==void 0&&s.searchParams.set("save_card",`${t}`);const h=document.createElement("iframe");return h.id="moneyhash-submit-iframe",h.src=s.toString(),h.hidden=!0,document.body.appendChild(h),h},be});

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

"use strict";var n=Object.defineProperty;var d=(t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var a=(t,e,s)=>(d(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-cc60367b.cjs");class o{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start({selector:e,intentId:s}){return r.throwIf(!e,"selector is required for start"),r.throwIf(!s,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:s})}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 n=Object.defineProperty;var d=(t,e,s)=>e in t?n(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var a=(t,e,s)=>(d(t,typeof e!="symbol"?e+"":e,s),s);const r=require("./warnIf-a8bc2152.cjs");class o{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new r.SDKEmbed(e)}start({selector:e,intentId:s}){return r.throwIf(!e,"selector is required for start"),r.throwIf(!s,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:s})}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 o = Object.defineProperty;
var n = (r, s, e) => s in r ? o(r, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[s] = e;
var t = (r, s, e) => (n(r, typeof s != "symbol" ? s + "" : s, e), e);
import { S as i, t as d, w as u, s as a } from "./warnIf-94e30d35.js";
import { S as i, t as d, w as u, s as a } from "./warnIf-389f3200.js";
class b {

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

@@ -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 F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,s,t)=>s in i?F(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,w=(i,s)=>{for(var t in s||(s={}))U.call(s,t)&&v(i,t,s[t]);if(O)for(var t of O(s))$.call(s,t)&&v(i,t,s[t]);return i};var a=(i,s,t)=>(v(i,typeof s!="symbol"?s+"":s,t),t);var b=(i,s,t)=>new Promise((g,o)=>{var p=r=>{try{h(t.next(r))}catch(e){o(e)}},f=r=>{try{h(t.throw(r))}catch(e){o(e)}},h=r=>r.done?g(r.value):Promise.resolve(r.value).then(p,f);h((t=t.apply(i,s)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(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 s(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function t(r,e){if(r)throw new Error(e)}const g=new Set(["payment","payout"]),o=new Set(["en","fr","ar"]);class p{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!g.has(e.type),`MoneyHash constructor must be called with valid type (${[...g].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}){var L,M;(L=this.messagingService)==null||L.abortService();const S=s(),c=new URL(`${S}/embed/${this.options.type}/${n}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.5.2-beta.2");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const m=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(m))};(l=this.messagingService)==null||l.onReceive(m)}),this.messagingService.onReceive((y,m)=>{var d,I,k,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{m({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(I=(d=this.options).onComplete)==null||I.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(k=this.options).onFail)==null||C.call(k,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(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 b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function f(r,e){r&&console.warn(e)}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new p(e)}start({selector:e,intentId:n}){return t(!e,"selector is required for start"),t(!n,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:n})}setLocale(e){f(!!e&&!o.has(e),`Invalid locale. Supported languages (${[...o].join(" | ")})`);const n=o.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
(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 F=Object.defineProperty;var O=Object.getOwnPropertySymbols;var U=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable;var v=(i,s,t)=>s in i?F(i,s,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[s]=t,w=(i,s)=>{for(var t in s||(s={}))U.call(s,t)&&v(i,t,s[t]);if(O)for(var t of O(s))$.call(s,t)&&v(i,t,s[t]);return i};var a=(i,s,t)=>(v(i,typeof s!="symbol"?s+"":s,t),t);var b=(i,s,t)=>new Promise((g,o)=>{var p=r=>{try{h(t.next(r))}catch(e){o(e)}},f=r=>{try{h(t.throw(r))}catch(e){o(e)}},h=r=>r.done?g(r.value):Promise.resolve(r.value).then(p,f);h((t=t.apply(i,s)).next())});class i{constructor(e){a(this,"target");a(this,"targetOrigin");a(this,"listeners");a(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 s(){var e;return(e=window.MONEYHASH_IFRAME_URL)!=null?e:"https://embed.moneyhash.io"}function t(r,e){if(r)throw new Error(e)}const g=new Set(["payment","payout"]),o=new Set(["en","fr","ar"]);class p{constructor(e){a(this,"options");a(this,"messagingService",null);a(this,"iframe",null);a(this,"isCommunicationReady",null);t(!g.has(e.type),`MoneyHash constructor must be called with valid type (${[...g].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}){var L,M;(L=this.messagingService)==null||L.abortService();const S=s(),c=new URL(`${S}/embed/${this.options.type}/${n}`);c.searchParams.set("sdk","true"),c.searchParams.set("parent",window.location.origin),c.searchParams.set("version","js@1.5.2-beta.3");const R=(M=this.options.locale)==null?void 0:M.split("-")[0];R&&c.searchParams.set("lang",R),this.iframe=document.createElement("iframe"),this.iframe.src=c.toString(),this.iframe.style.height="100%",this.iframe.style.width="100%",this.iframe.style.border="0";const E=document.querySelector(e);return t(!E,`Couldn't find an element with selector ${e}!`),E.replaceChildren(this.iframe),this.messagingService=new i({target:this.iframe.contentWindow,targetOrigin:S}),this.isCommunicationReady=new Promise(y=>{var l;const m=u=>{var d;u.data.type==="sdk:init"&&(y(),(d=this.messagingService)==null||d.removeListener(m))};(l=this.messagingService)==null||l.onReceive(m)}),this.messagingService.onReceive((y,m)=>{var d,I,k,C;const{type:l,data:u}=y.data;switch(l){case"sdk:init":{m({type:"sdk:init",data:{headless:Boolean(this.options.headless),styles:this.options.styles}});break}case"onComplete":{(I=(d=this.options).onComplete)==null||I.call(d,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}case"onFail":{(C=(k=this.options).onFail)==null||C.call(k,w({type:this.options.type},u)),this.options.headless&&this.iframe&&(this.iframe.hidden=!0);break}}}),this.isCommunicationReady}setLocale(e){return b(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 b(this,null,function*(){var e;yield this==null?void 0:this.isCommunicationReady,(e=this.messagingService)==null||e.abortService()})}}function f(r,e){r&&console.warn(e)}class h{constructor(e){a(this,"options");a(this,"sdkEmbed");this.options=e,this.sdkEmbed=new p(e)}start({selector:e,intentId:n}){return t(!e,"selector is required for start"),t(!n,"intentId is required for start"),this.sdkEmbed.render({selector:e,intentId:n})}setLocale(e){f(!!e&&!o.has(e),`Invalid locale. Supported languages (${[...o].join(" | ")})`);const n=o.has(e)?e:"en";return this.sdkEmbed.setLocale(n)}removeEventListeners(){return this.sdkEmbed.abortService()}}return h});
{
"name": "@moneyhash/js-sdk",
"version": "1.5.2-beta.2",
"version": "1.5.2-beta.3",
"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