@paynext/sdk 0.0.102 → 0.0.103

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.
package/dist/index.umd.js CHANGED
@@ -26,7 +26,7 @@
26
26
  <%s {...props} />
27
27
  React keys must be passed directly to JSX without using spread:
28
28
  let props = %s;
29
- <%s key={someKey} {...props} />`,b,w,B,w),E[w+b]=!0)}if(w=null,V!==void 0&&(e(V),w=""+V),s(R)&&(e(R.key),w=""+R.key),"key"in R){V={};for(var Z in R)Z!=="key"&&(V[Z]=R[Z])}else V=R;return w&&o(V,typeof g=="function"?g.displayName||g.name||"Unknown":g),l(g,w,_,T,a(),V,P,D)}function u(g){typeof g=="object"&&g!==null&&g.$$typeof===p&&g._store&&(g._store.validated=1)}var h=ie,p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),x=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),G=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,z=Array.isArray,j=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(g){return g()}};var ee,M={},q=h.react_stack_bottom_frame.bind(h,i)(),K=j(r(i)),E={};mt.Fragment=m,mt.jsx=function(g,R,V,b,T){var _=1e4>G.recentlyCreatedOwnerStacks++;return d(g,R,V,!1,b,T,_?Error("react-stack-top-frame"):q,_?j(r(g)):K)},mt.jsxs=function(g,R,V,b,T){var _=1e4>G.recentlyCreatedOwnerStacks++;return d(g,R,V,!0,b,T,_?Error("react-stack-top-frame"):q,_?j(r(g)):K)}}()),mt}var Ii;function Lc(){return Ii||(Ii=1,process.env.NODE_ENV==="production"?Tt.exports=Nc():Tt.exports=Pc()),Tt.exports}Lc();const Rc=[he.DinersClub,he.DinersClub,he.JCB,he.Mastercard,he.Visa,he.UnionPay,he.Maestro],kc=n=>({}),It=(n,t)=>{var i,s;const e=kc(),r=((s=(i=t==null?void 0:t.card)==null?void 0:i.status)==null?void 0:s.error)||t.status.error,a=o=>o&&e[o]?e[o]:r;if(n&&typeof n=="object"){const o=n,c=o&&typeof o.status_reason=="object"&&o.status_reason?o.status_reason:o,l=c&&typeof c.decline_code=="string"?c.decline_code:void 0,d=c&&typeof c.message=="string"?c.message:void 0,u=typeof o.message=="string"?o.message:void 0;return l?a(l):d&&e[d]?e[d]:u&&e[u]?e[u]:r}return n instanceof Error?a(n.message):typeof n=="string"?a(n):r};class Sc{constructor(t){C(this,"element");C(this,"events",{ready:new de});C(this,"ev");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"onPaymentAttempt");this.config=t;const e=this.config.state.styles.getState().ApplePayButton;this.onPaymentAttempt=this.config.state.checkout.getState().onCheckoutAttempt,this.ev=this.config.service.ev,this.customButtonStyles=e,this.element=document.createElement("div"),this.element.classList.add(bn.applePay,bn.hidden)}init(t){return W(this,null,function*(){if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.translate.locale(),a=Ac(e);if(!a)return!1;const i=t?J(H({},t),{onError:s=>{var c;if(!this.isInitialized){console.error("Apple Pay error:",s);return}const o=this.config.state.translate.messages();It(s,o),(c=t.onError)==null||c.call(t,s)},onSuccess:s=>{var o;(o=t.onSuccess)==null||o.call(t,s)}}):void 0;return yield this.ev.initApple(J(H({},i),{transaction:a,supportedCardTypes:Tc(Rc),locale:Ic(r||"en"),onPaymentAttempt:this.onPaymentAttempt}),this.customButtonStyles),this.ev.isAppleAvailable()?(yield this.ev.renderApple(this.element),this.isInitialized=!0,this.element.classList.remove(bn.hidden),this.events.ready.emit(),!0):!1})}addEventListener(t,e){return this.events[t].addListener(e)}render(){return this.element}}const Mc=[{type:Y.PAYPAL,is_active:!0,order:1},{type:Y.APPLE_PAY,is_active:!0,order:2},{type:Y.GOOGLE_PAY,is_active:!0,order:3},{type:Y.VENMO,is_active:!0,order:4},{type:Y.CARD,is_active:!0,order:5}],Ge={open:{y:0,opacity:1},close:{y:100,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},xt={open:{y:0,opacity:1},close:{y:-100,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},me={open:{y:0,opacity:1},close:{y:15,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},_e={open:{y:0,opacity:1,height:"auto"},close:{y:-15,opacity:0,height:0},transition:{duration:.25,type:"spring",bounce:0}},Cn={googlePay:"_googlePay_1u4c9_1",hidden:"_hidden_1u4c9_20"};class Dc{constructor(t){C(this,"element");C(this,"events",{ready:new de});C(this,"ev");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"onPaymentAttempt");this.config=t,this.ev=this.config.service.ev,this.customButtonStyles=this.config.state.styles.getState().GooglePayButton,this.onPaymentAttempt=this.config.state.checkout.getState().onCheckoutAttempt,this.element=document.createElement("div"),this.element.classList.add(Cn.googlePay,Cn.hidden)}init(t){return W(this,null,function*(){if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.translate.locale(),a=wc(e);if(!a)return!1;const i=t?J(H({},t),{onError:s=>{var o;if(!this.isInitialized){console.error("Google Pay error:",s);return}It(s,this.config.state.translate.messages()),(o=t.onError)==null||o.call(t,s)},onSuccess:s=>{var o;(o=t.onSuccess)==null||o.call(t,s)}}):void 0;return yield this.ev.initGoogle(J(H({},i),{transaction:a,locale:xc(r||"en"),onPaymentAttempt:this.onPaymentAttempt}),this.customButtonStyles),yield this.ev.renderGoogle(this.element),this.element.classList.remove(Cn.hidden),this.isInitialized=!0,this.events.ready.emit(),!0})}addEventListener(t,e){return this.events[t].addListener(e)}render(){return this.element}}const wn={paypal:"_paypal_1p7d0_1",hidden:"_hidden_1p7d0_10"};class Vc{constructor(t){C(this,"element");C(this,"events",{ready:new de,onPaymentAttempt:new de});C(this,"paypal");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"attemptEmitted",!1);C(this,"interceptOverlay");this.config=t,this.paypal=this.config.service.paypal,this.customButtonStyles=this.config.state.styles.getState().PayPalButton,this.element=document.createElement("div"),this.element.classList.add(wn.paypal,wn.hidden)}init(t){return W(this,null,function*(){var s,o;if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.checkout.getState(),a=()=>W(this,null,function*(){try{return yield ea(r.clientToken,r.environment,r.apiVersion)}catch(c){throw c}});if(!e||Object.keys(e).length===0)return console.error("PayPal transaction data is empty or invalid"),!1;if(!((s=e==null?void 0:e.paypal_info)!=null&&s.client_id))return!1;try{if(yield this.paypal.init({clientId:e.paypal_info.client_id,environment:e.paypal_info.environment||"sandbox",vault:!0,locale:Oc(this.config.state.translate.locale()),intent:"tokenize"}),!this.paypal.isLoaded())return!1}catch(c){return!1}const i=t?J(H({},t),{onError:c=>{var d,u;if(this.emitAttemptOnce(),!this.isInitialized){console.error("PayPal error:",c);return}!this.isUserCancellationError(c)&&c?(d=t.onError)==null||d.call(t,c):(u=t.onCancel)==null||u.call(t),this.attemptEmitted=!1},onCancel:()=>{var c;this.emitAttemptOnce(),(c=t.onCancel)==null||c.call(t),this.attemptEmitted=!1},onSuccess:c=>{var l;(l=t.onSuccess)==null||l.call(t,c),this.attemptEmitted=!1}}):void 0;try{yield this.paypal.render(this.element,J(H({},i),{createBillingAgreement:a,onClick:()=>{this.emitAttemptOnce()},onApprove:l=>W(this,[l],function*({billingToken:c}){var d;(d=i==null?void 0:i.onSuccess)==null||d.call(i,c||"")}),style:(o=this.customButtonStyles)==null?void 0:o.styles,onCancel:()=>{var c;(c=i==null?void 0:i.onCancel)==null||c.call(i)},onError:c=>{var d,u;const l=this.isUserCancellationError(c);!l&&c?(d=i==null?void 0:i.onError)==null||d.call(i,c):l&&((u=i==null?void 0:i.onCancel)==null||u.call(i))}}))}catch(c){return!1}return this.setupInterceptOverlay(),this.element.classList.remove(wn.hidden),this.isInitialized=!0,this.events.ready.emit(),!0})}addEventListener(t,e){return this.events[t].addListener(e)}emitAttemptOnce(){this.attemptEmitted||(this.attemptEmitted=!0,this.events.onPaymentAttempt.emit(Y.PAYPAL))}isUserCancellationError(t){var a;if(!t)return!1;const e=typeof t=="string"?t:(t==null?void 0:t.message)||((a=t==null?void 0:t.status_reason)==null?void 0:a.message)||"";return["window is closed","window closed","popup closed","user closed","cancelled by user","user cancelled"].some(i=>e.toLowerCase().includes(i))}setupInterceptOverlay(){if(this.interceptOverlay)return;this.element.style.position=this.element.style.position||"relative";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.background="transparent",t.style.zIndex="2",t.style.pointerEvents="auto";const e=()=>{this.emitAttemptOnce(),t.style.pointerEvents="none",setTimeout(()=>{t.style.pointerEvents="auto"},250)};t.addEventListener("pointerdown",e,{capture:!0}),t.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&e()},{capture:!0}),this.element.appendChild(t),this.interceptOverlay=t}render(){return this.element}}class Fc{constructor(){C(this,"template",`
29
+ <%s key={someKey} {...props} />`,b,w,B,w),E[w+b]=!0)}if(w=null,V!==void 0&&(e(V),w=""+V),s(R)&&(e(R.key),w=""+R.key),"key"in R){V={};for(var Z in R)Z!=="key"&&(V[Z]=R[Z])}else V=R;return w&&o(V,typeof g=="function"?g.displayName||g.name||"Unknown":g),l(g,w,_,T,a(),V,P,D)}function u(g){typeof g=="object"&&g!==null&&g.$$typeof===p&&g._store&&(g._store.validated=1)}var h=ie,p=Symbol.for("react.transitional.element"),f=Symbol.for("react.portal"),m=Symbol.for("react.fragment"),v=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),x=Symbol.for("react.context"),N=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),L=Symbol.for("react.suspense_list"),O=Symbol.for("react.memo"),S=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),$=Symbol.for("react.client.reference"),G=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,F=Object.prototype.hasOwnProperty,z=Array.isArray,j=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(g){return g()}};var ee,M={},q=h.react_stack_bottom_frame.bind(h,i)(),K=j(r(i)),E={};mt.Fragment=m,mt.jsx=function(g,R,V,b,T){var _=1e4>G.recentlyCreatedOwnerStacks++;return d(g,R,V,!1,b,T,_?Error("react-stack-top-frame"):q,_?j(r(g)):K)},mt.jsxs=function(g,R,V,b,T){var _=1e4>G.recentlyCreatedOwnerStacks++;return d(g,R,V,!0,b,T,_?Error("react-stack-top-frame"):q,_?j(r(g)):K)}}()),mt}var Ii;function Lc(){return Ii||(Ii=1,process.env.NODE_ENV==="production"?Tt.exports=Nc():Tt.exports=Pc()),Tt.exports}Lc();const Rc=[he.DinersClub,he.DinersClub,he.JCB,he.Mastercard,he.Visa,he.UnionPay,he.Maestro],kc=n=>({}),It=(n,t)=>{var i,s;const e=kc(),r=((s=(i=t==null?void 0:t.card)==null?void 0:i.status)==null?void 0:s.error)||t.status.error,a=o=>o&&e[o]?e[o]:r;if(n&&typeof n=="object"){const o=n,c=o&&typeof o.status_reason=="object"&&o.status_reason?o.status_reason:o,l=c&&typeof c.decline_code=="string"?c.decline_code:void 0,d=c&&typeof c.message=="string"?c.message:void 0,u=typeof o.message=="string"?o.message:void 0;return l?a(l):d&&e[d]?e[d]:u&&e[u]?e[u]:r}return n instanceof Error?a(n.message):typeof n=="string"?a(n):r};class Sc{constructor(t){C(this,"element");C(this,"events",{ready:new de});C(this,"ev");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"onPaymentAttempt");this.config=t;const e=this.config.state.styles.getState().ApplePayButton;this.onPaymentAttempt=this.config.state.checkout.getState().onCheckoutAttempt,this.ev=this.config.service.ev,this.customButtonStyles=e,this.element=document.createElement("div"),this.element.classList.add(bn.applePay,bn.hidden)}init(t){return W(this,null,function*(){if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.translate.locale(),a=Ac(e);if(!a)return!1;const i=t?J(H({},t),{onError:s=>{var c,l;if(!this.isInitialized){console.error("Apple Pay error:",s);return}const o=this.config.state.translate.messages();s!=null&&s.toLowerCase().includes("cancelled")?(c=t.onCancel)==null||c.call(t):(It(s,o),(l=t.onError)==null||l.call(t,s))},onSuccess:s=>{var o;(o=t.onSuccess)==null||o.call(t,s)}}):void 0;return yield this.ev.initApple(J(H({},i),{transaction:a,supportedCardTypes:Tc(Rc),locale:Ic(r||"en"),onPaymentAttempt:this.onPaymentAttempt}),this.customButtonStyles),this.ev.isAppleAvailable()?(yield this.ev.renderApple(this.element),this.isInitialized=!0,this.element.classList.remove(bn.hidden),this.events.ready.emit(),!0):!1})}addEventListener(t,e){return this.events[t].addListener(e)}render(){return this.element}}const Mc=[{type:Y.PAYPAL,is_active:!0,order:1},{type:Y.APPLE_PAY,is_active:!0,order:2},{type:Y.GOOGLE_PAY,is_active:!0,order:3},{type:Y.VENMO,is_active:!0,order:4},{type:Y.CARD,is_active:!0,order:5}],Ge={open:{y:0,opacity:1},close:{y:100,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},xt={open:{y:0,opacity:1},close:{y:-100,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},me={open:{y:0,opacity:1},close:{y:15,opacity:0},transition:{duration:.25,type:"spring",bounce:0}},_e={open:{y:0,opacity:1,height:"auto"},close:{y:-15,opacity:0,height:0},transition:{duration:.25,type:"spring",bounce:0}},Cn={googlePay:"_googlePay_1u4c9_1",hidden:"_hidden_1u4c9_20"};class Dc{constructor(t){C(this,"element");C(this,"events",{ready:new de});C(this,"ev");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"onPaymentAttempt");this.config=t,this.ev=this.config.service.ev,this.customButtonStyles=this.config.state.styles.getState().GooglePayButton,this.onPaymentAttempt=this.config.state.checkout.getState().onCheckoutAttempt,this.element=document.createElement("div"),this.element.classList.add(Cn.googlePay,Cn.hidden)}init(t){return W(this,null,function*(){if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.translate.locale(),a=wc(e);if(!a)return!1;const i=t?J(H({},t),{onError:s=>{var o;if(!this.isInitialized){console.error("Google Pay error:",s);return}It(s,this.config.state.translate.messages()),(o=t.onError)==null||o.call(t,s)},onSuccess:s=>{var o;(o=t.onSuccess)==null||o.call(t,s)}}):void 0;return yield this.ev.initGoogle(J(H({},i),{transaction:a,locale:xc(r||"en"),onPaymentAttempt:this.onPaymentAttempt}),this.customButtonStyles),yield this.ev.renderGoogle(this.element),this.element.classList.remove(Cn.hidden),this.isInitialized=!0,this.events.ready.emit(),!0})}addEventListener(t,e){return this.events[t].addListener(e)}render(){return this.element}}const wn={paypal:"_paypal_1p7d0_1",hidden:"_hidden_1p7d0_10"};class Vc{constructor(t){C(this,"element");C(this,"events",{ready:new de,onPaymentAttempt:new de});C(this,"paypal");C(this,"customButtonStyles");C(this,"isInitialized",!1);C(this,"attemptEmitted",!1);C(this,"interceptOverlay");this.config=t,this.paypal=this.config.service.paypal,this.customButtonStyles=this.config.state.styles.getState().PayPalButton,this.element=document.createElement("div"),this.element.classList.add(wn.paypal,wn.hidden)}init(t){return W(this,null,function*(){var s,o;if(!this.config)return!1;const e=this.config.state.transaction.getState(),r=this.config.state.checkout.getState(),a=()=>W(this,null,function*(){try{return yield ea(r.clientToken,r.environment,r.apiVersion)}catch(c){throw c}});if(!e||Object.keys(e).length===0)return console.error("PayPal transaction data is empty or invalid"),!1;if(!((s=e==null?void 0:e.paypal_info)!=null&&s.client_id))return!1;try{if(yield this.paypal.init({clientId:e.paypal_info.client_id,environment:e.paypal_info.environment||"sandbox",vault:!0,locale:Oc(this.config.state.translate.locale()),intent:"tokenize"}),!this.paypal.isLoaded())return!1}catch(c){return!1}const i=t?J(H({},t),{onError:c=>{var d,u;if(this.emitAttemptOnce(),!this.isInitialized){console.error("PayPal error:",c);return}!this.isUserCancellationError(c)&&c?(d=t.onError)==null||d.call(t,c):(u=t.onCancel)==null||u.call(t),this.attemptEmitted=!1},onCancel:()=>{var c;this.emitAttemptOnce(),(c=t.onCancel)==null||c.call(t),this.attemptEmitted=!1},onSuccess:c=>{var l;(l=t.onSuccess)==null||l.call(t,c),this.attemptEmitted=!1}}):void 0;try{yield this.paypal.render(this.element,J(H({},i),{createBillingAgreement:a,onClick:()=>{this.emitAttemptOnce()},onApprove:l=>W(this,[l],function*({billingToken:c}){var d;(d=i==null?void 0:i.onSuccess)==null||d.call(i,c||"")}),style:(o=this.customButtonStyles)==null?void 0:o.styles,onCancel:()=>{var c;(c=i==null?void 0:i.onCancel)==null||c.call(i)},onError:c=>{var d,u;const l=this.isUserCancellationError(c);!l&&c?(d=i==null?void 0:i.onError)==null||d.call(i,c):l&&((u=i==null?void 0:i.onCancel)==null||u.call(i))}}))}catch(c){return!1}return this.setupInterceptOverlay(),this.element.classList.remove(wn.hidden),this.isInitialized=!0,this.events.ready.emit(),!0})}addEventListener(t,e){return this.events[t].addListener(e)}emitAttemptOnce(){this.attemptEmitted||(this.attemptEmitted=!0,this.events.onPaymentAttempt.emit(Y.PAYPAL))}isUserCancellationError(t){var a;if(!t)return!1;const e=typeof t=="string"?t:(t==null?void 0:t.message)||((a=t==null?void 0:t.status_reason)==null?void 0:a.message)||"";return["window is closed","window closed","popup closed","user closed","cancelled by user","user cancelled"].some(i=>e.toLowerCase().includes(i))}setupInterceptOverlay(){if(this.interceptOverlay)return;this.element.style.position=this.element.style.position||"relative";const t=document.createElement("div");t.style.position="absolute",t.style.inset="0",t.style.background="transparent",t.style.zIndex="2",t.style.pointerEvents="auto";const e=()=>{this.emitAttemptOnce(),t.style.pointerEvents="none",setTimeout(()=>{t.style.pointerEvents="auto"},250)};t.addEventListener("pointerdown",e,{capture:!0}),t.addEventListener("keydown",r=>{(r.key==="Enter"||r.key===" ")&&e()},{capture:!0}),this.element.appendChild(t),this.interceptOverlay=t}render(){return this.element}}class Fc{constructor(){C(this,"template",`
30
30
  <svg xmlns="http://www.w3.org/2000/svg"
