1import{u as n,T as w,l as q,q as g,h as k,g as Q,k as W}from"./2c1ab0fe.BqEHHmaW.js";import{bq as K,B as T,y as Y,c as N,n as R,l as F,h as U,br as $,e as V,M as X,bs as Z,bt as ee,A as te,bu as ne,N as ae,bv as re}from"./164ad2e3.B-RZxMRs.js";import{O as h,bx as L,P as oe,bb as ie,Q as se,by as le,aT as ce}from"./4c290a1e.BmtxTAo1.js";import{u as de}from"./f5a7bb50.rgvpynK5.js";import{U as ue}from"./5c5c2e96.Cmvw_wfN.js";import{u as me,S as B}from"./ca5e9c49.C2DTz5K6.js";import{S as pe}from"./f3e117aa.B_ssYfAu.js";import"./app.BDuyPyLD.js";import"./65f3d4da.CQOrKSzr.js";import"./60a453ce.X8MjBCGm.js";import"./0a7dffce.CgLOt3SL.js";import"./bb728e1c.Doa1ZBzp.js";function z({progressing:e,onClick:t,cartEmpty:r,inlineSize:a}){const{i18n:o,embed:d}=h(),s=r&&!L(d?.embedder);return n(F,{variant:"primary",disabled:e,loading:e,onClick:t,inlineSize:a,children:s?o.translate("stock.return_to_store_label"):o.translate("stock.continue_cta_label")})}function be({progressing:e,onSecondaryClick:t}){const{i18n:r,url:a,observability:o}=h();return n(F,{onClick:async()=>{try{await t()}catch(s){o.leaveErrorBreadcrumb("Error negotiating before returning to cart",{error:s})}finally{window.location.replace(a.cart())}},variant:"plain",disabled:e,children:n(N,{direction:"inline",gap:"small-200",alignItems:"center",children:n(R,{children:r.translate("general.back_to_cart")})})})}function ge(e){const{shop:t,embed:r}=h(),{isAppLayout:a}=K(),o=L(r?.embedder);if(!t.hasStorefront&&e.cartEmpty&&!o)return null;const{primary:d,secondary:s}=he(t.hasStorefront,e,a,o);return n(Y,{alignItems:"center",alignContent:"center",gridTemplateRows:"minmax(auto, max-content)",gridAutoRows:"minmax(auto, max-content)",gap:"large-300",...o?{gridTemplateColumns:"1fr",inlineSize:"100%"}:{gridTemplateColumns:"@media (inline-size >= extraSmall) 'minmax(auto, max-content) minmax(auto, max-content)', none",justifyContent:"@media (inline-size >= extraSmall) end, ''",justifyItems:"@media (inline-size >= extraSmall) end, ''"},children:[n(T,{display:"@media (inline-size >= extraSmall) auto, none",children:s}),d,n(T,{display:"@media (inline-size >= extraSmall) none, auto",inlineAlignment:"center",children:s})]})}function he(e,t,r,a){return e?{primary:t.cartEmpty&&r&&!a?null:n(z,{...t,inlineSize:a?"fill":void 0}),secondary:t.cartEmpty||a||r&&!t.cartEmpty?null:n(be,{...t})}:!e&&!t.cartEmpty?{primary:n(z,{...t,inlineSize:a?"fill":void 0})}:{}}function ye({lineItems:e,showLineItems:t=!0,cartEmpty:r,type:a,subtitle:o}){const d=oe(),{value:s}=d.merchandiseLines,p=ie("merchandiseLines").value,{progress:b,progressing:P}=U(),u=se().merchandiseLines,f=$(),{observability:x,router:_,embed:v}=h(),{currentDetour:O}=V().value,M=w(()=>s?.lines??[],[s]),[C,D]=q(p);X("stock_problems"),me({stage:C?B.Loading:B.Complete,id:"StockProblems"});const G=r&&L(v?.embedder),A=g(l=>{const i=u.value;u.value=i.filter(({stableId:y})=>!l.includes(y))},[u]),J=g(()=>{le(v,ue)},[v]),E=w(()=>M.reduce((l,i)=>({...l,[i.stableId]:i}),{}),[M]),S=g(({removeUnavailableMerchandise:l=!1}={})=>{const i=u.value,y=i.flatMap(m=>{const c=E[m.stableId];return l&&(!c||c.quantity===0)?[]:!c||c.quantity===0?[m]:m.quantity===c.quantity&&m.totalPrice===c.totalPrice?[m]:[{...m,quantity:c.quantity,totalPrice:c.totalPrice}]});y.length===i.length&&y.every((m,c)=>m===i[c])||(u.value=y)},[E,u]),j=g(async()=>{const l=e.filter(({problem:i})=>Z(i.type)).map(({line:i})=>i.stableId);l.length&&A(l),S({removeUnavailableMerchandise:!0}),x.log("stock_problems_actions_submitted","Stock problems actions submitted",{unshippableMerchandiseIds:JSON.stringify(l),currentDetour:JSON.stringify(O),routerCurrentUrl:_.currentUrl.value.normalizedPath}),await b("checkout-stock-problems-submit")},[O,e,x,b,A,_,S]),I=ee(),H=g(async()=>{await I(e)},[I,e]);return k(function(){S()},[M,S]),k(()=>{p||(D(!1),f.notify({checkout_in_progress:!1}))},[p,C,f]),n(ne,{message:o,errorType:te.InventoryError,children:n(N,{gap:"large-200",children:[n(R,{children:o}),t&&e.length>0?n(pe,{lineItems:e,loading:C,type:a}):null,n(ge,{cartEmpty:r,progressing:P.value,onClick:G?J:j,onSecondaryClick:H})]})})}function Ie(){const{observability:e,checkout:{wallets:t}}=h(),{canBeDismissed:r,...a}=de(),{progress:o}=U(),[d,s]=q(!0),p=Q(()=>t.activeSession.value?.wallet!=="GOOGLE_PAY"),{checkoutProtocolModalEventSignal:b}=ce(),P=g(()=>{o("stock-problems-modal-close",()=>{s(!1)})},[o]),u=r?{blocking:!1,onHide:P}:{blocking:!0};k(()=>()=>{b.value="none"},[b]);const f=()=>{e.leaveErrorBreadcrumb("Stock problems modal opened",{type:a.type}),b.value="stockProblems"};return n(W,{when:p,children:[n(fe,{state:a}),n(ae,{section:"stock-problems",children:n(re,{id:"stock-problems-modal",open:d,heading:a.title,size:"large",onShow:f,...u,children:n(ye,{...a}
1)})})]})}function fe({state:e}){const{observability:t}=h();return k(()=>{e.lineItems.length!==0&&t.leaveErrorBreadcrumb("Displaying stock problems modal",{type:e.type,lineItems:e.lineItems.map(r=>({stableId:r.line.stableId,problem:r.problem.type}))})},[t,e.lineItems,e.type]),null}export{Ie 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.