/*!
 * Crafted with ❤ by Salla
 */
import{r as t,h as s,H as a}from"./p-Cb4NFvMH.js";const l=class{constructor(s){t(this,s),this.order=null,this.loading=!0}async componentWillLoad(){await salla.onReady(),await this.loadOrder()}async onOrderIdChange(){this.loading=!0,this.order=null,await this.loadOrder()}get paymentUrl(){return this.order?.customer_editing?.payment_url}async loadOrder(){const t=this.orderId||salla.config.get("page.id");if(t)try{const s=await salla.order.api.getDetails(t);this.order=s?.data??s??null}catch(t){salla.logger?.warn?.("[salla-edit-order-button] failed to fetch order details",t),this.order=null}finally{this.loading=!1}else this.loading=!1}renderEditButton(){return s("salla-count-down",{prefixText:salla.lang.getWithDefault("pages.orders.edit_within","يمكنك التعديل خلال"),buttonHref:this.order?.edit_url,buttonText:salla.lang.getWithDefault("pages.orders.edit_order","تعديل الطلب"),buttonIcon:"sicon-edit",date:this.order?.editable_until,horizontal:!0,autoSegments:!0,withButton:!0,labeled:!1,size:"sm",color:"primary"})}render(){return this.loading||!this.order?null:this.order?.is_editable?s(a,null,this.renderEditButton()):this.paymentUrl?s(a,null,s("salla-button",{href:this.paymentUrl,color:"primary",size:"small"},s("i",{class:"sicon-wallet"}),salla.lang.getWithDefault("pages.orders.pay_difference","دفع فارق المبلغ"))):null}static get watchers(){return{orderId:["onOrderIdChange"]}}};l.style=":host{display:block}";export{l as salla_edit_order_button}