@monei-js/components 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@
8
8
  void main() {
9
9
  gl_FragColor = vec4(0.812, 0.195, 0.553, 0.921); // Set line color
10
10
  }
11
- `),S.compileShader(e),!S.getShaderParameter(e,S.COMPILE_STATUS))throw Error(`Vertex shader compilation failed: `+S.getShaderInfoLog(e));if(S.compileShader(t),!S.getShaderParameter(t,S.COMPILE_STATUS))throw Error(`Fragment shader compilation failed: `+S.getShaderInfoLog(t));let n=S.createProgram();if(!n)throw Error(`Failed to create shader program`);if(S.attachShader(n,e),S.attachShader(n,t),S.linkProgram(n),!S.getProgramParameter(n,S.LINK_STATUS))throw Error(`Shader program linking failed: `+S.getProgramInfoLog(n));S.useProgram(n);let r=new Float32Array(548),i=2*Math.PI/137;for(let e=0;e<137;e++){let t=e*i;r[4*e]=0,r[4*e+1]=0,r[4*e+2]=Math.cos(t)*(x.width/2),r[4*e+3]=Math.sin(t)*(x.height/2)}let a=S.createBuffer();S.bindBuffer(S.ARRAY_BUFFER,a),S.bufferData(S.ARRAY_BUFFER,r,S.STATIC_DRAW);let o=S.getAttribLocation(n,`position`);S.enableVertexAttribArray(o),S.vertexAttribPointer(o,2,S.FLOAT,!1,0,0),S.viewport(0,0,x.width,x.height),S.clearColor(0,0,0,1),S.clear(S.COLOR_BUFFER_BIT),S.drawArrays(S.LINES,0,274);let s=new Uint8ClampedArray(x.width*x.height*4);return S.readPixels(0,0,x.width,x.height,S.RGBA,S.UNSIGNED_BYTE,s),new ImageData(s,x.width,x.height)}catch{return new ImageData(1,1)}finally{S&&(S.bindBuffer(S.ARRAY_BUFFER,null),S.useProgram(null),S.viewport(0,0,S.drawingBufferWidth,S.drawingBufferHeight),S.clearColor(0,0,0,0))}}())),x.width,x.height).data.toString()).toString()}}catch{return{webgl:`unsupported`}}},webrtc:async function(e){return new Promise((t=>{try{let n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!n)return void t({supported:!1,error:`WebRTC not supported`});let r=new n({iceCandidatePoolSize:1,iceServers:[]});r.createDataChannel(``),(async()=>{try{let n=await r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});await r.setLocalDescription(n);let i=n.sdp||``,a=[...new Set((i.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,``))))].sort(),o=e=>{let t=i.match(RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(` `):[]},s=(e,t)=>t.map((t=>{let n=RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,`g`),r=[...i.matchAll(n)];if(!r.length)return null;let a={};return r.forEach((t=>{let[n,r,i]=t,o=i.split(`/`);r===`rtpmap`?(a.mimeType=`${e}/${o[0]}`,a.clockRate=+o[1],e===`audio`&&(a.channels=+o[2]||1)):r===`rtcp-fb`?(a.feedbackSupport=a.feedbackSupport||[],a.feedbackSupport.push(i)):r===`fmtp`&&(a.sdpFmtpLine=i)})),a})).filter(Boolean),c=s(`audio`,o(`audio`)),l=s(`video`,o(`video`)),u={audio:{count:c.length,hash:h(C(c))},video:{count:l.length,hash:h(C(l))},extensionsHash:h(C(a))},d=e?.timeout||5e3,f=Math.floor(.9*d),p=await new Promise((e=>{let t=setTimeout((()=>{r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,timeout:!0})}),f),n=i=>{let a=i.candidate;a&&a.candidate&&(clearTimeout(t),r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,candidateType:a.type||``}))};r.addEventListener(`icecandidate`,n)}));t({details:p,hash:h(C(p))})}catch(e){r.close(),t({supported:!0,error:`WebRTC offer failed: ${e.message}`})}})()}catch(e){t({supported:!1,error:`WebRTC error: ${e.message}`})}}))},speech:async function(){return new Promise((e=>{try{if(typeof window>`u`||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!=`function`)return void e({supported:!1,error:`Speech Synthesis API not supported`});let t=!1,n=null,r=r=>{if(!t){t=!0,n&&clearTimeout(n);try{let t=r.map((e=>{let t=e=>e.replace(/\\/g,`\\\\`).replace(/,/g,`\\,`);return[t(e.voiceURI||``),t(e.name||``),t(e.lang||``),e.localService?`1`:`0`,e.default?`1`:`0`].join(`,`)}));t.sort();let n={voiceCount:r.length,voicesHash:h(C(t))};e({details:n,hash:h(C(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},i=window.speechSynthesis.getVoices();if(i.length>0)return void r(i);n=setTimeout((()=>{r(window.speechSynthesis.getVoices())}),800);let a=()=>{window.speechSynthesis.removeEventListener(`voiceschanged`,a),r(window.speechSynthesis.getVoices())};window.speechSynthesis.addEventListener(`voiceschanged`,a)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},ge={mathml:async function(){return new Promise((e=>{try{g((async({iframe:t})=>{try{if(!function(e){try{let t=e.createElement(`math`);t.innerHTML=`<mrow><mi>x</mi></mrow>`,t.style.position=`absolute`,t.style.visibility=`hidden`,e.body.appendChild(t);let n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch{return!1}}(t))return void e({supported:!1,error:`MathML not supported`});let n=[w(`integral`,`<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>`),w(`fraction`,`<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>`),w(`matrix`,`<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>`),pe(),...me()],r=[],i=``;n.forEach(((e,n)=>{let a=function(e,t){try{let n=t.createElement(`math`);n.innerHTML=e.replace(/<\/?math>/g,``),n.style.whiteSpace=`nowrap`,n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.top=`-9999px`,t.body.appendChild(n);let r=n.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(n),a={dimensions:{width:r.width,height:r.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||`normal`,fontStretch:i.fontStretch||`normal`,fontSizeAdjust:i.fontSizeAdjust||`none`,textRendering:i.textRendering||`auto`,fontFeatureSettings:i.fontFeatureSettings||`normal`,fontVariantNumeric:i.fontVariantNumeric||`normal`,fontKerning:i.fontKerning||`auto`}};return t.body.removeChild(n),a}catch(e){return{error:e.message}}}(e,t);r.push({width:a.dimensions.width,height:a.dimensions.height}),n===0&&a.fontInfo&&(i=h(C(a.fontInfo)))}));let a={fontStyleHash:i,dimensions:r};e({details:a,hash:h(C(a))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}},_e={},ve={timeout:`true`};function ye(e,t){let n=ae();if(n.name===`unknown`&&t){let e=t.system?.browser;e!=null&&e.name&&(n={name:String(e.name),version:String(e.version||`unknown`)})}let r=n.name.toLowerCase(),i=parseInt(n.version.split(`.`)[0]||`0`,10),a=[...e?.exclude||[]],o=[...new Set([...e?.stabilize||[],`always`])];for(let e of o){let t=s[e];if(t)for(let e of t)`browsers`in e&&!e.browsers?.some((e=>{let t=e.match(/(.+?)(>=)(\d+)/);return t?r===t[1]&&i>=+t[3]:r===e}))||a.push(...e.exclude)}return a}function be(e,t){let n=ye(t,e),r=t?.include||[];return function e(t,i=``){let a={};for(let[o,s]of Object.entries(t)){let t=i?`${i}.${o}`:o;if(typeof s!=`object`||Array.isArray(s)||s===null){let e=n.some((e=>t.startsWith(e))),i=r.some((e=>t.startsWith(e)));e&&!i||(a[o]=s)}else{let n=e(s,t);Object.keys(n).length>0&&(a[o]=n)}}return a}(e)}let xe=`visitor_id`;function Se(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(xe)}let Ce=`${i}_${xe}`;function we(e,t){try{localStorage.setItem(Se(t),e)}catch{}}let Te=`cache`;function T(e){try{let t=localStorage.getItem(e.property_name_factory(Te));return JSON.parse(t)||{}}catch{}return{}}function Ee(e){return e.cache_lifetime_in_ms>r?Date.now()+r:Date.now()+e.cache_lifetime_in_ms}var E=class extends Error{constructor(e){super(`HTTP error! status: ${e}`),this.status=e}};let D=null,O=null;async function De(e,t,n,r){let i=await fetch(e,{method:`POST`,headers:{"x-api-key":n.api_key,Authorization:`custom-authorized`,"Content-Type":`application/json`},body:JSON.stringify(t)});if(!i.ok)throw new E(i.status);let a=await i.json();return a.visitorId&&a.visitorId!==r&&we(a.visitorId,n),O=a,function(e,t){!e.cache_api_call||!e.cache_lifetime_in_ms||(function(e,t){let n={...T(e),...t};try{localStorage.setItem(e.property_name_factory(Te),JSON.stringify(n))}catch{}})(e,{apiResponseExpiry:Ee(e),apiResponse:t})}(n,a),a}let Oe=(e,t)=>{if(e.cache_api_call){if(O)return Promise.resolve(O);let t=function(e){let t=T(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse}(e);if(t)return Promise.resolve(t);if(D)return D}let n=`${e.api_endpoint||a}/thumbmark`,r=function(e){try{let t=Se(e),n=localStorage.getItem(t);return n||t===Ce||(n=localStorage.getItem(Ce),n&&we(n,e)),n}catch{return null}}(e),i={components:t,options:e,clientHash:h(C(t)),version:`1.7.6`};if(r&&(i.visitorId=r),e.metadata){let t=typeof e.metadata==`function`?e.metadata():e.metadata;t&&((typeof t==`string`?t.length:JSON.stringify(t).length)>1e3?console.error(`ThumbmarkJS: Metadata exceeds 1000 characters. Skipping metadata.`):i.metadata=t)}let o=e.timeout||5e3,s=async function(e,t,n,r){for(let i=0;i<3;i++){i>0&&await new Promise((e=>setTimeout(e,200*i)));try{return await De(e,t,n,r)}catch(e){if(e instanceof E||i===2)throw e}}throw Error(`Unreachable`)}(n,i,e,r).finally((()=>{D=null})),c=new Promise((t=>{setTimeout((()=>{t(T(e)?.apiResponse||{info:{timed_out:!0},...r&&{visitorId:r}})}),o)}));return D=Promise.race([s,c]),D};async function ke(e,t={}){var n;if(typeof document>`u`||typeof window>`u`)return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:`Browser environment required`}]};try{let r={...o,...e},i=[],s=r.logging&&!sessionStorage.getItem(`_tmjs_l`)&&Math.random()<1e-4,{elapsed:c,resolvedComponents:l,errors:u}=await Ae({...he,..._e,...t},r);i.push(...u);let d={},f={};if(s||r.experimental){let{elapsed:e,resolvedComponents:t,errors:n}=await Ae(ge,r);d=t,f=e,i.push(...n)}let p=r.api_key?Oe(r,l):null,m=null;if(p)try{m=await p}catch(e){if(e instanceof E&&e.status===403)return{error:[{type:`api_unauthorized`,message:`Invalid API key or quota exceeded`}],components:{},info:{},version:`1.7.6`,thumbmark:``};i.push({type:e instanceof E?`api_error`:`network_error`,message:e instanceof Error?e.message:String(e)})}(n=m?.info)!=null&&n.timed_out&&i.push({type:`api_timeout`,message:`API request timed out`});let g={...c,...f},_=r.performance?{elapsed:g}:{},ee=be(m?.components||{},r),v={...l,...ee},y=m?.info||{uniqueness:{score:`api only`}},te=m?.thumbmark??h(C(v));return s&&async function(e,t,n,r={},i=[]){let o=`${a}/log`,s={thumbmark:e,components:t,experimental:r,version:`1.7.6`,options:n,path:(window==null?void 0:window.location)?.pathname,...i.length>0&&{errors:i}};sessionStorage.setItem(`_tmjs_l`,`1`);try{await fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)})}catch{}}(te,v,r,d,i).catch((()=>{})),{...m?.visitorId&&{visitorId:m.visitorId},thumbmark:te,components:v,info:y,version:`1.7.6`,..._,...i.length>0&&{error:i},...Object.keys(d).length>0&&r.experimental&&{experimental:d},...m?.requestId&&{requestId:m.requestId},...m?.metadata&&{metadata:m.metadata}}}catch(e){return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:e instanceof Error?e.message:String(e)}]}}}async function Ae(e,t){let n={...o,...t},r=ye(n).filter((e=>!e.includes(`.`))),i=Object.entries(e).filter((([e])=>!(n?.exclude)?.includes(e))).filter((([e])=>!r.includes(e))).filter((([e])=>(n?.include)?.some((e=>e.includes(`.`)))?(n?.include)?.some((t=>t.startsWith(e))):n?.include?.length===0||(n?.include)?.includes(e))),a=i.map((([e])=>e)),s=await function(e,t,n){return Promise.all(e.map((e=>{let r=performance.now();return Promise.race([e.then((e=>({value:e,elapsed:performance.now()-r}))).catch((e=>({value:n,elapsed:performance.now()-r,error:e instanceof Error?e.message:String(e)}))),(i=t,a=n,new Promise((e=>{setTimeout((()=>e(a)),i)}))).then((e=>({value:e,elapsed:performance.now()-r,error:`timeout`})))]);var i,a})))}(i.map((([e,n])=>n(t))),n?.timeout||5e3,ve),c={},l={},u=[];return s.forEach(((e,t)=>{let n=a[t];c[n]=e.elapsed??0,e.error===`timeout`?u.push({type:`component_timeout`,message:`Component '${n}' timed out`,component:n}):e.error&&u.push({type:`component_error`,message:e.error,component:n}),e.value!=null&&(l[n]=e.value)})),{elapsed:c,resolvedComponents:be(l,n),errors:u}}var je=class{constructor(e){this.options={...o,...e},this.customComponents={}}async get(e){return ke({...this.options,...e},this.customComponents)}getVersion(){return`1.7.6`}includeComponent(e,t){this.customComponents[e]=t}};let k=(e,t)=>{if(e==null)return t;if(typeof e==`number`)return e;let n=parseInt(e);return isNaN(n)?t:n},Me=(e,t)=>e==null?t:typeof e==`number`?`${e}px`:e||t;var Ne=n({fixLocalstorage:()=>Ie,getClientEnv:()=>M,getClientFingerprint:()=>P,isMethodSupported:()=>Ue,loadScript:()=>Pe,parsePx:()=>k,stringify:()=>Fe,toCssPx:()=>Me,transformStyle:()=>A,validateComponentProps:()=>F,withError:()=>He});let A=e=>Object.keys(e).reduce((t,n)=>(typeof e[n]==`string`?t[n]=e[n]:t[n]=`${e[n]}px`,t),{}),Pe=(e,t,n,r)=>new Promise((i,a)=>{let o=Array.from(document.scripts).find(t=>t.src===e);if(o)if(r)o.remove();else{i(o);return}let s=document.createElement(`script`);s.src=e,s.onload=()=>i(s),s.onerror=e=>a(e),t&&s.setAttribute(`nonce`,t),n&&Object.keys(n).forEach(e=>{n[e]&&(s.dataset[e]=n[e])}),document.head.appendChild(s)}),Fe=e=>Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`),t),[]).join(`&`),Ie=()=>{let e;try{({localStorage:e}=window)}catch{let t=(()=>{let e=new Map;return{getItem(t){return e.get(t)},setItem:function(t,n){e.set(t,n)},clear:function(){e=new Map},removeItem:function(t){e.delete(t)}}})();Object.defineProperty(window,`localStorage`,{value:t}),e=t}return e},Le=()=>{let e,t=Ie();try{e=t.getItem(`i18nextLng`)}catch{}return e?e.split(`-`)[0]:``},j=e=>{try{return String(e()??``)}catch{return``}},M=()=>{let e=[window.screen.colorDepth,window.screen.height,window.screen.width,new Date().getTimezoneOffset(),Le(),j(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),j(()=>window.devicePixelRatio),j(()=>navigator.hardwareConcurrency),j(()=>navigator.deviceMemory),j(()=>navigator.maxTouchPoints),j(()=>navigator.platform),j(()=>navigator.languages?.join(`,`))].join(`|`);return window.btoa(e)},Re=`_monei_fp`,ze=e=>{if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>(e%16).toString(16)).join(``)}return Array.from({length:e},()=>Math.floor(Math.random()*16).toString(16)).join(``)},N=null,Be=async()=>{if(N)return{seed:N};try{let e=Ie();if(N=e.getItem(Re),!N){N=ze(32);try{e.setItem(Re,N)}catch{}}}catch{N=ze(32)}return{seed:N}},Ve=new je({logging:!1});Ve.includeComponent(`persistent_seed`,Be);let P=async()=>{let[,e]=await He(Ve.get());return e?.thumbmark??``},He=async e=>{try{return[void 0,await e]}catch(e){return[e,void 0]}},Ue=(e,t)=>e.paymentMethods&&e.paymentMethods.includes(t),F=({props:e})=>{if(!e.paymentId&&!(e.accountId&&e.amount&&e.currency))throw Error(`You need to provide paymentId or accountId amount and currency`)},We={}.env?.STAGE||`local`,I={}.env?.DOMAIN||`http://localhost:3001`,L={}.env?.VERSION||`v1`,Ge={domain:I,version:L,stage:We,isProduction:We===`prod`,paymentPageUrl:`${I}/${L}/payment-page/`,cardInputUrl:`${I}/${L}/inner-card-input/`,paymentModalUrl:`${I}/${L}/inner-payment-modal/`,paypalUrl:`${I}/${L}/inner-paypal/`,bizumUrl:`${I}/${L}/inner-bizum/`,bizumButtonUrl:`${I}/${L}/inner-bizum-button/`,paymentRequestUrl:`${I}/${L}/inner-payment-request/`},Ke={local:{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},"local-prod":{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},tunnel:{domain:`https://card-input.monei-dev-tunnel.com`,paymentPageUrl:`https://payment-page.monei-dev-tunnel.com/`,cardInputUrl:`https://card-input.monei-dev-tunnel.com/`,paymentModalUrl:`https://payment-modal.monei-dev-tunnel.com/`,paypalUrl:`https://paypal.monei-dev-tunnel.com/`,bizumUrl:`https://bizum.monei-dev-tunnel.com/`,bizumButtonUrl:`https://bizum-button.monei-dev-tunnel.com/`,paymentRequestUrl:`https://payment-request.monei-dev-tunnel.com/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},dev:{apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},prod:{apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`}},R={...Ge,...Ke[We]};var qe=n({confirmPayment:()=>Xe,createApplePaySession:()=>$e,createPayment:()=>Ze,createToken:()=>Je,getPayment:()=>Ye,getPaymentMethods:()=>V,sendPaymentReceipt:()=>Qe,validateBizumPhone:()=>et});let z=async(e,{method:t=`GET`,headers:n,body:r}={})=>{t===`POST`&&(n={"Content-Type":`application/json`,...n});let i=await fetch(`${R.apiUrl}${e}`,{method:t,headers:n,body:r?JSON.stringify(r):void 0}),[,a]=await He(i.json());if(!i.ok)throw a||Error(i.statusText);return a},B={},V=async({accountId:e,paymentId:t})=>{let n;if(t)n={paymentId:t};else if(e)n={accountId:e};else throw Error(`You need to provide paymentId or accountId`);let r=Fe(n);if(r in B)return B[r];let i=z(`/payment-methods?${r}`);return B[r]=i,i.catch(()=>delete B[r]),i},Je=async({paymentMethod:e,paymentId:t,sessionId:n,amount:r,currency:i,accountId:a,transactionType:o})=>{let s;if(t)s={paymentId:t,paymentMethod:e};else if(a)s={accountId:a,paymentMethod:e,sessionId:n,amount:r,currency:i,transactionType:o};else throw Error(`You need to provide paymentId or accountId`);let c=await z(`/tokens`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:s});return c.paymentToken&&!c.token&&(c.token=c.paymentToken),c},Ye=async e=>z(`/payments/${e}/client-get`),Xe=async({paymentId:e,...t})=>z(`/payments/${e}/client-confirm`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:t}),Ze=async({signature:e,...t})=>z(`/client-payments`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P(),"Client-Signature":e},body:t}),Qe=async({paymentId:e,customerEmail:t,signature:n,language:r})=>z(`/payments/${e}/client-receipt`,{method:`POST`,body:{customerEmail:t,signature:n,language:r}}),$e=async e=>z(`/apple-pay/sessions`,{method:`POST`,body:e}),et=async e=>z(`/bizum/validate-phone`,{method:`POST`,body:e});var tt=class{constructor(){this.listeners=new Map,this.destroyed=!1}on(e,t){if(this.destroyed)return{cancel:()=>{}};let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{cancel:()=>{n.delete(t)}}}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}trigger(e,...t){if(this.destroyed)return;let n=this.listeners.get(e);if(n)for(let e of n)try{e(...t)}catch(e){console.error(e)}}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}destroy(){this.destroyed=!0,this.listeners.clear()}};function nt(e){return({React:t})=>t.forwardRef(function(n,r){let i=t.useRef(null),a=t.useRef(null),o=t.useRef(!1),s=t.useRef({});return t.useLayoutEffect(()=>{let t=i.current;if(!t)return;let s=!1,c=new e({...n});return a.current=c,c.render(t).then(()=>{s||(rt(r,c),o.current=!0)}).catch(e=>{s||console.error(e)}),()=>{s=!0,c.destroy(),a.current=null,o.current=!1,rt(r,null)}},[]),t.useEffect(()=>{!o.current||!a.current||it(s.current,n)||(s.current={...n},a.current.updateProps({...n}).catch(at))}),t.createElement(`div`,{ref:i})})}function rt(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function it(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function at(){}function ot(e){return()=>({template:`<div></div>`,inheritAttrs:!1,mounted(){let t=this.$el;this.__bridgeInstance=new e({...this.$attrs}),this.__bridgeInstance.render(t).catch(console.error)},watch:{$attrs:{handler(){this.__bridgeInstance&&this.__bridgeInstance.updateProps({...this.$attrs}).catch(()=>{})},deep:!0}},unmounted(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}})}function st(e){return({Component:t,NgModule:n,ElementRef:r,NgZone:i,Inject:a})=>{class o{constructor(e,t){this.props={},this.__bridgeInstance=null,this._prevProps={},this.elementRef=e,this.zone=t}getProps(){let e={...this.props},{zone:t}=this;for(let[n,r]of Object.entries(e))typeof r==`function`&&(e[n]=function(...e){return t.run(()=>r.apply(this,e))});return e}ngOnInit(){let t=this.elementRef.nativeElement;this.__bridgeInstance=new e(this.getProps()),this.__bridgeInstance.render(t).catch(console.error)}ngDoCheck(){this.__bridgeInstance&&!ct(this._prevProps,this.props)&&(this._prevProps={...this.props},this.__bridgeInstance.updateProps(this.getProps()).catch(()=>{}))}ngOnDestroy(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}}o.parameters=[[new a(r)],[new a(i)]],o.annotations=[new t({selector:e.prototype.__options?.tag||`bridge-component`,template:`<div></div>`,inputs:[`props`]})];class s{}return s.annotations=[new n({declarations:[o],exports:[o]})],s}}function ct(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}let lt={react:nt,vue3:ot,angular:st};function ut(e,t,n){let r=lt[e];if(!r)throw Error(`Unknown driver: ${e}. Available: ${Object.keys(lt).join(`, `)}`);return r(t)(n)}var H=class extends Error{code;constructor(e,t){super(t),this.name=`PenpalError`,this.code=e}},dt=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof H?e.code:void 0}),ft=({name:e,message:t,stack:n,penpalCode:r})=>{let i=r?new H(r,t):Error(t);return i.name=e,i.stack=n,i},pt=class{value;transferables;constructor(e,t){this.value=e,this.transferables=t?.transferables}},U=`penpal`,W=e=>typeof e==`object`&&!!e,mt=e=>typeof e==`function`,ht=e=>W(e)&&e.namespace===U,G=e=>e.type===`SYN`,gt=e=>e.type===`ACK1`,_t=e=>e.type===`ACK2`,vt=e=>e.type===`CALL`,yt=e=>e.type===`REPLY`,bt=e=>e.type===`DESTROY`,xt=(e,t=[])=>{let n=[];for(let r of Object.keys(e)){let i=e[r];mt(i)?n.push([...t,r]):W(i)&&n.push(...xt(i,[...t,r]))}return n},St=(e,t)=>{let n=e.reduce((e,t)=>W(e)?e[t]:void 0,t);return mt(n)?n:void 0},K=e=>e.join(`.`),Ct=(e,t,n)=>({namespace:U,channel:e,type:`REPLY`,callId:t,isError:!0,...n instanceof Error?{value:dt(n),isSerializedErrorInstance:!0}:{value:n}}),wt=(e,t,n,r)=>{let i=!1,a=async a=>{if(i||!vt(a))return;r?.(`Received ${K(a.methodPath)}() call`,a);let{methodPath:o,args:s,id:c}=a,l,u;try{let e=St(o,t);if(!e)throw new H(`METHOD_NOT_FOUND`,`Method \`${K(o)}\` is not found.`);let r=await e(...s);r instanceof pt&&(u=r.transferables,r=await r.value),l={namespace:U,channel:n,type:`REPLY`,callId:c,value:r}}catch(e){l=Ct(n,c,e)}if(!i)try{r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l,u)}catch(t){throw t.name===`DataCloneError`&&(l=Ct(n,c,t),r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l)),t}};return e.addMessageHandler(a),()=>{i=!0,e.removeMessageHandler(a)}},Tt=crypto.randomUUID?.bind(crypto)??(()=>[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)),Et=class{transferables;timeout;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},Dt=new Set([`apply`,`call`,`bind`]),Ot=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,i){if(i!==`then`)return n.length&&Dt.has(i)?Reflect.get(r,i):Ot(e,t,[...n,i])},apply(t,r,i){return e(n,i)}}),kt=e=>new H(`CONNECTION_DESTROYED`,`Method call ${K(e)}() failed due to destroyed connection`),At=(e,t,n)=>{let r=!1,i=new Map,a=e=>{if(!yt(e))return;let{callId:t,value:r,isError:a,isSerializedErrorInstance:o}=e,s=i.get(t);s&&(i.delete(t),n?.(`Received ${K(s.methodPath)}() call`,e),a?s.reject(o?ft(r):r):s.resolve(r))};return e.addMessageHandler(a),{remoteProxy:Ot((a,o)=>{if(r)throw kt(a);let s=Tt(),c=o[o.length-1],l=c instanceof Et,{timeout:u,transferables:d}=l?c:{},f=l?o.slice(0,-1):o;return new Promise((r,o)=>{let c=u===void 0?void 0:window.setTimeout(()=>{i.delete(s),o(new H(`METHOD_CALL_TIMEOUT`,`Method call ${K(a)}() timed out after ${u}ms`))},u);i.set(s,{methodPath:a,resolve:r,reject:o,timeoutId:c});try{let r={namespace:U,channel:t,type:`CALL`,id:s,methodPath:a,args:f};n?.(`Sending ${K(a)}() call`,r),e.sendMessage(r,d)}catch(e){o(new H(`TRANSMISSION_FAILED`,e.message))}})},n),destroy:()=>{r=!0,e.removeMessageHandler(a);for(let{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(kt(e));i.clear()}}},jt=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},Mt=`deprecated-penpal`,Nt=e=>W(e)&&`penpal`in e,Pt=e=>e.split(`.`),Ft=e=>e.join(`.`),It=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Lt=e=>new H(`TRANSMISSION_FAILED`,`Unexpected message to translate: ${It(e)}`),Rt=e=>{if(e.penpal===`syn`)return{namespace:U,channel:void 0,type:`SYN`,participantId:Mt};if(e.penpal===`ack`)return{namespace:U,channel:void 0,type:`ACK2`};if(e.penpal===`call`)return{namespace:U,channel:void 0,type:`CALL`,id:e.id,methodPath:Pt(e.methodName),args:e.args};if(e.penpal===`reply`)return e.resolution===`fulfilled`?{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,value:e.returnValue}:{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw Lt(e)},zt=e=>{if(gt(e))return{penpal:`synAck`,methodNames:e.methodPaths.map(Ft)};if(vt(e))return{penpal:`call`,id:e.id,methodName:Ft(e.methodPath),args:e.args};if(yt(e))return e.isError?{penpal:`reply`,id:e.callId,resolution:`rejected`,...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:`reply`,id:e.callId,resolution:`fulfilled`,returnValue:e.value};throw Lt(e)},Bt=({messenger:e,methods:t,timeout:n,channel:r,log:i})=>{let a=Tt(),o,s=[],c=!1,l=xt(t),{promise:u,resolve:d,reject:f}=jt(),p=n===void 0?void 0:setTimeout(()=>{f(new H(`CONNECTION_TIMEOUT`,`Connection timed out after ${n}ms`))},n),m=()=>{for(let e of s)e()},h=()=>{if(c)return;s.push(wt(e,t,r,i));let{remoteProxy:n,destroy:a}=At(e,r,i);s.push(a),clearTimeout(p),c=!0,d({remoteProxy:n,destroy:m})},g=()=>{let t={namespace:U,type:`SYN`,channel:r,participantId:a};i?.(`Sending handshake SYN`,t);try{e.sendMessage(t)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message))}},_=t=>{if(i?.(`Received handshake SYN`,t),t.participantId===o&&o!==Mt||(o=t.participantId,g(),!(a>o||o===Mt)))return;let n={namespace:U,channel:r,type:`ACK1`,methodPaths:l};i?.(`Sending handshake ACK1`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}},ee=t=>{i?.(`Received handshake ACK1`,t);let n={namespace:U,channel:r,type:`ACK2`};i?.(`Sending handshake ACK2`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}h()},v=e=>{i?.(`Received handshake ACK2`,e),h()},y=e=>{G(e)&&_(e),gt(e)&&ee(e),_t(e)&&v(e)};return e.addMessageHandler(y),s.push(()=>e.removeMessageHandler(y)),g(),u},Vt=e=>{let t=!1,n;return(...r)=>(t||(t=!0,n=e(...r)),n)},Ht=new WeakSet,Ut=({messenger:e,methods:t={},timeout:n,channel:r,log:i})=>{if(!e)throw new H(`INVALID_ARGUMENT`,`messenger must be defined`);if(Ht.has(e))throw new H(`INVALID_ARGUMENT`,`A messenger can only be used for a single connection`);Ht.add(e);let a=[e.destroy],o=Vt(t=>{if(t){let t={namespace:U,channel:r,type:`DESTROY`};try{e.sendMessage(t)}catch{}}for(let e of a)e();i?.(`Connection destroyed`)}),s=e=>ht(e)&&e.channel===r;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:s}),e.addMessageHandler(e=>{bt(e)&&o(!1)});let{remoteProxy:c,destroy:l}=await Bt({messenger:e,methods:t,timeout:n,channel:r,log:i});return a.push(l),c}catch(e){throw o(!0),e}})(),destroy:()=>{o(!0)}}},Wt=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new H(`INVALID_ARGUMENT`,`remoteWindow must be defined`);this.#e=e,this.#t=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#n=e,this.#r=t,window.addEventListener(`message`,this.#d)};sendMessage=(e,t)=>{if(G(e)){let n=this.#l(e);this.#e.postMessage(e,{targetOrigin:n,transfer:t});return}if(gt(e)||this.#s){let n=this.#s?zt(e):e,r=this.#l(e);this.#e.postMessage(n,{targetOrigin:r,transfer:t});return}if(_t(e)){let{port1:n,port2:r}=new MessageChannel;this.#o=n,n.addEventListener(`message`,this.#f),n.start();let i=[r,...t||[]],a=this.#l(e);this.#e.postMessage(e,{targetOrigin:a,transfer:i});return}if(this.#o){this.#o.postMessage(e,{transfer:t});return}throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the MessagePort is not connected`)};addMessageHandler=e=>{this.#a.add(e)};removeMessageHandler=e=>{this.#a.delete(e)};destroy=()=>{window.removeEventListener(`message`,this.#d),this.#u(),this.#a.clear()};#c=e=>this.#t.some(t=>t instanceof RegExp?t.test(e):t===e||t===`*`);#l=e=>{if(G(e))return`*`;if(!this.#i)throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the remote origin is not established`);return this.#i===`null`&&this.#t.includes(`*`)?`*`:this.#i};#u=()=>{this.#o?.removeEventListener(`message`,this.#f),this.#o?.close(),this.#o=void 0};#d=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#e){if(Nt(r)){this.#n?.(`Please upgrade the child window to the latest version of Penpal.`),this.#s=!0;try{r=Rt(r)}catch(e){this.#n?.(`Failed to translate deprecated message: ${e.message}`);return}}if(this.#r?.(r)){if(!this.#c(t)){this.#n?.(`Received a message from origin \`${t}\` which did not match allowed origins \`[${this.#t.join(`, `)}]\``);return}if(G(r)&&(this.#u(),this.#i=t),_t(r)&&!this.#s){if(this.#o=n[0],!this.#o){this.#n?.(`Ignoring ACK2 because it did not include a MessagePort`);return}this.#o.addEventListener(`message`,this.#f),this.#o.start()}for(let e of this.#a)e(r)}}};#f=({data:e})=>{if(this.#r?.(e))for(let t of this.#a)t(e)}};let q={RENDERED:`RENDERED`,RESIZE:`RESIZE`,DESTROY:`DESTROY`,BEFORE_CLOSE:`BEFORE_CLOSE`,DISPLAY:`DISPLAY`},Gt=new Set([`onClose`,`onDestroy`,`onRendered`,`onRender`,`onDisplay`,`onResize`,`onProps`]);function J(e){e&&e.remove()}function Y(e){return typeof e==`number`?`${e}px`:e}let Kt={"monei-card-input":`allow-scripts allow-forms allow-same-origin`,"monei-bizum":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-bizum-button":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-paypal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-payment-request":`allow-scripts allow-forms allow-same-origin allow-popups`,"monei-payment-modal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-google-pay":`allow-scripts allow-forms allow-same-origin allow-popups`};function qt(e){if(!e)throw Error(`render() requires a container element or selector`);if(typeof e==`string`){let t=document.querySelector(e);if(!t)throw Error(`Container not found: ${e}`);return t}return e}function Jt(e){return`${e}-${Math.random().toString(36).slice(2,9)}`}function Yt(e,t){let n=[[`onClose`,q.DESTROY],[`onDestroy`,q.DESTROY],[`onRendered`,q.RENDERED],[`onResize`,q.RESIZE]];for(let[r,i]of n)t.on(i,(...t)=>{let n=e[r];typeof n==`function`&&n(...t)})}function Xt(e){let{props:t,options:n,state:r,dispatchMap:i}=e,a={},o=new Set(n.computedProps?Object.keys(n.computedProps):[]);if(n.computedProps)for(let[e,o]of Object.entries(n.computedProps)){let n=o.factory({props:t,state:r});o.type===`function`?i.set(e,n):a[e]=n}for(let[e,n]of Object.entries(t))Gt.has(e)||o.has(e)||(typeof n==`function`?i.set(e,n):a[e]=n);let s=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);return{dataProps:a,functionNames:[...i.keys()].filter(e=>!s.has(e))}}function Zt(e,t){let n={dispatchMap:new Map,connection:null,remote:null,containerEl:null,frame:null,destroyed:!1,ownsContainer:!1,pendingPropsUpdate:null,pendingRemovals:new Set},r=!1,i=!1;n.dispatchMap.set(`resize`,i=>{let{autoResize:a}=t,o={};i.width!==void 0&&(!a||a.width===!0)&&(o.width=i.width),i.height!==void 0&&(!a||a.height===!0)&&(o.height=i.height),n.frame&&(o.width!==void 0&&(n.frame.style.width=Y(o.width)),o.height!==void 0&&(n.frame.style.height=Y(o.height))),r||(r=!0,e.event.trigger(q.RENDERED)),e.event.trigger(q.RESIZE,o)}),n.dispatchMap.set(`close`,()=>e.close()),n.dispatchMap.set(`show`,()=>{n.frame&&(n.frame.style.display=``)}),n.dispatchMap.set(`hide`,()=>{n.frame&&(n.frame.style.display=`none`)}),n.dispatchMap.set(`getParentDomain`,()=>window.location.origin),n.dispatchMap.set(`focus`,()=>{n.frame&&n.frame.focus()}),e.render=async a=>{if(n.destroyed)throw Error(`Component is destroyed`);if(n.frame)throw Error(`Component already rendered`);let o=qt(a),s=Jt(t.tag),c=o.ownerDocument,l=c.createElement(`iframe`);l.src=t.url,l.setAttribute(`title`,t.tag.replace(/-/g,`_`)),l.setAttribute(`allowpaymentrequest`,`true`),l.setAttribute(`allow`,`payment`),l.style.border=`none`;let u=Kt[t.tag]??`allow-scripts allow-forms allow-same-origin`;l.setAttribute(`sandbox`,u),i||=(Yt(e.props,e.event),!0);let d=[],f={on(t,n){let r=e.event.on(t,n);return d.push(r),r},once(t,n){let r=e.event.once(t,n);return d.push(r),r},trigger(t,...n){e.event.trigger(t,...n)},off(t,n){e.event.off(t,n)},destroy(){e.event.destroy()}},p,m,h={},g=[];try{t.prerenderTemplate&&(p=t.prerenderTemplate({uid:s,frame:l,placeholder:void 0,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),t.containerTemplate&&(m=t.containerTemplate({uid:s,frame:l,placeholder:p,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),{dataProps:h,functionNames:g}=Xt({props:e.props,options:t,state:e.state,dispatchMap:n.dispatchMap})}catch(e){for(let e of d)e.cancel();let t=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())t.has(e)||n.dispatchMap.delete(e);throw e}n.frame=l;let _=()=>{l.contentWindow&&l.contentWindow.postMessage({type:`__monei_bridge_init__`,props:h,functionNames:g},new URL(t.url).origin)};try{if(m?(o.appendChild(m),n.containerEl=m,n.ownsContainer=!0):(o.appendChild(l),n.containerEl=o),e.event.trigger(q.DISPLAY),l.addEventListener(`load`,_),l.contentWindow&&_(),!l.contentWindow)throw Error(`iframe contentWindow is not available — frame may not be in the DOM`);let i=Ut({messenger:new Wt({remoteWindow:l.contentWindow,allowedOrigins:[new URL(t.url).origin]}),methods:{callParent:(e,t)=>{let r=n.dispatchMap.get(e);if(!r)throw Error(`Unknown parent method: ${e}`);return r(...t)}}});n.connection=i;let a;try{a=await i.promise}catch(e){if(n.destroyed)return;throw e}if(n.destroyed||(n.remote=a,e.state.__callChild=a.callChild,await a.updateProps(h,g),n.destroyed))return;if(n.pendingPropsUpdate){let e=n.pendingPropsUpdate;n.pendingPropsUpdate=null;let t=new Set(e.functionNames??[]),r=new Map;for(let i of Object.keys(e.dataProps))n.dispatchMap.has(i)&&!t.has(i)&&(r.set(i,n.dispatchMap.get(i)),n.pendingRemovals.add(i));if(await n.remote.updateProps(e.dataProps,e.functionNames),n.destroyed)return;for(let[e,t]of r)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}r||(r=!0,e.event.trigger(q.RENDERED)),l.removeEventListener(`load`,_)}catch(t){l.removeEventListener(`load`,_);for(let e of d)e.cancel();delete e.state.__callChild,n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame=null,n.ownsContainer&&n.containerEl?n.containerEl.remove():l.parentNode&&l.remove(),n.containerEl=null,n.ownsContainer=!1,n.pendingPropsUpdate=null,n.pendingRemovals.clear();let i=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())i.has(e)||n.dispatchMap.delete(e);throw r=!1,t}},e.updateProps=async r=>{if(n.destroyed)throw Error(`Component is destroyed`);let i=Qt(r,t.aliases);if(Object.assign(e.props,i),!n.frame)return;let a={},o=[],s=new Set(t.computedProps?Object.keys(t.computedProps):[]),c=new Map;for(let[e,t]of Object.entries(i))if(!(Gt.has(e)||s.has(e)))if(typeof t==`function`){let r=n.pendingPropsUpdate!=null&&e in n.pendingPropsUpdate.dataProps,i=n.pendingRemovals.has(e);(!n.dispatchMap.has(e)||r||i)&&o.push(e),n.dispatchMap.set(e,t)}else n.dispatchMap.has(e)&&n.remote&&(c.set(e,n.dispatchMap.get(e)),n.pendingRemovals.add(e)),a[e]=t;let l=o.length>0?o:void 0;if(n.remote){await n.remote.updateProps(a,l);for(let[e,t]of c)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}else{if(n.pendingPropsUpdate||={dataProps:{},functionNames:void 0},Object.assign(n.pendingPropsUpdate.dataProps,a),n.pendingPropsUpdate.functionNames){let e=Object.keys(a);if(e.length>0){let t=new Set(e);n.pendingPropsUpdate.functionNames=n.pendingPropsUpdate.functionNames.filter(e=>!t.has(e)),n.pendingPropsUpdate.functionNames.length===0&&(n.pendingPropsUpdate.functionNames=void 0)}}if(l){for(let e of l)delete n.pendingPropsUpdate.dataProps[e];n.pendingPropsUpdate.functionNames=[...n.pendingPropsUpdate.functionNames??[],...l]}}},e.destroy=async()=>{n.destroyed||(n.destroyed=!0,e.event.trigger(q.DESTROY),n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame&&=(n.frame.remove(),null),n.ownsContainer&&n.containerEl&&n.containerEl.remove(),e.event.destroy(),n.dispatchMap.clear())},e.close=async()=>{await e.destroy()},e.__renderState=n}function Qt(e,t){if(!t)return e;let n=new Map;for(let[e,r]of Object.entries(t))n.set(r,e);let r={};for(let[t,i]of Object.entries(e)){let e=n.get(t)??t;r[e]=i}return r}function X(e){class t{constructor(t){this.state={},this.event=new tt;let n=Qt(t,e.aliases);e.defaultProps?this.props={...e.defaultProps({event:this.event}),...n}:this.props={...n},e.validate&&e.validate({props:this.props}),Zt(this,e)}async render(e){throw Error(`render() not attached`)}async updateProps(e){throw Error(`updateProps() not attached — call render() first`)}async close(){throw Error(`close() not attached`)}async destroy(){throw Error(`destroy() not attached`)}driver(e,n){return ut(e,t,n)}}function n(e){return this instanceof n?new t(e):new n(e)}return n.prototype=t.prototype,n.driver=function(e,t){return ut(e,n,t)},t.prototype.__options=e,n}let Z=function(e){return e.VISIBLE=`is-visible`,e.INVISIBLE=`is-invisible`,e}({});function $t(e={}){let{background:t=`#fff`,overflow:n,borderRadius:r,fadeOnRender:i=!0,allowTransparency:a=!1,modal:o=!1}=e;return function({uid:e,frame:s,placeholder:c,doc:l,props:u,event:d,dimensions:{width:f,height:p}}){if(!s)return;a&&(s.setAttribute(`allowtransparency`,`true`),s.style.background=`transparent`);let m=l.createElement(`div`);m.setAttribute(`id`,e);let h=l.createElement(`style`);if(u?.cspNonce&&h.setAttribute(`nonce`,u.cspNonce),o){let t=l.createElement(`div`);t.classList.add(`backdrop`),h.appendChild(l.createTextNode(`
11
+ `),S.compileShader(e),!S.getShaderParameter(e,S.COMPILE_STATUS))throw Error(`Vertex shader compilation failed: `+S.getShaderInfoLog(e));if(S.compileShader(t),!S.getShaderParameter(t,S.COMPILE_STATUS))throw Error(`Fragment shader compilation failed: `+S.getShaderInfoLog(t));let n=S.createProgram();if(!n)throw Error(`Failed to create shader program`);if(S.attachShader(n,e),S.attachShader(n,t),S.linkProgram(n),!S.getProgramParameter(n,S.LINK_STATUS))throw Error(`Shader program linking failed: `+S.getProgramInfoLog(n));S.useProgram(n);let r=new Float32Array(548),i=2*Math.PI/137;for(let e=0;e<137;e++){let t=e*i;r[4*e]=0,r[4*e+1]=0,r[4*e+2]=Math.cos(t)*(x.width/2),r[4*e+3]=Math.sin(t)*(x.height/2)}let a=S.createBuffer();S.bindBuffer(S.ARRAY_BUFFER,a),S.bufferData(S.ARRAY_BUFFER,r,S.STATIC_DRAW);let o=S.getAttribLocation(n,`position`);S.enableVertexAttribArray(o),S.vertexAttribPointer(o,2,S.FLOAT,!1,0,0),S.viewport(0,0,x.width,x.height),S.clearColor(0,0,0,1),S.clear(S.COLOR_BUFFER_BIT),S.drawArrays(S.LINES,0,274);let s=new Uint8ClampedArray(x.width*x.height*4);return S.readPixels(0,0,x.width,x.height,S.RGBA,S.UNSIGNED_BYTE,s),new ImageData(s,x.width,x.height)}catch{return new ImageData(1,1)}finally{S&&(S.bindBuffer(S.ARRAY_BUFFER,null),S.useProgram(null),S.viewport(0,0,S.drawingBufferWidth,S.drawingBufferHeight),S.clearColor(0,0,0,0))}}())),x.width,x.height).data.toString()).toString()}}catch{return{webgl:`unsupported`}}},webrtc:async function(e){return new Promise((t=>{try{let n=window.RTCPeerConnection||window.webkitRTCPeerConnection||window.mozRTCPeerConnection;if(!n)return void t({supported:!1,error:`WebRTC not supported`});let r=new n({iceCandidatePoolSize:1,iceServers:[]});r.createDataChannel(``),(async()=>{try{let n=await r.createOffer({offerToReceiveAudio:!0,offerToReceiveVideo:!0});await r.setLocalDescription(n);let i=n.sdp||``,a=[...new Set((i.match(/extmap:\d+ [^\n\r]+/g)||[]).map((e=>e.replace(/extmap:\d+ /,``))))].sort(),o=e=>{let t=i.match(RegExp(`m=${e} [^\\s]+ [^\\s]+ ([^\\n\\r]+)`));return t?t[1].split(` `):[]},s=(e,t)=>t.map((t=>{let n=RegExp(`(rtpmap|fmtp|rtcp-fb):${t} (.+)`,`g`),r=[...i.matchAll(n)];if(!r.length)return null;let a={};return r.forEach((t=>{let[n,r,i]=t,o=i.split(`/`);r===`rtpmap`?(a.mimeType=`${e}/${o[0]}`,a.clockRate=+o[1],e===`audio`&&(a.channels=+o[2]||1)):r===`rtcp-fb`?(a.feedbackSupport=a.feedbackSupport||[],a.feedbackSupport.push(i)):r===`fmtp`&&(a.sdpFmtpLine=i)})),a})).filter(Boolean),c=s(`audio`,o(`audio`)),l=s(`video`,o(`video`)),u={audio:{count:c.length,hash:h(C(c))},video:{count:l.length,hash:h(C(l))},extensionsHash:h(C(a))},d=e?.timeout||5e3,f=Math.floor(.9*d),p=await new Promise((e=>{let t=setTimeout((()=>{r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,timeout:!0})}),f),n=i=>{let a=i.candidate;a&&a.candidate&&(clearTimeout(t),r.removeEventListener(`icecandidate`,n),r.close(),e({supported:!0,...u,candidateType:a.type||``}))};r.addEventListener(`icecandidate`,n)}));t({details:p,hash:h(C(p))})}catch(e){r.close(),t({supported:!0,error:`WebRTC offer failed: ${e.message}`})}})()}catch(e){t({supported:!1,error:`WebRTC error: ${e.message}`})}}))},speech:async function(){return new Promise((e=>{try{if(typeof window>`u`||!window.speechSynthesis||typeof window.speechSynthesis.getVoices!=`function`)return void e({supported:!1,error:`Speech Synthesis API not supported`});let t=!1,n=null,r=r=>{if(!t){t=!0,n&&clearTimeout(n);try{let t=r.map((e=>{let t=e=>e.replace(/\\/g,`\\\\`).replace(/,/g,`\\,`);return[t(e.voiceURI||``),t(e.name||``),t(e.lang||``),e.localService?`1`:`0`,e.default?`1`:`0`].join(`,`)}));t.sort();let n={voiceCount:r.length,voicesHash:h(C(t))};e({details:n,hash:h(C(n))})}catch(t){e({supported:!0,error:`Voice processing failed: ${t.message}`})}}},i=window.speechSynthesis.getVoices();if(i.length>0)return void r(i);n=setTimeout((()=>{r(window.speechSynthesis.getVoices())}),800);let a=()=>{window.speechSynthesis.removeEventListener(`voiceschanged`,a),r(window.speechSynthesis.getVoices())};window.speechSynthesis.addEventListener(`voiceschanged`,a)}catch(t){e({supported:!1,error:`Speech Synthesis error: ${t.message}`})}}))}},ge={mathml:async function(){return new Promise((e=>{try{g((async({iframe:t})=>{try{if(!function(e){try{let t=e.createElement(`math`);t.innerHTML=`<mrow><mi>x</mi></mrow>`,t.style.position=`absolute`,t.style.visibility=`hidden`,e.body.appendChild(t);let n=t.getBoundingClientRect();return e.body.removeChild(t),n.width>0&&n.height>0}catch{return!1}}(t))return void e({supported:!1,error:`MathML not supported`});let n=[w(`integral`,`<msubsup><mo>∫</mo><mi>a</mi><mi>b</mi></msubsup><mfrac><mrow><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow><mrow><mi>g</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></mfrac><mi>dx</mi>`),w(`fraction`,`<mfrac><mrow><mi>π</mi><mo>×</mo><msup><mi>r</mi><mn>2</mn></msup></mrow><mrow><mn>2</mn><mi>σ</mi></mrow></mfrac>`),w(`matrix`,`<mo>[</mo><mtable><mtr><mtd><mi>α</mi></mtd><mtd><mi>β</mi></mtd></mtr><mtr><mtd><mi>γ</mi></mtd><mtd><mi>δ</mi></mtd></mtr></mtable><mo>]</mo>`),pe(),...me()],r=[],i=``;n.forEach(((e,n)=>{let a=function(e,t){try{let n=t.createElement(`math`);n.innerHTML=e.replace(/<\/?math>/g,``),n.style.whiteSpace=`nowrap`,n.style.position=`absolute`,n.style.visibility=`hidden`,n.style.top=`-9999px`,t.body.appendChild(n);let r=n.getBoundingClientRect(),i=(t.defaultView||window).getComputedStyle(n),a={dimensions:{width:r.width,height:r.height},fontInfo:{fontFamily:i.fontFamily,fontSize:i.fontSize,fontWeight:i.fontWeight,fontStyle:i.fontStyle,lineHeight:i.lineHeight,fontVariant:i.fontVariant||`normal`,fontStretch:i.fontStretch||`normal`,fontSizeAdjust:i.fontSizeAdjust||`none`,textRendering:i.textRendering||`auto`,fontFeatureSettings:i.fontFeatureSettings||`normal`,fontVariantNumeric:i.fontVariantNumeric||`normal`,fontKerning:i.fontKerning||`auto`}};return t.body.removeChild(n),a}catch(e){return{error:e.message}}}(e,t);r.push({width:a.dimensions.width,height:a.dimensions.height}),n===0&&a.fontInfo&&(i=h(C(a.fontInfo)))}));let a={fontStyleHash:i,dimensions:r};e({details:a,hash:h(C(a))})}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}catch(t){e({supported:!1,error:`MathML error: ${t.message}`})}}))}},_e={},ve={timeout:`true`};function ye(e,t){let n=ae();if(n.name===`unknown`&&t){let e=t.system?.browser;e!=null&&e.name&&(n={name:String(e.name),version:String(e.version||`unknown`)})}let r=n.name.toLowerCase(),i=parseInt(n.version.split(`.`)[0]||`0`,10),a=[...e?.exclude||[]],o=[...new Set([...e?.stabilize||[],`always`])];for(let e of o){let t=s[e];if(t)for(let e of t)`browsers`in e&&!e.browsers?.some((e=>{let t=e.match(/(.+?)(>=)(\d+)/);return t?r===t[1]&&i>=+t[3]:r===e}))||a.push(...e.exclude)}return a}function be(e,t){let n=ye(t,e),r=t?.include||[];return function e(t,i=``){let a={};for(let[o,s]of Object.entries(t)){let t=i?`${i}.${o}`:o;if(typeof s!=`object`||Array.isArray(s)||s===null){let e=n.some((e=>t.startsWith(e))),i=r.some((e=>t.startsWith(e)));e&&!i||(a[o]=s)}else{let n=e(s,t);Object.keys(n).length>0&&(a[o]=n)}}return a}(e)}let xe=`visitor_id`;function Se(e){return e.storage_property_name?e.storage_property_name:e.property_name_factory(xe)}let Ce=`${i}_${xe}`;function we(e,t){try{localStorage.setItem(Se(t),e)}catch{}}let Te=`cache`;function T(e){try{let t=localStorage.getItem(e.property_name_factory(Te));return JSON.parse(t)||{}}catch{}return{}}function Ee(e){return e.cache_lifetime_in_ms>r?Date.now()+r:Date.now()+e.cache_lifetime_in_ms}var E=class extends Error{constructor(e){super(`HTTP error! status: ${e}`),this.status=e}};let D=null,O=null;async function De(e,t,n,r){let i=await fetch(e,{method:`POST`,headers:{"x-api-key":n.api_key,Authorization:`custom-authorized`,"Content-Type":`application/json`},body:JSON.stringify(t)});if(!i.ok)throw new E(i.status);let a=await i.json();return a.visitorId&&a.visitorId!==r&&we(a.visitorId,n),O=a,function(e,t){!e.cache_api_call||!e.cache_lifetime_in_ms||(function(e,t){let n={...T(e),...t};try{localStorage.setItem(e.property_name_factory(Te),JSON.stringify(n))}catch{}})(e,{apiResponseExpiry:Ee(e),apiResponse:t})}(n,a),a}let Oe=(e,t)=>{if(e.cache_api_call){if(O)return Promise.resolve(O);let t=function(e){let t=T(e);if(t&&t.apiResponse&&t.apiResponseExpiry&&Date.now()<=t.apiResponseExpiry)return t.apiResponse}(e);if(t)return Promise.resolve(t);if(D)return D}let n=`${e.api_endpoint||a}/thumbmark`,r=function(e){try{let t=Se(e),n=localStorage.getItem(t);return n||t===Ce||(n=localStorage.getItem(Ce),n&&we(n,e)),n}catch{return null}}(e),i={components:t,options:e,clientHash:h(C(t)),version:`1.7.6`};if(r&&(i.visitorId=r),e.metadata){let t=typeof e.metadata==`function`?e.metadata():e.metadata;t&&((typeof t==`string`?t.length:JSON.stringify(t).length)>1e3?console.error(`ThumbmarkJS: Metadata exceeds 1000 characters. Skipping metadata.`):i.metadata=t)}let o=e.timeout||5e3,s=async function(e,t,n,r){for(let i=0;i<3;i++){i>0&&await new Promise((e=>setTimeout(e,200*i)));try{return await De(e,t,n,r)}catch(e){if(e instanceof E||i===2)throw e}}throw Error(`Unreachable`)}(n,i,e,r).finally((()=>{D=null})),c=new Promise((t=>{setTimeout((()=>{t(T(e)?.apiResponse||{info:{timed_out:!0},...r&&{visitorId:r}})}),o)}));return D=Promise.race([s,c]),D};async function ke(e,t={}){var n;if(typeof document>`u`||typeof window>`u`)return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:`Browser environment required`}]};try{let r={...o,...e},i=[],s=r.logging&&!sessionStorage.getItem(`_tmjs_l`)&&Math.random()<1e-4,{elapsed:c,resolvedComponents:l,errors:u}=await Ae({...he,..._e,...t},r);i.push(...u);let d={},f={};if(s||r.experimental){let{elapsed:e,resolvedComponents:t,errors:n}=await Ae(ge,r);d=t,f=e,i.push(...n)}let p=r.api_key?Oe(r,l):null,m=null;if(p)try{m=await p}catch(e){if(e instanceof E&&e.status===403)return{error:[{type:`api_unauthorized`,message:`Invalid API key or quota exceeded`}],components:{},info:{},version:`1.7.6`,thumbmark:``};i.push({type:e instanceof E?`api_error`:`network_error`,message:e instanceof Error?e.message:String(e)})}(n=m?.info)!=null&&n.timed_out&&i.push({type:`api_timeout`,message:`API request timed out`});let g={...c,...f},_=r.performance?{elapsed:g}:{},ee=be(m?.components||{},r),v={...l,...ee},y=m?.info||{uniqueness:{score:`api only`}},te=m?.thumbmark??h(C(v));return s&&async function(e,t,n,r={},i=[]){let o=`${a}/log`,s={thumbmark:e,components:t,experimental:r,version:`1.7.6`,options:n,path:(window==null?void 0:window.location)?.pathname,...i.length>0&&{errors:i}};sessionStorage.setItem(`_tmjs_l`,`1`);try{await fetch(o,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(s)})}catch{}}(te,v,r,d,i).catch((()=>{})),{...m?.visitorId&&{visitorId:m.visitorId},thumbmark:te,components:v,info:y,version:`1.7.6`,..._,...i.length>0&&{error:i},...Object.keys(d).length>0&&r.experimental&&{experimental:d},...m?.requestId&&{requestId:m.requestId},...m?.metadata&&{metadata:m.metadata}}}catch(e){return{thumbmark:``,components:{},info:{},version:`1.7.6`,error:[{type:`fatal`,message:e instanceof Error?e.message:String(e)}]}}}async function Ae(e,t){let n={...o,...t},r=ye(n).filter((e=>!e.includes(`.`))),i=Object.entries(e).filter((([e])=>!(n?.exclude)?.includes(e))).filter((([e])=>!r.includes(e))).filter((([e])=>(n?.include)?.some((e=>e.includes(`.`)))?(n?.include)?.some((t=>t.startsWith(e))):n?.include?.length===0||(n?.include)?.includes(e))),a=i.map((([e])=>e)),s=await function(e,t,n){return Promise.all(e.map((e=>{let r=performance.now();return Promise.race([e.then((e=>({value:e,elapsed:performance.now()-r}))).catch((e=>({value:n,elapsed:performance.now()-r,error:e instanceof Error?e.message:String(e)}))),(i=t,a=n,new Promise((e=>{setTimeout((()=>e(a)),i)}))).then((e=>({value:e,elapsed:performance.now()-r,error:`timeout`})))]);var i,a})))}(i.map((([e,n])=>n(t))),n?.timeout||5e3,ve),c={},l={},u=[];return s.forEach(((e,t)=>{let n=a[t];c[n]=e.elapsed??0,e.error===`timeout`?u.push({type:`component_timeout`,message:`Component '${n}' timed out`,component:n}):e.error&&u.push({type:`component_error`,message:e.error,component:n}),e.value!=null&&(l[n]=e.value)})),{elapsed:c,resolvedComponents:be(l,n),errors:u}}var je=class{constructor(e){this.options={...o,...e},this.customComponents={}}async get(e){return ke({...this.options,...e},this.customComponents)}getVersion(){return`1.7.6`}includeComponent(e,t){this.customComponents[e]=t}};let k=(e,t)=>{if(e==null)return t;if(typeof e==`number`)return e;let n=parseInt(e);return isNaN(n)?t:n},Me=(e,t)=>e==null?t:typeof e==`number`?`${e}px`:e||t;var Ne=n({fixLocalstorage:()=>Ie,getClientEnv:()=>M,getClientFingerprint:()=>P,isMethodSupported:()=>Ue,loadScript:()=>Pe,parsePx:()=>k,stringify:()=>Fe,toCssPx:()=>Me,transformStyle:()=>A,validateComponentProps:()=>F,withError:()=>He});let A=e=>Object.keys(e).reduce((t,n)=>(typeof e[n]==`string`?t[n]=e[n]:t[n]=`${e[n]}px`,t),{}),Pe=(e,t,n,r)=>new Promise((i,a)=>{let o=Array.from(document.scripts).find(t=>t.src===e);if(o)if(r)o.remove();else{i(o);return}let s=document.createElement(`script`);s.src=e,s.onload=()=>i(s),s.onerror=e=>a(e),t&&s.setAttribute(`nonce`,t),n&&Object.keys(n).forEach(e=>{n[e]&&(s.dataset[e]=n[e])}),document.head.appendChild(s)}),Fe=e=>Object.keys(e).reduce((t,n)=>(e[n]!==void 0&&t.push(`${encodeURIComponent(n)}=${encodeURIComponent(e[n])}`),t),[]).join(`&`),Ie=()=>{let e;try{({localStorage:e}=window)}catch{let t=(()=>{let e=new Map;return{getItem(t){return e.get(t)},setItem:function(t,n){e.set(t,n)},clear:function(){e=new Map},removeItem:function(t){e.delete(t)}}})();Object.defineProperty(window,`localStorage`,{value:t}),e=t}return e},Le=()=>{let e,t=Ie();try{e=t.getItem(`i18nextLng`)}catch{}return e?e.split(`-`)[0]:``},j=e=>{try{return String(e()??``)}catch{return``}},M=()=>{let e=[window.screen.colorDepth,window.screen.height,window.screen.width,new Date().getTimezoneOffset(),Le(),j(()=>Intl.DateTimeFormat().resolvedOptions().timeZone),j(()=>window.devicePixelRatio),j(()=>navigator.hardwareConcurrency),j(()=>navigator.deviceMemory),j(()=>navigator.maxTouchPoints),j(()=>navigator.platform),j(()=>navigator.languages?.join(`,`))].join(`|`);return window.btoa(e)},Re=`_monei_fp`,ze=e=>{if(typeof crypto<`u`&&typeof crypto.getRandomValues==`function`){let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>(e%16).toString(16)).join(``)}return Array.from({length:e},()=>Math.floor(Math.random()*16).toString(16)).join(``)},N=null,Be=async()=>{if(N)return{seed:N};try{let e=Ie();if(N=e.getItem(Re),!N){N=ze(32);try{e.setItem(Re,N)}catch{}}}catch{N=ze(32)}return{seed:N}},Ve=new je({logging:!1});Ve.includeComponent(`persistent_seed`,Be);let P=async()=>{let[,e]=await He(Ve.get());return e?.thumbmark??``},He=async e=>{try{return[void 0,await e]}catch(e){return[e,void 0]}},Ue=(e,t)=>e.paymentMethods&&e.paymentMethods.includes(t),F=({props:e})=>{if(!e.paymentId&&!(e.accountId&&e.amount&&e.currency))throw Error(`You need to provide paymentId or accountId amount and currency`)},We={}.env?.STAGE||`prod`,I={}.env?.DOMAIN||`http://localhost:3001`,L={}.env?.VERSION||`v1`,Ge={domain:I,version:L,stage:We,isProduction:We===`prod`,paymentPageUrl:`${I}/${L}/payment-page/`,cardInputUrl:`${I}/${L}/inner-card-input/`,paymentModalUrl:`${I}/${L}/inner-payment-modal/`,paypalUrl:`${I}/${L}/inner-paypal/`,bizumUrl:`${I}/${L}/inner-bizum/`,bizumButtonUrl:`${I}/${L}/inner-bizum-button/`,paymentRequestUrl:`${I}/${L}/inner-payment-request/`},Ke={local:{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},"local-prod":{domain:`http://card-input.localhost:1355`,paymentPageUrl:`http://payment-page.localhost:1355/`,cardInputUrl:`http://card-input.localhost:1355/`,paymentModalUrl:`http://payment-modal.localhost:1355/`,paypalUrl:`http://paypal.localhost:1355/`,bizumUrl:`http://bizum.localhost:1355/`,bizumButtonUrl:`http://bizum-button.localhost:1355/`,paymentRequestUrl:`http://payment-request.localhost:1355/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},tunnel:{domain:`https://card-input.monei-dev-tunnel.com`,paymentPageUrl:`https://payment-page.monei-dev-tunnel.com/`,cardInputUrl:`https://card-input.monei-dev-tunnel.com/`,paymentModalUrl:`https://payment-modal.monei-dev-tunnel.com/`,paypalUrl:`https://paypal.monei-dev-tunnel.com/`,bizumUrl:`https://bizum.monei-dev-tunnel.com/`,bizumButtonUrl:`https://bizum-button.monei-dev-tunnel.com/`,paymentRequestUrl:`https://payment-request.monei-dev-tunnel.com/`,apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`},dev:{apiUrl:`https://api.monei-dev.com/v1`,secureDomain:`https://secure.monei-dev.com`,rootDomain:`monei-dev.com`},prod:{apiUrl:`https://api.monei.com/v1`,secureDomain:`https://secure.monei.com`,rootDomain:`monei.com`}},R={...Ge,...Ke[We]};var qe=n({confirmPayment:()=>Xe,createApplePaySession:()=>$e,createPayment:()=>Ze,createToken:()=>Je,getPayment:()=>Ye,getPaymentMethods:()=>V,sendPaymentReceipt:()=>Qe,validateBizumPhone:()=>et});let z=async(e,{method:t=`GET`,headers:n,body:r}={})=>{t===`POST`&&(n={"Content-Type":`application/json`,...n});let i=await fetch(`${R.apiUrl}${e}`,{method:t,headers:n,body:r?JSON.stringify(r):void 0}),[,a]=await He(i.json());if(!i.ok)throw a||Error(i.statusText);return a},B={},V=async({accountId:e,paymentId:t})=>{let n;if(t)n={paymentId:t};else if(e)n={accountId:e};else throw Error(`You need to provide paymentId or accountId`);let r=Fe(n);if(r in B)return B[r];let i=z(`/payment-methods?${r}`);return B[r]=i,i.catch(()=>delete B[r]),i},Je=async({paymentMethod:e,paymentId:t,sessionId:n,amount:r,currency:i,accountId:a,transactionType:o})=>{let s;if(t)s={paymentId:t,paymentMethod:e};else if(a)s={accountId:a,paymentMethod:e,sessionId:n,amount:r,currency:i,transactionType:o};else throw Error(`You need to provide paymentId or accountId`);let c=await z(`/tokens`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:s});return c.paymentToken&&!c.token&&(c.token=c.paymentToken),c},Ye=async e=>z(`/payments/${e}/client-get`),Xe=async({paymentId:e,...t})=>z(`/payments/${e}/client-confirm`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P()},body:t}),Ze=async({signature:e,...t})=>z(`/client-payments`,{method:`POST`,headers:{"X-Client-Env":M(),"X-Client-Fingerprint":await P(),"Client-Signature":e},body:t}),Qe=async({paymentId:e,customerEmail:t,signature:n,language:r})=>z(`/payments/${e}/client-receipt`,{method:`POST`,body:{customerEmail:t,signature:n,language:r}}),$e=async e=>z(`/apple-pay/sessions`,{method:`POST`,body:e}),et=async e=>z(`/bizum/validate-phone`,{method:`POST`,body:e});var tt=class{constructor(){this.listeners=new Map,this.destroyed=!1}on(e,t){if(this.destroyed)return{cancel:()=>{}};let n=this.listeners.get(e);return n||(n=new Set,this.listeners.set(e,n)),n.add(t),{cancel:()=>{n.delete(t)}}}once(e,t){let n=(...r)=>{this.off(e,n),t(...r)};return this.on(e,n)}trigger(e,...t){if(this.destroyed)return;let n=this.listeners.get(e);if(n)for(let e of n)try{e(...t)}catch(e){console.error(e)}}off(e,t){let n=this.listeners.get(e);n&&n.delete(t)}destroy(){this.destroyed=!0,this.listeners.clear()}};function nt(e){return({React:t})=>t.forwardRef(function(n,r){let i=t.useRef(null),a=t.useRef(null),o=t.useRef(!1),s=t.useRef({});return t.useLayoutEffect(()=>{let t=i.current;if(!t)return;let s=!1,c=new e({...n});return a.current=c,c.render(t).then(()=>{s||(rt(r,c),o.current=!0)}).catch(e=>{s||console.error(e)}),()=>{s=!0,c.destroy(),a.current=null,o.current=!1,rt(r,null)}},[]),t.useEffect(()=>{!o.current||!a.current||it(s.current,n)||(s.current={...n},a.current.updateProps({...n}).catch(at))}),t.createElement(`div`,{ref:i})})}function rt(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function it(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}function at(){}function ot(e){return()=>({template:`<div></div>`,inheritAttrs:!1,mounted(){let t=this.$el;this.__bridgeInstance=new e({...this.$attrs}),this.__bridgeInstance.render(t).catch(console.error)},watch:{$attrs:{handler(){this.__bridgeInstance&&this.__bridgeInstance.updateProps({...this.$attrs}).catch(()=>{})},deep:!0}},unmounted(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}})}function st(e){return({Component:t,NgModule:n,ElementRef:r,NgZone:i,Inject:a})=>{class o{constructor(e,t){this.props={},this.__bridgeInstance=null,this._prevProps={},this.elementRef=e,this.zone=t}getProps(){let e={...this.props},{zone:t}=this;for(let[n,r]of Object.entries(e))typeof r==`function`&&(e[n]=function(...e){return t.run(()=>r.apply(this,e))});return e}ngOnInit(){let t=this.elementRef.nativeElement;this.__bridgeInstance=new e(this.getProps()),this.__bridgeInstance.render(t).catch(console.error)}ngDoCheck(){this.__bridgeInstance&&!ct(this._prevProps,this.props)&&(this._prevProps={...this.props},this.__bridgeInstance.updateProps(this.getProps()).catch(()=>{}))}ngOnDestroy(){this.__bridgeInstance&&=(this.__bridgeInstance.destroy(),null)}}o.parameters=[[new a(r)],[new a(i)]],o.annotations=[new t({selector:e.prototype.__options?.tag||`bridge-component`,template:`<div></div>`,inputs:[`props`]})];class s{}return s.annotations=[new n({declarations:[o],exports:[o]})],s}}function ct(e,t){let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(e[r]!==t[r])return!1;return!0}let lt={react:nt,vue3:ot,angular:st};function ut(e,t,n){let r=lt[e];if(!r)throw Error(`Unknown driver: ${e}. Available: ${Object.keys(lt).join(`, `)}`);return r(t)(n)}var H=class extends Error{code;constructor(e,t){super(t),this.name=`PenpalError`,this.code=e}},dt=e=>({name:e.name,message:e.message,stack:e.stack,penpalCode:e instanceof H?e.code:void 0}),ft=({name:e,message:t,stack:n,penpalCode:r})=>{let i=r?new H(r,t):Error(t);return i.name=e,i.stack=n,i},pt=class{value;transferables;constructor(e,t){this.value=e,this.transferables=t?.transferables}},U=`penpal`,W=e=>typeof e==`object`&&!!e,mt=e=>typeof e==`function`,ht=e=>W(e)&&e.namespace===U,G=e=>e.type===`SYN`,gt=e=>e.type===`ACK1`,_t=e=>e.type===`ACK2`,vt=e=>e.type===`CALL`,yt=e=>e.type===`REPLY`,bt=e=>e.type===`DESTROY`,xt=(e,t=[])=>{let n=[];for(let r of Object.keys(e)){let i=e[r];mt(i)?n.push([...t,r]):W(i)&&n.push(...xt(i,[...t,r]))}return n},St=(e,t)=>{let n=e.reduce((e,t)=>W(e)?e[t]:void 0,t);return mt(n)?n:void 0},K=e=>e.join(`.`),Ct=(e,t,n)=>({namespace:U,channel:e,type:`REPLY`,callId:t,isError:!0,...n instanceof Error?{value:dt(n),isSerializedErrorInstance:!0}:{value:n}}),wt=(e,t,n,r)=>{let i=!1,a=async a=>{if(i||!vt(a))return;r?.(`Received ${K(a.methodPath)}() call`,a);let{methodPath:o,args:s,id:c}=a,l,u;try{let e=St(o,t);if(!e)throw new H(`METHOD_NOT_FOUND`,`Method \`${K(o)}\` is not found.`);let r=await e(...s);r instanceof pt&&(u=r.transferables,r=await r.value),l={namespace:U,channel:n,type:`REPLY`,callId:c,value:r}}catch(e){l=Ct(n,c,e)}if(!i)try{r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l,u)}catch(t){throw t.name===`DataCloneError`&&(l=Ct(n,c,t),r?.(`Sending ${K(o)}() reply`,l),e.sendMessage(l)),t}};return e.addMessageHandler(a),()=>{i=!0,e.removeMessageHandler(a)}},Tt=crypto.randomUUID?.bind(crypto)??(()=>[,,,,].fill(0).map(()=>Math.floor(Math.random()*(2**53-1)).toString(16)).join(`-`)),Et=class{transferables;timeout;constructor(e){this.transferables=e?.transferables,this.timeout=e?.timeout}},Dt=new Set([`apply`,`call`,`bind`]),Ot=(e,t,n=[])=>new Proxy(n.length?()=>{}:Object.create(null),{get(r,i){if(i!==`then`)return n.length&&Dt.has(i)?Reflect.get(r,i):Ot(e,t,[...n,i])},apply(t,r,i){return e(n,i)}}),kt=e=>new H(`CONNECTION_DESTROYED`,`Method call ${K(e)}() failed due to destroyed connection`),At=(e,t,n)=>{let r=!1,i=new Map,a=e=>{if(!yt(e))return;let{callId:t,value:r,isError:a,isSerializedErrorInstance:o}=e,s=i.get(t);s&&(i.delete(t),n?.(`Received ${K(s.methodPath)}() call`,e),a?s.reject(o?ft(r):r):s.resolve(r))};return e.addMessageHandler(a),{remoteProxy:Ot((a,o)=>{if(r)throw kt(a);let s=Tt(),c=o[o.length-1],l=c instanceof Et,{timeout:u,transferables:d}=l?c:{},f=l?o.slice(0,-1):o;return new Promise((r,o)=>{let c=u===void 0?void 0:window.setTimeout(()=>{i.delete(s),o(new H(`METHOD_CALL_TIMEOUT`,`Method call ${K(a)}() timed out after ${u}ms`))},u);i.set(s,{methodPath:a,resolve:r,reject:o,timeoutId:c});try{let r={namespace:U,channel:t,type:`CALL`,id:s,methodPath:a,args:f};n?.(`Sending ${K(a)}() call`,r),e.sendMessage(r,d)}catch(e){o(new H(`TRANSMISSION_FAILED`,e.message))}})},n),destroy:()=>{r=!0,e.removeMessageHandler(a);for(let{methodPath:e,reject:t,timeoutId:n}of i.values())clearTimeout(n),t(kt(e));i.clear()}}},jt=()=>{let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}},Mt=`deprecated-penpal`,Nt=e=>W(e)&&`penpal`in e,Pt=e=>e.split(`.`),Ft=e=>e.join(`.`),It=e=>{try{return JSON.stringify(e)}catch{return String(e)}},Lt=e=>new H(`TRANSMISSION_FAILED`,`Unexpected message to translate: ${It(e)}`),Rt=e=>{if(e.penpal===`syn`)return{namespace:U,channel:void 0,type:`SYN`,participantId:Mt};if(e.penpal===`ack`)return{namespace:U,channel:void 0,type:`ACK2`};if(e.penpal===`call`)return{namespace:U,channel:void 0,type:`CALL`,id:e.id,methodPath:Pt(e.methodName),args:e.args};if(e.penpal===`reply`)return e.resolution===`fulfilled`?{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,value:e.returnValue}:{namespace:U,channel:void 0,type:`REPLY`,callId:e.id,isError:!0,...e.returnValueIsError?{value:e.returnValue,isSerializedErrorInstance:!0}:{value:e.returnValue}};throw Lt(e)},zt=e=>{if(gt(e))return{penpal:`synAck`,methodNames:e.methodPaths.map(Ft)};if(vt(e))return{penpal:`call`,id:e.id,methodName:Ft(e.methodPath),args:e.args};if(yt(e))return e.isError?{penpal:`reply`,id:e.callId,resolution:`rejected`,...e.isSerializedErrorInstance?{returnValue:e.value,returnValueIsError:!0}:{returnValue:e.value}}:{penpal:`reply`,id:e.callId,resolution:`fulfilled`,returnValue:e.value};throw Lt(e)},Bt=({messenger:e,methods:t,timeout:n,channel:r,log:i})=>{let a=Tt(),o,s=[],c=!1,l=xt(t),{promise:u,resolve:d,reject:f}=jt(),p=n===void 0?void 0:setTimeout(()=>{f(new H(`CONNECTION_TIMEOUT`,`Connection timed out after ${n}ms`))},n),m=()=>{for(let e of s)e()},h=()=>{if(c)return;s.push(wt(e,t,r,i));let{remoteProxy:n,destroy:a}=At(e,r,i);s.push(a),clearTimeout(p),c=!0,d({remoteProxy:n,destroy:m})},g=()=>{let t={namespace:U,type:`SYN`,channel:r,participantId:a};i?.(`Sending handshake SYN`,t);try{e.sendMessage(t)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message))}},_=t=>{if(i?.(`Received handshake SYN`,t),t.participantId===o&&o!==Mt||(o=t.participantId,g(),!(a>o||o===Mt)))return;let n={namespace:U,channel:r,type:`ACK1`,methodPaths:l};i?.(`Sending handshake ACK1`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}},ee=t=>{i?.(`Received handshake ACK1`,t);let n={namespace:U,channel:r,type:`ACK2`};i?.(`Sending handshake ACK2`,n);try{e.sendMessage(n)}catch(e){f(new H(`TRANSMISSION_FAILED`,e.message));return}h()},v=e=>{i?.(`Received handshake ACK2`,e),h()},y=e=>{G(e)&&_(e),gt(e)&&ee(e),_t(e)&&v(e)};return e.addMessageHandler(y),s.push(()=>e.removeMessageHandler(y)),g(),u},Vt=e=>{let t=!1,n;return(...r)=>(t||(t=!0,n=e(...r)),n)},Ht=new WeakSet,Ut=({messenger:e,methods:t={},timeout:n,channel:r,log:i})=>{if(!e)throw new H(`INVALID_ARGUMENT`,`messenger must be defined`);if(Ht.has(e))throw new H(`INVALID_ARGUMENT`,`A messenger can only be used for a single connection`);Ht.add(e);let a=[e.destroy],o=Vt(t=>{if(t){let t={namespace:U,channel:r,type:`DESTROY`};try{e.sendMessage(t)}catch{}}for(let e of a)e();i?.(`Connection destroyed`)}),s=e=>ht(e)&&e.channel===r;return{promise:(async()=>{try{e.initialize({log:i,validateReceivedMessage:s}),e.addMessageHandler(e=>{bt(e)&&o(!1)});let{remoteProxy:c,destroy:l}=await Bt({messenger:e,methods:t,timeout:n,channel:r,log:i});return a.push(l),c}catch(e){throw o(!0),e}})(),destroy:()=>{o(!0)}}},Wt=class{#e;#t;#n;#r;#i;#a=new Set;#o;#s=!1;constructor({remoteWindow:e,allowedOrigins:t}){if(!e)throw new H(`INVALID_ARGUMENT`,`remoteWindow must be defined`);this.#e=e,this.#t=t?.length?t:[window.origin]}initialize=({log:e,validateReceivedMessage:t})=>{this.#n=e,this.#r=t,window.addEventListener(`message`,this.#d)};sendMessage=(e,t)=>{if(G(e)){let n=this.#l(e);this.#e.postMessage(e,{targetOrigin:n,transfer:t});return}if(gt(e)||this.#s){let n=this.#s?zt(e):e,r=this.#l(e);this.#e.postMessage(n,{targetOrigin:r,transfer:t});return}if(_t(e)){let{port1:n,port2:r}=new MessageChannel;this.#o=n,n.addEventListener(`message`,this.#f),n.start();let i=[r,...t||[]],a=this.#l(e);this.#e.postMessage(e,{targetOrigin:a,transfer:i});return}if(this.#o){this.#o.postMessage(e,{transfer:t});return}throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the MessagePort is not connected`)};addMessageHandler=e=>{this.#a.add(e)};removeMessageHandler=e=>{this.#a.delete(e)};destroy=()=>{window.removeEventListener(`message`,this.#d),this.#u(),this.#a.clear()};#c=e=>this.#t.some(t=>t instanceof RegExp?t.test(e):t===e||t===`*`);#l=e=>{if(G(e))return`*`;if(!this.#i)throw new H(`TRANSMISSION_FAILED`,`Cannot send message because the remote origin is not established`);return this.#i===`null`&&this.#t.includes(`*`)?`*`:this.#i};#u=()=>{this.#o?.removeEventListener(`message`,this.#f),this.#o?.close(),this.#o=void 0};#d=({source:e,origin:t,ports:n,data:r})=>{if(e===this.#e){if(Nt(r)){this.#n?.(`Please upgrade the child window to the latest version of Penpal.`),this.#s=!0;try{r=Rt(r)}catch(e){this.#n?.(`Failed to translate deprecated message: ${e.message}`);return}}if(this.#r?.(r)){if(!this.#c(t)){this.#n?.(`Received a message from origin \`${t}\` which did not match allowed origins \`[${this.#t.join(`, `)}]\``);return}if(G(r)&&(this.#u(),this.#i=t),_t(r)&&!this.#s){if(this.#o=n[0],!this.#o){this.#n?.(`Ignoring ACK2 because it did not include a MessagePort`);return}this.#o.addEventListener(`message`,this.#f),this.#o.start()}for(let e of this.#a)e(r)}}};#f=({data:e})=>{if(this.#r?.(e))for(let t of this.#a)t(e)}};let q={RENDERED:`RENDERED`,RESIZE:`RESIZE`,DESTROY:`DESTROY`,BEFORE_CLOSE:`BEFORE_CLOSE`,DISPLAY:`DISPLAY`},Gt=new Set([`onClose`,`onDestroy`,`onRendered`,`onRender`,`onDisplay`,`onResize`,`onProps`]);function J(e){e&&e.remove()}function Y(e){return typeof e==`number`?`${e}px`:e}let Kt={"monei-card-input":`allow-scripts allow-forms allow-same-origin`,"monei-bizum":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-bizum-button":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-paypal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-payment-request":`allow-scripts allow-forms allow-same-origin allow-popups`,"monei-payment-modal":`allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox`,"monei-google-pay":`allow-scripts allow-forms allow-same-origin allow-popups`};function qt(e){if(!e)throw Error(`render() requires a container element or selector`);if(typeof e==`string`){let t=document.querySelector(e);if(!t)throw Error(`Container not found: ${e}`);return t}return e}function Jt(e){return`${e}-${Math.random().toString(36).slice(2,9)}`}function Yt(e,t){let n=[[`onClose`,q.DESTROY],[`onDestroy`,q.DESTROY],[`onRendered`,q.RENDERED],[`onResize`,q.RESIZE]];for(let[r,i]of n)t.on(i,(...t)=>{let n=e[r];typeof n==`function`&&n(...t)})}function Xt(e){let{props:t,options:n,state:r,dispatchMap:i}=e,a={},o=new Set(n.computedProps?Object.keys(n.computedProps):[]);if(n.computedProps)for(let[e,o]of Object.entries(n.computedProps)){let n=o.factory({props:t,state:r});o.type===`function`?i.set(e,n):a[e]=n}for(let[e,n]of Object.entries(t))Gt.has(e)||o.has(e)||(typeof n==`function`?i.set(e,n):a[e]=n);let s=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);return{dataProps:a,functionNames:[...i.keys()].filter(e=>!s.has(e))}}function Zt(e,t){let n={dispatchMap:new Map,connection:null,remote:null,containerEl:null,frame:null,destroyed:!1,ownsContainer:!1,pendingPropsUpdate:null,pendingRemovals:new Set},r=!1,i=!1;n.dispatchMap.set(`resize`,i=>{let{autoResize:a}=t,o={};i.width!==void 0&&(!a||a.width===!0)&&(o.width=i.width),i.height!==void 0&&(!a||a.height===!0)&&(o.height=i.height),n.frame&&(o.width!==void 0&&(n.frame.style.width=Y(o.width)),o.height!==void 0&&(n.frame.style.height=Y(o.height))),r||(r=!0,e.event.trigger(q.RENDERED)),e.event.trigger(q.RESIZE,o)}),n.dispatchMap.set(`close`,()=>e.close()),n.dispatchMap.set(`show`,()=>{n.frame&&(n.frame.style.display=``)}),n.dispatchMap.set(`hide`,()=>{n.frame&&(n.frame.style.display=`none`)}),n.dispatchMap.set(`getParentDomain`,()=>window.location.origin),n.dispatchMap.set(`focus`,()=>{n.frame&&n.frame.focus()}),e.render=async a=>{if(n.destroyed)throw Error(`Component is destroyed`);if(n.frame)throw Error(`Component already rendered`);let o=qt(a),s=Jt(t.tag),c=o.ownerDocument,l=c.createElement(`iframe`);l.src=t.url,l.setAttribute(`title`,t.tag.replace(/-/g,`_`)),l.setAttribute(`allowpaymentrequest`,`true`),l.setAttribute(`allow`,`payment`),l.style.border=`none`;let u=Kt[t.tag]??`allow-scripts allow-forms allow-same-origin`;l.setAttribute(`sandbox`,u),i||=(Yt(e.props,e.event),!0);let d=[],f={on(t,n){let r=e.event.on(t,n);return d.push(r),r},once(t,n){let r=e.event.once(t,n);return d.push(r),r},trigger(t,...n){e.event.trigger(t,...n)},off(t,n){e.event.off(t,n)},destroy(){e.event.destroy()}},p,m,h={},g=[];try{t.prerenderTemplate&&(p=t.prerenderTemplate({uid:s,frame:l,placeholder:void 0,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),t.containerTemplate&&(m=t.containerTemplate({uid:s,frame:l,placeholder:p,doc:c,props:e.props,event:f,dimensions:t.dimensions??{width:`100%`,height:`auto`},state:e.state,container:o})),{dataProps:h,functionNames:g}=Xt({props:e.props,options:t,state:e.state,dispatchMap:n.dispatchMap})}catch(e){for(let e of d)e.cancel();let t=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())t.has(e)||n.dispatchMap.delete(e);throw e}n.frame=l;let _=()=>{l.contentWindow&&l.contentWindow.postMessage({type:`__monei_bridge_init__`,props:h,functionNames:g},new URL(t.url).origin)};try{if(m?(o.appendChild(m),n.containerEl=m,n.ownsContainer=!0):(o.appendChild(l),n.containerEl=o),e.event.trigger(q.DISPLAY),l.addEventListener(`load`,_),l.contentWindow&&_(),!l.contentWindow)throw Error(`iframe contentWindow is not available — frame may not be in the DOM`);let i=Ut({messenger:new Wt({remoteWindow:l.contentWindow,allowedOrigins:[new URL(t.url).origin]}),methods:{callParent:(e,t)=>{let r=n.dispatchMap.get(e);if(!r)throw Error(`Unknown parent method: ${e}`);return r(...t)}}});n.connection=i;let a;try{a=await i.promise}catch(e){if(n.destroyed)return;throw e}if(n.destroyed||(n.remote=a,e.state.__callChild=a.callChild,await a.updateProps(h,g),n.destroyed))return;if(n.pendingPropsUpdate){let e=n.pendingPropsUpdate;n.pendingPropsUpdate=null;let t=new Set(e.functionNames??[]),r=new Map;for(let i of Object.keys(e.dataProps))n.dispatchMap.has(i)&&!t.has(i)&&(r.set(i,n.dispatchMap.get(i)),n.pendingRemovals.add(i));if(await n.remote.updateProps(e.dataProps,e.functionNames),n.destroyed)return;for(let[e,t]of r)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}r||(r=!0,e.event.trigger(q.RENDERED)),l.removeEventListener(`load`,_)}catch(t){l.removeEventListener(`load`,_);for(let e of d)e.cancel();delete e.state.__callChild,n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame=null,n.ownsContainer&&n.containerEl?n.containerEl.remove():l.parentNode&&l.remove(),n.containerEl=null,n.ownsContainer=!1,n.pendingPropsUpdate=null,n.pendingRemovals.clear();let i=new Set([`close`,`resize`,`show`,`hide`,`getParentDomain`,`focus`]);for(let e of n.dispatchMap.keys())i.has(e)||n.dispatchMap.delete(e);throw r=!1,t}},e.updateProps=async r=>{if(n.destroyed)throw Error(`Component is destroyed`);let i=en(r,t.aliases);if(Object.assign(e.props,i),!n.frame)return;let a={},o=[],s=new Set(t.computedProps?Object.keys(t.computedProps):[]),c=new Map;for(let[e,t]of Object.entries(i))if(!(Gt.has(e)||s.has(e)))if(typeof t==`function`){let r=n.pendingPropsUpdate!=null&&e in n.pendingPropsUpdate.dataProps,i=n.pendingRemovals.has(e);(!n.dispatchMap.has(e)||r||i)&&o.push(e),n.dispatchMap.set(e,t)}else n.dispatchMap.has(e)&&n.remote&&(c.set(e,n.dispatchMap.get(e)),n.pendingRemovals.add(e)),a[e]=t;let l=o.length>0?o:void 0;if(n.remote){await n.remote.updateProps(a,l);for(let[e,t]of c)n.pendingRemovals.delete(e),n.dispatchMap.get(e)===t&&n.dispatchMap.delete(e)}else{if(n.pendingPropsUpdate||={dataProps:{},functionNames:void 0},Object.assign(n.pendingPropsUpdate.dataProps,a),n.pendingPropsUpdate.functionNames){let e=Object.keys(a);if(e.length>0){let t=new Set(e);n.pendingPropsUpdate.functionNames=n.pendingPropsUpdate.functionNames.filter(e=>!t.has(e)),n.pendingPropsUpdate.functionNames.length===0&&(n.pendingPropsUpdate.functionNames=void 0)}}if(l){for(let e of l)delete n.pendingPropsUpdate.dataProps[e];n.pendingPropsUpdate.functionNames=[...n.pendingPropsUpdate.functionNames??[],...l]}}},e.destroy=async()=>{n.destroyed||(n.destroyed=!0,e.event.trigger(q.DESTROY),n.connection&&=(n.connection.destroy(),null),n.remote=null,n.frame&&=(n.frame.remove(),null),n.ownsContainer&&n.containerEl&&n.containerEl.remove(),e.event.destroy(),n.dispatchMap.clear())},e.close=async()=>{await e.destroy()},e.__renderState=n}let Qt={react:`@monei-js/react-components`,vue3:`@monei-js/vue-components`,angular:`@monei-js/angular-components`};function $t(e){let t=Qt[e],n=t?`Use ${t} instead.`:``;console.warn(`[MONEI] .driver('${e}') is deprecated. ${n}`.trim())}function en(e,t){if(!t)return e;let n=new Map;for(let[e,r]of Object.entries(t))n.set(r,e);let r={};for(let[t,i]of Object.entries(e)){let e=n.get(t)??t;r[e]=i}return r}function X(e){class t{constructor(t){this.state={},this.event=new tt;let n=en(t,e.aliases);e.defaultProps?this.props={...e.defaultProps({event:this.event}),...n}:this.props={...n},e.validate&&e.validate({props:this.props}),Zt(this,e),e.submit&&(this.submit=e.submit(this))}async render(e){throw Error(`render() not attached`)}async updateProps(e){throw Error(`updateProps() not attached — call render() first`)}async close(){throw Error(`close() not attached`)}async destroy(){throw Error(`destroy() not attached`)}driver(e,n){return $t(e),ut(e,t,n)}}function n(e){return this instanceof n?new t(e):new n(e)}return n.prototype=t.prototype,n.driver=function(e,t){return $t(e),ut(e,n,t)},t.prototype.__options=e,n}let Z=function(e){return e.VISIBLE=`is-visible`,e.INVISIBLE=`is-invisible`,e}({});function tn(e={}){let{background:t=`#fff`,overflow:n,borderRadius:r,fadeOnRender:i=!0,allowTransparency:a=!1,modal:o=!1}=e;return function({uid:e,frame:s,placeholder:c,doc:l,props:u,event:d,dimensions:{width:f,height:p}}){if(!s)return;a&&(s.setAttribute(`allowtransparency`,`true`),s.style.background=`transparent`);let m=l.createElement(`div`);m.setAttribute(`id`,e);let h=l.createElement(`style`);if(u?.cspNonce&&h.setAttribute(`nonce`,u.cspNonce),o){let t=l.createElement(`div`);t.classList.add(`backdrop`),h.appendChild(l.createTextNode(`
12
12
  #${e} {
