https://www.levenger.com/cdn/shopifycloud/checkout-web/assets/c1/page-StockProblemsModal.tOhwcp7i.js
1import{u as n,T as w,k as q,q as g,h as k,f as H,i as K}from"./esnext-vendor.BBoIVOQW.js";import{bd as Q,B,G as Y,k as R,l as F,j as G,f as N,be as $,o as V,bf as X,bg as Z,A as ee,bh as te,K as ne,bi as ae}from"./hydrate.Tsur0pib.js";import{T as h,bB as L,a5 as oe,bf as re,W as ie,ai as se,bC as le,aq as ce}from"./addresses-is-address-empty.ZJ1ThpFy.js";import{u as de}from"./stock-problems-useStockProblemsState.B5daEJge.js";import{U as ue}from"./embed-deferred.h5O_Zmjn.js";import{u as me,S as T}from"./Page.B9pV9lua.js";import{S as pe}from"./StockProblems-StockProblemsLineItemList.Beyqm7Al.js";import"./app.CUBUOQtX.js";import"./shared-permissions.DW7FOCqf.js";import"./hooks-useShopPayExternalAppContext.YLtTu3k6.js";function z({progressing:e,onClick:t,cartEmpty:o,inlineSize:a}){const{i18n:r,embed:d}=h(),s=o&&!L(d?.embedder);return n(G,{variant:"primary",disabled:e,loading:e,onClick:t,inlineSize:a,children:s?r.translate("stock.return_to_store_label"):r.translate("stock.continue_cta_label")})}function be({progressing:e,onSecondaryClick:t}){const{i18n:o,url:a,observability:r}=h();return n(G,{onClick:async()=>{try{await t()}catch(s){r.leaveErrorBreadcrumb("Error negotiating before returning to cart",{error:s})}finally{window.location.replace(a.cart())}},variant:"plain",disabled:e,children:n(R,{direction:"inline",gap:"small-200",alignItems:"center",children:n(F,{children:o.translate("general.back_to_cart")})})})}function ge(e){const{shop:t,embed:o}=h(),{isAppLayout:a}=Q(),r=L(o?.embedder);if(!t.hasStorefront&&e.cartEmpty&&!r)return null;const{primary:d,secondary:s}=he(t.hasStorefront,e,a,r);return n(Y,{alignItems:"center",alignContent:"center",gridTemplateRows:"minmax(auto, max-content)",gridAutoRows:"minmax(auto, max-content)",gap:"large-300",...r?{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(B,{display:"@media (inline-size >= extraSmall) auto, none",children:s}),d,n(B,{display:"@media (inline-size >= extraSmall) none, auto",inlineAlignment:"center",children:s})]})}function he(e,t,o,a){return e?{primary:t.cartEmpty&&o&&!a?null:n(z,{...t,inlineSize:a?"fill":void 0}),secondary:t.cartEmpty||a||o&&!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:o,type:a,subtitle:r}){const d=oe(),{value:s}=d.merchandiseLines,p=re("merchandiseLines").value,{progress:b,progressing:P}=N(),u=ie().merchandiseLines,f=$(),{observability:_,router:x,embed:v}=h(),{currentDetour:A}=V().value,M=w(()=>s?.lines??[],[s]),[C,U]=q(p);se("stock_problems"),me({stage:C?T.Loading:T.Complete,id:"StockProblems"});const D=o&&L(v?.embedder),E=g(l=>{const i=u.value;u.value=i.filter(({stableId:y})=>!l.includes(y))},[u]),J=g(()=>{le(v,ue)},[v]),I=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=I[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)},[I,u]),j=g(async()=>{const l=e.filter(({problem:i})=>X(i.type)).map(({line:i})=>i.stableId);l.length&&E(l),S({removeUnavailableMerchandise:!0}),_.log("stock_problems_actions_submitted","Stock problems actions submitted",{unshippableMerchandiseIds:JSON.stringify(l),currentDetour:JSON.stringify(A),routerCurrentUrl:x.currentUrl.value.normalizedPath}),await b("checkout-stock-problems-submit")},[A,e,_,b,E,x,S]),O=Z(),W=g(async()=>{await O(e)},[O,e]);return k(function(){S()},[M,S]),k(()=>{p||(U(!1),f.notify({checkout_in_progress:!1}))},[p,C,f]),n(te,{message:r,errorType:ee.InventoryError,children:n(R,{gap:"large-200",children:[n(F,{children:r}),t&&e.length>0?n(pe,{lineItems:e,loading:C,type:a}):null,n(ge,{cartEmpty:o,progressing:P.value,onClick:D?J:j,onSecondaryClick:W})]})})}function Ee(){const{observability:e,checkout:{wallets:t}}=h(),{canBeDismissed:o,...a}=de(),{progress:r}=N(),[d,s]=q(!0),p=H(()=>t.activeSession.value?.wallet!=="GOOGLE_PAY"),{checkoutProtocolModalEventSignal:b}=ce(),P=g(()=>{r("stock-problems-modal-close",()=>{s(!1)})},[r]),u=o?{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(K,{when:p,children:[n(fe,{state:a}),n(ne,{section:"stock-problems",children:n(ae,{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(o=>({stableId:o.line.stableId,problem:o.problem.type}))})},[t,e.lineItems,e.type]),null}export{Ee 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.