import{r as i,h as l,a as e,H as s}from"./p-9add63ef.js";import"./p-445fd8b4.js";import{a as n}from"./p-401e165e.js";import{a as t}from"./p-259c3935.js";import"./p-d3366af3.js";const d=".fulfillment{display:grid;gap:var(--sc-spacing-x-large)}.fulfillment__number{font-weight:bold}.fulfillment__header{display:flex;align-items:center;gap:var(--sc-spacing-medium)}sc-card{--sc-card-padding:var(--sc-spacing-x-large)}.trackings{display:flex;gap:0.75em;color:var(--sc-line-item-title-color, var(--sc-input-label-color))}.trackings__title{line-height:var(--sc-line-height-dense);font-weight:var(--sc-font-weight-bold)}.trackings sc-icon{opacity:0.5;font-size:22px}.line_items{display:grid;gap:var(--sc-spacing-large)}.line_item__info{display:flex;gap:var(--sc-spacing-medium);align-items:center}.line_item__image img{width:var(--sc-product-line-item-image-size, 4em);height:var(--sc-product-line-item-image-size, 4em);object-fit:cover;border-radius:4px;border:solid 1px var(--sc-input-border-color, var(--sc-input-border));display:block;box-shadow:var(--sc-input-box-shadow)}";const o=d;const a=class{constructor(l){i(this,l);this.orderId=undefined;this.heading=undefined;this.fulfillments=undefined;this.loading=undefined;this.busy=undefined;this.error=undefined}componentDidLoad(){this.fetch()}async fetch(){try{this.busy=true;this.fulfillments=await t({path:n(`surecart/v1/fulfillments`,{expand:["trackings","fulfillment_items","fulfillment_item.line_item","line_item.price","price.product"],order_ids:[this.orderId],shipment_status:["shipped","delivered"]})})}catch(i){console.error(this.error);this.error=(i===null||i===void 0?void 0:i.message)||wp.i18n.__("Something went wrong","surecart")}finally{this.busy=false}}renderLoading(){return l("sc-flex",{flexDirection:"column",style:{gap:"1em"}},l("sc-skeleton",{style:{width:"20%",display:"inline-block"}}),l("sc-skeleton",{style:{width:"60%",display:"inline-block"}}),l("sc-skeleton",{style:{width:"40%",display:"inline-block"}}))}render(){var i,e;if(this.loading||!((i=this.fulfillments)===null||i===void 0?void 0:i.length))return l(s,{style:{display:"none"}});return l("sc-spacing",{style:{"--spacing":"var(--sc-spacing-large)"}},l("sc-dashboard-module",{error:this.error},l("span",{slot:"heading"},this.heading||wp.i18n._n("Shipment","Shipments",(e=this.fulfillments)===null||e===void 0?void 0:e.length,"surecart")),this.fulfillments.map((i=>{var e,s,n,t,d,o;return l("sc-card",{noPadding:true},l("sc-stacked-list",null,l("sc-stacked-list-row",null,l("div",{class:"fulfillment__header"},l("sc-fulfillment-shipping-status-badge",{status:i.shipment_status}),l("div",{class:"fulfillment__number"},"#",i===null||i===void 0?void 0:i.number))),!!((s=(e=i===null||i===void 0?void 0:i.trackings)===null||e===void 0?void 0:e.data)===null||s===void 0?void 0:s.length)&&l("sc-stacked-list-row",null,l("div",{class:"trackings"},l("sc-icon",{name:"truck"}),l("div",{class:"trackings__details"},l("div",{class:"trackings__title"},wp.i18n._n("Tracking number","Tracking numbers",(t=(n=i===null||i===void 0?void 0:i.trackings)===null||n===void 0?void 0:n.data)===null||t===void 0?void 0:t.length,"surecart")),l("div",{class:"trackings__list"},(((d=i===null||i===void 0?void 0:i.trackings)===null||d===void 0?void 0:d.data)||[]).map((({number:i,url:e})=>l("a",{href:e,target:"_blank"},i))))))),(((o=i===null||i===void 0?void 0:i.fulfillment_items)===null||o===void 0?void 0:o.data)||[]).map((({id:i,line_item:e,quantity:s})=>{var n,t,d,o,a,r,c,v,u,p,m,g;return l("sc-stacked-list-row",{key:i,style:{"--columns":"2"}},l("div",null,l("div",{class:"line_item__info"},l("div",{class:"line_item__image"},!!((t=(n=e===null||e===void 0?void 0:e.price)===null||n===void 0?void 0:n.product)===null||t===void 0?void 0:t.line_item_image)&&l("img",{...(o=(d=e===null||e===void 0?void 0:e.price)===null||d===void 0?void 0:d.product)===null||o===void 0?void 0:o.line_item_image})),l("div",{class:"line_item__text"},l("div",null,(r=(a=e===null||e===void 0?void 0:e.price)===null||a===void 0?void 0:a.product)===null||r===void 0?void 0:r.name),l("div",null,!!((v=(c=e===null||e===void 0?void 0:e.price)===null||c===void 0?void 0:c.product)===null||v===void 0?void 0:v.weight)&&l("sc-format-number",{type:"unit",value:(p=(u=e===null||e===void 0?void 0:e.price)===null||u===void 0?void 0:u.product)===null||p===void 0?void 0:p.weight,unit:(g=(m=e===null||e===void 0?void 0:e.price)===null||m===void 0?void 0:m.product)===null||g===void 0?void 0:g.weight_unit}))))),l("span",null,wp.i18n.sprintf(wp.i18n.__("Qty: %d","surecart"),s||0)))}))))}))))}get el(){return e(this)}};a.style=o;export{a as sc_fulfillments};
//# sourceMappingURL=p-a770a2e4.entry.js.map