import{r as i,h as t}from"./p-e97fde0a.js";import{a as e}from"./p-dd3464cd.js";import{U as o}from"./p-4ea36f1e.js";import{g as r}from"./p-d3366af3.js";import{a as s}from"./p-401e165e.js";const n=":host{display:block;max-width:800px;margin:auto}::slotted(*:not(:last-child)),sc-form form>*:not(:last-child){margin-bottom:var(--sc-form-row-spacing-large)}.order-confirmation__content{color:var(--sc-order-confirmation-color, var(--sc-color-gray-500))}.order-confirmation__content.hidden{display:none}::part(line-items){display:grid;gap:0.5em}";const a=n;const d=class{constructor(t){i(this,t);this.order=undefined;this.loading=false;this.error=undefined}componentWillLoad(){o.create(this,this.state());this.getSession()}getSessionId(){var i;if((i=this.order)===null||i===void 0?void 0:i.id)return this.order.id;return r(window.location.href,"sc_order")}async getSession(){var i;if(!this.getSessionId())return;if((i=this.order)===null||i===void 0?void 0:i.id)return;try{this.loading=true;this.order=await await e({path:s(`surecart/v1/checkouts/${this.getSessionId()}`,{expand:["checkout_fees","shipping_fees","line_items","line_item.price","line_item.fees","price.product","customer","customer.shipping_address","payment_intent","discount","manual_payment_method","discount.promotion","billing_address","shipping_address"],refresh_status:true,currency_conversion:false})})}catch(i){if(i===null||i===void 0?void 0:i.message){this.error=i.message}else{this.error=wp.i18n.__("Something went wrong","surecart")}}finally{this.loading=false}}state(){var i,t;const e=(i=this.order)===null||i===void 0?void 0:i.manual_payment_method;return{processor:"stripe",loading:this.loading,orderId:this.getSessionId(),order:this.order,customer:(t=this.order)===null||t===void 0?void 0:t.customer,manualPaymentTitle:e===null||e===void 0?void 0:e.name,manualPaymentInstructions:e===null||e===void 0?void 0:e.instructions}}renderOnHold(){var i,e,o;if(((i=this.order)===null||i===void 0?void 0:i.status)!=="processing")return null;if(((o=(e=this===null||this===void 0?void 0:this.order)===null||e===void 0?void 0:e.payment_intent)===null||o===void 0?void 0:o.processor_type)==="paypal"){return t("sc-alert",{type:"warning",open:true},wp.i18n.__("Paypal is taking a closer look at this payment. It’s required for some payments and normally takes up to 3 business days.","surecart"))}}renderManualInstructions(){var i;const e=(i=this.order)===null||i===void 0?void 0:i.manual_payment_method;if(!(e===null||e===void 0?void 0:e.instructions))return;return t("sc-alert",{type:"info",open:true},t("span",{slot:"title"},e===null||e===void 0?void 0:e.name),t("div",{innerHTML:e===null||e===void 0?void 0:e.instructions}))}render(){var i,e;return t(o.Provider,{key:"1d7b9de387c84b9490b84362607c2c1c921642e4",state:this.state()},t("div",{key:"b36d9210520c562f88266c8589e6bb801d8c7cf4",class:{"order-confirmation":true}},t("div",{key:"3fc37ba8fa7a90da751e775ab2aa717659d7a3c4",class:{"order-confirmation__content":true,hidden:!((i=this.order)===null||i===void 0?void 0:i.id)&&!this.loading}},t("sc-order-confirm-components-validator",{key:"421cdfc8571238db8ed3e4f6586818fd7edaa77c",checkout:this.order},t("slot",{key:"aa1ce42db5b05f70771de5d2687d792bc9aa56af"}))),!((e=this.order)===null||e===void 0?void 0:e.id)&&!this.loading&&t("sc-heading",{key:"c368279e2cba021c385a5cbbf3be11c81d389101"},wp.i18n.__("Order not found.","surecart"),t("span",{key:"43b29624fbce205aeb352a480023ebf5a4231ab3",slot:"description"},wp.i18n.__("This order could not be found. Please try again.","surecart")))))}};d.style=a;export{d as sc_order_confirmation};
//# sourceMappingURL=p-9a45e867.entry.js.map