import{r as i,h as e}from"./p-e97fde0a.js";import{g as t}from"./p-93127aa7.js";import{a as o}from"./p-401e165e.js";const s=":host{display:block}.sc-product-variation-choice-wrap{display:flex;flex-direction:column;gap:var(--sc-variation-gap, 12px)}";const a=s;const n=class{constructor(e){i(this,e);this.heading=undefined;this.product=undefined;this.price=undefined;this.subscription=undefined;this.busy=false;this.variantValues=[];this.handleSubmit=this.handleSubmit.bind(this)}componentWillLoad(){var i;this.variantValues=(i=this.subscription)===null||i===void 0?void 0:i.variant_options}async handleSubmit(){var i,e,s,a;this.busy=true;const n=t({variants:(e=(i=this.product)===null||i===void 0?void 0:i.variants)===null||e===void 0?void 0:e.data,values:this.variantValues});if((s=this.price)===null||s===void 0?void 0:s.ad_hoc){return window.location.assign(o(window.location.href,{action:"confirm_amount",price_id:(a=this.price)===null||a===void 0?void 0:a.id,variant:n===null||n===void 0?void 0:n.id}))}return window.location.assign(o(window.location.href,{action:"confirm",variant:n===null||n===void 0?void 0:n.id}))}buttonText(){var i,e,t,o;if((i=this.price)===null||i===void 0?void 0:i.ad_hoc){if(((e=this.price)===null||e===void 0?void 0:e.id)===((o=(t=this.subscription)===null||t===void 0?void 0:t.price)===null||o===void 0?void 0:o.id)){return wp.i18n.__("Update Amount","surecart")}return wp.i18n.__("Choose Amount","surecart")}return wp.i18n.__("Next","surecart")}render(){var i,t;return e("sc-dashboard-module",{key:"3298d794ecc73202e3cef49a919d28d8b04b7012",heading:this.heading||wp.i18n.__("Enter An Amount","surecart"),class:"subscription-switch"},e("sc-card",{key:"bf2aec09964de6050a62b2503fb5316c78ba9f95"},e("sc-form",{key:"0f8df5d4edf7ebbd7312c7801d4ed16d42409827",onScSubmit:this.handleSubmit},e("div",{key:"0924c6948b70bef2384a58ed1340fb96541fef8a",class:"sc-product-variation-choice-wrap"},(((t=(i=this.product)===null||i===void 0?void 0:i.variant_options)===null||t===void 0?void 0:t.data)||[]).map((({name:i,values:t,id:o},s)=>{var a,n;return e("sc-select",{exportparts:"base:select__base, input, form-control, label, help-text, trigger, panel, caret, menu__base, spinner__base, empty",part:"name__input",value:((n=(a=this.subscription)===null||a===void 0?void 0:a.variant_options)===null||n===void 0?void 0:n[s])||"",onScChange:i=>{this.variantValues[s]=i.detail.value},label:i,choices:t===null||t===void 0?void 0:t.map((i=>({label:i,value:i}))),unselect:false,key:o})}))),e("sc-button",{key:"ac6cff734f6d877e3dd8b5d245920ff37a61d64b",type:"primary",full:true,submit:true,loading:this.busy},this.buttonText()," ",e("sc-icon",{key:"392c573e38b3a388e2b1813f574490fcb3110bef",name:"arrow-right",slot:"suffix"})))),this.busy&&e("sc-block-ui",{key:"75c84aff1c1c7ed82201245ba557274b29c0f7a5",style:{zIndex:"9"}}))}};n.style=a;export{n as sc_subscription_variation_confirm};
//# sourceMappingURL=p-47fc4e65.entry.js.map