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