import{r as e,c as i,h as t,F as s,H as r}from"./p-dfbe004d.js";import{_ as c}from"./p-8415f806.js";import"./p-fd56940f.js";import{i as l}from"./p-e05449ea.js";import{g as o}from"./p-f56cd460.js";import{f as a}from"./p-a447ac09.js";import{o as n}from"./p-10aa7556.js";import"./p-9a7a47e8.js";import"./p-75c9e181.js";import"./p-35c4916d.js";import"./p-1c2e2695.js";const p=class{constructor(t){e(this,t),this.scUpdateLineItem=i(this,"scUpdateLineItem",7)}lineItem(){return o(this.productId)}componentWillLoad(){n("checkout",(()=>{var e,i,t;this.adHocAmount=(null===(e=this.lineItem())||void 0===e?void 0:e.ad_hoc_amount)||(null===(t=null===(i=this.lineItem())||void 0===i?void 0:i.price)||void 0===t?void 0:t.amount)}))}updatePrice(){var e,i,t;this.showInput=!1,(this.adHocAmount||0===this.adHocAmount)&&this.adHocAmount!==(null===(e=this.lineItem())||void 0===e?void 0:e.ad_hoc_amount)&&this.scUpdateLineItem.emit({price_id:null===(t=null===(i=this.lineItem())||void 0===i?void 0:i.price)||void 0===t?void 0:t.id,quantity:1,ad_hoc_amount:this.adHocAmount})}handleShowInputChange(e){e&&setTimeout((()=>{this.input.triggerFocus()}),50)}render(){var e,i,o,n,p;const d=null===(e=this.lineItem())||void 0===e?void 0:e.price;return d?t("div",{class:{"selected-price":!0}},this.showInput?t("sc-form",{onScSubmit:e=>{e.preventDefault(),e.stopImmediatePropagation(),this.updatePrice()},onScFormSubmit:e=>{e.preventDefault(),e.stopImmediatePropagation()}},t("sc-price-input",{ref:e=>this.input=e,size:"large","currency-code":(null==d?void 0:d.currency)||"usd",min:null==d?void 0:d.ad_hoc_min_amount,max:null==d?void 0:d.ad_hoc_max_amount,placeholder:"0.00",required:!0,value:null===(o=null===(i=this.adHocAmount)||void 0===i?void 0:i.toString)||void 0===o?void 0:o.call(i),onScInput:e=>this.adHocAmount=parseInt(e.target.value)},t("sc-button",{slot:"suffix",type:"link",submit:!0},c("Update","surecart")))):t(s,null,t("div",{class:"selected-price__wrap"},t("span",{class:"selected-price__price"},(null==d?void 0:d.scratch_amount)>d.amount&&t(s,null,t("sc-format-number",{class:"selected-price__scratch-price",part:"price__scratch",type:"currency",currency:null==d?void 0:d.currency,value:null==d?void 0:d.scratch_amount})," "),t("sc-format-number",{type:"currency",currency:null==d?void 0:d.currency,value:null!==(null===(n=this.lineItem())||void 0===n?void 0:n.ad_hoc_amount)?null===(p=this.lineItem())||void 0===p?void 0:p.ad_hoc_amount:null==d?void 0:d.amount})),t("span",{class:"selected-price__interval"},l(d,{labels:{interval:"/",period:c("for","surecart")}}))),(null==d?void 0:d.ad_hoc)&&!a()&&t("sc-button",{class:"selected-price__change-amount",type:"primary",size:"small",onClick:()=>this.showInput=!0},t("sc-icon",{name:"edit",slot:"prefix"}),c("Change Amount","surecart")))):t(r,{style:{display:"none"}})}static get watchers(){return{showInput:["handleShowInputChange"]}}};p.style=":host{display:block}sc-form{width:100%}.selected-price{display:flex;align-items:center;gap:var(--sc-spacing-small);flex-wrap:wrap}.selected-price__wrap{display:flex;align-items:baseline;flex-wrap:wrap;gap:var(--sc-spacing-xx-small);color:var(--sc-selected-price-color, var(--sc-color-gray-800));line-height:1}.selected-price__price{font-size:var(--sc-font-size-xxx-large);font-weight:var(--sc-font-weight-bold);white-space:nowrap}.selected-price__interval{font-weight:var(--sc-font-weight-bold);opacity:0.65;white-space:nowrap}.selected-price__scratch-price{opacity:0.65;font-weight:var(--sc-font-weight-normal);text-decoration:line-through}";export{p as sc_product_selected_price}