@ic-pay/icpay-widget 1.1.45 → 1.1.46

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.
@@ -1,4 +1,4 @@
1
- import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1
+ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var K=Fe`
2
2
  :host {
3
3
  --icpay-primary: #f9fafb;
4
4
  --icpay-secondary: #e5e7eb;
@@ -56,7 +56,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
56
56
  0%, 100% { opacity: 1; }
57
57
  50% { opacity: 0.7; }
58
58
  }
59
- `;function ce(r,d){if(!r||!d)return;let e=d.primaryColor||void 0,t=d.secondaryColor||void 0,i=(V,G)=>{G&&r.style.setProperty(V,G)};i("--icpay-primary",e),i("--icpay-secondary",t);let s=V=>{if(!V)return null;let G=V.replace("#",""),Y=G.length===3?G.split("").map(Re=>Re+Re).join(""):G,X=parseInt(Y,16),le=X>>16&255,ze=X>>8&255,Ke=X&255;return{r:le,g:ze,b:Ke}},l=(V=>{let G=s(V);if(!G)return 0;let Y=X=>{let le=X/255;return le<=.03928?le/12.92:Math.pow((le+.055)/1.055,2.4)};return .2126*Y(G.r)+.7152*Y(G.g)+.0722*Y(G.b)})(e||t)>.6,p=d.surfaceColor||(l?"#f3f4f6":"#1f2937"),c=d.surfaceAltColor||(l?"#e5e7eb":"#374151"),h=d.borderColor||(l?"#d1d5db":"#4b5563"),N=d.textColor||(l?"#111827":"#f9fafb"),B=d.accentColor||t||e||(l?"#6b7280":"#9ca3af"),we=d.mutedTextColor||(l?"#6b7280":"#9ca3af");i("--icpay-accent",B),i("--icpay-text",N),i("--icpay-muted",we),i("--icpay-surface",p),i("--icpay-surface-alt",c),i("--icpay-border",h)}import{Icpay as Ue}from"@ic-pay/icpay-sdk";var $e=typeof window<"u";function Se(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}function g(r){if(!$e)return{client:{},quoteUsd:async()=>({tokenAmountDecimals:"0"}),sendUsd:async()=>({transactionId:"0",status:"pending"}),startOnrampUsd:async()=>({transactionId:"0",status:"pending",metadata:{onramp:{sessionId:null}}}),notifyIntentUntilComplete:()=>({stop:()=>{}})};Se(r.debug||!1,"Creating SDK with config:",r);let d={publishableKey:r.publishableKey};r.enableEvents!==void 0?d.enableEvents=r.enableEvents:d.enableEvents=!0,r.apiUrl&&(d.apiUrl=r.apiUrl),r.icHost&&(d.icHost=r.icHost),r.actorProvider&&(d.actorProvider=r.actorProvider),r.connectedWallet&&(d.connectedWallet=r.connectedWallet),r.onrampDisabled!==void 0&&(d.onrampDisabled=r.onrampDisabled),r.debug!==void 0&&(d.debug=r.debug),Se(r.debug||!1,"Filtered SDK config:",d);try{let a=function(l,p,c){return t.notifyPaymentIntentOnRamp({paymentIntentId:l,intervalMs:p,orderId:c})};var e=a;Se(r.debug||!1,"typeof Icpay:",typeof Ue);let t=new Ue(d);if($e){let l=t,p=c=>{l.addEventListener(c,h=>{window.dispatchEvent(new CustomEvent(c,{detail:h?.detail??h}))})};["icpay-sdk-error","icpay-sdk-transaction-created","icpay-sdk-transaction-updated","icpay-sdk-transaction-completed","icpay-sdk-transaction-failed","icpay-sdk-method-start","icpay-sdk-method-success","icpay-sdk-method-error"].forEach(p)}async function i(l,p){return t.calculateTokenAmountFromUSD({usdAmount:l,ledgerCanisterId:p})}async function s(l,p,c){let h={...r.metadata,...c||{}};return t.createPaymentUsd({usdAmount:l,ledgerCanisterId:p,metadata:h})}async function o(l,p,c){let h={...r.metadata,...c||{}};return t.createPaymentUsd({usdAmount:l,ledgerCanisterId:p,metadata:h,onrampPayment:!0})}return{client:t,quoteUsd:i,sendUsd:s,startOnrampUsd:o,notifyIntentUntilComplete:a}}catch(t){throw Se(r.debug||!1,"Error creating SDK:",t),t}}import{LitElement as je,html as x,css as He}from"lit";import{customElement as Ve,property as se,state as K}from"lit/decorators.js";function u(r,d,e){r&&(e!==void 0?console.log(d,e):console.log(d))}var Ge=[{key:"wallet",label:"Connect Wallet",tooltip:"Awaiting wallet connection",status:"pending"},{key:"init",label:"Initialising ICPay",tooltip:"Initializing payment",status:"pending"},{key:"await",label:"Awaiting payment confirmation",tooltip:"Preparing payment",status:"pending"},{key:"transfer",label:"Transferring funds",tooltip:"Submitting payment",status:"pending"},{key:"verify",label:"Verifying payment",tooltip:"Confirming payment",status:"pending"},{key:"confirm",label:"Payment confirmed",tooltip:"Payment completed",status:"pending"}],y=class extends je{constructor(){super(...arguments);this.open=!1;this.steps=Ge;this.amount=0;this.currency="";this.ledgerSymbol="";this.debug=!1;this.activeIndex=0;this.completed=!1;this.failed=!1;this.errorMessage=null;this.showSuccess=!1;this.showConfetti=!1;this.currentSteps=[];this.currentAmount=0;this.currentCurrency="";this.currentLedgerSymbol="";this.confirmLoadingStartedAt=null;this.progressionTimer=null;this.currentWalletType=null;this.showWalletSelector=!1;this.isTransitioning=!1;this.onMethodStart=e=>{let t=e?.detail?.name||"",i=e?.detail?.type||"";if(u(this.debug,"ICPay Progress: Method start event received:",e.detail),t==="createPayment"||t==="createPaymentUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order"){if(this.open=!0,this.activeIndex=0,this.completed=!1,this.failed=!1,this.errorMessage=null,this.showSuccess=!1,this.showConfetti=!1,this.showWalletSelector=!1,this.isTransitioning=!1,this.currentSteps=this.currentSteps.map(s=>({...s,status:"pending"})),i==="onramp"){let s=this.getStepIndexByKey("wallet");s>=0&&(this.currentSteps[s]={...this.currentSteps[s],label:"Transak Started",tooltip:"Awaiting Transak information"})}this.setLoadingByKey("wallet"),e?.detail?.amount!==void 0&&(this.currentAmount=e.detail.amount,this.amount=e.detail.amount,u(this.debug,"ICPay Progress: Amount updated to:",e.detail.amount)),e?.detail?.currency&&(this.currentCurrency=e.detail.currency,this.currency=e.detail.currency,u(this.debug,"ICPay Progress: Currency updated to:",e.detail.currency)),e?.detail?.ledgerSymbol&&(this.currentLedgerSymbol=e.detail.ledgerSymbol,this.ledgerSymbol=e.detail.ledgerSymbol,u(this.debug,"ICPay Progress: Current state after method start:",{activeIndex:this.activeIndex,currentAmount:this.currentAmount,currentCurrency:this.currentCurrency,currentLedgerSymbol:this.currentLedgerSymbol})),u(this.debug,"ICPay Progress: Waiting for wallet confirmation before starting progression"),this.requestUpdate()}!this.failed&&!this.completed&&(t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")))};this.onMethodSuccess=e=>{let t=e?.detail?.name||"";(t==="createPayment"||t==="createPaymentUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&this.dispatchEvent(new CustomEvent("icpay-progress-method-success",{detail:{methodName:t,step:this.activeIndex},bubbles:!0})),!this.failed&&!this.completed&&(t==="getLedgerBalance"?(this.completeByKey("wallet"),this.completeByKey("init"),this.setLoadingByKey("await")):t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.completeByKey("verify"),this.setLoadingByKey("confirm")))};this.onTransactionCreated=e=>{let t=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction created event received:",e.detail),!this.failed&&!this.completed&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")),this.dispatchEvent(new CustomEvent("icpay-progress-transaction-created",{detail:{transactionId:t,step:this.activeIndex},bubbles:!0}))};this.onTransactionUpdated=e=>{let t=e?.detail?.status||"pending",i=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction updated event received:",e.detail),!this.failed&&this.completed,this.dispatchEvent(new CustomEvent("icpay-progress-transaction-updated",{detail:{status:t,transactionId:i,step:this.activeIndex},bubbles:!0}))};this.onTransactionCompleted=e=>{let t=e?.detail?.transactionId||e?.detail?.id,i=e?.detail?.status||"completed";u(this.debug,"ICPay Progress: Transaction completed event received:",e.detail),u(this.debug,"ICPay Progress: Current state when transaction completed:",{activeIndex:this.activeIndex,completed:this.completed,failed:this.failed,showSuccess:this.showSuccess}),this.completeByKey("transfer"),this.completeByKey("await"),this.completeByKey("init"),this.completeByKey("verify"),this.completeByKey("confirm"),this.completed=!0,this.showSuccess=!0,this.showConfetti=!0,this.dispatchEvent(new CustomEvent("icpay-progress-completed",{detail:{transactionId:t,status:i,amount:this.currentAmount||this.amount,currency:this.currentCurrency||this.currency,ledgerSymbol:this.currentLedgerSymbol||this.ledgerSymbol},bubbles:!0})),setTimeout(()=>{this.showConfetti=!1},3e3)};this.onTransactionFailed=e=>{let t=e?.detail?.message||e?.detail?.error?.message||"Transaction failed",i=e?.detail?.error?.code||e?.detail?.code||"UNKNOWN_ERROR",s=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction failed event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:t,errorCode:i,transactionId:s,step:this.activeIndex},bubbles:!0}))};this.onTransactionMismatched=e=>{let t=e?.detail?.requestedAmount,i=e?.detail?.paidAmount,s=e?.detail?.transactionId||e?.detail?.id;this.failed=!0;let o=t!=null?String(t):"unknown",a=i!=null?String(i):"unknown";this.errorMessage=`Amount mismatch. Requested ${o}, paid ${a}.`,this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",this.errorMessage),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:this.errorMessage,errorCode:"MISMATCHED_AMOUNT",transactionId:s,step:this.activeIndex,requestedAmount:t,paidAmount:i},bubbles:!0}))};this.onMethodError=e=>{let t=e?.detail?.name||"",i=e?.detail?.error?.message||e?.detail?.message||"An error occurred",s=e?.detail?.error?.code||e?.detail?.code||"METHOD_ERROR";u(this.debug,"ICPay Progress: Method error event received:",e.detail),(t?.startsWith("createPayment")||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.failed=!0,this.errorMessage=this.transformErrorMessage(i),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",i),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-error",{detail:{methodName:t,errorMessage:i,errorCode:s,step:this.activeIndex},bubbles:!0})))};this.onSDKError=e=>{let t=e?.detail?.message||"SDK error occurred",i=e?.detail?.code||"SDK_ERROR";u(this.debug,"ICPay Progress: SDK error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-sdk-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWalletConnected=e=>{let t=e?.detail?.walletType||"unknown";u(this.debug,"ICPay Progress: Wallet connected event received:",e.detail),this.completeByKey("wallet"),this.setLoadingByKey("init"),this.startTransitionToProgress(),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-connected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0})),this.currentWalletType=t};this.onWalletDisconnected=e=>{let t=e?.detail?.walletType||"unknown";u(this.debug,"ICPay Progress: Wallet disconnected event received:",e.detail),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-disconnected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0})),this.currentWalletType=null};this.onBalanceCheck=e=>{let t=e?.detail?.hasBalance||!1,i=e?.detail?.balance||0;u(this.debug,"ICPay Progress: Balance check event received:",e.detail),t||(this.failed=!0,this.errorMessage="Insufficient balance for transaction",this.updateStepStatus(this.activeIndex,"error","Insufficient balance for transaction"),this.stopAutomaticProgression(),this.showWalletSelector=!1,this.dispatchEvent(new CustomEvent("icpay-progress-insufficient-balance",{detail:{balance:i,required:this.currentAmount||this.amount,step:this.activeIndex},bubbles:!0})))};this.onLedgerVerified=e=>{let t=e?.detail?.ledgerId||e?.detail?.canisterId,i=e?.detail?.symbol||"unknown";u(this.debug,"ICPay Progress: Ledger verified event received:",e.detail),i&&i!=="unknown"&&(this.currentLedgerSymbol=i,this.ledgerSymbol=i),this.dispatchEvent(new CustomEvent("icpay-progress-ledger-verified",{detail:{ledgerId:t,symbol:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetPayment=e=>{let t=e?.detail?.amount,i=e?.detail?.currency,s=e?.detail?.ledgerSymbol;if(u(this.debug,"ICPay Progress: Widget payment event received:",e.detail),t!==void 0&&(this.currentAmount=t,this.amount=t),i&&(this.currentCurrency=i,this.currency=i),s&&(this.currentLedgerSymbol=s,this.ledgerSymbol=s),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-payment",{detail:{amount:t,currency:i,ledgerSymbol:s,step:this.activeIndex},bubbles:!0}))};this.onWidgetError=e=>{let t=e?.detail?.message||"Widget error occurred",i=e?.detail?.code||"WIDGET_ERROR";u(this.debug,"ICPay Progress: Widget error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-widget-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetUnlock=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget unlock event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-unlock",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetTip=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget tip event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-tip",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetDonation=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget donation event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-donation",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetCoffee=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget coffee event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-coffee",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))}}connectedCallback(){super.connectedCallback();try{ce(this,this.theme)}catch{}this.currentSteps=[...this.steps],this.currentAmount=this.amount,this.currentCurrency=this.currency,this.currentLedgerSymbol=this.ledgerSymbol,this.attachSDKEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.detachSDKEventListeners(),this.stopAutomaticProgression()}updated(e){if(e.has("theme"))try{ce(this,this.theme)}catch{}}attachSDKEventListeners(){window.addEventListener("icpay-sdk-method-start",this.onMethodStart),window.addEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.addEventListener("icpay-sdk-method-error",this.onMethodError),window.addEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.addEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.addEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.addEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.addEventListener("icpay-sdk-transaction-mismatched",this.onTransactionMismatched),window.addEventListener("icpay-sdk-error",this.onSDKError),window.addEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.addEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.addEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.addEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.addEventListener("icpay-pay",this.onWidgetPayment),window.addEventListener("icpay-error",this.onWidgetError),window.addEventListener("icpay-unlock",this.onWidgetUnlock),window.addEventListener("icpay-tip",this.onWidgetTip),window.addEventListener("icpay-donation",this.onWidgetDonation),window.addEventListener("icpay-coffee",this.onWidgetCoffee)}detachSDKEventListeners(){window.removeEventListener("icpay-sdk-method-start",this.onMethodStart),window.removeEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.removeEventListener("icpay-sdk-method-error",this.onMethodError),window.removeEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.removeEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.removeEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.removeEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.removeEventListener("icpay-sdk-transaction-mismatched",this.onTransactionMismatched),window.removeEventListener("icpay-sdk-error",this.onSDKError),window.removeEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.removeEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.removeEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.removeEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.removeEventListener("icpay-pay",this.onWidgetPayment),window.removeEventListener("icpay-error",this.onWidgetError),window.removeEventListener("icpay-unlock",this.onWidgetUnlock),window.removeEventListener("icpay-tip",this.onWidgetTip),window.removeEventListener("icpay-donation",this.onWidgetDonation),window.removeEventListener("icpay-coffee",this.onWidgetCoffee)}startAutomaticProgression(){this.progressionTimer&&clearInterval(this.progressionTimer),this.activeIndex=1,this.updateStepStatus(this.activeIndex,"loading"),u(this.debug,"ICPay Progress: Starting automatic progression from step:",this.activeIndex),this.progressionTimer=setInterval(()=>{if(this.failed||this.completed){this.stopAutomaticProgression();return}u(this.debug,"ICPay Progress: Processing step:",this.activeIndex),this.updateStepStatus(this.activeIndex,"completed"),this.activeIndex<this.currentSteps.length-1?(this.activeIndex++,this.updateStepStatus(this.activeIndex,"loading"),u(this.debug,"ICPay Progress: Auto-progressed to step:",this.activeIndex)):(this.stopAutomaticProgression(),u(this.debug,"ICPay Progress: All steps completed, waiting for transaction completion")),this.requestUpdate()},3e3)}stopAutomaticProgression(){this.progressionTimer&&(clearInterval(this.progressionTimer),this.progressionTimer=null)}updateStepStatus(e,t,i){if(e>=0&&e<this.currentSteps.length){let s=this.currentSteps[e],o=s.status;s.status=t,t==="completed"&&(s.timestamp=this.getCurrentTime()),t==="error"&&i&&(s.errorMessage=this.transformErrorMessage(i)),u(this.debug,`ICPay Progress: Step ${e} (${s.label}) status changed from ${o} to ${t}`),this.requestUpdate()}}getCurrentTime(){return new Date().toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}getStepIcon(e){switch(e.status){case"loading":return x`<div class="loading-spinner"></div>`;case"completed":return x`<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
59
+ `;function de(r,d){if(!r||!d)return;let e=d.primaryColor||void 0,t=d.secondaryColor||void 0,i=(R,G)=>{G&&r.style.setProperty(R,G)};i("--icpay-primary",e),i("--icpay-secondary",t);let s=R=>{if(!R)return null;let G=R.replace("#",""),q=G.length===3?G.split("").map(Re=>Re+Re).join(""):G,X=parseInt(q,16),ce=X>>16&255,ze=X>>8&255,Ke=X&255;return{r:ce,g:ze,b:Ke}},a=(R=>{let G=s(R);if(!G)return 0;let q=X=>{let ce=X/255;return ce<=.03928?ce/12.92:Math.pow((ce+.055)/1.055,2.4)};return .2126*q(G.r)+.7152*q(G.g)+.0722*q(G.b)})(e||t)>.6,p=d.surfaceColor||(a?"#f3f4f6":"#1f2937"),c=d.surfaceAltColor||(a?"#e5e7eb":"#374151"),h=d.borderColor||(a?"#d1d5db":"#4b5563"),A=d.textColor||(a?"#111827":"#f9fafb"),N=d.accentColor||t||e||(a?"#6b7280":"#9ca3af"),se=d.mutedTextColor||(a?"#6b7280":"#9ca3af");i("--icpay-accent",N),i("--icpay-text",A),i("--icpay-muted",se),i("--icpay-surface",p),i("--icpay-surface-alt",c),i("--icpay-border",h)}import{Icpay as Ue}from"@ic-pay/icpay-sdk";var $e=typeof window<"u";function Ee(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}function g(r){if(!$e)return{client:{},quoteUsd:async()=>({tokenAmountDecimals:"0"}),sendUsd:async()=>({transactionId:"0",status:"pending"}),startOnrampUsd:async()=>({transactionId:"0",status:"pending",metadata:{onramp:{sessionId:null}}}),notifyIntentUntilComplete:()=>({stop:()=>{}})};Ee(r.debug||!1,"Creating SDK with config:",r);let d={publishableKey:r.publishableKey};r.enableEvents!==void 0?d.enableEvents=r.enableEvents:d.enableEvents=!0,r.apiUrl&&(d.apiUrl=r.apiUrl),r.icHost&&(d.icHost=r.icHost),r.actorProvider&&(d.actorProvider=r.actorProvider),r.connectedWallet&&(d.connectedWallet=r.connectedWallet),r.onrampDisabled!==void 0&&(d.onrampDisabled=r.onrampDisabled),r.debug!==void 0&&(d.debug=r.debug),Ee(r.debug||!1,"Filtered SDK config:",d);try{let l=function(a,p,c){return t.notifyPaymentIntentOnRamp({paymentIntentId:a,intervalMs:p,orderId:c})};var e=l;Ee(r.debug||!1,"typeof Icpay:",typeof Ue);let t=new Ue(d);if($e){let a=t,p=c=>{a.addEventListener(c,h=>{window.dispatchEvent(new CustomEvent(c,{detail:h?.detail??h}))})};["icpay-sdk-error","icpay-sdk-transaction-created","icpay-sdk-transaction-updated","icpay-sdk-transaction-completed","icpay-sdk-transaction-failed","icpay-sdk-method-start","icpay-sdk-method-success","icpay-sdk-method-error"].forEach(p)}async function i(a,p){return t.calculateTokenAmountFromUSD({usdAmount:a,ledgerCanisterId:p})}async function s(a,p,c){let h={...r.metadata,...c||{}};return t.createPaymentUsd({usdAmount:a,ledgerCanisterId:p,metadata:h})}async function o(a,p,c){let h={...r.metadata,...c||{}};return t.createPaymentUsd({usdAmount:a,ledgerCanisterId:p,metadata:h,onrampPayment:!0})}return{client:t,quoteUsd:i,sendUsd:s,startOnrampUsd:o,notifyIntentUntilComplete:l}}catch(t){throw Ee(r.debug||!1,"Error creating SDK:",t),t}}import{LitElement as je,html as x,css as He}from"lit";import{customElement as Ve,property as oe,state as F}from"lit/decorators.js";function u(r,d,e){r&&(e!==void 0?console.log(d,e):console.log(d))}var Ge=[{key:"wallet",label:"Connect Wallet",tooltip:"Awaiting wallet connection",status:"pending"},{key:"init",label:"Initialising ICPay",tooltip:"Initializing payment",status:"pending"},{key:"await",label:"Awaiting payment confirmation",tooltip:"Preparing payment",status:"pending"},{key:"transfer",label:"Transferring funds",tooltip:"Submitting payment",status:"pending"},{key:"verify",label:"Verifying payment",tooltip:"Confirming payment",status:"pending"},{key:"confirm",label:"Payment confirmed",tooltip:"Payment completed",status:"pending"}],y=class extends je{constructor(){super(...arguments);this.open=!1;this.steps=Ge;this.amount=0;this.currency="";this.ledgerSymbol="";this.debug=!1;this.activeIndex=0;this.completed=!1;this.failed=!1;this.errorMessage=null;this.showSuccess=!1;this.showConfetti=!1;this.currentSteps=[];this.currentAmount=0;this.currentCurrency="";this.currentLedgerSymbol="";this.confirmLoadingStartedAt=null;this.progressionTimer=null;this.currentWalletType=null;this.showWalletSelector=!1;this.isTransitioning=!1;this.onMethodStart=e=>{let t=e?.detail?.name||"",i=e?.detail?.type||"";if(u(this.debug,"ICPay Progress: Method start event received:",e.detail),t==="createPayment"||t==="createPaymentUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order"){if(this.open=!0,this.activeIndex=0,this.completed=!1,this.failed=!1,this.errorMessage=null,this.showSuccess=!1,this.showConfetti=!1,this.showWalletSelector=!1,this.isTransitioning=!1,this.currentSteps=this.currentSteps.map(s=>({...s,status:"pending"})),i==="onramp"){let s=this.getStepIndexByKey("wallet");s>=0&&(this.currentSteps[s]={...this.currentSteps[s],label:"Transak Started",tooltip:"Awaiting Transak information"})}this.setLoadingByKey("wallet"),e?.detail?.amount!==void 0&&(this.currentAmount=e.detail.amount,this.amount=e.detail.amount,u(this.debug,"ICPay Progress: Amount updated to:",e.detail.amount)),e?.detail?.currency&&(this.currentCurrency=e.detail.currency,this.currency=e.detail.currency,u(this.debug,"ICPay Progress: Currency updated to:",e.detail.currency)),e?.detail?.ledgerSymbol&&(this.currentLedgerSymbol=e.detail.ledgerSymbol,this.ledgerSymbol=e.detail.ledgerSymbol,u(this.debug,"ICPay Progress: Current state after method start:",{activeIndex:this.activeIndex,currentAmount:this.currentAmount,currentCurrency:this.currentCurrency,currentLedgerSymbol:this.currentLedgerSymbol})),u(this.debug,"ICPay Progress: Waiting for wallet confirmation before starting progression"),this.requestUpdate()}!this.failed&&!this.completed&&(t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")))};this.onMethodSuccess=e=>{let t=e?.detail?.name||"";(t==="createPayment"||t==="createPaymentUsd"||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&this.dispatchEvent(new CustomEvent("icpay-progress-method-success",{detail:{methodName:t,step:this.activeIndex},bubbles:!0})),!this.failed&&!this.completed&&(t==="getLedgerBalance"?(this.completeByKey("wallet"),this.completeByKey("init"),this.setLoadingByKey("await")):t==="sendFundsToLedger"?(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.setLoadingByKey("verify")):t==="notifyLedgerTransaction"&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.completeByKey("transfer"),this.completeByKey("verify"),this.setLoadingByKey("confirm")))};this.onTransactionCreated=e=>{let t=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction created event received:",e.detail),!this.failed&&!this.completed&&(this.completeByKey("wallet"),this.completeByKey("init"),this.completeByKey("await"),this.setLoadingByKey("transfer")),this.dispatchEvent(new CustomEvent("icpay-progress-transaction-created",{detail:{transactionId:t,step:this.activeIndex},bubbles:!0}))};this.onTransactionUpdated=e=>{let t=e?.detail?.status||"pending",i=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction updated event received:",e.detail),!this.failed&&this.completed,this.dispatchEvent(new CustomEvent("icpay-progress-transaction-updated",{detail:{status:t,transactionId:i,step:this.activeIndex},bubbles:!0}))};this.onTransactionCompleted=e=>{let t=e?.detail?.transactionId||e?.detail?.id,i=e?.detail?.status||"completed";u(this.debug,"ICPay Progress: Transaction completed event received:",e.detail),u(this.debug,"ICPay Progress: Current state when transaction completed:",{activeIndex:this.activeIndex,completed:this.completed,failed:this.failed,showSuccess:this.showSuccess}),this.completeByKey("transfer"),this.completeByKey("await"),this.completeByKey("init"),this.completeByKey("verify"),this.completeByKey("confirm"),this.completed=!0,this.showSuccess=!0,this.showConfetti=!0,this.dispatchEvent(new CustomEvent("icpay-progress-completed",{detail:{transactionId:t,status:i,amount:this.currentAmount||this.amount,currency:this.currentCurrency||this.currency,ledgerSymbol:this.currentLedgerSymbol||this.ledgerSymbol},bubbles:!0})),setTimeout(()=>{this.showConfetti=!1},3e3)};this.onTransactionFailed=e=>{let t=e?.detail?.message||e?.detail?.error?.message||"Transaction failed",i=e?.detail?.error?.code||e?.detail?.code||"UNKNOWN_ERROR",s=e?.detail?.transactionId||e?.detail?.id;u(this.debug,"ICPay Progress: Transaction failed event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:t,errorCode:i,transactionId:s,step:this.activeIndex},bubbles:!0}))};this.onTransactionMismatched=e=>{let t=e?.detail?.requestedAmount,i=e?.detail?.paidAmount,s=e?.detail?.transactionId||e?.detail?.id;this.failed=!0;let o=t!=null?String(t):"unknown",l=i!=null?String(i):"unknown";this.errorMessage=`Amount mismatch. Requested ${o}, paid ${l}.`,this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",this.errorMessage),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-failed",{detail:{errorMessage:this.errorMessage,errorCode:"MISMATCHED_AMOUNT",transactionId:s,step:this.activeIndex,requestedAmount:t,paidAmount:i},bubbles:!0}))};this.onMethodError=e=>{let t=e?.detail?.name||"",i=e?.detail?.error?.message||e?.detail?.message||"An error occurred",s=e?.detail?.error?.code||e?.detail?.code||"METHOD_ERROR";u(this.debug,"ICPay Progress: Method error event received:",e.detail),(t?.startsWith("createPayment")||t==="sendUsd"||t==="pay"||t==="unlock"||t==="tip"||t==="donate"||t==="order")&&(this.failed=!0,this.errorMessage=this.transformErrorMessage(i),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",i),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-error",{detail:{methodName:t,errorMessage:i,errorCode:s,step:this.activeIndex},bubbles:!0})))};this.onSDKError=e=>{let t=e?.detail?.message||"SDK error occurred",i=e?.detail?.code||"SDK_ERROR";u(this.debug,"ICPay Progress: SDK error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-sdk-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWalletConnected=e=>{let t=e?.detail?.walletType||"unknown";u(this.debug,"ICPay Progress: Wallet connected event received:",e.detail),this.completeByKey("wallet"),this.setLoadingByKey("init"),this.startTransitionToProgress(),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-connected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0})),this.currentWalletType=t};this.onWalletDisconnected=e=>{let t=e?.detail?.walletType||"unknown";u(this.debug,"ICPay Progress: Wallet disconnected event received:",e.detail),this.dispatchEvent(new CustomEvent("icpay-progress-wallet-disconnected",{detail:{walletType:t,step:this.activeIndex},bubbles:!0})),this.currentWalletType=null};this.onBalanceCheck=e=>{let t=e?.detail?.hasBalance||!1,i=e?.detail?.balance||0;u(this.debug,"ICPay Progress: Balance check event received:",e.detail),t||(this.failed=!0,this.errorMessage="Insufficient balance for transaction",this.updateStepStatus(this.activeIndex,"error","Insufficient balance for transaction"),this.stopAutomaticProgression(),this.showWalletSelector=!1,this.dispatchEvent(new CustomEvent("icpay-progress-insufficient-balance",{detail:{balance:i,required:this.currentAmount||this.amount,step:this.activeIndex},bubbles:!0})))};this.onLedgerVerified=e=>{let t=e?.detail?.ledgerId||e?.detail?.canisterId,i=e?.detail?.symbol||"unknown";u(this.debug,"ICPay Progress: Ledger verified event received:",e.detail),i&&i!=="unknown"&&(this.currentLedgerSymbol=i,this.ledgerSymbol=i),this.dispatchEvent(new CustomEvent("icpay-progress-ledger-verified",{detail:{ledgerId:t,symbol:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetPayment=e=>{let t=e?.detail?.amount,i=e?.detail?.currency,s=e?.detail?.ledgerSymbol;if(u(this.debug,"ICPay Progress: Widget payment event received:",e.detail),t!==void 0&&(this.currentAmount=t,this.amount=t),i&&(this.currentCurrency=i,this.currency=i),s&&(this.currentLedgerSymbol=s,this.ledgerSymbol=s),!this.failed){for(let o=this.activeIndex;o<this.currentSteps.length;o++)this.updateStepStatus(o,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-payment",{detail:{amount:t,currency:i,ledgerSymbol:s,step:this.activeIndex},bubbles:!0}))};this.onWidgetError=e=>{let t=e?.detail?.message||"Widget error occurred",i=e?.detail?.code||"WIDGET_ERROR";u(this.debug,"ICPay Progress: Widget error event received:",e.detail),this.failed=!0,this.errorMessage=this.transformErrorMessage(t),this.showSuccess=!1,this.updateStepStatus(this.activeIndex,"error",t),this.stopAutomaticProgression(),this.open=!0,this.dispatchEvent(new CustomEvent("icpay-progress-widget-error",{detail:{errorMessage:t,errorCode:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetUnlock=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget unlock event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-unlock",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetTip=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget tip event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-tip",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetDonation=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget donation event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-donation",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))};this.onWidgetCoffee=e=>{let t=e?.detail?.amount,i=e?.detail?.currency;if(u(this.debug,"ICPay Progress: Widget coffee event received:",e.detail),!this.failed){for(let s=this.activeIndex;s<this.currentSteps.length;s++)this.updateStepStatus(s,"completed");this.activeIndex=this.currentSteps.length-1,this.completed=!0,this.showSuccess=!0,this.showConfetti=!0}this.dispatchEvent(new CustomEvent("icpay-progress-widget-coffee",{detail:{amount:t,currency:i,step:this.activeIndex},bubbles:!0}))}}connectedCallback(){super.connectedCallback();try{de(this,this.theme)}catch{}this.currentSteps=[...this.steps],this.currentAmount=this.amount,this.currentCurrency=this.currency,this.currentLedgerSymbol=this.ledgerSymbol,this.attachSDKEventListeners()}disconnectedCallback(){super.disconnectedCallback(),this.detachSDKEventListeners(),this.stopAutomaticProgression()}updated(e){if(e.has("theme"))try{de(this,this.theme)}catch{}}attachSDKEventListeners(){window.addEventListener("icpay-sdk-method-start",this.onMethodStart),window.addEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.addEventListener("icpay-sdk-method-error",this.onMethodError),window.addEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.addEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.addEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.addEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.addEventListener("icpay-sdk-transaction-mismatched",this.onTransactionMismatched),window.addEventListener("icpay-sdk-error",this.onSDKError),window.addEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.addEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.addEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.addEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.addEventListener("icpay-pay",this.onWidgetPayment),window.addEventListener("icpay-error",this.onWidgetError),window.addEventListener("icpay-unlock",this.onWidgetUnlock),window.addEventListener("icpay-tip",this.onWidgetTip),window.addEventListener("icpay-donation",this.onWidgetDonation),window.addEventListener("icpay-coffee",this.onWidgetCoffee)}detachSDKEventListeners(){window.removeEventListener("icpay-sdk-method-start",this.onMethodStart),window.removeEventListener("icpay-sdk-method-success",this.onMethodSuccess),window.removeEventListener("icpay-sdk-method-error",this.onMethodError),window.removeEventListener("icpay-sdk-transaction-created",this.onTransactionCreated),window.removeEventListener("icpay-sdk-transaction-updated",this.onTransactionUpdated),window.removeEventListener("icpay-sdk-transaction-completed",this.onTransactionCompleted),window.removeEventListener("icpay-sdk-transaction-failed",this.onTransactionFailed),window.removeEventListener("icpay-sdk-transaction-mismatched",this.onTransactionMismatched),window.removeEventListener("icpay-sdk-error",this.onSDKError),window.removeEventListener("icpay-sdk-wallet-connected",this.onWalletConnected),window.removeEventListener("icpay-sdk-wallet-disconnected",this.onWalletDisconnected),window.removeEventListener("icpay-sdk-balance-check",this.onBalanceCheck),window.removeEventListener("icpay-sdk-ledger-verified",this.onLedgerVerified),window.removeEventListener("icpay-pay",this.onWidgetPayment),window.removeEventListener("icpay-error",this.onWidgetError),window.removeEventListener("icpay-unlock",this.onWidgetUnlock),window.removeEventListener("icpay-tip",this.onWidgetTip),window.removeEventListener("icpay-donation",this.onWidgetDonation),window.removeEventListener("icpay-coffee",this.onWidgetCoffee)}startAutomaticProgression(){this.progressionTimer&&clearInterval(this.progressionTimer),this.activeIndex=1,this.updateStepStatus(this.activeIndex,"loading"),u(this.debug,"ICPay Progress: Starting automatic progression from step:",this.activeIndex),this.progressionTimer=setInterval(()=>{if(this.failed||this.completed){this.stopAutomaticProgression();return}u(this.debug,"ICPay Progress: Processing step:",this.activeIndex),this.updateStepStatus(this.activeIndex,"completed"),this.activeIndex<this.currentSteps.length-1?(this.activeIndex++,this.updateStepStatus(this.activeIndex,"loading"),u(this.debug,"ICPay Progress: Auto-progressed to step:",this.activeIndex)):(this.stopAutomaticProgression(),u(this.debug,"ICPay Progress: All steps completed, waiting for transaction completion")),this.requestUpdate()},3e3)}stopAutomaticProgression(){this.progressionTimer&&(clearInterval(this.progressionTimer),this.progressionTimer=null)}updateStepStatus(e,t,i){if(e>=0&&e<this.currentSteps.length){let s=this.currentSteps[e],o=s.status;s.status=t,t==="completed"&&(s.timestamp=this.getCurrentTime()),t==="error"&&i&&(s.errorMessage=this.transformErrorMessage(i)),u(this.debug,`ICPay Progress: Step ${e} (${s.label}) status changed from ${o} to ${t}`),this.requestUpdate()}}getCurrentTime(){return new Date().toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}getStepIcon(e){switch(e.status){case"loading":return x`<div class="loading-spinner"></div>`;case"completed":return x`<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
60
60
  <path stroke-linecap="round" stroke-linejoin="round" d="M5 13l4 4L19 7" />
61
61
  </svg>`;case"error":return x`<svg fill="none" viewBox="0 0 24 24" stroke="currentColor">
62
62
  <path stroke-linecap="round" stroke-linejoin="round" d="M6 18L18 6M6 6l12 12" />
@@ -801,12 +801,12 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
801
801
  opacity: 0;
802
802
  }
803
803
  }
