import{r as i,h as e}from"./p-e97fde0a.js";import{g as t}from"./p-93127aa7.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 d=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 d=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:d===null||d===void 0?void 0:d.id}))}return window.location.assign(a(window.location.href,{action:"confirm",variant:d===null||d===void 0?void 0:d.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:"4a421841b01001aaa2dd43dedd90094ec1bffcf9",heading:this.heading||wp.i18n.__("Enter An Amount","surecart"),class:"subscription-switch"},e("sc-card",{key:"2ce23936605fb3adf36824b720b84be1ada4ff36"},e("sc-form",{key:"33dda8dee9d902f282bae556f27f3eabe335de32",onScSubmit:this.handleSubmit},e("div",{key:"b830d6118e280daa5cda4c8ea9b9bf37409946e9",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,d;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:((d=(s=this.subscription)===null||s===void 0?void 0:s.variant_options)===null||d===void 0?void 0:d[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:"64f6dbcba51b057f761ad1bbbe53dde1cb1ba27d",type:"primary",full:true,submit:true,loading:this.busy},this.buttonText()," ",e("sc-icon",{key:"a8da70bc22713863e3d634a940d3eb592dc8745f",name:"arrow-right",slot:"suffix"})))),this.busy&&e("sc-block-ui",{key:"c345ee15f7342ebe416767c8f291af7e97489238",style:{zIndex:"9"}}))}};d.style=s;export{d as sc_subscription_variation_confirm};
//# sourceMappingURL=p-8c0a78df.entry.js.map