import{r as o,c as r,h as i}from"./p-dfbe004d.js";import{o as t}from"./p-d63f2554.js";import{_ as s}from"./p-8415f806.js";import"./p-fd56940f.js";import{i as n}from"./p-d556eec7.js";import"./p-9a7a47e8.js";const e=class{constructor(i){o(this,i),this.scApplyCoupon=r(this,"scApplyCoupon",7)}handleErrorsChange(){var o;const r=((null===(o=null==this?void 0:this.error)||void 0===o?void 0:o.additional_errors)||[]).find((o=>{var r;return"discount.promotion_code"===(null===(r=null==o?void 0:o.data)||void 0===r?void 0:r.attribute)}));this.errorMessage=(null==r?void 0:r.message)?null==r?void 0:r.message:""}render(){var o,r,t,e,l,a;return i("sc-coupon-form",{label:this.label||s("Add Coupon Code","surecart"),collapsed:this.collapsed,placeholder:this.placeholder,loading:this.busy&&!(null===(t=null===(r=null===(o=this.order)||void 0===o?void 0:o.line_items)||void 0===r?void 0:r.data)||void 0===t?void 0:t.length),busy:this.busy,error:this.errorMessage,discount:null===(e=null==this?void 0:this.order)||void 0===e?void 0:e.discount,currency:null===(l=null==this?void 0:this.order)||void 0===l?void 0:l.currency,"discount-amount":null===(a=null==this?void 0:this.order)||void 0===a?void 0:a.discount_amount,class:{"order-coupon-form--is-rtl":n()},"button-text":this.buttonText||s("Apply","surecart")})}static get watchers(){return{error:["handleErrorsChange"]}}};t(e,["loading","busy","order","error"],!1),e.style=":host{display:block}.coupon-form{position:relative}.form{opacity:0;visibility:hidden;height:0;transition:opacity var(--sc-transition-fast) ease-in-out}.coupon-form--is-open .form{opacity:1;visibility:visible;height:auto;margin-top:var(--sc-spacing-small);display:grid;gap:var(--sc-spacing-small)}.coupon-form--is-open .trigger{color:var(--sc-input-label-color)}.coupon-form--is-open .trigger:hover{text-decoration:none}.trigger{cursor:pointer;font-size:var(--sc-font-size-small);color:var(--sc-color-gray-500);user-select:none}.trigger:hover{text-decoration:underline}.order-coupon-form--is-rtl .trigger,.order-coupon-form--is-rtl .trigger:hover{text-align:right}";export{e as sc_order_coupon_form}