31
31
  width="24"
32
32
  height="24"
@@ -52,7 +52,7 @@ React keys must be passed directly to JSX without using spread:
52
52
 
53
53
  💡 Note:
54
54
  If "Actual parallel execution time" ≈ "Longest button init" → buttons load in parallel ✅
55
- If "Actual parallel execution time" ≈ "Sum of durations" → buttons load sequentially ⚠️`,"color: #666;"),console.groupEnd()}init(){return W(this,null,function*(){this.config.state.transaction.subscribe(()=>{this.config.service.ev.isReady&&this.initPaymentMethods().catch(console.error)}),this.config.state.checkout.subscribe(()=>{this.config.service.ev.isReady&&this.initPaymentMethods().catch(console.error)}),this.config.service.ev.addEventListener("ready",()=>{this.initPaymentMethods().catch(console.error)})})}initApple(t){return W(this,null,function*(){const e=performance.now(),r="Apple Pay";if(!this.applePay){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isAppleReady=!1;try{if(yield this.applePay.init({onError:i=>{this.events.error.emit(i),console.log("Apple Pay error:",i),this.attempted.delete(Y.APPLE_PAY)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.APPLE_PAY)},onSuccess:i=>{this.events.success.emit(J(H({},i),{type:"apple"})),this.attempted.delete(Y.APPLE_PAY)}})){const i=this.applePay.render();t==null||t.appendChild(i);const s=()=>{this.attempted.has(Y.APPLE_PAY)||(this.attempted.add(Y.APPLE_PAY),this.events.onPaymentAttempt.emit(Y.APPLE_PAY))};i.addEventListener("pointerdown",s,{capture:!0}),i.addEventListener("click",s,{capture:!0}),i.addEventListener("keydown",c=>{((c==null?void 0:c.key)==="Enter"||(c==null?void 0:c.key)===" ")&&s()},{capture:!0}),i.addEventListener("focusin",s,{capture:!0}),t==null||t.addEventListener("pointerdown",s,{capture:!0}),t==null||t.addEventListener("click",s,{capture:!0}),t==null||t.addEventListener("focusin",s,{capture:!0});const o=performance.now();this.performanceMetrics.set(r,{start:e,end:o,duration:o-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isAppleReady=!0}})}initGoogle(t){return W(this,null,function*(){const e=performance.now(),r="Google Pay";if(!this.googlePay){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isGoogleReady=!1;try{if(yield this.googlePay.init({onError:i=>{this.events.error.emit(i),t==null||t.remove(),this.attempted.delete(Y.GOOGLE_PAY)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.GOOGLE_PAY)},onSuccess:i=>{this.events.success.emit(J(H({},i),{type:"google"})),this.attempted.delete(Y.GOOGLE_PAY)}})){const i=this.googlePay.render();t==null||t.appendChild(i);const s=()=>{this.attempted.has(Y.GOOGLE_PAY)||(this.attempted.add(Y.GOOGLE_PAY),this.events.onPaymentAttempt.emit(Y.GOOGLE_PAY))};i.addEventListener("pointerdown",s,{capture:!0}),i.addEventListener("click",s,{capture:!0}),i.addEventListener("keydown",c=>{((c==null?void 0:c.key)==="Enter"||(c==null?void 0:c.key)===" ")&&s()},{capture:!0}),i.addEventListener("focusin",s,{capture:!0}),t==null||t.addEventListener("pointerdown",s,{capture:!0}),t==null||t.addEventListener("click",s,{capture:!0}),t==null||t.addEventListener("focusin",s,{capture:!0});const o=performance.now();this.performanceMetrics.set(r,{start:e,end:o,duration:o-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isGoogleReady=!0}})}initPayPal(t){return W(this,null,function*(){const e=performance.now(),r="PayPal";if(!this.paypal){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isPayPalReady=!1;try{const a=this.paypal.render();if(t==null||t.appendChild(a),yield this.paypal.init({onError:s=>{this.events.error.emit(s),this.attempted.delete(Y.PAYPAL)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.PAYPAL)},onSuccess:s=>{this.events.success.emit({paypalId:s,type:"paypal"}),this.attempted.delete(Y.PAYPAL)}})){const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✓ Rendered"})}else{t==null||t.remove();const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✗ Not supported"})}}catch(a){t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isPayPalReady=!0}})}initBraintreeVenmo(t){return W(this,null,function*(){const e=performance.now(),r="Venmo";if(!this.braintree){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isBraintreeReady=!1;try{if(yield this.braintree.init({onError:i=>{this.events.error.emit(i),t==null||t.remove()},onCancel:()=>this.events.cancel.emit(),onSuccess:i=>{this.events.success.emit({nonce:i==null?void 0:i.nonce,type:"venmo"})}})){const i=this.braintree.render();t==null||t.appendChild(i);const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isBraintreeReady=!0}})}initCard(t){return W(this,null,function*(){const e=performance.now(),r="Card";if(!this.card){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}t==null||t.appendChild(this.card.render());const a=performance.now();this.performanceMetrics.set(r,{start:e,end:a,duration:a-e,status:"✓ Rendered"})})}waitForElementVisible(t,e=150){return!t||!(t instanceof HTMLElement)?Promise.resolve():new Promise(r=>{const a=performance.now(),i=()=>{const s=t.getBoundingClientRect();if(s.width>0&&s.height>0||performance.now()-a>=e)return r();requestAnimationFrame(i)};requestAnimationFrame(i)})}initPaymentMethods(){return W(this,null,function*(){const t=this.config.state.transaction.getState(),e=Bc(Mc,(t==null?void 0:t.checkout_config)||[],(h,p)=>h.type===p.type),r=this.config.state.checkout.getState();let a=e.filter(({is_active:h})=>h);(r==null?void 0:r.variant)==="default"&&(a=a.filter(({type:h})=>h!==Y.CARD)),this.initializeButtonInstances(a),this.buttons.innerHTML="";const i=a.sort((h,p)=>h.order-p.order),s=new Map;for(const{type:h}of i){const p=document.createElement("div");this.buttons.appendChild(p),s.set(h,p)}const o=performance.now(),c=i.map(({type:h})=>{const p=s.get(h);switch(h){case Y.APPLE_PAY:return this.initApple(p);case Y.GOOGLE_PAY:return this.initGoogle(p);case Y.PAYPAL:return this.initPayPal(p);case Y.VENMO:return this.initBraintreeVenmo(p);case Y.CARD:return this.initCard(p);default:throw new Error("Unknown button type")}});yield Promise.all(c);const l=performance.now(),d=l-o;this.performanceMetrics.set("__parallel_total__",{start:o,end:l,duration:d,status:"Parallel execution"});const u=[];for(const h of s.values()){const p=h.firstElementChild;p&&u.push(this.waitForElementVisible(p))}yield Promise.all(u),this.handleReady()})}initializeButtonInstances(t){const e=t.map(({type:r})=>r);e.includes(Y.APPLE_PAY)&&!this.applePay&&(this.applePay=new Sc(this.config)),e.includes(Y.GOOGLE_PAY)&&!this.googlePay&&(this.googlePay=new Dc(this.config)),e.includes(Y.PAYPAL)&&!this.paypal&&(this.paypal=new Vc(this.config),this.paypal.addEventListener("onPaymentAttempt",r=>this.events.onPaymentAttempt.emit(r))),e.includes(Y.VENMO)&&!this.braintree&&(this.braintree=new Hc(this.config),this.braintree.addEventListener("onPaymentAttempt",r=>this.events.onPaymentAttempt.emit(r))),e.includes(Y.CARD)&&!this.card&&(this.card=new Uc(this.config),this.card.addEventListener(()=>{this.events.open.emit()}))}handleReady(){this.isAppleReady&&this.isGoogleReady&&this.isPayPalReady&&this.isBraintreeReady&&(this.logPerformanceMetrics(),this.events.ready.emit())}addEventListener(t,e){return this.events[t].addListener(e)}showButton(){this.buttons.classList.remove(yn.hidden)}render(){return this.buttons}}class Wc{constructor(t){C(this,"template",`
55
+ If "Actual parallel execution time" ≈ "Sum of durations" → buttons load sequentially ⚠️`,"color: #666;"),console.groupEnd()}init(){return W(this,null,function*(){this.config.state.transaction.subscribe(()=>{this.config.service.ev.isReady&&this.initPaymentMethods().catch(console.error)}),this.config.state.checkout.subscribe(()=>{this.config.service.ev.isReady&&this.initPaymentMethods().catch(console.error)}),this.config.service.ev.addEventListener("ready",()=>{this.initPaymentMethods().catch(console.error)})})}initApple(t){return W(this,null,function*(){const e=performance.now(),r="Apple Pay";if(!this.applePay){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isAppleReady=!1;try{if(yield this.applePay.init({onError:i=>{this.events.error.emit(i),console.log("Apple Pay error:",i),t==null||t.remove(),this.attempted.delete(Y.APPLE_PAY)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.APPLE_PAY)},onSuccess:i=>{this.events.success.emit(J(H({},i),{type:"apple"})),this.attempted.delete(Y.APPLE_PAY)}})){const i=this.applePay.render();t==null||t.appendChild(i);const s=()=>{this.attempted.has(Y.APPLE_PAY)||(this.attempted.add(Y.APPLE_PAY),this.events.onPaymentAttempt.emit(Y.APPLE_PAY))};i.addEventListener("pointerdown",s,{capture:!0}),i.addEventListener("click",s,{capture:!0}),i.addEventListener("keydown",c=>{((c==null?void 0:c.key)==="Enter"||(c==null?void 0:c.key)===" ")&&s()},{capture:!0}),i.addEventListener("focusin",s,{capture:!0}),t==null||t.addEventListener("pointerdown",s,{capture:!0}),t==null||t.addEventListener("click",s,{capture:!0}),t==null||t.addEventListener("focusin",s,{capture:!0});const o=performance.now();this.performanceMetrics.set(r,{start:e,end:o,duration:o-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isAppleReady=!0}})}initGoogle(t){return W(this,null,function*(){const e=performance.now(),r="Google Pay";if(!this.googlePay){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isGoogleReady=!1;try{if(yield this.googlePay.init({onError:i=>{this.events.error.emit(i),t==null||t.remove(),this.attempted.delete(Y.GOOGLE_PAY)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.GOOGLE_PAY)},onSuccess:i=>{this.events.success.emit(J(H({},i),{type:"google"})),this.attempted.delete(Y.GOOGLE_PAY)}})){const i=this.googlePay.render();t==null||t.appendChild(i);const s=()=>{this.attempted.has(Y.GOOGLE_PAY)||(this.attempted.add(Y.GOOGLE_PAY),this.events.onPaymentAttempt.emit(Y.GOOGLE_PAY))};i.addEventListener("pointerdown",s,{capture:!0}),i.addEventListener("click",s,{capture:!0}),i.addEventListener("keydown",c=>{((c==null?void 0:c.key)==="Enter"||(c==null?void 0:c.key)===" ")&&s()},{capture:!0}),i.addEventListener("focusin",s,{capture:!0}),t==null||t.addEventListener("pointerdown",s,{capture:!0}),t==null||t.addEventListener("click",s,{capture:!0}),t==null||t.addEventListener("focusin",s,{capture:!0});const o=performance.now();this.performanceMetrics.set(r,{start:e,end:o,duration:o-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isGoogleReady=!0}})}initPayPal(t){return W(this,null,function*(){const e=performance.now(),r="PayPal";if(!this.paypal){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isPayPalReady=!1;try{const a=this.paypal.render();if(t==null||t.appendChild(a),yield this.paypal.init({onError:s=>{this.events.error.emit(s),this.attempted.delete(Y.PAYPAL)},onCancel:()=>{this.events.cancel.emit(),this.attempted.delete(Y.PAYPAL)},onSuccess:s=>{this.events.success.emit({paypalId:s,type:"paypal"}),this.attempted.delete(Y.PAYPAL)}})){const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✓ Rendered"})}else{t==null||t.remove();const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✗ Not supported"})}}catch(a){t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isPayPalReady=!0}})}initBraintreeVenmo(t){return W(this,null,function*(){const e=performance.now(),r="Venmo";if(!this.braintree){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}this.isBraintreeReady=!1;try{if(yield this.braintree.init({onError:i=>{this.events.error.emit(i),t==null||t.remove()},onCancel:()=>this.events.cancel.emit(),onSuccess:i=>{this.events.success.emit({nonce:i==null?void 0:i.nonce,type:"venmo"})}})){const i=this.braintree.render();t==null||t.appendChild(i);const s=performance.now();this.performanceMetrics.set(r,{start:e,end:s,duration:s-e,status:"✓ Rendered"})}else{t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Not supported"})}}catch(a){console.error(a),t==null||t.remove();const i=performance.now();this.performanceMetrics.set(r,{start:e,end:i,duration:i-e,status:"✗ Error"})}finally{this.isBraintreeReady=!0}})}initCard(t){return W(this,null,function*(){const e=performance.now(),r="Card";if(!this.card){t==null||t.remove(),this.performanceMetrics.set(r,{start:e,end:performance.now(),duration:performance.now()-e,status:"Skipped (not configured)"});return}t==null||t.appendChild(this.card.render());const a=performance.now();this.performanceMetrics.set(r,{start:e,end:a,duration:a-e,status:"✓ Rendered"})})}waitForElementVisible(t,e=150){return!t||!(t instanceof HTMLElement)?Promise.resolve():new Promise(r=>{const a=performance.now(),i=()=>{const s=t.getBoundingClientRect();if(s.width>0&&s.height>0||performance.now()-a>=e)return r();requestAnimationFrame(i)};requestAnimationFrame(i)})}initPaymentMethods(){return W(this,null,function*(){const t=this.config.state.transaction.getState(),e=Bc(Mc,(t==null?void 0:t.checkout_config)||[],(h,p)=>h.type===p.type),r=this.config.state.checkout.getState();let a=e.filter(({is_active:h})=>h);(r==null?void 0:r.variant)==="default"&&(a=a.filter(({type:h})=>h!==Y.CARD)),this.initializeButtonInstances(a),this.buttons.innerHTML="";const i=a.sort((h,p)=>h.order-p.order),s=new Map;for(const{type:h}of i){const p=document.createElement("div");this.buttons.appendChild(p),s.set(h,p)}const o=performance.now(),c=i.map(({type:h})=>{const p=s.get(h);switch(h){case Y.APPLE_PAY:return this.initApple(p);case Y.GOOGLE_PAY:return this.initGoogle(p);case Y.PAYPAL:return this.initPayPal(p);case Y.VENMO:return this.initBraintreeVenmo(p);case Y.CARD:return this.initCard(p);default:throw new Error("Unknown button type")}});yield Promise.all(c);const l=performance.now(),d=l-o;this.performanceMetrics.set("__parallel_total__",{start:o,end:l,duration:d,status:"Parallel execution"});const u=[];for(const h of s.values()){const p=h.firstElementChild;p&&u.push(this.waitForElementVisible(p))}yield Promise.all(u),this.handleReady()})}initializeButtonInstances(t){const e=t.map(({type:r})=>r);e.includes(Y.APPLE_PAY)&&!this.applePay&&(this.applePay=new Sc(this.config)),e.includes(Y.GOOGLE_PAY)&&!this.googlePay&&(this.googlePay=new Dc(this.config)),e.includes(Y.PAYPAL)&&!this.paypal&&(this.paypal=new Vc(this.config),this.paypal.addEventListener("onPaymentAttempt",r=>this.events.onPaymentAttempt.emit(r))),e.includes(Y.VENMO)&&!this.braintree&&(this.braintree=new Hc(this.config),this.braintree.addEventListener("onPaymentAttempt",r=>this.events.onPaymentAttempt.emit(r))),e.includes(Y.CARD)&&!this.card&&(this.card=new Uc(this.config),this.card.addEventListener(()=>{this.events.open.emit()}))}handleReady(){this.isAppleReady&&this.isGoogleReady&&this.isPayPalReady&&this.isBraintreeReady&&(this.logPerformanceMetrics(),this.events.ready.emit())}addEventListener(t,e){return this.events[t].addListener(e)}showButton(){this.buttons.classList.remove(yn.hidden)}render(){return this.buttons}}class Wc{constructor(t){C(this,"template",`
56
56
  <svg
57
57
  xmlns='http://www.w3.org/2000/svg'
58
58
  width='24'