13
13
  position: fixed;
14
14
  inset: 0;
@@ -60,5 +60,5 @@
60
60
  #${e} > iframe.${Z.VISIBLE} {
61
61
  opacity: 1;
62
62
  }
63
- `)),m.appendChild(s),c&&m.appendChild(c),m.appendChild(h),d.on(q.RESIZE,({width:e,height:t})=>{typeof e==`number`&&(m.style.width=Y(e)),typeof t==`number`&&(m.style.height=Y(t))}),c&&(s.classList.add(Z.INVISIBLE),i&&c.classList.add(Z.VISIBLE),d.on(q.RENDERED,()=>{i?(c.classList.remove(Z.VISIBLE),c.classList.add(Z.INVISIBLE),s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE),setTimeout(()=>J(c),1)):(J(c),s.style.transition=`none`,s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE))}))}return m}}let Q=$t({overflow:`hidden`,borderRadius:`var(--monei-radius, 4px)`}),en=$t({modal:!0}),tn=e=>{if(e.state?.__createToken)return e.state.__createToken;throw Error(`Index is not registered`)},nn=async(e,t)=>{let{data:n}=await tn(e)(t);return n},rn=X({tag:`monei-card-input`,url:R.cardInputUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{sessionId:`orderId`,style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:e=>(e.state.__createToken=async(t={})=>{let n=e.state.__callChild;if(!n)throw Error(`CardInput instance is not registered`);return{data:await n(`createToken`,[t])}},Q(e)),prerenderTemplate:({doc:e,props:t})=>{let n=e.createElement(`html`),r=e.createElement(`body`);r.style.margin=`0`,r.style.background=`#fff`;let i=e.createElement(`div`);i.style.height=`45px`,i.style.boxSizing=`border-box`;let a=t.style||t.innerStyle;return a?.base&&Object.assign(i.style,A(a.base)),a?.loading&&Object.assign(i.style,A(a.loading)),r.appendChild(i),n.appendChild(r),n}}),an=X({tag:`monei-payment-modal`,url:R.paymentModalUrl,dimensions:{width:`100%`,height:`100%`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},containerTemplate:$t({background:`transparent`,fadeOnRender:!1,allowTransparency:!0})}),on=e=>{let t=document.createElement(`div`),n=document.body.style.overflow;Object.assign(document.body.style,{overflow:`hidden`}),Object.assign(t.style,{position:`fixed`,overflow:`hidden`,display:`block`,top:`0`,bottom:`0`,left:`0`,right:`0`,width:`100%`,height:`100%`,zIndex:`99999`}),document.body.appendChild(t);let r=null,i=()=>{r?.destroy(),r=null,Object.assign(document.body.style,{overflow:n}),t.parentNode&&t.parentNode.removeChild(t)};return new Promise((n,a)=>{r=new an({...e,isOpen:!0,onResult:e=>{n(e),i()},onError:e=>{a(e),i()}}),r.render(t).catch(e=>{i(),a(e)})})},$=`monei-paypal`,sn=async(e,t,n)=>{t.__scriptId=(await Pe(n,e.cspNonce,{namespace:$,cspNonce:e.cspNonce},!0)).dataset.uidAuto;let r={layout:`horizontal`,tagline:!1,height:45},i=k(e.style?.borderRadius??e.borderRadius);i&&(r.borderRadius=i);let a={...r,...e.style};a.height=k(a.height,45),e.onLoad?.(!0);let o;await window[$].Buttons({createOrder:async()=>{try{let t=await Je({paymentId:e.paymentId,accountId:e.accountId,sessionId:e.sessionId,amount:e.amount,currency:e.currency,transactionType:e.transactionType,paymentMethod:{paypal:{}}});return{token:o}=t,t.paypal?.orderId}catch(t){e.onError?.(t);return}},onApprove:function(t){t.orderID?e.onSubmit({token:o}):e.onError?.(t)},onClick:function(t,n){let r=!0;if(e.onBeforeOpen&&(r=e.onBeforeOpen()),!r)return n.reject()},style:a}).render(t.__container)},cn=X({tag:$,url:R.paypalUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onLoadPayPal:{factory:({props:e,state:t})=>sn.bind(null,e,t),type:`function`}},containerTemplate:e=>{if(e.state.__container=e.container,!e.props.accountId&&!e.props.paymentId)throw Error(`You need to provide paymentId or accountId`);let t=Q(e);return e.event.on(q.DESTROY,()=>{window[$]?.Buttons?.instances?.forEach(e=>{e.close()});let t=e.state.__scriptId;if(t){let e=document.querySelector(`script[data-uid-auto="${t}"]`);e&&e.remove()}}),t}}),ln=X({tag:`monei-bizum`,url:R.bizumUrl,autoResize:{width:!1,height:!1},containerTemplate:e=>{if(e.frame){if(e.props.isHidden){let t=e.doc.createElement(`div`);return t.setAttribute(`id`,e.uid),t.style.display=`none`,t.appendChild(e.frame),e.placeholder&&t.appendChild(e.placeholder),t}return en(e)}},defaultProps:({event:e})=>({onBeforeClose:()=>{e.trigger(q.BEFORE_CLOSE)}})}),un=X({tag:`monei-bizum-button`,url:R.bizumButtonUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onClick:{factory:({props:e,state:t})=>{let n=document.createElement(`div`);return({amount:r,currency:i})=>{if(t.isOpen)return;let a=!0;if(e.onBeforeOpen&&(a=e.onBeforeOpen()),!a)return;t.isOpen=!0,n.parentNode||document.body.appendChild(n);let o=new ln({amount:r,currency:i,...e,onClose:()=>{t.isOpen=!1,window.onpopstate=null,document.body.style.overflow=``},isOpen:!0});return window.history.pushState(null,``,window.location.href),window.onpopstate=()=>o.updateProps({isOpen:!1}),Object.assign(document.body.style,{overflow:`hidden`}),o.render(n)}},type:`function`}},validate:F,containerTemplate:Q}),dn=X({tag:`monei-google-pay`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),fn=X({tag:`monei-payment-request`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),pn=function(e){return e.CONFIRM=`CONFIRM`,e.FRICTIONLESS_CHALLENGE=`FRICTIONLESS_CHALLENGE`,e.BIZUM_CHALLENGE=`BIZUM_CHALLENGE`,e.CHALLENGE=`CHALLENGE`,e.COMPLETE=`COMPLETE`,e}({}),mn=function(e){return e.Visa=`visa`,e.Mastercard=`mastercard`,e.Amex=`amex`,e.Discover=`discover`,e.Diners=`diners`,e.JCB=`jcb`,e.Maestro=`maestro`,e.UnionPay=`unionpay`,e.Elo=`elo`,e.Hipercard=`hipercard`,e}({}),hn=function(e){return e.AUTH=`AUTH`,e.SALE=`SALE`,e.PAYOUT=`PAYOUT`,e.VERIF=`VERIF`,e}({}),gn=qe,_n=Ne;e.Bizum=un,e.BizumModal=ln,e.CardBrand=mn,e.CardInput=rn,e.GooglePay=dn,e.NextActionType=pn,e.PayPal=cn,e.PaymentModal=an,e.PaymentRequest=fn,e.TransactionType=hn,e.api=gn,e.config=R,e.confirmPayment=on,e.createToken=nn,e.utils=_n});
63
+ `)),m.appendChild(s),c&&m.appendChild(c),m.appendChild(h),d.on(q.RESIZE,({width:e,height:t})=>{typeof e==`number`&&(m.style.width=Y(e)),typeof t==`number`&&(m.style.height=Y(t))}),c&&(s.classList.add(Z.INVISIBLE),i&&c.classList.add(Z.VISIBLE),d.on(q.RENDERED,()=>{i?(c.classList.remove(Z.VISIBLE),c.classList.add(Z.INVISIBLE),s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE),setTimeout(()=>J(c),1)):(J(c),s.style.transition=`none`,s.classList.remove(Z.INVISIBLE),s.classList.add(Z.VISIBLE))}))}return m}}let Q=tn({overflow:`hidden`,borderRadius:`var(--monei-radius, 4px)`}),nn=tn({modal:!0}),rn=e=>{if(e.state?.__createToken)return e.state.__createToken;throw Error(`Index is not registered`)},an=async(e,t)=>{console.warn(`[MONEI] Standalone createToken() is deprecated. Use cardInput.submit() instead.`);let{data:n}=await rn(e)(t);return n},on=X({tag:`monei-card-input`,url:R.cardInputUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{sessionId:`orderId`,style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,submit:e=>async t=>{let n=e.state?.__createToken;if(!n)throw Error(`CardInput is not rendered or connection is pending — call render() first`);let{data:r}=await n(t);return r},containerTemplate:e=>(e.state.__createToken=async(t={})=>{let n=e.state.__callChild;if(!n)throw Error(`CardInput instance is not registered`);return{data:await n(`createToken`,[t])}},Q(e)),prerenderTemplate:({doc:e,props:t})=>{let n=e.createElement(`html`),r=e.createElement(`body`);r.style.margin=`0`,r.style.background=`#fff`;let i=e.createElement(`div`);i.style.height=`45px`,i.style.boxSizing=`border-box`;let a=t.style||t.innerStyle;return a?.base&&Object.assign(i.style,A(a.base)),a?.loading&&Object.assign(i.style,A(a.loading)),r.appendChild(i),n.appendChild(r),n}}),sn=X({tag:`monei-payment-modal`,url:R.paymentModalUrl,dimensions:{width:`100%`,height:`100%`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},containerTemplate:tn({background:`transparent`,fadeOnRender:!1,allowTransparency:!0})}),cn=e=>{let t=document.createElement(`div`),n=document.body.style.overflow;Object.assign(document.body.style,{overflow:`hidden`}),Object.assign(t.style,{position:`fixed`,overflow:`hidden`,display:`block`,top:`0`,bottom:`0`,left:`0`,right:`0`,width:`100%`,height:`100%`,zIndex:`99999`}),document.body.appendChild(t);let r=null,i=()=>{r?.destroy(),r=null,Object.assign(document.body.style,{overflow:n}),t.parentNode&&t.parentNode.removeChild(t)};return new Promise((n,a)=>{r=new sn({...e,isOpen:!0,onResult:e=>{n(e),i()},onError:e=>{a(e),i()}}),r.render(t).catch(e=>{i(),a(e)})})},$=`monei-paypal`,ln=async(e,t,n)=>{t.__scriptId=(await Pe(n,e.cspNonce,{namespace:$,cspNonce:e.cspNonce},!0)).dataset.uidAuto;let r={layout:`horizontal`,tagline:!1,height:45},i=k(e.style?.borderRadius??e.borderRadius);i&&(r.borderRadius=i);let a={...r,...e.style};a.height=k(a.height,45),e.onLoad?.(!0);let o;await window[$].Buttons({createOrder:async()=>{try{let t=await Je({paymentId:e.paymentId,accountId:e.accountId,sessionId:e.sessionId,amount:e.amount,currency:e.currency,transactionType:e.transactionType,paymentMethod:{paypal:{}}});return{token:o}=t,t.paypal?.orderId}catch(t){e.onError?.(t);return}},onApprove:function(t){t.orderID?e.onSubmit({token:o}):e.onError?.(t)},onClick:function(t,n){let r=!0;if(e.onBeforeOpen&&(r=e.onBeforeOpen()),!r)return n.reject()},style:a}).render(t.__container)},un=X({tag:$,url:R.paypalUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!1},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onLoadPayPal:{factory:({props:e,state:t})=>ln.bind(null,e,t),type:`function`}},containerTemplate:e=>{if(e.state.__container=e.container,!e.props.accountId&&!e.props.paymentId)throw Error(`You need to provide paymentId or accountId`);let t=Q(e);return e.event.on(q.DESTROY,()=>{window[$]?.Buttons?.instances?.forEach(e=>{e.close()});let t=e.state.__scriptId;if(t){let e=document.querySelector(`script[data-uid-auto="${t}"]`);e&&e.remove()}}),t}}),dn=X({tag:`monei-bizum`,url:R.bizumUrl,autoResize:{width:!1,height:!1},containerTemplate:e=>{if(e.frame){if(e.props.isHidden){let t=e.doc.createElement(`div`);return t.setAttribute(`id`,e.uid),t.style.display=`none`,t.appendChild(e.frame),e.placeholder&&t.appendChild(e.placeholder),t}return nn(e)}},defaultProps:({event:e})=>({onBeforeClose:()=>{e.trigger(q.BEFORE_CLOSE)}})}),fn=X({tag:`monei-bizum-button`,url:R.bizumButtonUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`},__onClick:{factory:({props:e,state:t})=>{let n=document.createElement(`div`);return({amount:r,currency:i})=>{if(t.isOpen)return;let a=!0;if(e.onBeforeOpen&&(a=e.onBeforeOpen()),!a)return;t.isOpen=!0,n.parentNode||document.body.appendChild(n);let o=new dn({amount:r,currency:i,...e,onClose:()=>{t.isOpen=!1,window.onpopstate=null,document.body.style.overflow=``},isOpen:!0});return window.history.pushState(null,``,window.location.href),window.onpopstate=()=>o.updateProps({isOpen:!1}),Object.assign(document.body.style,{overflow:`hidden`}),o.render(n)}},type:`function`}},validate:F,containerTemplate:Q}),pn=X({tag:`monei-google-pay`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`0`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),mn=X({tag:`monei-payment-request`,url:R.paymentRequestUrl,dimensions:{width:`100%`,height:`auto`},autoResize:{width:!1,height:!0},aliases:{style:`innerStyle`},computedProps:{__getConfig:{factory:({props:e})=>V.bind(null,e),type:`function`}},validate:F,containerTemplate:Q}),hn=function(e){return e.CONFIRM=`CONFIRM`,e.FRICTIONLESS_CHALLENGE=`FRICTIONLESS_CHALLENGE`,e.BIZUM_CHALLENGE=`BIZUM_CHALLENGE`,e.CHALLENGE=`CHALLENGE`,e.COMPLETE=`COMPLETE`,e}({}),gn=function(e){return e.Visa=`visa`,e.Mastercard=`mastercard`,e.Amex=`amex`,e.Discover=`discover`,e.Diners=`diners`,e.JCB=`jcb`,e.Maestro=`maestro`,e.UnionPay=`unionpay`,e.Elo=`elo`,e.Hipercard=`hipercard`,e}({}),_n=function(e){return e.AUTH=`AUTH`,e.SALE=`SALE`,e.PAYOUT=`PAYOUT`,e.VERIF=`VERIF`,e}({}),vn=qe,yn=Ne;e.Bizum=fn,e.BizumModal=dn,e.CardBrand=gn,e.CardInput=on,e.GooglePay=pn,e.NextActionType=hn,e.PayPal=un,e.PaymentModal=sn,e.PaymentRequest=mn,e.TransactionType=_n,e.api=vn,e.config=R,e.confirmPayment=cn,e.createToken=an,e.utils=yn});
64
64
  //# sourceMappingURL=monei.umd.production.min.js.map