804
- `,n([se({type:Boolean})],y.prototype,"open",2),n([se({type:Array})],y.prototype,"steps",2),n([se({type:Number})],y.prototype,"amount",2),n([se({type:String})],y.prototype,"currency",2),n([se({type:String})],y.prototype,"ledgerSymbol",2),n([se({type:Boolean})],y.prototype,"debug",2),n([K()],y.prototype,"activeIndex",2),n([K()],y.prototype,"completed",2),n([K()],y.prototype,"failed",2),n([K()],y.prototype,"errorMessage",2),n([K()],y.prototype,"showSuccess",2),n([K()],y.prototype,"showConfetti",2),n([K()],y.prototype,"currentSteps",2),n([K()],y.prototype,"currentAmount",2),n([K()],y.prototype,"currentCurrency",2),n([K()],y.prototype,"currentLedgerSymbol",2),n([K()],y.prototype,"confirmLoadingStartedAt",2),n([K()],y.prototype,"currentWalletType",2),n([K()],y.prototype,"showWalletSelector",2),n([K()],y.prototype,"isTransitioning",2),n([se({type:Object})],y.prototype,"theme",2),y=n([Ve("icpay-progress-bar")],y);import{html as ke}from"lit";function F(r){if(!r.visible)return null;let d=r.environment??"STAGING",e=r.width??420,t=r.height??680,i="";return r.sessionId&&(i=`${d==="PRODUCTION"?"https://global.transak.com":"https://global-stg.transak.com"}?sessionId=${encodeURIComponent(r.sessionId)}`),ke`
804
+ `,n([oe({type:Boolean})],y.prototype,"open",2),n([oe({type:Array})],y.prototype,"steps",2),n([oe({type:Number})],y.prototype,"amount",2),n([oe({type:String})],y.prototype,"currency",2),n([oe({type:String})],y.prototype,"ledgerSymbol",2),n([oe({type:Boolean})],y.prototype,"debug",2),n([F()],y.prototype,"activeIndex",2),n([F()],y.prototype,"completed",2),n([F()],y.prototype,"failed",2),n([F()],y.prototype,"errorMessage",2),n([F()],y.prototype,"showSuccess",2),n([F()],y.prototype,"showConfetti",2),n([F()],y.prototype,"currentSteps",2),n([F()],y.prototype,"currentAmount",2),n([F()],y.prototype,"currentCurrency",2),n([F()],y.prototype,"currentLedgerSymbol",2),n([F()],y.prototype,"confirmLoadingStartedAt",2),n([F()],y.prototype,"currentWalletType",2),n([F()],y.prototype,"showWalletSelector",2),n([F()],y.prototype,"isTransitioning",2),n([oe({type:Object})],y.prototype,"theme",2),y=n([Ve("icpay-progress-bar")],y);import{html as Me}from"lit";function j(r){if(!r.visible)return null;let d=r.environment??"STAGING",e=r.width??420,t=r.height??680,i="";return r.sessionId&&(i=`${d==="PRODUCTION"?"https://global.transak.com":"https://global-stg.transak.com"}?sessionId=${encodeURIComponent(r.sessionId)}`),Me`
805
805
  <div style="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.85);backdrop-filter:blur(10px);z-index:10000">
