1import{T as w,k as ue,q as v,h as W,u as e}from"./esnext-vendor.BBoIVOQW.js";import{f as de,J as pe,be as he,bY as me,bZ as be,bd as ge,bg as fe,j as G,k as P,I as Y,l as g,m as _e,bh as ye,A as ke,n as ve,P as Pe,Y as Le,ap as Ie,am as Ue,an as A,af as a,ao as Me,aj as Se,ag as T,ak as Ce,al as we,L as Ae,K as Te,at as xe,a8 as Oe,G as qe}from"./hydrate.CpZpwHoK.js";import{C as Be}from"./OffsitePaymentFailed.51Qv3RTo.js";import{u as Re,P as Ee,a as De,b as Fe,d as He,c as Ne,S as J}from"./Page.BD2h8hg5.js";import{P as V,a1 as K,bc as ze,Q as Qe,a_ as $e,ae as je,by as We,bz as Ge}from"./addresses-is-address-empty.PepcBFSY.js";import{U as Je}from"./embed-deferred.C0mqGCnh.js";import{u as Ke,N as Ye}from"./stock-problems-useStockProblemsState.lAkkLb80.js";import"./app.Czj2iPYR.js";import"./shared-permissions.DRm-hbfF.js";import"./hooks-useShopPayExternalAppContext.DBGG1iea.js";function ut(){const{i18n:t,observability:c,shop:x,url:O,source:Z,router:L,embed:I}=V(),{value:q}=K().allViolations,{value:B}=K().merchandiseLines,R=ze("merchandiseLines").value,{progress:U}=de(),{previousPage:X}=pe(),p=Qe().merchandiseLines,E=he(),i=Ke(),u=i.type,{value:D}=$e();je("stock_problems");const M=w(()=>B?.lines??[],[B]),[f]=ue(p.peek()),h=me(f,q),d=be(f,M,q),ee=Z.type==="draftOrder",_=We(I?.embedder),{hasStorefront:S}=x,{isAppLayout:F}=ge(),m=i.cartEmpty,te=m||!f?0:f.length,ae=S||te>1,H=w(()=>M.reduce((o,n)=>({...o,[n.stableId]:n}),{}),[M]),y=v(({removeUnavailableMerchandise:o=!1}={})=>{const n=p.value,r=n.flatMap(s=>{const l=H[s.stableId];return o&&(!l||l.quantity===0||h.has(s.stableId))?[]:!l||l.quantity===0||h.has(s.stableId)?[s]:s.quantity===l.quantity&&s.totalPrice===l.totalPrice?[s]:[{...s,quantity:l.quantity,totalPrice:l.totalPrice}]});r.length===n.length&&r.every((s,l)=>s===n[l])||(p.value=r)},[H,p,h]),ne=v(()=>{Ge(I,Je)},[I]),re=v(()=>{y({removeUnavailableMerchandise:!0}),U("stock-problems-submit")},[U,y]),N=fe(),se=v(async()=>{await N(i.lineItems),window.location.replace(O.cart())},[N,i.lineItems,O]),le=o=>{const n=p.peek();p.value=n.filter(({stableId:r,quantity:s})=>r!==o&&s>0),U("stock-problems-remove-item")};W(()=>{E.notify({checkout_in_progress:!1})},[E]),Re({stage:R?J.Loading:J.Complete,id:"StockProblems"}),W(()=>{let o=L.currentUrl.value;return L.currentUrl.subscribe(n=>{o!==n&&(o=n,y())})},[L,y]);const z=w(()=>u===a.Unfulfillable?xe([...h],D):null,[D,u,h]),C=()=>{if(!i.showLineItems)return i.title;switch(u){case a.Unavailable:return t.translate("contextual_availability.title",{count:d.length});case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.title");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.title");case a.QuantityChange:return t.translate("stock.quantity_update.title");case a.Unshippable:return t.translate("stock.unshippable_product.title");case a.Unfulfillable:return t.translate("stock.unfulfillable_product.title");default:return t.translate("stock.title")}},ie=()=>{if(!i.showLineItems)return i.title;switch(u){case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.header");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.header");case a.Unshippable:return t.translate("stock.unshippable_product.header",{count:d.length});case a.Unfulfillable:return t.translate("stock.unfulfillable_product.title");default:return C()}},Q=S&&!(F&&m)||_?e(Ee,{children:e(G,{variant:"primary",size:"large",inlineSize:"fill",onClick:m&&_?ne:re,loading:R,children:ee||m&&!_?t.translate("stock.return_to_store_label"):t.translate("general.continue_button_label")})}):null,$=S&&X.route&&!F&&!m&&!_?e(De,{children:e(G,{onClick:async()=>{await se()},variant:"plain",inlineSize:"fill",textDecoration:"none",children:e(P,{direction:"inline",gap:"small-200",alignItems:"center",children:[e(Y,{type:"chevron-left",size:"small"}),e(g,{children:t.translate("general.back_to_cart")})]})})}):null,j=()=>{if(!i.showLineItems)return i.subtitle;switch(u){case a.Unavailable:return m?t.translate("contextual_availability.all_products_in_cart_unavailable",{count:d.length}):t.translate("contextual_availability.products_not_available",{count:d.length});case a.UnpurchasableB2B:return t.translate("stock.unpurchasable_product.message");case a.Unpurchasable:return t.translate("stock.unpurchasable_product_generic.message");case a.QuantityChange:return t.translate("stock.quantity_update.description");case a.Unshippable:return t.translate("stock.unshippable_product.message",{count:d.length});case a.Unfulfillable:return z?t.translate("stock.unfulfillable_product.message",{delivery_method:z,count:d.length}):(c.error(new Ye),t.translate("stock.unfulfillable_product.default_message",{count:d.length}));default:return t.translate("stock.items_unavailable_notice")}},oe=()=>u===a.QuantityChange?t.translate("stock.quantity_update.page_title"):C();return e(Te,{section:"stock-problems",children:[e(_e,{children:C()}),e(ye,{message:j(),errorType:ke.InventoryError,children:e(P,{gap:"large-500",children:[e(Be,{status:"warning",children:[e(ve,{children:ie()}),e(Pe,{color:"subdued",children:j()})]}),e(Fe,{children:[d.length>0&&i.showLineItems?e(He,{children:e(Le,{children:e(Ie,{titleHidden:!0,border:"outer",spacing:"none",title:oe(),children:[e(Ue,{blockPadding:"base",children:[e(A,{hidden:!0,children:t.translate("order_summary.product_image_label")}),e(A,{primary:!0,children:e(g,{type:"strong",children:t.translate("order_summary.description_label")})}),e(A,{hidden:u!==a.OutOfStock,children:e(g,{type:"strong",children:u===a.OutOfStock?t.translate("order_summary.quantity_label"):t.translate("order_summary.description_label")})})]}),e(Me,{children:d.map(({proposed:o,negotiated:n})=>{const r=n??o,s=o?.quantity,l=n?.quantity,{stableId:k,image:b,title:ce}=r;return e(Se,{spacing:"base",blockPadding:"base",children:[e(T,{children:e(Ce,{src:b?.one,srcSet:b?`${b.one} 1x, ${b.two} 2x, ${b.four} 4x`:void 0,alt:b?.altText})}),e(T,{primary:!0,children:e(we,{id:null,deferredAmount:r.deferredAmount,options:r.options,properties:r.properties,recurringTotal:r.recurringTotal,sellingPlan:r.sellingPlan,subtitle:r.subtitle,title:ce,totalPrice:r.totalPrice})}),e(T,{noWrap:!0,children:l!=null&&l>0&&!h.has(k)?e(P,{alignItems:"end",gap:"small-400",children:[e(Ze,{quantity:l,previousQuantity:s??0}),ae?e(Ae,{id:`remove-${k}`,onClick:()=>le(k),children:t.translate("stock.remove")}):null]}):e(Ve,{merchandiseIssueType:u})})]},k)})})]})})}):null,Q||$?e(Ne,{children:[Q,$]}):null]})]})})]})}function Ve({merchandiseIssueType:t}){const{i18n:c}=V();return e(qe,{gridAutoFlow:"column",gridAutoColumns:"minmax(auto, max-content)",gridTemplateColumns:"minmax(auto, max-content)",gridTemplateRows:"minmax(0, 1fr)",gap:"small-400",alignItems:"center",alignContent:"center",children:[e(Y,{type:"disabled",tone:"critical",size:"small"}),e(Oe,{children:(()=>{switch(t){case a.Unfulfillable:case a.Unavailable:return c.translate("contextual_availability.unavailable_label");case a.UnpurchasableB2B:return c.translate("stock.unpurchasable_product.status_column_header");case a.Unpurchasable:return c.translate("stock.unpurchasable_product_generic.status_column_header");case a.Unshippable:return c.translate("stock.unshippable_product.status_column_header");default:return c.translate("stock.sold_out_label")}})()})]})}function Ze({quantity:t,previousQuantity:c}){return e(P,{direction:"inline",gap:"small-200",children:[e(g,{color:"subdued",children:c}),e(g,{color:"subdued",children:"â"}),e(g,{type:"strong",children:t})]})}
1export{ut as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.