import{r as i,h as e}from"./p-9add63ef.js";import{g as t}from"./p-fb28f84f.js";import{a}from"./p-401e165e.js";const o=":host{display:block}.sc-product-variation-choice-wrap{display:flex;flex-direction:column;gap:var(--sc-variation-gap, 12px)}";const s=o;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,o,s;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((o=this.price)===null||o===void 0?void 0:o.ad_hoc){return window.location.assign(a(window.location.href,{action:"confirm_amount",price_id:(s=this.price)===null||s===void 0?void 0:s.id,variant:n===null||n===void 0?void 0:n.id}))}return window.location.assign(a(window.location.href,{action:"confirm",variant:n===null||n===void 0?void 0:n.id}))}buttonText(){var i,e,t,a;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)===((a=(t=this.subscription)===null||t===void 0?void 0:t.price)===null||a===void 0?void 0:a.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:"2479cd5a7263812752bc04d08dd35d59899b3115",heading:this.heading||wp.i18n.__("Enter An Amount","surecart"),class:"subscription-switch"},e("sc-card",{key:"373ccca15a80f68c5a329b2b9e2df22033cd90c7"},e("sc-form",{key:"613e318362f2c383b4ab32734d37a75ee7860f68",onScSubmit:this.handleSubmit},e("div",{key:"d035b0af942defd3a9ec5cf9ef375261963869ea",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:a},o)=>{var s,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=(s=this.subscription)===null||s===void 0?void 0:s.variant_options)===null||n===void 0?void 0:n[o])||"",onScChange:i=>{this.variantValues[o]=i.detail.value},label:i,choices:t===null||t===void 0?void 0:t.map((i=>({label:i,value:i}))),unselect:false,key:a})}))),e("sc-button",{key:"d4abfc09ef8f898fec2366685e2dd6cd6c62532e",type:"primary",full:true,submit:true,loading:this.busy},this.buttonText()," ",e("sc-icon",{key:"c9a7e0baad949142a62e884d0f1c6d52dab741a7",name:"arrow-right",slot:"suffix"})))),this.busy&&e("sc-block-ui",{key:"47a2e10ba0f48a73a2f48cab1d8938e92b09b948",style:{zIndex:"9"}}))}};n.style=s;export{n as sc_subscription_variation_confirm};
//# sourceMappingURL=p-a5dcde2b.entry.js.map