806
806
  <div style="position:relative;background:#0f1115;border:1px solid rgba(255,255,255,0.1);border-radius:16px;padding:16px;box-shadow:0 20px 60px rgba(0,0,0,0.5)">
807
807
  <button @click=${r.onClose} aria-label="Close" title="Close"
808
808
  style="position:absolute;top:10px;right:10px;background:transparent;border:none;color:#9ca3af;cursor:pointer;font-size:20px">✕</button>
809
- ${r.sessionId?ke`
809
+ ${r.sessionId?Me`
810
810
  <iframe
811
811
  id="transak-iframe"
812
812
  style="border:none;border-radius:12px;background:#111"
@@ -815,7 +815,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
815
815
  src="${i}"
816
816
  allow="camera;microphone;payment"
817
817
  ></iframe>
818
- `:ke`
818
+ `:Me`
819
819
  <div style="width:${String(e)}px;max-width:90vw;padding:12px">
820
820
  <div style="background:#1a1f2e;border:1px solid rgba(255,255,255,0.1);border-radius:12px;padding:24px;color:#e5e7eb;text-align:center">
821
821
  <div style="font-size:18px;font-weight:600;margin-bottom:8px">Service unavailable</div>
@@ -830,8 +830,8 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
830
830
  `}
831
831
  </div>
832
832
  </div>
833
- `}import{LitElement as tt,html as de,css as it}from"lit";import{customElement as nt,property as st,state as W}from"lit/decorators.js";import{IcpayError as De}from"@ic-pay/icpay-sdk";var Z={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},Ye={onError:r=>{console.error("[ICPay Widget] Error:",r)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:r=>{console.warn("[ICPay Widget] Insufficient balance:",r.message)},onWalletError:r=>{console.warn("[ICPay Widget] Wallet error:",r.message)},onNetworkError:r=>{console.error("[ICPay Widget] Network error:",r.message)}};function P(r,d=Ye){r instanceof De?(d.onError(r),r.isUserCancelled()?d.onUserCancelled?.():r.isBalanceError()?d.onInsufficientBalance?.(r):r.isWalletError()?d.onWalletError?.(r):r.isNetworkError()&&d.onNetworkError?.(r)):(console.error("[ICPay Widget] Unknown error:",r),d.onError(new De({code:Z.UNKNOWN_ERROR,message:r instanceof Error?r.message:"An unknown error occurred",details:r})))}var Ze={[Z.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[Z.WALLET_USER_CANCELLED]:"User have rejected the transfer",[Z.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[Z.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[Z.NETWORK_ERROR]:"Network error. Please try again",[Z.API_ERROR]:"Service temporarily unavailable",[Z.LEDGER_NOT_FOUND]:"Selected token is not supported",[Z.TRANSACTION_FAILED]:"Transaction failed. Please try again",[Z.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[Z.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function R(r){return Ze[r.code]||r.message||"An error occurred"}function U(r){return!r.isUserCancelled()}function $(r){return null}function D(r){return r.isUserCancelled()?"info":r.isBalanceError()||r.isWalletError()?"warning":"error"}import{LitElement as qe,html as oe,css as Je}from"lit";import{customElement as Xe,property as re}from"lit/decorators.js";import{query as Be}from"lit/decorators.js";var j=class extends qe{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons";this.open=!1;this.showLabel=!0;this.menuPos={left:0,top:0,width:0}}connectedCallback(){super.connectedCallback();try{ce(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{ce(this,this.theme)}catch{}}firstUpdated(){let e=i=>{if(!this.open)return;i.composedPath().includes(this)||this.closeDropdown()},t=i=>{i.key==="Escape"&&this.open&&this.closeDropdown()};this._onDocClick=e,this._onKey=t,window.addEventListener("click",e),window.addEventListener("keydown",t)}disconnectedCallback(){super.disconnectedCallback();let e=this._onDocClick,t=this._onKey;e&&window.removeEventListener("click",e),t&&window.removeEventListener("keydown",t)}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}getOptionBySymbol(e){return(this.options||[]).find(t=>t.symbol===e)}getLogoUrl(e){return`https://widget.icpay.org/ledger/${String(e||"").toLowerCase()}.svg`}onSelect(e){this.value=e,this.requestUpdate("value"),this.open=!1,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}toggleDropdown(){this.open=!this.open}closeDropdown(){this.open=!1}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),oe``}if(this.mode==="dropdown"){let i=this.effectiveSymbol,s=this.getOptionBySymbol(i)||{symbol:i,label:i};return oe`
834
- ${this.showLabel?oe`<label class="icpay-dropdown-label">Payment method</label>`:null}
833
+ `}import{LitElement as tt,html as pe,css as it}from"lit";import{customElement as nt,property as st,state as L}from"lit/decorators.js";import{IcpayError as De}from"@ic-pay/icpay-sdk";var Z={WALLET_NOT_CONNECTED:"WALLET_NOT_CONNECTED",WALLET_USER_CANCELLED:"WALLET_USER_CANCELLED",WALLET_SIGNATURE_REJECTED:"WALLET_SIGNATURE_REJECTED",INSUFFICIENT_BALANCE:"INSUFFICIENT_BALANCE",NETWORK_ERROR:"NETWORK_ERROR",API_ERROR:"API_ERROR",LEDGER_NOT_FOUND:"LEDGER_NOT_FOUND",TRANSACTION_FAILED:"TRANSACTION_FAILED",TRANSACTION_TIMEOUT:"TRANSACTION_TIMEOUT",UNKNOWN_ERROR:"UNKNOWN_ERROR"},Ye={onError:r=>{console.error("[ICPay Widget] Error:",r)},onUserCancelled:()=>{console.log("[ICPay Widget] User cancelled the action")},onInsufficientBalance:r=>{console.warn("[ICPay Widget] Insufficient balance:",r.message)},onWalletError:r=>{console.warn("[ICPay Widget] Wallet error:",r.message)},onNetworkError:r=>{console.error("[ICPay Widget] Network error:",r.message)}};function U(r,d=Ye){r instanceof De?(d.onError(r),r.isUserCancelled()?d.onUserCancelled?.():r.isBalanceError()?d.onInsufficientBalance?.(r):r.isWalletError()?d.onWalletError?.(r):r.isNetworkError()&&d.onNetworkError?.(r)):(console.error("[ICPay Widget] Unknown error:",r),d.onError(new De({code:Z.UNKNOWN_ERROR,message:r instanceof Error?r.message:"An unknown error occurred",details:r})))}var qe={[Z.WALLET_NOT_CONNECTED]:"Please connect your wallet to continue",[Z.WALLET_USER_CANCELLED]:"User have rejected the transfer",[Z.WALLET_SIGNATURE_REJECTED]:"User have rejected the transfer",[Z.INSUFFICIENT_BALANCE]:"Insufficient balance for this transaction",[Z.NETWORK_ERROR]:"Network error. Please try again",[Z.API_ERROR]:"Service temporarily unavailable",[Z.LEDGER_NOT_FOUND]:"Selected token is not supported",[Z.TRANSACTION_FAILED]:"Transaction failed. Please try again",[Z.TRANSACTION_TIMEOUT]:"Transaction timed out. Please try again",[Z.UNKNOWN_ERROR]:"Something went wrong. Please try again"};function $(r){return qe[r.code]||r.message||"An error occurred"}function D(r){return!r.isUserCancelled()}function B(r){return null}function z(r){return r.isUserCancelled()?"info":r.isBalanceError()||r.isWalletError()?"warning":"error"}import{LitElement as Ze,html as re,css as Je}from"lit";import{customElement as Xe,property as ae}from"lit/decorators.js";import{query as Be}from"lit/decorators.js";var H=class extends Ze{constructor(){super(...arguments);this.options=[];this.value=null;this.defaultSymbol="ICP";this.mode="buttons";this.open=!1;this.showLabel=!0;this.menuPos={left:0,top:0,width:0}}connectedCallback(){super.connectedCallback();try{de(this,this.theme)}catch{}}updated(e){if(e.has("theme"))try{de(this,this.theme)}catch{}}firstUpdated(){let e=i=>{if(!this.open)return;i.composedPath().includes(this)||this.closeDropdown()},t=i=>{i.key==="Escape"&&this.open&&this.closeDropdown()};this._onDocClick=e,this._onKey=t,window.addEventListener("click",e),window.addEventListener("keydown",t)}disconnectedCallback(){super.disconnectedCallback();let e=this._onDocClick,t=this._onKey;e&&window.removeEventListener("click",e),t&&window.removeEventListener("keydown",t)}get effectiveSymbol(){if(this.value)return this.value;let e=this.options?.[0]?.symbol;return this.defaultSymbol||e||"ICP"}getOptionBySymbol(e){return(this.options||[]).find(t=>t.symbol===e)}getLogoUrl(e){return`https://widget.icpay.org/ledger/${String(e||"").toLowerCase()}.svg`}onSelect(e){this.value=e,this.requestUpdate("value"),this.open=!1,this.dispatchEvent(new CustomEvent("icpay-token-change",{detail:{symbol:e},bubbles:!0,composed:!0}))}toggleDropdown(){this.open=!this.open}closeDropdown(){this.open=!1}render(){let e=this.options||[];if(this.mode==="none"||e.length<=1){let i=e.length===1?e[0].symbol:this.effectiveSymbol;return this.value!==i&&queueMicrotask(()=>this.onSelect(i)),re``}if(this.mode==="dropdown"){let i=this.effectiveSymbol,s=this.getOptionBySymbol(i)||{symbol:i,label:i};return re`
834
+ ${this.showLabel?re`<label class="icpay-dropdown-label">Payment method</label>`:null}
835
835
  <div class="dropdown-wrapper">
836
836
  <div class="dropdown-trigger ${this.open?"open":""}" @click=${()=>this.toggleDropdown()}>
837
837
  <div class="selected-option">
@@ -847,7 +847,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
847
847
  </div>
848
848
 
849
849
  <div class="dropdown-menu ${this.open?"open":""}">
850
- ${e.map(o=>oe`
850
+ ${e.map(o=>re`
851
851
  <div class="dropdown-option ${this.value===o.symbol||i===o.symbol?"selected":""}" @click=${()=>this.onSelect(o.symbol)}>
852
852
  <img class="dropdown-selected-icon" src="${this.getLogoUrl(o.symbol)}" alt="${o.symbol}" />
853
853
  <div class="crypto-info">
@@ -859,11 +859,11 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
859
859
  </div>
860
860
  </div>
861
861
  <div class="dropdown-backdrop ${this.open?"open":""}" @click=${()=>this.closeDropdown()}></div>
862
- `}let t=this.effectiveSymbol;return oe`
862
+ `}let t=this.effectiveSymbol;return re`
863
863
  <div class="icpay-token-selector" style="width:100%;box-sizing:border-box;">
864
- ${this.showLabel?oe`<label class="label">Payment method</label>`:null}
864
+ ${this.showLabel?re`<label class="label">Payment method</label>`:null}
865
865
  <div class="crypto-grid">
866
- ${e.map(i=>oe`
866
+ ${e.map(i=>re`
867
867
  <div class="crypto-option ${t===i.symbol?"selected":""}" @click=${()=>this.onSelect(i.symbol)}>
868
868
  <img class="crypto-icon" src="${this.getLogoUrl(i.symbol)}" alt="${i.symbol}" />
869
869
  <div class="crypto-name">${i.label}</div>
@@ -872,7 +872,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
872
872
  `)}
873
873
  </div>
874
874
  </div>
875
- `}};j.styles=Je`
875
+ `}};H.styles=Je`
876
876
  :host { display: block; width: 100%; box-sizing: border-box; }
877
877
 
878
878
  /* Common */
@@ -929,7 +929,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
929
929
  .dropdown-option { padding: 10px 12px; }
930
930
  .dropdown-selected-icon { width: 28px; height: 28px; }
931
931
  }
932
- `,n([re({type:Array})],j.prototype,"options",2),n([re({type:String})],j.prototype,"value",2),n([re({type:String})],j.prototype,"defaultSymbol",2),n([re({type:String})],j.prototype,"mode",2),n([re({type:Object})],j.prototype,"theme",2),n([re({type:Boolean})],j.prototype,"open",2),n([re({type:Boolean})],j.prototype,"showLabel",2),n([Be(".dropdown-trigger")],j.prototype,"triggerEl",2),n([Be(".dropdown-wrapper")],j.prototype,"wrapperEl",2),j=n([Xe("icpay-token-selector")],j);import{html as Q}from"lit";var Qe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAE9GlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78i iglkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgOS4xLWMwMDIgNzkuZGJhM2RhM2I1LCAyMDIzLzEyLzE1LTEwOjQyOjM3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpypmY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjUuNyAoTWFjaW50b3NoKSIgeG1wOkNyZWF0ZUR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ldW8SfIfUWmt8PJ3U03edpI3eUkR9sesNFFpLD5XGKRCotgNjjGbNE9Ykx1eiuessjympBZI1cKS5Var1DaVDLU+qxHKpt6TpeBmJptOishnjKWpdpIT52O/lak9UvVB5ANMODxNL5VJmxMkyyTJqQhVqjiy+ou5rPQcYWjJrSgzITTl8CY6Q0Mwng0ckCUWZpzHeDuHkEeoSGNxYxJm3n4klXaoabuGLN84XTdk/AbjvcMZaNx2vokARjHPJEgZG2JTiaFFK89xguMTgiiFZEtecnaoJfPTyf0tQCSzg9XWirR5ZNJua5ETREhqV98GKymgRDBcQop4kCE5q0z2lzoeV6PWaimbp5TDNjdJ2TobHrPZJjaFPnrvmofoZaA2yeEb+OBoSVX+Fptxu1zMt08mM3l/okz0A2RNJ8+UyKHnJvucRt7fYo7G52n/P922iheCzzh8AAAAAElFTkSuQmCC";function _e(r){return!r||!r.startsWith("data:")?r:r.replace(/\s+/g,"")}function et(r,d){let e=(r||"").toLowerCase();return e==="ii"?"Internet Identity":e==="nfid"?"NFID":e==="plug"?"Plug":e==="oisy"?"Oisy":d&&d.trim()?d:r?r.charAt(0).toUpperCase()+r.slice(1):"Wallet"}function H(r){if(!r.visible)return null;let{wallets:d,onSelect:e,onClose:t,isConnecting:i}=r,s=d.map(a=>{let l=(a.id||"").toLowerCase();return{...a,icon:l==="nfid"?Qe:a.icon??null}});return Q`
932
+ `,n([ae({type:Array})],H.prototype,"options",2),n([ae({type:String})],H.prototype,"value",2),n([ae({type:String})],H.prototype,"defaultSymbol",2),n([ae({type:String})],H.prototype,"mode",2),n([ae({type:Object})],H.prototype,"theme",2),n([ae({type:Boolean})],H.prototype,"open",2),n([ae({type:Boolean})],H.prototype,"showLabel",2),n([Be(".dropdown-trigger")],H.prototype,"triggerEl",2),n([Be(".dropdown-wrapper")],H.prototype,"wrapperEl",2),H=n([Xe("icpay-token-selector")],H);import{html as Q}from"lit";var Qe="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaX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vokARjHPJEgZG2JTiaFFK89xguMTgiiFZEtecnaoJfPTyf0tQCSzg9XWirR5ZNJua5ETREhqV98GKymgRDBcQop4kCE5q0z2lzoeV6PWaimbp5TDNjdJ2TobHrPZJjaFPnrvmofoZaA2yeEb+OBoSVX+Fptxu1zMt08mM3l/okz0A2RNJ8+UyKHnJvucRt7fYo7G52n/P922iheCzzh8AAAAAElFTkSuQmCC";function _e(r){return!r||!r.startsWith("data:")?r:r.replace(/\s+/g,"")}function et(r,d){let e=(r||"").toLowerCase();return e==="ii"?"Internet Identity":e==="nfid"?"NFID":e==="plug"?"Plug":e==="oisy"?"Oisy":d&&d.trim()?d:r?r.charAt(0).toUpperCase()+r.slice(1):"Wallet"}function V(r){if(!r.visible)return null;let{wallets:d,onSelect:e,onClose:t,isConnecting:i}=r,s=d.map(l=>{let a=(l.id||"").toLowerCase();return{...l,icon:a==="nfid"?Qe:l.icon??null}});return Q`
933
933
  <div style="position:fixed;inset:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.5);z-index:10000">
934
934
  <div style="background:#1f2937;border-radius:12px;padding:24px;max-width:400px;width:90%;border:1px solid rgba(255,255,255,0.1);position:relative">
935
935
  <button @click=${t} style="position:absolute;top:16px;right:16px;width:32px;height:32px;display:flex;align-items:center;justify-content:center;color:#9ca3af;cursor:pointer;border:none;background:transparent;font-size:20px">✕</button>
@@ -941,13 +941,13 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
941
941
  style="width:100%;padding:12px 16px;background:rgba(255,255,255,0.05);border:1px solid rgba(255,255,255,0.1);border-radius:8px;color:#fff;text-align:left;cursor:pointer;font-size:14px;display:flex;align-items:center;gap:12px;justify-content:center">
942
942
  Pay with OISY
943
943
  </button>
944
- `:s.map(a=>{let l=(a.id||"").toLowerCase(),p=et(a.id,a.label),c=Q`
944
+ `:s.map(l=>{let a=(l.id||"").toLowerCase(),p=et(l.id,l.label),c=Q`
945
945
  <button
946
- @click=${()=>e(a.id)}
946
+ @click=${()=>e(l.id)}
947
947
  style="width:100%;padding:12px 16px;background:rgba(255,255,255,0.05);border:1px solid rgba(255,255,255,0.1);border-radius:8px;color:#fff;text-align:left;cursor:pointer;font-size:14px;opacity:${i?.5:1};display:flex;align-items:center;gap:12px">
948
- ${a.icon?Q`
948
+ ${l.icon?Q`
949
949
  <div style="width:48px;height:48px;display:flex;align-items:center;justify-content:center">
950
- <img src="${_e(a.icon)}" alt="${p} logo" style="width:40px;height:40px;object-fit:cover;border-radius:12px" />
950
+ <img src="${_e(l.icon)}" alt="${p} logo" style="width:40px;height:40px;object-fit:cover;border-radius:12px" />
951
951
  </div>
952
952
  `:Q`
953
953
  <div style="width:48px;height:48px;background:linear-gradient(135deg,#3b82f6 0%,#8b5cf6 100%);border-radius:12px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:bold">
@@ -955,7 +955,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
955
955
  </div>
956
956
  `}
957
957
  <div><div style="font-weight:500">${p}</div></div>
958
- </button>`;return l==="ii"?Q`
958
+ </button>`;return a==="ii"?Q`
959
959
  <div style="display:flex;gap:8px;align-items:center;width:100%">
960
960
  ${c}
961
961
  <button
@@ -970,9 +970,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
970
970
  ${null}
971
971
  </div>
972
972
  </div>
973
- `}function T(r){try{let d=r||{};d.adapters=d.adapters||{};let e=d.adapters.oisy||{},t=e.config||{},i={...t.transport||{},windowOpenerFeatures:"",detectNonClickEstablishment:!1};return d.adapters.oisy={...e,config:{...t,transport:i}},d}catch{return r}}function k(r,d){try{let e=d&&(d.owner||d.principal)||null,t=r&&r.account&&(r.account.owner||r.account.principal)||null,i=o=>typeof o=="string"?o:o&&typeof o.toString=="function"?o.toString():null,s=i(e)||i(t)||null;return s?{owner:s,principal:s}:d||{owner:null}}catch{return d||{owner:null}}}async function J(r){try{let e=r?.config?.adapters?.oisy,t=e?.adapter;if(!t)return null;let i=new t({adapter:e});if(!await i.isConnected())return null;let o=await i.getPrincipal();return o&&typeof o=="string"&&o.length>0&&o!=="2vxsx-fae"?o:null}catch{return null}}var Me=typeof window<"u",pe=null;function _(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var S=class extends tt{constructor(){super(...arguments);this.selectedSymbol=null;this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;pe||(pe=(await import("@windoge98/plug-n-play")).PNP);let i={...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new pe(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Me){_(this.config?.debug||!1,"Premium content connected",{config:this.config}),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.onPay()},0)}}async loadVerifiedLedgers(){if(!(!Me||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}async onPay(){if(Me&&!(this.processing||this.unlocked)){_(this.config?.debug||!1,"Premium content payment started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){_(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{pe||(pe=(await import("@windoge98/plug-n-play")).PNP);let l=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?T({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");l.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new pe(l);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(N,B)=>this.pnp.getActor({canisterId:N,idl:B,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.onPay();return}}catch{}let p=this.pnp.getEnabledWallets();if(_(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="pay",this.showWalletModal=!0;return}catch(a){_(this.config?.debug||!1,"Wallet connection error:",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error";return}}_(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(a=>a.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);_(this.config?.debug||!1,"Payment details",{priceUsd:this.config.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.config.priceUsd,s,{context:"premium-content"});_(this.config?.debug||!1,"Payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.config.priceUsd,s,{context:"premium:onramp"}),a=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,l=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=l,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}select(e){this.selectedSymbol=e}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="pay"&&setTimeout(()=>this.onPay(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?de`
973
+ `}function W(r){try{let d=r||{};d.adapters=d.adapters||{};let e=d.adapters.oisy||{},t=e.config||{},i={...t.transport||{},windowOpenerFeatures:"",detectNonClickEstablishment:!1};return d.adapters.oisy={...e,config:{...t,transport:i}},d}catch{return r}}function k(r,d){try{let e=d&&(d.owner||d.principal)||null,t=r&&r.account&&(r.account.owner||r.account.principal)||null,i=o=>typeof o=="string"?o:o&&typeof o.toString=="function"?o.toString():null,s=i(e)||i(t)||null;return s?{owner:s,principal:s}:d||{owner:null}}catch{return d||{owner:null}}}async function J(r){try{let e=r?.config?.adapters?.oisy,t=e?.adapter;if(!t)return null;let i=new t({adapter:e});if(!await i.isConnected())return null;let o=await i.getPrincipal();return o&&typeof o=="string"&&o.length>0&&o!=="2vxsx-fae"?o:null}catch{return null}}var Oe=typeof window<"u",he=null;function _(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var S=class extends tt{constructor(){super(...arguments);this.selectedSymbol=null;this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;he||(he=(await import("@windoge98/plug-n-play")).PNP);let i={...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new he(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Oe){_(this.config?.debug||!1,"Premium content connected",{config:this.config}),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.onPay()},0)}}async loadVerifiedLedgers(){if(!(!Oe||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}async onPay(){if(Oe&&!(this.processing||this.unlocked)){_(this.config?.debug||!1,"Premium content payment started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){_(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{he||(he=(await import("@windoge98/plug-n-play")).PNP);let a=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?W({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");a.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new he(a);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(A,N)=>this.pnp.getActor({canisterId:A,idl:N,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.onPay();return}}catch{}let p=this.pnp.getEnabledWallets();if(_(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="pay",this.showWalletModal=!0;return}catch(l){_(this.config?.debug||!1,"Wallet connection error:",l),this.errorMessage=l instanceof Error?l.message:"Wallet connection failed",this.errorSeverity="error";return}}_(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(l=>l.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);_(this.config?.debug||!1,"Payment details",{priceUsd:this.config.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.config.priceUsd,s,{context:"premium-content"});_(this.config?.debug||!1,"Payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.config.priceUsd,s,{context:"premium:onramp"}),l=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,a=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=a,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}select(e){this.selectedSymbol=e}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="pay"&&setTimeout(()=>this.onPay(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?pe`
974
974
  <div class="icpay-card icpay-section icpay-widget-base">
975
- ${this.config?.progressBar?.enabled!==!1?de`
975
+ ${this.config?.progressBar?.enabled!==!1?pe`
976
976
  <icpay-progress-bar
977
977
  .debug=${!!this.config?.debug}
978
978
  .theme=${this.config?.theme}
@@ -982,7 +982,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
982
982
  `:null}
983
983
  <div class="image-container">
984
984
  <div class="locked-image ${this.unlocked?"unlocked":""}" style="background-image:url('${this.config.imageUrl||""}')"></div>
985
- ${this.unlocked?null:de`<div class="lock-overlay">🔒</div>`}
985
+ ${this.unlocked?null:pe`<div class="lock-overlay">🔒</div>`}
986
986
  </div>
987
987
 
988
988
  <div class="pricing">
@@ -1004,21 +1004,21 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1004
1004
  ${this.unlocked?"Unlocked":this.processing?"Processing\u2026":(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",`${Number(this.config?.priceUsd??0).toFixed(2)}`).replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP")}
1005
1005
  </button>
1006
1006
 
1007
- ${this.errorMessage?de`
1007
+ ${this.errorMessage?pe`
1008
1008
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1009
1009
  ${this.errorMessage}
1010
- ${this.errorAction?de`
1010
+ ${this.errorAction?pe`
1011
1011
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
1012
1012
  ${this.errorAction}
1013
1013
  </button>
1014
1014
  `:""}
1015
1015
  </div>
1016
1016
  `:""}
1017
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=Number(this.config?.priceUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.onPay()}})})()}
1017
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=Number(this.config?.priceUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.onPay()}})})()}
1018
1018
 
1019
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1019
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1020
1020
  </div>
1021
- `:de`<div class="icpay-card icpay-section">Loading...</div>`}};S.styles=[z,it`
1021
+ `:pe`<div class="icpay-card icpay-section">Loading...</div>`}};S.styles=[K,it`
1022
1022
  .image-container {
1023
1023
  position: relative;
1024
1024
  border-radius: 16px;
@@ -1069,9 +1069,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1069
1069
  border-color: rgba(239, 68, 68, 0.3);
1070
1070
  color: #ef4444;
1071
1071
  }
1072
- `],n([st({type:Object})],S.prototype,"config",2),n([W()],S.prototype,"selectedSymbol",2),n([W()],S.prototype,"unlocked",2),n([W()],S.prototype,"succeeded",2),n([W()],S.prototype,"processing",2),n([W()],S.prototype,"availableLedgers",2),n([W()],S.prototype,"errorMessage",2),n([W()],S.prototype,"errorSeverity",2),n([W()],S.prototype,"errorAction",2),n([W()],S.prototype,"walletConnected",2),n([W()],S.prototype,"pendingAction",2),n([W()],S.prototype,"showWalletModal",2),n([W()],S.prototype,"oisyReadyToPay",2),n([W()],S.prototype,"lastWalletId",2),n([W()],S.prototype,"showOnrampModal",2),n([W()],S.prototype,"onrampSessionId",2),n([W()],S.prototype,"onrampPaymentIntentId",2),n([W()],S.prototype,"onrampErrorMessage",2),S=n([nt("icpay-premium-content")],S);import{LitElement as ot,html as ae,css as rt}from"lit";import{customElement as at,property as lt,state as M}from"lit/decorators.js";var Oe=typeof window<"u",ge=null;function ee(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var f=class extends ot{constructor(){super(...arguments);this.selectedAmount=1;this.selectedSymbol=null;this.total=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="tip",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedAmount||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ge||(ge=(await import("@windoge98/plug-n-play")).PNP);let i=T({...this.config?.plugNPlay||{}});try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new ge(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[1,5,10]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Oe){ee(this.config?.debug||!1,"Tip jar connected",{config:this.config}),this.config&&this.config.defaultAmountUsd&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol)}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="tip"&&this.tip()},0)}}async loadVerifiedLedgers(){if(!(!Oe||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.config?.cryptoOptions&&this.config.cryptoOptions.length===1&&(this.selectedSymbol=this.config.cryptoOptions[0].symbol),!this.selectedSymbol&&this.availableLedgers.length>0&&(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){return Math.min(this.total/50*100,100)}async tip(){if(Oe&&(ee(this.config?.debug||!1,"Tip button clicked!",{config:this.config,processing:this.processing}),!this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="tip",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ee(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ge||(ge=(await import("@windoge98/plug-n-play")).PNP);let l=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?T({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");l.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new ge(l);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(N,B)=>this.pnp.getActor({canisterId:N,idl:B,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.tip();return}}catch{}let p=this.pnp.getEnabledWallets();if(ee(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="tip",this.showWalletModal=!0;return}catch(a){ee(this.config?.debug||!1,"Wallet connection error:",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error";return}}ee(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(a=>a.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ee(this.config?.debug||!1,"Tip payment details",{amount:this.selectedAmount,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedAmount,s,{context:"tip-jar"});ee(this.config?.debug||!1,"Tip payment completed",{resp:o}),this.total+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,total:this.total}),this.dispatchEvent(new CustomEvent("icpay-tip",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedAmount,s,{context:"tip:onramp"}),a=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,l=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=l,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="tip"&&setTimeout(()=>this.tip(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){if(!this.config)return ae`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,s=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=s!=="none"&&(t||s==="dropdown"),a=s==="dropdown"?"dropdown":t?"buttons":"none";return ae`
1072
+ `],n([st({type:Object})],S.prototype,"config",2),n([L()],S.prototype,"selectedSymbol",2),n([L()],S.prototype,"unlocked",2),n([L()],S.prototype,"succeeded",2),n([L()],S.prototype,"processing",2),n([L()],S.prototype,"availableLedgers",2),n([L()],S.prototype,"errorMessage",2),n([L()],S.prototype,"errorSeverity",2),n([L()],S.prototype,"errorAction",2),n([L()],S.prototype,"walletConnected",2),n([L()],S.prototype,"pendingAction",2),n([L()],S.prototype,"showWalletModal",2),n([L()],S.prototype,"oisyReadyToPay",2),n([L()],S.prototype,"lastWalletId",2),n([L()],S.prototype,"showOnrampModal",2),n([L()],S.prototype,"onrampSessionId",2),n([L()],S.prototype,"onrampPaymentIntentId",2),n([L()],S.prototype,"onrampErrorMessage",2),S=n([nt("icpay-premium-content")],S);import{LitElement as ot,html as le,css as rt}from"lit";import{customElement as at,property as lt,state as M}from"lit/decorators.js";var Ce=typeof window<"u",ue=null;function ee(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var f=class extends ot{constructor(){super(...arguments);this.selectedAmount=1;this.selectedSymbol=null;this.total=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="tip",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedAmount||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ue||(ue=(await import("@windoge98/plug-n-play")).PNP);let i=W({...this.config?.plugNPlay||{}});try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new ue(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[1,5,10]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ce){ee(this.config?.debug||!1,"Tip jar connected",{config:this.config}),this.config&&this.config.defaultAmountUsd&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol)}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="tip"&&this.tip()},0)}}async loadVerifiedLedgers(){if(!(!Ce||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.config?.cryptoOptions&&this.config.cryptoOptions.length===1&&(this.selectedSymbol=this.config.cryptoOptions[0].symbol),!this.selectedSymbol&&this.availableLedgers.length>0&&(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0].symbol)}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){return Math.min(this.total/50*100,100)}async tip(){if(Ce&&(ee(this.config?.debug||!1,"Tip button clicked!",{config:this.config,processing:this.processing}),!this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"tip",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="tip",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ee(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ue||(ue=(await import("@windoge98/plug-n-play")).PNP);let a=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?W({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");a.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new ue(a);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(A,N)=>this.pnp.getActor({canisterId:A,idl:N,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.tip();return}}catch{}let p=this.pnp.getEnabledWallets();if(ee(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="tip",this.showWalletModal=!0;return}catch(l){ee(this.config?.debug||!1,"Wallet connection error:",l),this.errorMessage=l instanceof Error?l.message:"Wallet connection failed",this.errorSeverity="error";return}}ee(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(l=>l.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ee(this.config?.debug||!1,"Tip payment details",{amount:this.selectedAmount,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedAmount,s,{context:"tip-jar"});ee(this.config?.debug||!1,"Tip payment completed",{resp:o}),this.total+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,total:this.total}),this.dispatchEvent(new CustomEvent("icpay-tip",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedAmount,s,{context:"tip:onramp"}),l=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,a=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=a,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="tip"&&setTimeout(()=>this.tip(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){if(!this.config)return le`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,s=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=s!=="none"&&(t||s==="dropdown"),l=s==="dropdown"?"dropdown":t?"buttons":"none";return le`
1073
1073
  <div class="icpay-card icpay-section icpay-widget-base" style="text-align:center;">
1074
- ${this.config?.progressBar?.enabled!==!1?ae`
1074
+ ${this.config?.progressBar?.enabled!==!1?le`
1075
1075
  <icpay-progress-bar
1076
1076
  .debug=${!!this.config?.debug}
1077
1077
  .theme=${this.config?.theme}
@@ -1083,17 +1083,17 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1083
1083
  <div class="label">Total Tips: $${this.total}</div>
1084
1084
 
1085
1085
  <div class="amounts">
1086
- ${this.amounts.map(l=>ae`<div class="chip ${this.selectedAmount===l?"selected":""}" @click=${()=>this.selectAmount(l)}>$${l}</div>`)}
1086
+ ${this.amounts.map(a=>le`<div class="chip ${this.selectedAmount===a?"selected":""}" @click=${()=>this.selectAmount(a)}>$${a}</div>`)}
1087
1087
  </div>
1088
1088
 
1089
- ${o?ae`
1089
+ ${o?le`
1090
1090
  <div>
1091
1091
  <icpay-token-selector
1092
1092
  .options=${this.cryptoOptions}
1093
1093
  .value=${this.selectedSymbol||""}
1094
1094
  .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
1095
- mode=${a}
1096
- @icpay-token-change=${l=>this.selectSymbol(l.detail.symbol)}
1095
+ mode=${l}
1096
+ @icpay-token-change=${a=>this.selectSymbol(a.detail.symbol)}
1097
1097
  ></icpay-token-selector>
1098
1098
  </div>
1099
1099
  `:null}
@@ -1104,21 +1104,21 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1104
1104
  ${this.succeeded&&this.config?.disableAfterSuccess?"Paid":this.processing?"Processing\u2026":this.config?.buttonLabel?this.config.buttonLabel.replace("{amount}",String(this.selectedAmount)).replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP"):`Tip $${this.selectedAmount} with ${this.selectedSymbol||this.config?.defaultSymbol||"ICP"}`}
1105
1105
  </button>
1106
1106
 
1107
- ${this.errorMessage?ae`
1107
+ ${this.errorMessage?le`
1108
1108
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1109
1109
  ${this.errorMessage}
1110
- ${this.errorAction?ae`
1110
+ ${this.errorAction?le`
1111
1111
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
1112
1112
  ${this.errorAction}
1113
1113
  </button>
1114
1114
  `:""}
1115
1115
  </div>
1116
1116
  `:""}
1117
- ${(()=>{let p=(this.pnp?.getEnabledWallets?.()||[]).map(c=>({id:this.getWalletId(c),label:this.getWalletLabel(c),icon:this.getWalletIcon(c)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:p,isConnecting:!1,onSelect:c=>this.connectWithWallet(c),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1,creditCardTooltip:(()=>{let h=Number(this.selectedAmount||this.config?.defaultAmountUsd||0);return h>0&&h<5&&this.config?.onramp?.enabled!==!1?`Note: Minimum card amount is $5. You will pay about $${(5-h).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.tip()}})})()}
1117
+ ${(()=>{let p=(this.pnp?.getEnabledWallets?.()||[]).map(c=>({id:this.getWalletId(c),label:this.getWalletLabel(c),icon:this.getWalletIcon(c)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:p,isConnecting:!1,onSelect:c=>this.connectWithWallet(c),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1,creditCardTooltip:(()=>{let h=Number(this.selectedAmount||this.config?.defaultAmountUsd||0);return h>0&&h<5&&this.config?.onramp?.enabled!==!1?`Note: Minimum card amount is $5. You will pay about $${(5-h).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.tip()}})})()}
1118
1118
 
1119
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1119
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1120
1120
  </div>
1121
- `}};f.styles=[z,rt`
1121
+ `}};f.styles=[K,rt`
1122
1122
  .jar { width: 120px; height: 160px; margin: 0 auto 12px; position: relative; background: linear-gradient(135deg, #374151 0%, #4b5563 100%); border-radius: 0 0 60px 60px; border: 3px solid #6b7280; border-top: 8px solid #6b7280; overflow: hidden; }
1123
1123
  .fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%); transition: height 0.8s ease; height: 0%; }
1124
1124
  .amounts { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 12px 0; }
@@ -1150,9 +1150,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1150
1150
  border-color: rgba(239, 68, 68, 0.3);
1151
1151
  color: #ef4444;
1152
1152
  }
1153
- `],n([lt({type:Object})],f.prototype,"config",2),n([M()],f.prototype,"selectedAmount",2),n([M()],f.prototype,"selectedSymbol",2),n([M()],f.prototype,"total",2),n([M()],f.prototype,"processing",2),n([M()],f.prototype,"succeeded",2),n([M()],f.prototype,"availableLedgers",2),n([M()],f.prototype,"errorMessage",2),n([M()],f.prototype,"errorSeverity",2),n([M()],f.prototype,"errorAction",2),n([M()],f.prototype,"walletConnected",2),n([M()],f.prototype,"pendingAction",2),n([M()],f.prototype,"showWalletModal",2),n([M()],f.prototype,"oisyReadyToPay",2),n([M()],f.prototype,"lastWalletId",2),n([M()],f.prototype,"showOnrampModal",2),n([M()],f.prototype,"onrampSessionId",2),n([M()],f.prototype,"onrampPaymentIntentId",2),n([M()],f.prototype,"onrampErrorMessage",2),f=n([at("icpay-tip-jar")],f);import{LitElement as ct,html as xe,css as dt}from"lit";import{customElement as pt,property as Ee,state as L}from"lit/decorators.js";var Ce=typeof window<"u",ue=null;function te(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var m=class extends ct{constructor(){super(...arguments);this.title="Article Title";this.preview="";this.lockedContent="";this.selectedSymbol=null;this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="unlock",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get obfuscatedLockedContent(){try{return(this.lockedContent||"").replace(/[^\s]/g,"x")}catch{return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ue||(ue=(await import("@windoge98/plug-n-play")).PNP);let i={...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new ue(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.config.priceUsd,s,{context:"article:onramp"}),a=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,l=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=l,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ce){te(this.config?.debug||!1,"Article paywall connected",{config:this.config}),this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="unlock"&&this.unlock()},0)}}async loadVerifiedLedgers(){if(!(!Ce||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async unlock(){if(Ce&&!(this.processing||this.unlocked)){te(this.config?.debug||!1,"Article paywall unlock started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="unlock",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){te(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ue||(ue=(await import("@windoge98/plug-n-play")).PNP);let l=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?T({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");l.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new ue(l);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(N,B)=>this.pnp.getActor({canisterId:N,idl:B,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.unlock();return}}catch{}let p=this.pnp.getEnabledWallets();if(te(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="unlock",this.showWalletModal=!0;return}catch(a){te(this.config?.debug||!1,"Wallet connection error:",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error";return}}te(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(a=>a.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);te(this.config?.debug||!1,"Article payment details",{priceUsd:this.config.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.config.priceUsd,s,{context:"article"});te(this.config?.debug||!1,"Article payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="unlock"&&setTimeout(()=>this.unlock(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?xe`
1153
+ `],n([lt({type:Object})],f.prototype,"config",2),n([M()],f.prototype,"selectedAmount",2),n([M()],f.prototype,"selectedSymbol",2),n([M()],f.prototype,"total",2),n([M()],f.prototype,"processing",2),n([M()],f.prototype,"succeeded",2),n([M()],f.prototype,"availableLedgers",2),n([M()],f.prototype,"errorMessage",2),n([M()],f.prototype,"errorSeverity",2),n([M()],f.prototype,"errorAction",2),n([M()],f.prototype,"walletConnected",2),n([M()],f.prototype,"pendingAction",2),n([M()],f.prototype,"showWalletModal",2),n([M()],f.prototype,"oisyReadyToPay",2),n([M()],f.prototype,"lastWalletId",2),n([M()],f.prototype,"showOnrampModal",2),n([M()],f.prototype,"onrampSessionId",2),n([M()],f.prototype,"onrampPaymentIntentId",2),n([M()],f.prototype,"onrampErrorMessage",2),f=n([at("icpay-tip-jar")],f);import{LitElement as ct,html as Se,css as dt}from"lit";import{customElement as pt,property as ke,state as T}from"lit/decorators.js";var Ie=typeof window<"u",ye=null;function te(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var m=class extends ct{constructor(){super(...arguments);this.title="Article Title";this.preview="";this.lockedContent="";this.selectedSymbol=null;this.unlocked=!1;this.succeeded=!1;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="unlock",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get obfuscatedLockedContent(){try{return(this.lockedContent||"").replace(/[^\s]/g,"x")}catch{return"xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;ye||(ye=(await import("@windoge98/plug-n-play")).PNP);let i={...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new ye(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.config.priceUsd,s,{context:"article:onramp"}),l=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,a=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=a,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ie){te(this.config?.debug||!1,"Article paywall connected",{config:this.config}),this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.config&&(typeof this.config.title=="string"&&(this.title=this.config.title),typeof this.config.preview=="string"&&(this.preview=this.config.preview),typeof this.config.lockedContent=="string"&&(this.lockedContent=this.config.lockedContent)),e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="unlock"&&this.unlock()},0)}}async loadVerifiedLedgers(){if(!(!Ie||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async unlock(){if(Ie&&!(this.processing||this.unlocked)){te(this.config?.debug||!1,"Article paywall unlock started",{priceUsd:this.config.priceUsd,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"unlock",type:"sendUsd",amount:this.config.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="unlock",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){te(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{ye||(ye=(await import("@windoge98/plug-n-play")).PNP);let a=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?W({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");a.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new ye(a);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(A,N)=>this.pnp.getActor({canisterId:A,idl:N,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.unlock();return}}catch{}let p=this.pnp.getEnabledWallets();if(te(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="unlock",this.showWalletModal=!0;return}catch(l){te(this.config?.debug||!1,"Wallet connection error:",l),this.errorMessage=l instanceof Error?l.message:"Wallet connection failed",this.errorSeverity="error";return}}te(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(l=>l.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);te(this.config?.debug||!1,"Article payment details",{priceUsd:this.config.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.config.priceUsd,s,{context:"article"});te(this.config?.debug||!1,"Article payment completed",{resp:o}),this.unlocked=!0,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status}),this.dispatchEvent(new CustomEvent("icpay-unlock",{detail:{amount:this.config.priceUsd,tx:o},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="unlock"&&setTimeout(()=>this.unlock(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?Se`
1154
1154
  <div class="icpay-card icpay-section icpay-widget-base">
1155
- ${this.config?.progressBar?.enabled!==!1?xe`
1155
+ ${this.config?.progressBar?.enabled!==!1?Se`
1156
1156
  <icpay-progress-bar
1157
1157
  .debug=${!!this.config?.debug}
1158
1158
  .theme=${this.config?.theme}
@@ -1182,21 +1182,21 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1182
1182
  ${this.unlocked?"Unlocked":this.processing?"Processing\u2026":(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",`${Number(this.config?.priceUsd??0).toFixed(2)}`).replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP")}
1183
1183
  </button>
1184
1184
 
1185
- ${this.errorMessage?xe`
1185
+ ${this.errorMessage?Se`
1186
1186
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1187
1187
  ${this.errorMessage}
1188
- ${this.errorAction?xe`
1188
+ ${this.errorAction?Se`
1189
1189
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
1190
1190
  ${this.errorAction}
1191
1191
  </button>
1192
1192
  `:""}
1193
1193
  </div>
1194
1194
  `:""}
1195
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=Number(this.config?.priceUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.unlock()}})})()}
1195
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=Number(this.config?.priceUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.unlock()}})})()}
1196
1196
 
1197
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1197
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1198
1198
  </div>
1199
- `:xe`<div class="icpay-card icpay-section">Loading...</div>`}};m.styles=[z,dt`
1199
+ `:Se`<div class="icpay-card icpay-section">Loading...</div>`}};m.styles=[K,dt`
1200
1200
  .container { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); border-radius: 16px; padding: 16px; margin-bottom: 16px; }
1201
1201
  .title { color: var(--icpay-text); font-weight: 700; margin-bottom: 8px; }
1202
1202
  .preview { color: var(--icpay-muted); margin-bottom: 12px; line-height: 1.6; }
@@ -1228,9 +1228,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1228
1228
  border-color: rgba(239, 68, 68, 0.3);
1229
1229
  color: #ef4444;
1230
1230
  }
1231
- `],n([Ee({type:Object})],m.prototype,"config",2),n([Ee({type:String})],m.prototype,"title",2),n([Ee({type:String})],m.prototype,"preview",2),n([Ee({type:String})],m.prototype,"lockedContent",2),n([L()],m.prototype,"selectedSymbol",2),n([L()],m.prototype,"unlocked",2),n([L()],m.prototype,"succeeded",2),n([L()],m.prototype,"processing",2),n([L()],m.prototype,"availableLedgers",2),n([L()],m.prototype,"errorMessage",2),n([L()],m.prototype,"errorSeverity",2),n([L()],m.prototype,"errorAction",2),n([L()],m.prototype,"walletConnected",2),n([L()],m.prototype,"pendingAction",2),n([L()],m.prototype,"showWalletModal",2),n([L()],m.prototype,"oisyReadyToPay",2),n([L()],m.prototype,"lastWalletId",2),n([L()],m.prototype,"showOnrampModal",2),n([L()],m.prototype,"onrampSessionId",2),n([L()],m.prototype,"onrampPaymentIntentId",2),n([L()],m.prototype,"onrampErrorMessage",2),m=n([pt("icpay-article-paywall")],m);import{LitElement as ht,html as ye,css as gt}from"lit";import{customElement as ut,property as yt,state as A}from"lit/decorators.js";var Ie=typeof window<"u",We=null;function ie(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var E=class extends ht{constructor(){super(...arguments);this.selectedIndex=0;this.selectedSymbol=null;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="order",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedItem?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ie){ie(this.config?.debug||!1,"Coffee shop connected",{config:this.config}),this.config&&typeof this.config.defaultItemIndex=="number"&&(this.selectedIndex=this.config.defaultItemIndex),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="order"&&this.order()},0)}}async loadVerifiedLedgers(){if(!(!Ie||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectItem(e){this.selectedIndex=e}selectSymbol(e){this.selectedSymbol=e}get selectedItem(){return this.config?.items?.[this.selectedIndex]||{name:"Loading...",priceUsd:0}}async order(){if(Ie&&!this.processing){ie(this.config?.debug||!1,"Coffee order started",{selectedItem:this.selectedItem,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:this.selectedItem.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="order",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ie(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{We||(We=(await import("@windoge98/plug-n-play")).PNP);let l=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?T({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");l.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new We(l);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(N,B)=>this.pnp.getActor({canisterId:N,idl:B,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.order();return}}catch{}let p=this.pnp.getEnabledWallets();if(ie(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="order",this.showWalletModal=!0;return}catch(a){ie(this.config?.debug||!1,"Wallet connection error:",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error";return}}ie(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(a=>a.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ie(this.config?.debug||!1,"Coffee order payment details",{item:this.selectedItem.name,priceUsd:this.selectedItem.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedItem.priceUsd,s,{context:"coffee",item:this.selectedItem.name});ie(this.config?.debug||!1,"Coffee order payment completed",{resp:o}),this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,item:this.selectedItem.name}),this.dispatchEvent(new CustomEvent("icpay-coffee",{detail:{item:this.selectedItem,tx:o},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedItem.priceUsd,s,{context:"coffee:onramp",item:this.selectedItem.name}),a=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,l=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=l,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="order"&&setTimeout(()=>this.order(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?ye`
1231
+ `],n([ke({type:Object})],m.prototype,"config",2),n([ke({type:String})],m.prototype,"title",2),n([ke({type:String})],m.prototype,"preview",2),n([ke({type:String})],m.prototype,"lockedContent",2),n([T()],m.prototype,"selectedSymbol",2),n([T()],m.prototype,"unlocked",2),n([T()],m.prototype,"succeeded",2),n([T()],m.prototype,"processing",2),n([T()],m.prototype,"availableLedgers",2),n([T()],m.prototype,"errorMessage",2),n([T()],m.prototype,"errorSeverity",2),n([T()],m.prototype,"errorAction",2),n([T()],m.prototype,"walletConnected",2),n([T()],m.prototype,"pendingAction",2),n([T()],m.prototype,"showWalletModal",2),n([T()],m.prototype,"oisyReadyToPay",2),n([T()],m.prototype,"lastWalletId",2),n([T()],m.prototype,"showOnrampModal",2),n([T()],m.prototype,"onrampSessionId",2),n([T()],m.prototype,"onrampPaymentIntentId",2),n([T()],m.prototype,"onrampErrorMessage",2),m=n([pt("icpay-article-paywall")],m);import{LitElement as ht,html as me,css as gt}from"lit";import{customElement as ut,property as yt,state as P}from"lit/decorators.js";var We=typeof window<"u",Le=null;function ie(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var E=class extends ht{constructor(){super(...arguments);this.selectedIndex=0;this.selectedSymbol=null;this.processing=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="order",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedItem?.priceUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!We){ie(this.config?.debug||!1,"Coffee shop connected",{config:this.config}),this.config&&typeof this.config.defaultItemIndex=="number"&&(this.selectedIndex=this.config.defaultItemIndex),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="order"&&this.order()},0)}}async loadVerifiedLedgers(){if(!(!We||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectItem(e){this.selectedIndex=e}selectSymbol(e){this.selectedSymbol=e}get selectedItem(){return this.config?.items?.[this.selectedIndex]||{name:"Loading...",priceUsd:0}}async order(){if(We&&!this.processing){ie(this.config?.debug||!1,"Coffee order started",{selectedItem:this.selectedItem,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"order",type:"sendUsd",amount:this.selectedItem.priceUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="order",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ie(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{Le||(Le=(await import("@windoge98/plug-n-play")).PNP);let a=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?W({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");a.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new Le(a);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(A,N)=>this.pnp.getActor({canisterId:A,idl:N,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.order();return}}catch{}let p=this.pnp.getEnabledWallets();if(ie(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="order",this.showWalletModal=!0;return}catch(l){ie(this.config?.debug||!1,"Wallet connection error:",l),this.errorMessage=l instanceof Error?l.message:"Wallet connection failed",this.errorSeverity="error";return}}ie(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(l=>l.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ie(this.config?.debug||!1,"Coffee order payment details",{item:this.selectedItem.name,priceUsd:this.selectedItem.priceUsd,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedItem.priceUsd,s,{context:"coffee",item:this.selectedItem.name});ie(this.config?.debug||!1,"Coffee order payment completed",{resp:o}),this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,item:this.selectedItem.name}),this.dispatchEvent(new CustomEvent("icpay-coffee",{detail:{item:this.selectedItem,tx:o},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedItem.priceUsd,s,{context:"coffee:onramp",item:this.selectedItem.name}),l=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,a=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=a,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="order"&&setTimeout(()=>this.order(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?me`
1232
1232
  <div class="icpay-card icpay-section icpay-widget-base">
1233
- ${this.config?.progressBar?.enabled!==!1?ye`
1233
+ ${this.config?.progressBar?.enabled!==!1?me`
1234
1234
  <icpay-progress-bar
1235
1235
  .debug=${!!this.config?.debug}
1236
1236
  .theme=${this.config?.theme}
@@ -1239,7 +1239,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1239
1239
  ></icpay-progress-bar>
1240
1240
  `:null}
1241
1241
  <div class="menu">
1242
- ${this.config.items.map((e,t)=>ye`
1242
+ ${this.config.items.map((e,t)=>me`
1243
1243
  <div class="item ${this.selectedIndex===t?"selected":""}" @click=${()=>this.selectItem(t)}>
1244
1244
  <span>${e.name}</span>
1245
1245
  <span>$${Number(e?.priceUsd??0).toFixed(2)}</span>
@@ -1263,21 +1263,21 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1263
1263
  ${this.processing?"Processing\u2026":`Order ${this.selectedItem.name}`}
1264
1264
  </button>
1265
1265
 
1266
- ${this.errorMessage?ye`
1266
+ ${this.errorMessage?me`
1267
1267
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1268
1268
  ${this.errorMessage}
1269
- ${this.errorAction?ye`
1269
+ ${this.errorAction?me`
1270
1270
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
1271
1271
  ${this.errorAction}
1272
1272
  </button>
1273
1273
  `:""}
1274
1274
  </div>
1275
1275
  `:""}
1276
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=this.config?.defaultItemIndex??0,o=Number(this.config?.items?.[s]?.priceUsd||0);return o>0&&o<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-o).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.order()}})})()}
1276
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let s=this.config?.defaultItemIndex??0,o=Number(this.config?.items?.[s]?.priceUsd||0);return o>0&&o<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-o).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.order()}})})()}
1277
1277
 
1278
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1278
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1279
1279
  </div>
1280
- `:ye`<div class="icpay-card icpay-section">Loading...</div>`}};E.styles=[z,gt`
1280
+ `:me`<div class="icpay-card icpay-section">Loading...</div>`}};E.styles=[K,gt`
1281
1281
  .menu { display: grid; gap: 8px; margin-bottom: 12px; }
1282
1282
  .item { background: var(--icpay-surface-alt); border: 2px solid var(--icpay-border); border-radius: 12px; padding: 16px; display:flex; justify-content: space-between; align-items:center; cursor: pointer; color: var(--icpay-text); font-weight: 600; }
1283
1283
  .item.selected { background: var(--icpay-primary); color: #111827; border-color: var(--icpay-primary); }
@@ -1308,9 +1308,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1308
1308
  border-color: rgba(239, 68, 68, 0.3);
1309
1309
  color: #ef4444;
1310
1310
  }
1311
- `],n([yt({type:Object})],E.prototype,"config",2),n([A()],E.prototype,"selectedIndex",2),n([A()],E.prototype,"selectedSymbol",2),n([A()],E.prototype,"processing",2),n([A()],E.prototype,"availableLedgers",2),n([A()],E.prototype,"errorMessage",2),n([A()],E.prototype,"errorSeverity",2),n([A()],E.prototype,"errorAction",2),n([A()],E.prototype,"walletConnected",2),n([A()],E.prototype,"pendingAction",2),n([A()],E.prototype,"showWalletModal",2),n([A()],E.prototype,"oisyReadyToPay",2),n([A()],E.prototype,"lastWalletId",2),n([A()],E.prototype,"showOnrampModal",2),n([A()],E.prototype,"onrampSessionId",2),n([A()],E.prototype,"onrampPaymentIntentId",2),n([A()],E.prototype,"onrampErrorMessage",2),E=n([ut("icpay-coffee-shop")],E);import{LitElement as mt,html as me,css as ft}from"lit";import{customElement as bt,property as vt,state as O}from"lit/decorators.js";var Le=typeof window<"u",fe=null;function ne(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var b=class extends mt{constructor(){super(...arguments);this.selectedAmount=10;this.selectedSymbol=null;this.raised=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="donate",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedAmount||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;fe||(fe=(await import("@windoge98/plug-n-play")).PNP);let i=T({...this.config?.plugNPlay||{}});try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new fe(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[10,25,50,100,250,500]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Le){ne(this.config?.debug||!1,"Donation thermometer connected",{config:this.config}),this.config&&typeof this.config.defaultAmountUsd=="number"&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="donate"&&this.donate()},0)}}async loadVerifiedLedgers(){if(!(!Le||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){let e=Number(this.config?.goalUsd??1e3),t=e>0?e:1e3;return Math.min(this.raised/t*100,100)}async donate(){if(Le&&!this.processing){ne(this.config?.debug||!1,"Donation started",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="donate",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ne(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{fe||(fe=(await import("@windoge98/plug-n-play")).PNP);let l=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?T({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");l.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new fe(l);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(N,B)=>this.pnp.getActor({canisterId:N,idl:B,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.donate();return}}catch{}let p=this.pnp.getEnabledWallets();if(ne(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="donate",this.showWalletModal=!0;return}catch(a){ne(this.config?.debug||!1,"Wallet connection error:",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error";return}}ne(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(a=>a.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ne(this.config?.debug||!1,"Donation payment details",{amount:this.selectedAmount,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedAmount,s,{context:"donation"});ne(this.config?.debug||!1,"Donation payment completed",{resp:o}),this.raised+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,raised:this.raised}),this.dispatchEvent(new CustomEvent("icpay-donation",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedAmount,s,{context:"donation:onramp"}),a=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,l=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=l,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="donate"&&setTimeout(()=>this.donate(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?me`
1311
+ `],n([yt({type:Object})],E.prototype,"config",2),n([P()],E.prototype,"selectedIndex",2),n([P()],E.prototype,"selectedSymbol",2),n([P()],E.prototype,"processing",2),n([P()],E.prototype,"availableLedgers",2),n([P()],E.prototype,"errorMessage",2),n([P()],E.prototype,"errorSeverity",2),n([P()],E.prototype,"errorAction",2),n([P()],E.prototype,"walletConnected",2),n([P()],E.prototype,"pendingAction",2),n([P()],E.prototype,"showWalletModal",2),n([P()],E.prototype,"oisyReadyToPay",2),n([P()],E.prototype,"lastWalletId",2),n([P()],E.prototype,"showOnrampModal",2),n([P()],E.prototype,"onrampSessionId",2),n([P()],E.prototype,"onrampPaymentIntentId",2),n([P()],E.prototype,"onrampErrorMessage",2),E=n([ut("icpay-coffee-shop")],E);import{LitElement as mt,html as fe,css as ft}from"lit";import{customElement as bt,property as vt,state as O}from"lit/decorators.js";var Te=typeof window<"u",be=null;function ne(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var b=class extends mt{constructor(){super(...arguments);this.selectedAmount=10;this.selectedSymbol=null;this.raised=0;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="donate",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.selectedAmount||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}async tryAutoConnectPNP(){try{if(!this.config||this.config?.useOwnWallet)return;let e=localStorage.getItem("icpay:pnp");if(!e)return;let t=JSON.parse(e);if(!t?.provider||!t?.principal)return;be||(be=(await import("@windoge98/plug-n-play")).PNP);let i=W({...this.config?.plugNPlay||{}});try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}let s=new be(i);this.walletConnected=!1,this.config={...this.config,connectedWallet:{owner:t.principal,principal:t.principal,connected:!1}}}catch{}}get amounts(){return this.config?.amountsUsd||[10,25,50,100,250,500]}get cryptoOptions(){return this.config.cryptoOptions?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Te){ne(this.config?.debug||!1,"Donation thermometer connected",{config:this.config}),this.config&&typeof this.config.defaultAmountUsd=="number"&&(this.selectedAmount=this.config.defaultAmountUsd),this.tryAutoConnectPNP();try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers()}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="donate"&&this.donate()},0)}}async loadVerifiedLedgers(){if(!(!Te||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||this.availableLedgers[0]?.symbol||"ICP")}catch(e){console.warn("Failed to load verified ledgers:",e),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectAmount(e){this.selectedAmount=e}selectSymbol(e){this.selectedSymbol=e}get fillPercentage(){let e=Number(this.config?.goalUsd??1e3),t=e>0?e:1e3;return Math.min(this.raised/t*100,100)}async donate(){if(Te&&!this.processing){ne(this.config?.debug||!1,"Donation started",{amount:this.selectedAmount,selectedSymbol:this.selectedSymbol,useOwnWallet:this.config.useOwnWallet}),this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"donate",type:"sendUsd",amount:this.selectedAmount,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.config.useOwnWallet){if(!this.config.actorProvider){this.pendingAction="donate",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0}));return}}else if(!this.walletConnected){ne(this.config?.debug||!1,"Connecting to wallet via Plug N Play");try{be||(be=(await import("@windoge98/plug-n-play")).PNP);let a=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab)?W({...this.config?.plugNPlay||{}}):{...this.config?.plugNPlay||{}};try{if(typeof window<"u"){let{resolveDerivationOrigin:c}=await import("./origin-44ZEXSX4.js");a.derivationOrigin=this.config?.derivationOrigin||c()}}catch{}this.pnp=new be(a);try{let c=await J(this.pnp);if(c){this.walletConnected=!0;let h=k(this.pnp,{owner:c,principal:c,connected:!0});this.config={...this.config,connectedWallet:h,actorProvider:(A,N)=>this.pnp.getActor({canisterId:A,idl:N,requiresSigning:!0,anon:!1})};try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}this.donate();return}}catch{}let p=this.pnp.getEnabledWallets();if(ne(this.config?.debug||!1,"Available wallets",p),!p?.length)throw new Error("No wallets available");this.pendingAction="donate",this.showWalletModal=!0;return}catch(l){ne(this.config?.debug||!1,"Wallet connection error:",l),this.errorMessage=l instanceof Error?l.message:"Wallet connection failed",this.errorSeverity="error";return}}ne(this.config?.debug||!1,"Creating SDK for payment");let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(l=>l.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t);ne(this.config?.debug||!1,"Donation payment details",{amount:this.selectedAmount,selectedSymbol:t,canisterId:s});let o=await e.sendUsd(this.selectedAmount,s,{context:"donation"});ne(this.config?.debug||!1,"Donation payment completed",{resp:o}),this.raised+=this.selectedAmount,this.succeeded=!0,this.config.onSuccess&&this.config.onSuccess({id:o.transactionId,status:o.status,raised:this.raised}),this.dispatchEvent(new CustomEvent("icpay-donation",{detail:{amount:this.selectedAmount,tx:o},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(c=>c.symbol===t).canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=await e.startOnrampUsd(this.selectedAmount,s,{context:"donation:onramp"}),l=o?.metadata?.onramp?.sessionId||o?.metadata?.onramp?.session_id||null,a=o?.metadata?.paymentIntentId||o?.paymentIntentId||null,p=o?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=a,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=p||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="donate"&&setTimeout(()=>this.donate(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}render(){return this.config?fe`
1312
1312
  <div class="icpay-card icpay-section icpay-widget-base" style="text-align:center;">
1313
- ${this.config?.progressBar?.enabled!==!1?me`
1313
+ ${this.config?.progressBar?.enabled!==!1?fe`
1314
1314
  <icpay-progress-bar
1315
1315
  .debug=${!!this.config?.debug}
1316
1316
  .theme=${this.config?.theme}
@@ -1322,7 +1322,7 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1322
1322
  <div class="total">$${Number(this.raised).toFixed(0)} / $${Number(this.config?.goalUsd??0).toFixed(2)}</div>
1323
1323
 
1324
1324
  <div class="amounts">
1325
- ${this.amounts.map(e=>me`<div class="chip ${this.selectedAmount===e?"selected":""}" @click=${()=>this.selectAmount(e)}>$${e}</div>`)}
1325
+ ${this.amounts.map(e=>fe`<div class="chip ${this.selectedAmount===e?"selected":""}" @click=${()=>this.selectAmount(e)}>$${e}</div>`)}
1326
1326
  </div>
1327
1327
 
1328
1328
  <div>
@@ -1341,21 +1341,21 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1341
1341
  ${this.succeeded&&this.config?.disableAfterSuccess?"Donated":this.processing?"Processing\u2026":(this.config?.buttonLabel||"Donate {amount} with {symbol}").replace("{amount}",`${this.selectedAmount}`).replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP")}
1342
1342
  </button>
1343
1343
 
1344
- ${this.errorMessage?me`
1344
+ ${this.errorMessage?fe`
1345
1345
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1346
1346
  ${this.errorMessage}
1347
- ${this.errorAction?me`
1347
+ ${this.errorAction?fe`
1348
1348
  <button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">
1349
1349
  ${this.errorAction}
1350
1350
  </button>
1351
1351
  `:""}
1352
1352
  </div>
1353
1353
  `:""}
1354
- ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1,creditCardTooltip:(()=>{let s=Number(this.selectedAmount||this.config?.defaultAmountUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.donate()}})})()}
1354
+ ${(()=>{let t=(this.pnp?.getEnabledWallets?.()||[]).map(i=>({id:this.getWalletId(i),label:this.getWalletLabel(i),icon:this.getWalletIcon(i)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:t,isConnecting:!1,onSelect:i=>this.connectWithWallet(i),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1,creditCardTooltip:(()=>{let s=Number(this.selectedAmount||this.config?.defaultAmountUsd||0);return s>0&&s<5&&this.config?.onramp?.enabled!==!1?`Note: Minimum card amount is $5. You will pay about $${(5-s).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.donate()}})})()}
1355
1355
 
1356
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1356
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1357
1357
  </div>
1358
- `:me`<div class="icpay-card icpay-section">Loading...</div>`}};b.styles=[z,ft`
1358
+ `:fe`<div class="icpay-card icpay-section">Loading...</div>`}};b.styles=[K,ft`
1359
1359
  .thermo { width: 60px; height: 200px; background: var(--icpay-surface-alt); border: 3px solid #6b7280; border-radius: 30px; margin: 0 auto 12px; position: relative; overflow: hidden; }
1360
1360
  .fill { position: absolute; bottom: 0; left: 0; right: 0; background: linear-gradient(135deg, #d1d5db 0%, #9ca3af 100%); transition: height 0.8s ease; height: 0%; border-radius: 0 0 27px 27px; }
1361
1361
  .amounts { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin: 12px 0; }
@@ -1387,25 +1387,25 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1387
1387
  border-color: rgba(239, 68, 68, 0.3);
1388
1388
  color: #ef4444;
1389
1389
  }
1390
- `],n([vt({type:Object})],b.prototype,"config",2),n([O()],b.prototype,"selectedAmount",2),n([O()],b.prototype,"selectedSymbol",2),n([O()],b.prototype,"raised",2),n([O()],b.prototype,"processing",2),n([O()],b.prototype,"succeeded",2),n([O()],b.prototype,"availableLedgers",2),n([O()],b.prototype,"errorMessage",2),n([O()],b.prototype,"errorSeverity",2),n([O()],b.prototype,"errorAction",2),n([O()],b.prototype,"walletConnected",2),n([O()],b.prototype,"pendingAction",2),n([O()],b.prototype,"showWalletModal",2),n([O()],b.prototype,"oisyReadyToPay",2),n([O()],b.prototype,"lastWalletId",2),n([O()],b.prototype,"showOnrampModal",2),n([O()],b.prototype,"onrampSessionId",2),n([O()],b.prototype,"onrampPaymentIntentId",2),n([O()],b.prototype,"onrampErrorMessage",2),b=n([bt("icpay-donation-thermometer")],b);import{LitElement as wt,html as be,css as xt}from"lit";import{customElement as St,property as Et,state as C}from"lit/decorators.js";var Te=typeof window<"u",Ae=null;function q(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var v=class extends wt{constructor(){super(...arguments);this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.oisyReadyToPay=!1;this.oisySignerPreopened=!1;this.skipDisconnectOnce=!1;this.lastWalletId=null;this.onrampPollTimer=null;this.transakMessageHandlerBound=null;this.pnp=null;this.sdk=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.amountUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}getSdk(){return this.sdk||(this.sdk=g(this.config)),this.sdk}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Te){q(this.config?.debug||!1,"Pay button connected",{config:this.config}),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol);try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}try{window.addEventListener("icpay-sdk-transaction-created",(e=>{q(this.config?.debug||!1,"SDK transaction created",{detail:e?.detail})}))}catch{}}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}e.has("config")&&(this.sdk=null,!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}async loadVerifiedLedgers(){if(!(!Te||!this.config?.publishableKey))try{let t=await this.getSdk().client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{Ae||(Ae=(await import("@windoge98/plug-n-play")).PNP);let e=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab),t={...this.config?.plugNPlay||{}},i=e?T(t):t;try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}this.pnp=new Ae(i);let s=this.pnp.getEnabledWallets();if(q(this.config?.debug||!1,"Available wallets",s),!s?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(q(this.config?.debug||!1,"Wallet connect result",i),!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},(e||"").toLowerCase()==="oisy")this.oisyReadyToPay=!0,this.pendingAction=null;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="pay"&&(this.skipDisconnectOnce=!0,this.pay())}}).catch(i=>{q(this.config?.debug||!1,"Wallet connection error",i),this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){q(this.config?.debug||!1,"Wallet connection error (sync)",t),this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}renderWalletModal(){if(!this.showWalletModal||!this.pnp)return null;let t=(this.pnp.getEnabledWallets()||[]).map(c=>({id:this.getWalletId(c),label:this.getWalletLabel(c),icon:this.getWalletIcon(c)})),i=this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,s=5,o=Number(this.config?.amountUsd??0),a=i&&o>0&&o<s,l=Math.max(0,s-o),p=a?`Note: Minimum card amount is $${s}. You will pay about $${l.toFixed(2)} more.`:null;return H({visible:this.showWalletModal,wallets:t,isConnecting:!1,onSelect:c=>{this.connectWithWallet(c)},onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:i?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:i,creditCardTooltip:p,oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.skipDisconnectOnce=!0,this.oisyReadyToPay=!1,this.pay()}})}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=Number(this.config?.amountUsd??0),t=this.getSdk();this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP");let i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(h=>h.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),a=await t.startOnrampUsd(e,o,{context:"pay-button:onramp"}),l=a?.metadata?.onramp?.sessionId||a?.metadata?.onramp?.session_id||null,p=a?.metadata?.onramp?.errorMessage||null;this.onrampErrorMessage=p||null;let c=a?.metadata?.paymentIntentId||a?.paymentIntentId||null;this.onrampPaymentIntentId=c,l?(this.onrampSessionId=l,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||null,this.showOnrampModal=!0,P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}})}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"getLedgerBalance"}}))}catch{}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"sendFundsToLedger"}}))}catch{}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"notifyLedgerTransaction"}}))}catch{}this.showOnrampModal=!1,this.startOnrampPolling(s||void 0)}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=this.getSdk(),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1},o=a=>{s()};try{window.addEventListener("icpay-sdk-transaction-completed",o,{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}async pay(){if(!(!Te||this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config?.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.skipDisconnectOnce)this.skipDisconnectOnce=!1;else try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}if(!await this.ensureWallet())return;let t=this.getSdk();try{let c=this.config?.connectedWallet,h=this?.pnp?.account;q(this.config?.debug||!1,"Wallet state before payment",{connectedWallet:c,pnpAccount:h,principal:c?.owner||c?.principal||h?.owner||h?.principal||null})}catch{}this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP");let i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(c=>c.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i);q(this.config?.debug||!1,"Resolved ledger details",{symbol:i,canisterId:o});let a=Number(this.config?.amountUsd??0),l={context:"pay-button"};q(this.config?.debug||!1,"Calling sdk.sendUsd",{amountUsd:a,canisterId:o,meta:l});let p=await t.sendUsd(a,o,l);q(this.config?.debug||!1,"sdk.sendUsd response",p),this.config.onSuccess&&this.config.onSuccess({id:p.transactionId,status:p.status}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-pay",{detail:{amount:a,tx:p},bubbles:!0}))}catch(e){q(this.config?.debug||!1,"Payment error",{message:e?.message,code:e?.code,details:e?.details,stack:e?.stack}),P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}render(){if(!this.config)return be`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,s=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=s!=="none"&&(t||s==="dropdown"),a=s==="dropdown"?"dropdown":t?"buttons":"none",l=this.selectedSymbol||this.config?.defaultSymbol||"ICP",p=typeof this.config?.amountUsd=="number"?`${Number(this.config.amountUsd).toFixed(2)}`:"",h=(this.config?.buttonLabel||(typeof this.config?.amountUsd=="number"?"Pay ${amount} with {symbol}":"Pay with {symbol}")).replace("{amount}",p||"$0.00").replace("{symbol}",l),B=this.config?.progressBar?.enabled!==!1;return be`
1390
+ `],n([vt({type:Object})],b.prototype,"config",2),n([O()],b.prototype,"selectedAmount",2),n([O()],b.prototype,"selectedSymbol",2),n([O()],b.prototype,"raised",2),n([O()],b.prototype,"processing",2),n([O()],b.prototype,"succeeded",2),n([O()],b.prototype,"availableLedgers",2),n([O()],b.prototype,"errorMessage",2),n([O()],b.prototype,"errorSeverity",2),n([O()],b.prototype,"errorAction",2),n([O()],b.prototype,"walletConnected",2),n([O()],b.prototype,"pendingAction",2),n([O()],b.prototype,"showWalletModal",2),n([O()],b.prototype,"oisyReadyToPay",2),n([O()],b.prototype,"lastWalletId",2),n([O()],b.prototype,"showOnrampModal",2),n([O()],b.prototype,"onrampSessionId",2),n([O()],b.prototype,"onrampPaymentIntentId",2),n([O()],b.prototype,"onrampErrorMessage",2),b=n([bt("icpay-donation-thermometer")],b);import{LitElement as wt,html as ve,css as xt}from"lit";import{customElement as St,property as Et,state as C}from"lit/decorators.js";var Ae=typeof window<"u",we=null;function Y(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var v=class extends wt{constructor(){super(...arguments);this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.oisyReadyToPay=!1;this.oisySignerPreopened=!1;this.skipDisconnectOnce=!1;this.lastWalletId=null;this.onrampPollTimer=null;this.transakMessageHandlerBound=null;this.pnp=null;this.oisyConnectRetriedNewTab=!1;this.sdk=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.config?.amountUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}getSdk(){return this.sdk||(this.sdk=g(this.config)),this.sdk}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ae){Y(this.config?.debug||!1,"Pay button connected",{config:this.config}),this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol);try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}try{window.addEventListener("icpay-sdk-transaction-created",(e=>{Y(this.config?.debug||!1,"SDK transaction created",{detail:e?.detail})}))}catch{}}}updated(e){if(e.has("config")&&this.pendingAction&&this.config?.actorProvider){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}e.has("config")&&(this.sdk=null,!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol))}async loadVerifiedLedgers(){if(!(!Ae||!this.config?.publishableKey))try{let t=await this.getSdk().client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}selectSymbol(e){this.selectedSymbol=e}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{we||(we=(await import("@windoge98/plug-n-play")).PNP);let e=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab),t={...this.config?.plugNPlay||{}},i=e?W(t):t;try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}this.pnp=new we(i);let s=this.pnp.getEnabledWallets();if(Y(this.config?.debug||!1,"Available wallets",s),!s?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.lastWalletId==="oisy"&&(this.oisyConnectRetriedNewTab=!1),this.pnp.connect(e).then(i=>{if(Y(this.config?.debug||!1,"Wallet connect result",i),!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},(e||"").toLowerCase()==="oisy")this.oisyReadyToPay=!0,this.pendingAction=null;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="pay"&&(this.skipDisconnectOnce=!0,this.pay())}}).catch(i=>{Y(this.config?.debug||!1,"Wallet connection error",i);let s=(e||"").toLowerCase()==="oisy",o=i&&(i.message||String(i))||"";if(s&&!this.oisyConnectRetriedNewTab&&(o.includes("Signer window could not be opened")||o.includes("Communication channel could not be established"))){this.oisyConnectRetriedNewTab=!0,(async()=>{try{we||(we=(await import("@windoge98/plug-n-play")).PNP);let a={...this.config?.plugNPlay||{}},p=W(a);try{if(typeof window<"u"){let{resolveDerivationOrigin:h}=await import("./origin-44ZEXSX4.js");p.derivationOrigin=this.config?.derivationOrigin||h()}}catch{}this.pnp=new we(p),this.pnp.connect("oisy").then(h=>{if(!!!(h&&(h.connected===!0||h.principal||h.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"oisy"}}))}catch{}let N=k(this.pnp,h);this.config={...this.config,connectedWallet:N,actorProvider:(se,R)=>this.pnp.getActor({canisterId:se,idl:R,requiresSigning:!0,anon:!1})},this.oisyReadyToPay=!0,this.pendingAction=null}).catch(h=>{Y(this.config?.debug||!1,"Oisy retry connect (new tab) failed",h),this.errorMessage=h instanceof Error?h.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(a){Y(this.config?.debug||!1,"Oisy new-tab init failed",a),this.errorMessage=a instanceof Error?a.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}})();return}this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){Y(this.config?.debug||!1,"Wallet connection error (sync)",t),this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}renderWalletModal(){if(!this.showWalletModal||!this.pnp)return null;let t=(this.pnp.getEnabledWallets()||[]).map(c=>({id:this.getWalletId(c),label:this.getWalletLabel(c),icon:this.getWalletIcon(c)})),i=this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,s=5,o=Number(this.config?.amountUsd??0),l=i&&o>0&&o<s,a=Math.max(0,s-o),p=l?`Note: Minimum card amount is $${s}. You will pay about $${a.toFixed(2)} more.`:null;return V({visible:this.showWalletModal,wallets:t,isConnecting:!1,onSelect:c=>{this.connectWithWallet(c)},onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:i?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:i,creditCardTooltip:p,oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.skipDisconnectOnce=!0,this.oisyReadyToPay=!1,this.pay()}})}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=Number(this.config?.amountUsd??0),t=this.getSdk();this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP");let i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(h=>h.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=await t.startOnrampUsd(e,o,{context:"pay-button:onramp"}),a=l?.metadata?.onramp?.sessionId||l?.metadata?.onramp?.session_id||null,p=l?.metadata?.onramp?.errorMessage||null;this.onrampErrorMessage=p||null;let c=l?.metadata?.paymentIntentId||l?.paymentIntentId||null;this.onrampPaymentIntentId=c,a?(this.onrampSessionId=a,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||null,this.showOnrampModal=!0,U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}})}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"getLedgerBalance"}}))}catch{}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"sendFundsToLedger"}}))}catch{}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-success",{detail:{name:"notifyLedgerTransaction"}}))}catch{}this.showOnrampModal=!1,this.startOnrampPolling(s||void 0)}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=this.getSdk(),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1},o=l=>{s()};try{window.addEventListener("icpay-sdk-transaction-completed",o,{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}async pay(){if(!(!Ae||this.processing)){this.errorMessage=null,this.errorSeverity=null,this.errorAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.config?.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(this.skipDisconnectOnce)this.skipDisconnectOnce=!1;else try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}if(!await this.ensureWallet())return;let t=this.getSdk();try{let c=this.config?.connectedWallet,h=this?.pnp?.account;Y(this.config?.debug||!1,"Wallet state before payment",{connectedWallet:c,pnpAccount:h,principal:c?.owner||c?.principal||h?.owner||h?.principal||null})}catch{}this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP");let i=this.selectedSymbol||"ICP",o=this.cryptoOptions.find(c=>c.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i);Y(this.config?.debug||!1,"Resolved ledger details",{symbol:i,canisterId:o});let l=Number(this.config?.amountUsd??0),a={context:"pay-button"};Y(this.config?.debug||!1,"Calling sdk.sendUsd",{amountUsd:l,canisterId:o,meta:a});let p=await t.sendUsd(l,o,a);Y(this.config?.debug||!1,"sdk.sendUsd response",p),this.config.onSuccess&&this.config.onSuccess({id:p.transactionId,status:p.status}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-pay",{detail:{amount:l,tx:p},bubbles:!0}))}catch(e){Y(this.config?.debug||!1,"Payment error",{message:e?.message,code:e?.code,details:e?.details,stack:e?.stack}),U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}render(){if(!this.config)return ve`<div class="icpay-card icpay-section">Loading...</div>`;let t=(this.cryptoOptions?.length||0)>1,i=this.config?.showLedgerDropdown,s=i==="dropdown"?"dropdown":i==="none"?"none":"buttons",o=s!=="none"&&(t||s==="dropdown"),l=s==="dropdown"?"dropdown":t?"buttons":"none",a=this.selectedSymbol||this.config?.defaultSymbol||"ICP",p=typeof this.config?.amountUsd=="number"?`${Number(this.config.amountUsd).toFixed(2)}`:"",h=(this.config?.buttonLabel||(typeof this.config?.amountUsd=="number"?"Pay ${amount} with {symbol}":"Pay with {symbol}")).replace("{amount}",p||"$0.00").replace("{symbol}",a),N=this.config?.progressBar?.enabled!==!1;return ve`
1391
1391
  <div class="icpay-card icpay-section icpay-widget-base">
1392
- ${B?be`
1392
+ ${N?ve`
1393
1393
  <icpay-progress-bar
1394
1394
  .debug=${!!this.config?.debug}
1395
1395
  .theme=${this.config?.theme}
1396
1396
  .amount=${Number(this.config?.amountUsd||0)}
1397
- .ledgerSymbol=${l}
1397
+ .ledgerSymbol=${a}
1398
1398
  ></icpay-progress-bar>
1399
1399
  `:null}
1400
1400
 
1401
1401
  <div class="row ${o?"":"single"}">
1402
- ${o?be`
1402
+ ${o?ve`
1403
1403
  <icpay-token-selector
1404
1404
  .options=${this.cryptoOptions}
1405
1405
  .value=${this.selectedSymbol||""}
1406
1406
  .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
1407
- mode=${a}
1408
- @icpay-token-change=${we=>this.selectSymbol(we.detail.symbol)}
1407
+ mode=${l}
1408
+ @icpay-token-change=${se=>this.selectSymbol(se.detail.symbol)}
1409
1409
  ></icpay-token-selector>
1410
1410
  `:null}
1411
1411
  <button class="pay-button ${this.processing?"processing":""}"
@@ -1415,16 +1415,16 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1415
1415
  </button>
1416
1416
  </div>
1417
1417
 
1418
- ${this.errorMessage?be`
1418
+ ${this.errorMessage?ve`
1419
1419
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1420
1420
  ${this.errorMessage}
1421
- ${this.errorAction?be`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
1421
+ ${this.errorAction?ve`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
1422
1422
  </div>
1423
1423
  `:""}
1424
1424
  ${this.renderWalletModal()}
1425
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,apiUrl:this.config?.apiUrl,paymentIntentId:this.onrampPaymentIntentId,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1425
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,apiUrl:this.config?.apiUrl,paymentIntentId:this.onrampPaymentIntentId,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1426
1426
  </div>
1427
- `}};v.styles=[z,xt`
1427
+ `}};v.styles=[K,xt`
1428
1428
  .row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center; }
1429
1429
  .row.single { grid-template-columns: 1fr; }
1430
1430
  select { background: var(--icpay-surface-alt); border: 1px solid var(--icpay-border); color: var(--icpay-text); border-radius: 8px; padding: 10px; font-weight: 600; }
@@ -1432,9 +1432,9 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1432
1432
  .error-message.info { background: rgba(59,130,246,0.1); border-color: rgba(59,130,246,0.3); color: #3b82f6; }
1433
1433
  .error-message.warning { background: rgba(245,158,11,0.1); border-color: rgba(245,158,11,0.3); color: #f59e0b; }
1434
1434
  .error-message.error { background: rgba(239,68,68,0.1); border-color: rgba(239,68,68,0.3); color: #ef4444; }
1435
- `],n([Et({type:Object})],v.prototype,"config",2),n([C()],v.prototype,"selectedSymbol",2),n([C()],v.prototype,"processing",2),n([C()],v.prototype,"succeeded",2),n([C()],v.prototype,"availableLedgers",2),n([C()],v.prototype,"errorMessage",2),n([C()],v.prototype,"errorSeverity",2),n([C()],v.prototype,"errorAction",2),n([C()],v.prototype,"walletConnected",2),n([C()],v.prototype,"pendingAction",2),n([C()],v.prototype,"showWalletModal",2),n([C()],v.prototype,"showOnrampModal",2),n([C()],v.prototype,"onrampSessionId",2),n([C()],v.prototype,"onrampPaymentIntentId",2),n([C()],v.prototype,"onrampErrorMessage",2),n([C()],v.prototype,"oisyReadyToPay",2),n([C()],v.prototype,"oisySignerPreopened",2),n([C()],v.prototype,"skipDisconnectOnce",2),n([C()],v.prototype,"lastWalletId",2),v=n([St("icpay-pay-button")],v);import{LitElement as kt,html as ve,css as Mt}from"lit";import{customElement as Ot,property as Ct,state as I}from"lit/decorators.js";var Ne=typeof window<"u",Pe=null;function It(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var w=class extends kt{constructor(){super(...arguments);this.amountUsd=0;this.hasUserAmount=!1;this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.amountUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ne){It(this.config?.debug||!1,"Amount input connected",{config:this.config}),this.amountUsd=Number(this.config?.defaultAmountUsd??0),this.hasUserAmount=!1,this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol);try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}}}updated(e){if(e.has("config")&&(!this.hasUserAmount&&typeof this.config?.defaultAmountUsd=="number"&&(this.amountUsd===0||this.amountUsd==null||Number.isNaN(this.amountUsd))&&(this.amountUsd=Number(this.config.defaultAmountUsd)),!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol),!(this.config?.cryptoOptions&&this.config.cryptoOptions.length>0)&&this.availableLedgers.length===0&&this.loadVerifiedLedgers(),this.pendingAction&&this.config?.actorProvider)){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!Ne||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}onInputChange(e){let t=Number(this.config?.stepUsd??.5),i=Math.max(0,Number(e.target.value||0)),s=Math.round(i/t)*t;this.amountUsd=Number(s.toFixed(2)),this.hasUserAmount=!0}selectSymbol(e){this.selectedSymbol=e}isValidAmount(){let e=Number(this.config?.minUsd??.5),t=this.config?.maxUsd!==void 0?Number(this.config.maxUsd):1/0;return this.amountUsd>=e&&this.amountUsd<=t}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{Pe||(Pe=(await import("@windoge98/plug-n-play")).PNP);let e=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab),t={...this.config?.plugNPlay||{}},i=e?T(t):t;try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}if(this.pnp=new Pe(i),!this.pnp.getEnabledWallets()?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(l,p)=>this.pnp.getActor({canisterId:l,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let l=this.pendingAction;this.pendingAction=null,l==="pay"&&setTimeout(()=>this.pay(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(h=>h.symbol===t)?.canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=Number(this.amountUsd),a=await e.startOnrampUsd(o,s,{context:"amount-input:onramp"}),l=a?.metadata?.onramp?.sessionId||a?.metadata?.onramp?.session_id||null,p=a?.metadata?.paymentIntentId||a?.paymentIntentId||null,c=a?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=p,l?(this.onrampSessionId=l,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=c||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}async pay(){if(!(!Ne||this.processing)){if(this.errorMessage=null,this.errorSeverity=null,this.errorAction=null,!this.isValidAmount()){this.errorMessage="Please enter a valid amount",this.errorSeverity="warning";return}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=g(this.config),i=this.selectedSymbol||this.config?.defaultSymbol||"ICP",o=this.cryptoOptions.find(c=>c.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),a=Number(this.amountUsd),l={context:"amount-input"},p=await t.sendUsd(a,o,l);this.config.onSuccess&&this.config.onSuccess({id:p.transactionId,status:p.status,amountUsd:a}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-amount-pay",{detail:{amount:a,tx:p},bubbles:!0}))}catch(e){P(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),U(t)&&(this.errorMessage=R(t),this.errorSeverity=D(t),this.errorAction=$(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}render(){if(!this.config)return ve`<div class="icpay-card icpay-section">Loading...</div>`;let e=this.config?.placeholder||"Enter amount in USD",i=(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",this.amountUsd?`${Number(this.amountUsd).toFixed(2)}`:"$0.00").replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP"),s=this.cryptoOptions.find(V=>V.symbol===(this.selectedSymbol||""))?.label||this.cryptoOptions[0]?.label||this.config?.defaultSymbol||"ICP",o=this.config?.progressBar?.mode||"modal",a=this.config?.showLedgerDropdown,l=a==="buttons"?"buttons":a==="none"?"none":"dropdown",c=(this.cryptoOptions?.length||0)>1,h=l!=="none"&&(c||l==="dropdown"),N=l==="dropdown"?"dropdown":c?"buttons":"none",we=this.config?.progressBar?.enabled!==!1&&(o==="modal"?!0:this.processing);return ve`
1435
+ `],n([Et({type:Object})],v.prototype,"config",2),n([C()],v.prototype,"selectedSymbol",2),n([C()],v.prototype,"processing",2),n([C()],v.prototype,"succeeded",2),n([C()],v.prototype,"availableLedgers",2),n([C()],v.prototype,"errorMessage",2),n([C()],v.prototype,"errorSeverity",2),n([C()],v.prototype,"errorAction",2),n([C()],v.prototype,"walletConnected",2),n([C()],v.prototype,"pendingAction",2),n([C()],v.prototype,"showWalletModal",2),n([C()],v.prototype,"showOnrampModal",2),n([C()],v.prototype,"onrampSessionId",2),n([C()],v.prototype,"onrampPaymentIntentId",2),n([C()],v.prototype,"onrampErrorMessage",2),n([C()],v.prototype,"oisyReadyToPay",2),n([C()],v.prototype,"oisySignerPreopened",2),n([C()],v.prototype,"skipDisconnectOnce",2),n([C()],v.prototype,"lastWalletId",2),v=n([St("icpay-pay-button")],v);import{LitElement as kt,html as xe,css as Mt}from"lit";import{customElement as Ot,property as Ct,state as I}from"lit/decorators.js";var Ne=typeof window<"u",Pe=null;function It(r,d,e){r&&(e!==void 0?console.log(`[ICPay Widget] ${d}`,e):console.log(`[ICPay Widget] ${d}`))}var w=class extends kt{constructor(){super(...arguments);this.amountUsd=0;this.hasUserAmount=!1;this.selectedSymbol=null;this.processing=!1;this.succeeded=!1;this.availableLedgers=[];this.errorMessage=null;this.errorSeverity=null;this.errorAction=null;this.walletConnected=!1;this.pendingAction=null;this.showWalletModal=!1;this.showOnrampModal=!1;this.onrampSessionId=null;this.onrampPaymentIntentId=null;this.onrampErrorMessage=null;this.oisyReadyToPay=!1;this.lastWalletId=null;this.pnp=null;this.transakMessageHandlerBound=null;this.onrampPollTimer=null;this.onrampPollingActive=!1;this.onrampNotifyController=null;this.onSwitchAccount=async e=>{try{if(this.pnp)try{await this.pnp.disconnect()}catch{}this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0},this.pendingAction="pay",this.showWalletModal=!0,this.requestUpdate();try{let t=Number(this.amountUsd||0),i=this.selectedSymbol||this.config?.defaultSymbol;window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:t,currency:i}}))}catch{}}catch{}}}get cryptoOptions(){return this.config?.cryptoOptions?.length?this.config.cryptoOptions:this.availableLedgers}connectedCallback(){if(super.connectedCallback(),!!Ne){It(this.config?.debug||!1,"Amount input connected",{config:this.config}),this.amountUsd=Number(this.config?.defaultAmountUsd??0),this.hasUserAmount=!1,this.config?.cryptoOptions&&this.config.cryptoOptions.length>0||this.loadVerifiedLedgers(),this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol);try{window.addEventListener("icpay-switch-account",this.onSwitchAccount)}catch{}}}updated(e){if(e.has("config")&&(!this.hasUserAmount&&typeof this.config?.defaultAmountUsd=="number"&&(this.amountUsd===0||this.amountUsd==null||Number.isNaN(this.amountUsd))&&(this.amountUsd=Number(this.config.defaultAmountUsd)),!this.selectedSymbol&&this.config?.defaultSymbol&&(this.selectedSymbol=this.config.defaultSymbol),!(this.config?.cryptoOptions&&this.config.cryptoOptions.length>0)&&this.availableLedgers.length===0&&this.loadVerifiedLedgers(),this.pendingAction&&this.config?.actorProvider)){let t=this.pendingAction;this.pendingAction=null;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:"external"}}))}catch{}setTimeout(()=>{t==="pay"&&this.pay()},0)}}async loadVerifiedLedgers(){if(!(!Ne||!this.config?.publishableKey))try{let t=await g(this.config).client.getVerifiedLedgers();this.availableLedgers=t.map(i=>({symbol:i.symbol,label:i.name,canisterId:i.canisterId})),this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||(this.availableLedgers[0]?.symbol??"ICP"))}catch(e){this.dispatchEvent(new CustomEvent("icpay-error",{detail:{message:"Failed to load verified ledgers",cause:e},bubbles:!0})),this.availableLedgers=[{symbol:"ICP",label:"ICP",canisterId:"ryjl3-tyaaa-aaaaa-aaaba-cai"}],this.selectedSymbol||(this.selectedSymbol=this.config?.defaultSymbol||"ICP")}}onInputChange(e){let t=Number(this.config?.stepUsd??.5),i=Math.max(0,Number(e.target.value||0)),s=Math.round(i/t)*t;this.amountUsd=Number(s.toFixed(2)),this.hasUserAmount=!0}selectSymbol(e){this.selectedSymbol=e}isValidAmount(){let e=Number(this.config?.minUsd??.5),t=this.config?.maxUsd!==void 0?Number(this.config.maxUsd):1/0;return this.amountUsd>=e&&this.amountUsd<=t}async ensureWallet(){if(this.config.useOwnWallet)return this.config.actorProvider?!0:(this.pendingAction="pay",this.dispatchEvent(new CustomEvent("icpay-connect-wallet",{bubbles:!0})),!1);if(this.walletConnected)return!0;try{Pe||(Pe=(await import("@windoge98/plug-n-play")).PNP);let e=!!(this.config?.openOisyInNewTab||this.config?.plugNPlay?.openOisyInNewTab),t={...this.config?.plugNPlay||{}},i=e?W(t):t;try{if(typeof window<"u"){let{resolveDerivationOrigin:o}=await import("./origin-44ZEXSX4.js");i.derivationOrigin=this.config?.derivationOrigin||o()}}catch{}if(this.pnp=new Pe(i),!this.pnp.getEnabledWallets()?.length)throw new Error("No wallets available");return this.pendingAction="pay",this.showWalletModal=!0,!1}catch(e){return this.errorMessage=e instanceof Error?e.message:"Wallet connection failed",this.errorSeverity="error",!1}}getWalletId(e){return e&&(e.id||e.provider||e.key)||""}getWalletLabel(e){return e&&(e.label||e.name||e.title||e.id)||"Wallet"}getWalletIcon(e){return e&&(e.icon||e.logo||e.image)||null}connectWithWallet(e){if(this.pnp)try{if(!e)throw new Error("No wallet ID provided");this.lastWalletId=(e||"").toLowerCase(),this.pnp.connect(e).then(i=>{if(!!!(i&&(i.connected===!0||i.principal||i.owner||this.pnp?.account)))throw new Error("Wallet connection was rejected");this.walletConnected=!0;try{window.dispatchEvent(new CustomEvent("icpay-sdk-wallet-connected",{detail:{walletType:e}}))}catch{}let o=k(this.pnp,i);if(this.config={...this.config,connectedWallet:o,actorProvider:(a,p)=>this.pnp.getActor({canisterId:a,idl:p,requiresSigning:!0,anon:!1})},this.lastWalletId==="oisy")this.oisyReadyToPay=!0;else{this.showWalletModal=!1;let a=this.pendingAction;this.pendingAction=null,a==="pay"&&setTimeout(()=>this.pay(),0)}}).catch(i=>{this.errorMessage=i instanceof Error?i.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1})}catch(t){this.errorMessage=t instanceof Error?t.message:"Wallet connection failed",this.errorSeverity="error",this.showWalletModal=!1}}attachTransakMessageListener(){if(!this.transakMessageHandlerBound){this.transakMessageHandlerBound=e=>this.onTransakMessage(e);try{window.addEventListener("message",this.transakMessageHandlerBound)}catch{}}}detachTransakMessageListener(){if(this.transakMessageHandlerBound){try{window.removeEventListener("message",this.transakMessageHandlerBound)}catch{}this.transakMessageHandlerBound=null}}onTransakMessage(e){let t=e?.data,i=t?.event_id||t?.eventId||t?.id;if(!(!i||typeof i!="string")&&i==="TRANSAK_ORDER_SUCCESSFUL"){if(this.detachTransakMessageListener(),this.onrampPollingActive)return;this.showOnrampModal=!1;let s=t?.data?.id||t?.id||t?.webhookData?.id||null;this.startOnrampPolling(s||void 0)}}startOnramp(){try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"createPaymentUsd",type:"onramp"}}))}catch{}this.showWalletModal=!1,setTimeout(()=>this.createOnrampIntent(),0)}async createOnrampIntent(){try{let e=g(this.config),t=this.selectedSymbol||this.config?.defaultSymbol||"ICP",s=this.cryptoOptions.find(h=>h.symbol===t)?.canisterId||await e.client.getLedgerCanisterIdBySymbol(t),o=Number(this.amountUsd),l=await e.startOnrampUsd(o,s,{context:"amount-input:onramp"}),a=l?.metadata?.onramp?.sessionId||l?.metadata?.onramp?.session_id||null,p=l?.metadata?.paymentIntentId||l?.paymentIntentId||null,c=l?.metadata?.onramp?.errorMessage||null;this.onrampPaymentIntentId=p,a?(this.onrampSessionId=a,this.onrampErrorMessage=null,this.showOnrampModal=!0,this.attachTransakMessageListener()):(this.onrampSessionId=null,this.onrampErrorMessage=c||"Failed to obtain onramp sessionId",this.showOnrampModal=!0)}catch(e){this.onrampSessionId=null,this.onrampErrorMessage=e?.message||"Failed to obtain onramp sessionId",this.showOnrampModal=!0}}startOnrampPolling(e){if(this.onrampPollTimer){try{clearInterval(this.onrampPollTimer)}catch{}this.onrampPollTimer=null}if(this.onrampNotifyController){try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null}let t=this.onrampPaymentIntentId;if(!t)return;let i=g(this.config),s=()=>{if(this.detachTransakMessageListener(),this.onrampNotifyController)try{this.onrampNotifyController.stop()}catch{}this.onrampNotifyController=null,this.onrampPollingActive=!1};try{window.addEventListener("icpay-sdk-transaction-completed",(()=>s()),{once:!0})}catch{}this.onrampPollingActive=!0,this.onrampNotifyController=i.notifyIntentUntilComplete(t,5e3,e),this.onrampPollTimer=1}async pay(){if(!(!Ne||this.processing)){if(this.errorMessage=null,this.errorSeverity=null,this.errorAction=null,!this.isValidAmount()){this.errorMessage="Please enter a valid amount",this.errorSeverity="warning";return}try{window.dispatchEvent(new CustomEvent("icpay-sdk-method-start",{detail:{name:"pay",type:"sendUsd",amount:this.amountUsd,currency:this.selectedSymbol||this.config?.defaultSymbol}}))}catch{}this.processing=!0;try{if(!await this.ensureWallet())return;let t=g(this.config),i=this.selectedSymbol||this.config?.defaultSymbol||"ICP",o=this.cryptoOptions.find(c=>c.symbol===i)?.canisterId||await t.client.getLedgerCanisterIdBySymbol(i),l=Number(this.amountUsd),a={context:"amount-input"},p=await t.sendUsd(l,o,a);this.config.onSuccess&&this.config.onSuccess({id:p.transactionId,status:p.status,amountUsd:l}),this.succeeded=!0,this.dispatchEvent(new CustomEvent("icpay-amount-pay",{detail:{amount:l,tx:p},bubbles:!0}))}catch(e){U(e,{onError:t=>{this.dispatchEvent(new CustomEvent("icpay-error",{detail:t,bubbles:!0})),D(t)&&(this.errorMessage=$(t),this.errorSeverity=z(t),this.errorAction=B(t))}});try{!this.config.useOwnWallet&&this.pnp&&(await this.pnp.disconnect?.(),this.walletConnected=!1,this.config={...this.config,actorProvider:void 0,connectedWallet:void 0})}catch{}}finally{this.processing=!1}}}render(){if(!this.config)return xe`<div class="icpay-card icpay-section">Loading...</div>`;let e=this.config?.placeholder||"Enter amount in USD",i=(this.config?.buttonLabel||"Pay ${amount} with {symbol}").replace("{amount}",this.amountUsd?`${Number(this.amountUsd).toFixed(2)}`:"$0.00").replace("{symbol}",this.selectedSymbol||this.config?.defaultSymbol||"ICP"),s=this.cryptoOptions.find(R=>R.symbol===(this.selectedSymbol||""))?.label||this.cryptoOptions[0]?.label||this.config?.defaultSymbol||"ICP",o=this.config?.progressBar?.mode||"modal",l=this.config?.showLedgerDropdown,a=l==="buttons"?"buttons":l==="none"?"none":"dropdown",c=(this.cryptoOptions?.length||0)>1,h=a!=="none"&&(c||a==="dropdown"),A=a==="dropdown"?"dropdown":c?"buttons":"none",se=this.config?.progressBar?.enabled!==!1&&(o==="modal"?!0:this.processing);return xe`
1436
1436
  <div class="icpay-card icpay-section icpay-widget-base">
1437
- ${we?ve`
1437
+ ${se?xe`
1438
1438
  <icpay-progress-bar
1439
1439
  .debug=${!!this.config?.debug}
1440
1440
  .theme=${this.config?.theme}
@@ -1447,16 +1447,16 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1447
1447
  <div class="top-row ${h?"with-selector":""}">
1448
1448
  <div class="amount-field">
1449
1449
  <span class="currency-prefix">$</span>
1450
- <input type="number" min="0" step="${Number(this.config?.stepUsd??.5)}" .value=${String(this.amountUsd||"")} placeholder="${e}" @input=${V=>this.onInputChange(V)} />
1450
+ <input type="number" min="0" step="${Number(this.config?.stepUsd??.5)}" .value=${String(this.amountUsd||"")} placeholder="${e}" @input=${R=>this.onInputChange(R)} />
1451
1451
  </div>
1452
- ${h?ve`
1452
+ ${h?xe`
1453
1453
  <icpay-token-selector
1454
1454
  .options=${this.cryptoOptions}
1455
1455
  .value=${this.selectedSymbol||""}
1456
1456
  .defaultSymbol=${this.config?.defaultSymbol||"ICP"}
1457
- mode=${N}
1457
+ mode=${A}
1458
1458
  .showLabel=${!1}
1459
- @icpay-token-change=${V=>this.selectSymbol(V.detail.symbol)}
1459
+ @icpay-token-change=${R=>this.selectSymbol(R.detail.symbol)}
1460
1460
  ></icpay-token-selector>
1461
1461
  `:null}
1462
1462
  </div>
@@ -1468,17 +1468,17 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1468
1468
  </div>
1469
1469
  <div class="hint">Default: ${this.config?.defaultSymbol||"ICP"}. Min: $${Number(this.config?.minUsd??.5).toFixed(2)}${this.config?.maxUsd?`, Max: $${Number(this.config.maxUsd).toFixed(2)}`:""}</div>
1470
1470
 
1471
- ${this.errorMessage?ve`
1471
+ ${this.errorMessage?xe`
1472
1472
  <div class="error-message ${this.errorSeverity}" style="margin-top: 12px; padding: 8px 12px; border-radius: 6px; font-size: 14px; text-align: center;">
1473
1473
  ${this.errorMessage}
1474
- ${this.errorAction?ve`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
1474
+ ${this.errorAction?xe`<button style="margin-left: 8px; padding: 4px 8px; background: transparent; border: 1px solid currentColor; border-radius: 4px; font-size: 12px; cursor: pointer;">${this.errorAction}</button>`:""}
1475
1475
  </div>
1476
1476
  `:""}
1477
- ${(()=>{let G=(this.pnp?.getEnabledWallets?.()||[]).map(Y=>({id:this.getWalletId(Y),label:this.getWalletLabel(Y),icon:this.getWalletIcon(Y)}));return H({visible:!!(this.showWalletModal&&this.pnp),wallets:G,isConnecting:!1,onSelect:Y=>this.connectWithWallet(Y),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let X=Number(this.amountUsd||0);return X>0&&X<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-X).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.pay()}})})()}
1477
+ ${(()=>{let G=(this.pnp?.getEnabledWallets?.()||[]).map(q=>({id:this.getWalletId(q),label:this.getWalletLabel(q),icon:this.getWalletIcon(q)}));return V({visible:!!(this.showWalletModal&&this.pnp),wallets:G,isConnecting:!1,onSelect:q=>this.connectWithWallet(q),onClose:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1},onCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?()=>this.startOnramp():void 0,creditCardLabel:this.config?.onramp?.creditCardLabel||"Pay with credit card",showCreditCard:this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0,creditCardTooltip:(()=>{let X=Number(this.amountUsd||0);return X>0&&X<5&&this.config?.onramp?.enabled!==!1&&this.config?.onrampDisabled!==!0?`Note: Minimum card amount is $5. You will pay about $${(5-X).toFixed(2)} more.`:null})(),oisyReadyToPay:this.oisyReadyToPay,onOisyPay:()=>{this.showWalletModal=!1,this.oisyReadyToPay=!1,this.pay()}})})()}
1478
1478
 
1479
- ${this.showOnrampModal?F({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1479
+ ${this.showOnrampModal?j({visible:this.showOnrampModal,sessionId:this.onrampSessionId,errorMessage:this.onrampErrorMessage,apiKey:this.config?.onramp?.apiKey,environment:this.config?.onramp?.environment||"STAGING",width:this.config?.onramp?.width,height:this.config?.onramp?.height,onClose:()=>{this.showOnrampModal=!1},onBack:()=>{this.showOnrampModal=!1,this.showWalletModal=!0}}):null}
1480
1480
  </div>
1481
- `}};w.styles=[z,Mt`
1481
+ `}};w.styles=[K,Mt`
1482
1482
  .row { display: grid; grid-template-columns: 1fr; gap: 12px; align-items: stretch; }
1483
1483
  .top-row { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: center; }
1484
1484
  .top-row.with-selector { grid-template-columns: 1fr 2fr; }
@@ -1498,5 +1498,5 @@ import{a as n}from"./chunk-LTEQ7OUJ.js";import{css as Fe}from"lit";var z=Fe`
1498
1498
  @media (max-width: 520px) {
1499
1499
  .top-row { grid-template-columns: 1fr; }
1500
1500
  }
1501
- `],n([Ct({type:Object})],w.prototype,"config",2),n([I()],w.prototype,"amountUsd",2),n([I()],w.prototype,"hasUserAmount",2),n([I()],w.prototype,"selectedSymbol",2),n([I()],w.prototype,"processing",2),n([I()],w.prototype,"succeeded",2),n([I()],w.prototype,"availableLedgers",2),n([I()],w.prototype,"errorMessage",2),n([I()],w.prototype,"errorSeverity",2),n([I()],w.prototype,"errorAction",2),n([I()],w.prototype,"walletConnected",2),n([I()],w.prototype,"pendingAction",2),n([I()],w.prototype,"showWalletModal",2),n([I()],w.prototype,"showOnrampModal",2),n([I()],w.prototype,"onrampSessionId",2),n([I()],w.prototype,"onrampPaymentIntentId",2),n([I()],w.prototype,"onrampErrorMessage",2),n([I()],w.prototype,"oisyReadyToPay",2),n([I()],w.prototype,"lastWalletId",2),w=n([Ot("icpay-amount-input")],w);export{z as a,ce as b,g as c,F as d,S as e,f,m as g,E as h,b as i,v as j,w as k};
1502
- //# sourceMappingURL=chunk-GN2PEQBK.js.map
1501
+ `],n([Ct({type:Object})],w.prototype,"config",2),n([I()],w.prototype,"amountUsd",2),n([I()],w.prototype,"hasUserAmount",2),n([I()],w.prototype,"selectedSymbol",2),n([I()],w.prototype,"processing",2),n([I()],w.prototype,"succeeded",2),n([I()],w.prototype,"availableLedgers",2),n([I()],w.prototype,"errorMessage",2),n([I()],w.prototype,"errorSeverity",2),n([I()],w.prototype,"errorAction",2),n([I()],w.prototype,"walletConnected",2),n([I()],w.prototype,"pendingAction",2),n([I()],w.prototype,"showWalletModal",2),n([I()],w.prototype,"showOnrampModal",2),n([I()],w.prototype,"onrampSessionId",2),n([I()],w.prototype,"onrampPaymentIntentId",2),n([I()],w.prototype,"onrampErrorMessage",2),n([I()],w.prototype,"oisyReadyToPay",2),n([I()],w.prototype,"lastWalletId",2),w=n([Ot("icpay-amount-input")],w);export{K as a,de as b,g as c,j as d,S as e,f,m as g,E as h,b as i,v as j,w as k};
1502
+ //# sourceMappingURL=chunk-EEWBUAJY.js.map