1import{_ as P}from"./Screen-ClLks0_F.js";import{_ as q,a as x}from"./ScreenLayoutSection-KwZ7eMTX.js";import{_ as C}from"./Card-J7AKWS6F.js";import{_ as E,a as O,A as N}from"./index-BFSojNnq.js";import{_ as T}from"./PosLoadingState-C394rAv0.js";import{s as A}from"./scheduleOrder-P_8Hqsvd.js";import{S as D}from"./ScheduleOrderSummary-Cul4gXOU.js";import{P as B}from"./PosListGroup-CnbguUqo.js";import{P as $}from"./PosListItem-D3Rbf96i.js";import{n as V}from"./Navigator-nquAwlj6.js";import{g as R}from"./dom-DV8nAVoD.js";import{r as L,o as c,e as S,w as l,Q as m,J as h,N as d,H as y,K as I,L as z,cX as G,cV as H,O as M}from"./vendor-DbLbO5op.js";import"./ScreenHeaderBar-D4wc0l2z.js";import"./device-BsPl6oaQ.js";import"./FacilAccordionPanel-C-6hTxsu.js";import"./FacilLoader-BGI1stku.js";import"./People-BgEpYl1b.js";import"./TotalPrice-CQNg9K6L.js";import"./formatMoney-Dy4ZyQaX.js";import"./isFalsey-F2O9R8Fe.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};t.SENTRY_RELEASE={id:"kqhew@[email protected]"};var e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f7a9ff80-3539-484d-ac05-66b1d4e9a39a",t._sentryDebugIdIdentifier="sentry-dbid-f7a9ff80-3539-484d-ac05-66b1d4e9a39a")}catch{}})();const j={name:"ScheduleOrderSelectInventoryLocationLegacy",components:{PosListGroup:B,PosListItem:$,ScheduleOrderSummary:D},mixins:[V,A],data(){return{storeLocations:[],primaryLocation:{},isLocationsInventoriesLoaded:!1,location_inventories:[],primary_location_details:null,location_details:[]}},computed:{pos(){return N()},headerBar(){return{title:this.$tt("pos.schedule_shipping.ship_from.select_inventory_location"),leftAction:{icon:"chevron_left",onAction:()=>{this.navigatorPop()}}}},mappedLocations(){return this.storeLocations.map(t=>{let e=t.address1;return t.address2!=null&&(e=e+", "+t.address2),t.zip!=null&&(e=e+", "+t.zip),t.city!=null&&(e=e+", "+t.city),t.sub_district!=null&&(e=e+", "+t.sub_district),t.district!=null&&(e=e+", "+t.district),t.province!=null&&(e=e+", "+t.province),t.country!=null&&(e=e+", "+t.country),t.address=e,t})}},mounted(){this.loadStoreLocation()},methods:{handleClick(t,e="select"){const n=R(t,"data-id")||t;let s={};e==="select"&&!this.isLocationsInventoriesLoaded?s=this.storeLocations.find(o=>o.id==n):s=this.location_inventories.find(o=>o.id==n),this.scheduleOrder.shipping_origin=s,this.pos.SET_SCHEDULE_ORDER(this.scheduleOrder),e=="select"?this.statePickupHandle?(this.pos.calculateCart(),this.navigatorPush("checkout-summary")):this.navigatorPush("select-shipping-rate"):this.navigatorPush("view-product-inventory")},async loadStoreLocation(){let t=[],e=[];this.locations.length?t=this.locations:t=await this.$api.location.listLocations({include_hidden:!0,is_enabled:!0,is_filter_pos_location_permission:!0}).then(n=>{var s,o;return(o=(s=n.data)==null?void 0:s.data)!=null&&o.locations?n.data.data.locations:[]}).catch(()=>[]),this.storeLocations=t.filter(n=>{var s;return!!(n.is_primary==!0||n.track_inventory_enabled&&(n.online_fulfillment_enabled==!0||(s=this.currentState.selectedLocation)!=null&&s.id&&this.currentState.selectedLocation.id==n.id))}),e=this.storeLocations,this.primaryLocation=this.storeLocations.filter(n=>n.is_primary),this.storeLocations=this.storeLocations.sort((n,s)=>{var o,a;return(o=this.currentState.selectedLocation)!=null&&o.id&&this.currentState.selectedLocation.id==n.id?-1:(a=this.currentState.selectedLocation)!=null&&a.id&&this.currentState.selectedLocation.id==s.id?1:n.fulfillment_priority-s.fulfillment_priority}),this.loadLocationsInventories(e)},loadLocationsInventories(t){let e=[];t.forEach(n=>{let s=this.getInventoryLevel(n);e.push(s)}),Promise.all(e).then(()=>{this.location_inventories=this.location_inventories.concat(this.location_details),this.primary_location_details&&this.location_inventories.forEach((n,s)=>{n.track_inventory_enabled||(this.location_inventories[s].location_inventory_status=this.primary_location_details.location_inventory_status,this.location_inventories[s].location_items_inventory=this.primary_location_details.location_items_inventory)}),this.isLocationsInventoriesLoaded=!0}).catch(n=>{console.error("Error during API calls:",n),this.isLocationsInventoriesLoaded=!0})}
1,getInventoryLevel(t){return new Promise((e,n)=>{let s=this.pos.cart.items,o="sufficient",a=[],r=s.map(i=>{let u="sufficient";if(i.inventory_management==="none")u="not_tracked",o="not_tracked",a.push({product_name:i.product_name,variant_name:i.variant_name,image_url:i.image_url,inventory_status:u,onhand_inventory_quantity:0,inventory_quantity:0,is_new:!1});else{if(t.track_inventory_enabled&&!i.is_new)return this.$api.inventory_level.getInventoryLevel({variant_id:i.variant_id,location_id:t.id,fields:"committed_inventory_quantity,onhand_inventory_quantity",extras:"variant,location"}).then(p=>{var g;let v=0,_=0;if((g=p==null?void 0:p.data)!=null&&g.inventory_level){let k=p.data.inventory_level;v=k.onhand_inventory_quantity,_=k.inventory_quantity,o=="sufficient"&&(_<i.quantity||_<=0)&&(o="insufficient"),_<i.quantity&&(u="insufficient")}else o="insufficient",u="insufficient",v=0,_=0;a.push({product_name:i.product_name,variant_name:i.variant_name,image_url:i.image_url,inventory_status:u,onhand_inventory_quantity:v,inventory_quantity:_,is_new:!1})}).catch(()=>{o="insufficient",a.push({product_name:i.product_name,variant_name:i.variant_name,image_url:i.image_url,inventory_status:"insufficient",onhand_inventory_quantity:0,inventory_quantity:0,is_new:!1})});i.is_new?a.push({product_name:i.product_name,variant_name:"",image_url:null,inventory_status:"insufficient",onhand_inventory_quantity:0,inventory_quantity:0,is_new:!0}):(o="insufficient",a.push({product_name:i.product_name,variant_name:i.variant_name,image_url:i.image_url,inventory_status:"insufficient",onhand_inventory_quantity:0,inventory_quantity:0,is_new:!1}))}});Promise.all(r).then(()=>{let i={id:t.id,name:t.name,location_inventory_status:o,location_items_inventory:a,track_inventory_enabled:t.track_inventory_enabled};t.is_primary&&(this.primary_location_details=i),this.location_details.push(i),e()}).catch(i=>{console.error("Error during API calls:",i),n(i)})})},getInventoryStatus(t){const e=this.location_inventories.filter(r=>r.id==t);if(!e.length)return"not_tracked";const n=e[0].location_items_inventory||[];return n.length?n.some(r=>r.inventory_status==="insufficient")?"insufficient":n.every(r=>r.inventory_status==="not_tracked")?"not_tracked":n.every(r=>r.inventory_status==="sufficient"||r.inventory_status==="not_tracked")?"sufficient":"insufficient":"not_tracked"}}},F={class:"screen-text-large font-500"},J={class:"flex flex-col gap-y-1.5"},K={class:"font-medium screen-text-medium"},Q={class:"text-muted screen-text-default"},U={class:"flex flex-col justify-end gap-y-1.5"},X={key:0,class:"text-muted flex items-center justify-end"},Y={class:"ml-2"},W={key:0,class:"label label--success ml-auto font-medium screen-text-default"},Z={key:1,class:"label label--warning ml-auto font-medium screen-text-default"},tt={key:2,class:"label label--info ml-auto font-medium screen-text-default"};function et(t,e,n,s,o,a){const r=L("ScheduleOrderSummary"),i=x,u=T,p=O,v=L("PosListItem"),_=L("PosListGroup"),g=C,k=q,b=P;return c(),S(b,{"header-bar":a.headerBar,class:"bg-white"},{default:l(()=>[m(k,null,{default:l(()=>[m(i,{primary:"",class:"section-layout__left"},{default:l(()=>[m(r)]),_:1}),m(i,{class:"section-layout__right"},{default:l(()=>[m(g,{medium:""},{default:l(()=>[h("h3",F,d(t.$tt("pos.schedule_shipping.ship_from.from_location")),1),m(_,{onClick:a.handleClick},{default:l(()=>[(c(!0),y(I,null,z(a.mappedLocations,(f,w)=>(c(),S(v,{key:w,"data-id":f.id,"show-icon":!0},{left:l(()=>[...e[0]||(e[0]=[])]),content:l(()=>[h("div",J,[h("div",K,d(f.name),1),h("div",Q,d(f.address),1)])]),right:l(()=>[h("div",U,[o.isLocationsInventoriesLoaded?(c(),y(I,{key:1},[a.getInventoryStatus(f.id)=="sufficient"?(c(),y("div",W,d(t.$tt("pos.schedule_shipping.ship_from.sufficient")),1)):a.getInventoryStatus(f.id)=="insufficient"?(c(),y("div",Z,d(t.$tt("pos.schedule_shipping.ship_from.insufficient")),1)):(c(),y("div",tt,d(t.$tt("pos.schedule_shipping.ship_from.not_tracked")),1)),a.getInventoryStatus(f.id)!="not_tracked"?(c(),S(p,{key:3,kind:"link",type:"primary",size:"xl",onClick:G(nt=>a.handleClick(f.id,"view"),["prevent"])},{default:l(()=>[H(d(t.$tt("pos.schedule_shipping.ship_from.view_details")),1)]),_:1},8,["onClick"])):M("",!0)],64)):(c(),y("div",X,[m(u,{type:"optimistic"}),h("span",Y,d(t.$tt("pos.schedule_shipping.ship_from.fetching")),1)]))])]),_:2},1032,["data-id"]))),128))]),_:1},8,["onClick"])]),_:1})]),_:1})]),_:1})]),_:1},8,["header-bar"])}const It=E(j,[["render",et],["__scopeId","data-v-d9c983eb"]]);export{It 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.