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:["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:"0ec0bf6375a8d2984afd140641ff7aa0b08d2d6b",state:this.state()},t("div",{key:"50ec95cac58659680f4c8d61125e038356fb4de3",class:{"order-confirmation":true}},t("div",{key:"d857726a6d2674249d45a90a48af954ecaf1a75d",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:"ebaf4a3b890961683c7d1796487b331bc66f12af",checkout:this.order},t("slot",{key:"ce3115033f66d85a3b50eea57bd77d918c36dd0e"}))),!((e=this.order)===null||e===void 0?void 0:e.id)&&!this.loading&&t("sc-heading",{key:"dd906afd44fcca32c8415fa93d78aa8be39f0454"},wp.i18n.__("Order not found.","surecart"),t("span",{key:"3f09d15923ae8b46a9accf76bd39ce99420c1313",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-3d31f065.entry.js.map