@codingfactory/inventory-locator-client 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index-BrZt55_Z.js +22405 -0
- package/dist/index-D6KBu_HL.cjs +20 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1803 -0
- package/dist/index.js +6020 -0
- package/dist/inventory-locator-client.css +1 -0
- package/package.json +2 -1
- package/tsconfig.json +0 -21
- package/vite.config.ts +0 -37
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),Ne=require("pinia"),Pe=require("axios"),ae=require("vue-router"),le=Ne.defineStore("inventoryLocation",()=>{const t=e.ref([]),n=e.ref(null),o=e.ref(new Set),h=e.ref(new Map),s=e.ref(!1);function _(u){const m=f=>{for(const w of f){if(w.id===u)return w;if(w.children){const V=m(w.children);if(V)return V}}return null};return m(t.value)}const y=e.computed(()=>n.value?_(n.value):null),i=e.computed(()=>u=>o.value.has(u));function l(u){t.value=u}function c(u){n.value=u}function a(u){o.value.has(u)?o.value.delete(u):o.value.add(u)}function r(u,m){h.value.set(u,m)}function d(u){const m=f=>{for(let w=0;w<f.length;w++){if(f[w].id===u.id)return f[w]={...f[w],...u},!0;if(f[w].children&&m(f[w].children))return!0}return!1};m(t.value)}function p(u){const m=f=>{const w=f.findIndex(V=>V.id===u);if(w!==-1)return f.splice(w,1),!0;for(const V of f)if(V.children&&m(V.children))return!0;return!1};m(t.value),n.value===u&&(n.value=null)}function v(){t.value=[],n.value=null,o.value.clear(),h.value.clear()}return{roots:t,selectedLocationId:n,expandedNodeIds:o,childrenCache:h,loading:s,selectedLocation:y,isExpanded:i,setRoots:l,selectLocation:c,toggleExpand:a,cacheChildren:r,updateLocationInTree:d,removeLocationFromTree:p,findInTree:_,reset:v}}),we=Ne.defineStore("inventoryScanner",()=>{const t=e.ref([]),n=e.ref(null);function o(_){t.value.unshift({..._,scannedAt:new Date().toISOString()}),t.value.length>20&&(t.value=t.value.slice(0,20)),n.value=_.code,sessionStorage.setItem("inv-scan-history",JSON.stringify(t.value))}function h(){const _=sessionStorage.getItem("inv-scan-history");if(_)try{t.value=JSON.parse(_)}catch{}}function s(){t.value=[],n.value=null,sessionStorage.removeItem("inv-scan-history")}return{history:t,lastScannedCode:n,addToHistory:o,loadFromSession:h,clearHistory:s}}),ve=Ne.defineStore("inventoryCount",()=>{const t=e.ref(null),n=e.ref(null),o=e.ref([]),h=e.ref(typeof navigator<"u"?navigator.onLine:!0),s=e.computed(()=>o.value.length>0),_=e.computed(()=>t.value!==null);function y(v){t.value=v}function i(){t.value=null,n.value=null}function l(v){n.value=v}function c(v){o.value.push({...v,queuedAt:new Date().toISOString()}),r()}function a(v){o.value=o.value.filter(u=>u.entryId!==v),r()}function r(){sessionStorage.setItem("inv-count-queue",JSON.stringify(o.value))}function d(){const v=sessionStorage.getItem("inv-count-queue");if(v)try{o.value=JSON.parse(v)}catch{}}async function p(v){const u=[...o.value];for(const m of u)try{await v(m),a(m.entryId)}catch{break}}return{activeSessionId:t,currentLocationId:n,pendingSubmissions:o,isOnline:h,hasPendingSubmissions:s,isCountingMode:_,startCounting:y,stopCounting:i,setCurrentLocation:l,queueCount:c,removeFromQueue:a,persistQueue:r,loadQueue:d,syncPendingCounts:p}});let ue=null,xe="/api/inventory-locator/v1";function Se(t){t.axiosInstance&&(ue=t.axiosInstance),t.prefix&&(xe=t.prefix)}function R(){return ue||(ue=Pe),ue}function q(t){return`${xe}${t}`}function ee(){const t=e.ref([]),n=e.ref(!1),o=e.ref(null),h=le();async function s(){var v,u;n.value=!0,o.value=null;try{const f=(await R().get(q("/locations"))).data.data;return h.setRoots(f),t.value=f,f}catch(m){throw o.value=((u=(v=m.response)==null?void 0:v.data)==null?void 0:u.message)||"Failed to load locations",m}finally{n.value=!1}}async function _(v){var u,m;n.value=!0,o.value=null;try{return(await R().get(q(`/locations/${v}?include_path=1`))).data.data}catch(f){throw o.value=((m=(u=f.response)==null?void 0:u.data)==null?void 0:m.message)||"Failed to load location",f}finally{n.value=!1}}async function y(v){var m,f;const u=h.childrenCache.get(v);if(u)return u;try{const V=(await R().get(q(`/locations/${v}`))).data.data.children||[];return h.cacheChildren(v,V),V}catch(w){throw o.value=((f=(m=w.response)==null?void 0:m.data)==null?void 0:f.message)||"Failed to load children",w}}async function i(v){var u,m;n.value=!0,o.value=null;try{return(await R().get(q(`/locations/${v}/tree`))).data}catch(f){throw o.value=((m=(u=f.response)==null?void 0:u.data)==null?void 0:m.message)||"Failed to load tree",f}finally{n.value=!1}}async function l(v){var u,m;n.value=!0,o.value=null;try{const w=(await R().post(q("/locations"),v)).data.data;return await s(),w}catch(f){throw o.value=((m=(u=f.response)==null?void 0:u.data)==null?void 0:m.message)||"Failed to create location",f}finally{n.value=!1}}async function c(v,u){var m,f;n.value=!0,o.value=null;try{const V=(await R().put(q(`/locations/${v}`),u)).data.data;return h.updateLocationInTree(V),V}catch(w){throw o.value=((f=(m=w.response)==null?void 0:m.data)==null?void 0:f.message)||"Failed to update location",w}finally{n.value=!1}}async function a(v){var u,m;n.value=!0,o.value=null;try{await R().delete(q(`/locations/${v}`)),h.removeLocationFromTree(v)}catch(f){throw o.value=((m=(u=f.response)==null?void 0:u.data)==null?void 0:m.message)||"Failed to delete location",f}finally{n.value=!1}}async function r(v,u){var m,f;n.value=!0,o.value=null;try{const V=(await R().post(q(`/locations/${v}/move`),{parent_id:u})).data.data;return await s(),V}catch(w){throw o.value=((f=(m=w.response)==null?void 0:m.data)==null?void 0:f.message)||"Failed to move location",w}finally{n.value=!1}}async function d(){var v,u;try{return(await R().get(q("/locations/types"))).data}catch(m){throw o.value=((u=(v=m.response)==null?void 0:v.data)==null?void 0:u.message)||"Failed to load types",m}}async function p(v){var u;try{return(await R().get(q(`/scan/${encodeURIComponent(v)}`))).data.data}catch(m){if(((u=m.response)==null?void 0:u.status)===404)return null;throw m}}return{locations:t,loading:n,error:o,fetchRoots:s,fetchLocation:_,fetchChildren:y,fetchTree:i,create:l,update:c,remove:a,move:r,fetchTypes:d,scanLookup:p}}function te(){const t=e.ref([]),n=e.ref(!1),o=e.ref(null);async function h(a){var r,d;n.value=!0,o.value=null;try{const p=await R().get(q(`/locations/${a}/products`));t.value=p.data.data}catch(p){throw o.value=((d=(r=p.response)==null?void 0:r.data)==null?void 0:d.message)||"Failed to load products",p}finally{n.value=!1}}async function s(a,r){var d,p;n.value=!0,o.value=null;try{const u=(await R().post(q(`/locations/${a}/products`),r)).data.data;return await h(a),u}catch(v){throw o.value=((p=(d=v.response)==null?void 0:d.data)==null?void 0:p.message)||"Failed to add product",v}finally{n.value=!1}}async function _(a,r,d){var p,v;n.value=!0,o.value=null;try{const m=(await R().patch(q(`/locations/${a}/products/${r}`),d)).data.data,f=t.value.findIndex(w=>w.product_id===r);return f!==-1&&(t.value[f]=m),m}catch(u){throw o.value=((v=(p=u.response)==null?void 0:p.data)==null?void 0:v.message)||"Failed to update product",u}finally{n.value=!1}}async function y(a,r,d){var p,v;n.value=!0,o.value=null;try{const u=d!==void 0?`?quantity=${d}`:"";await R().delete(q(`/locations/${a}/products/${r}${u}`)),t.value=t.value.filter(m=>m.product_id!==r)}catch(u){throw o.value=((v=(p=u.response)==null?void 0:p.data)==null?void 0:v.message)||"Failed to remove product",u}finally{n.value=!1}}async function i(a,r){var d,p;n.value=!0,o.value=null;try{await R().post(q(`/products/${a}/move`),r)}catch(v){throw o.value=((p=(d=v.response)==null?void 0:d.data)==null?void 0:p.message)||"Failed to move product",v}finally{n.value=!1}}async function l(a,r){var d,p;n.value=!0,o.value=null;try{await R().post(q(`/locations/${a}/products/bulk`),{items:r}),await h(a)}catch(v){throw o.value=((p=(d=v.response)==null?void 0:d.data)==null?void 0:p.message)||"Failed to bulk add products",v}finally{n.value=!1}}async function c(a){var r,d;n.value=!0,o.value=null;try{return(await R().get(q(`/products/${a}/locations`))).data.data}catch(p){throw o.value=((d=(r=p.response)==null?void 0:r.data)==null?void 0:d.message)||"Failed to load product locations",p}finally{n.value=!1}}return{products:t,loading:n,error:o,fetchProducts:h,addProduct:s,updateProduct:_,removeProduct:y,moveProduct:i,bulkAdd:l,fetchProductLocations:c}}function ie(){const t=e.ref([]),n=e.ref(""),o=e.ref(!1),h=e.ref(null);let s=null;function _(i,l){if(n.value=i,s&&clearTimeout(s),!i||i.length<2){t.value=[];return}s=setTimeout(async()=>{var c,a;o.value=!0,h.value=null;try{const r=new URLSearchParams({q:i});l!=null&&l.type&&r.set("type",l.type);const d=await R().get(q(`/locations/search?${r}`));t.value=d.data.data}catch(r){h.value=((a=(c=r.response)==null?void 0:c.data)==null?void 0:a.message)||"Search failed"}finally{o.value=!1}},300)}function y(){n.value="",t.value=[],s&&clearTimeout(s)}return{results:t,query:n,loading:o,error:h,search:_,clear:y}}function Le(){var a;const t=e.ref(!1),n=e.ref(null),o=e.ref(null),h=e.ref(!1),s=e.ref(!1),_=e.ref(!1);let y=null;h.value=typeof navigator<"u"&&!!((a=navigator.mediaDevices)!=null&&a.getUserMedia);async function i(r,d){if(!h.value){o.value="Camera scanning not supported in this browser";return}try{const{Html5Qrcode:p,Html5QrcodeSupportedFormats:v}=await Promise.resolve().then(()=>require("./index-D6KBu_HL.cjs"));y=new p(r),t.value=!0,o.value=null,await y.start({facingMode:"environment"},{fps:10,qrbox:{width:250,height:250},formatsToSupport:[v.QR_CODE,v.CODE_128,v.CODE_39]},u=>{n.value=u,navigator.vibrate&&navigator.vibrate(100),d(u)},()=>{})}catch(p){o.value=(p==null?void 0:p.message)||"Camera access denied or not available",t.value=!1}}async function l(){y!=null&&y.isScanning&&await y.stop(),y=null,t.value=!1}async function c(){_.value=!_.value}return e.onUnmounted(()=>{l()}),{isScanning:t,lastResult:n,error:o,isSupported:h,hasFlash:s,flashOn:_,startScanning:i,stopScanning:l,toggleFlash:c}}function se(){const t=e.ref([]),n=e.ref(null),o=e.ref([]),h=e.ref(null),s=e.ref(!1),_=e.ref(null);async function y(m){var f,w;s.value=!0,_.value=null;try{const V=m?`?status=${m}`:"",g=await R().get(q(`/counts${V}`));t.value=g.data.data}catch(V){throw _.value=((w=(f=V.response)==null?void 0:f.data)==null?void 0:w.message)||"Failed to load sessions",V}finally{s.value=!1}}async function i(m,f){var w,V;s.value=!0,_.value=null;try{const b=(await R().post(q("/counts"),{name:m,scope_location_id:f||null})).data.data;return t.value.unshift(b),b}catch(g){throw _.value=((V=(w=g.response)==null?void 0:w.data)==null?void 0:V.message)||"Failed to create session",g}finally{s.value=!1}}async function l(m){var f,w;s.value=!0,_.value=null;try{const V=await R().get(q(`/counts/${m}`));return n.value=V.data.data,V.data.data}catch(V){throw _.value=((w=(f=V.response)==null?void 0:f.data)==null?void 0:w.message)||"Failed to load session",V}finally{s.value=!1}}async function c(m,f){var w,V;s.value=!0,_.value=null;try{const g=await R().patch(q(`/counts/${m}`),{status:f});n.value=g.data.data}catch(g){throw _.value=((V=(w=g.response)==null?void 0:w.data)==null?void 0:V.message)||"Failed to update session",g}finally{s.value=!1}}async function a(m){var f,w;s.value=!0,_.value=null;try{return(await R().post(q(`/counts/${m}/generate`))).data}catch(V){throw _.value=((w=(f=V.response)==null?void 0:f.data)==null?void 0:w.message)||"Failed to generate entries",V}finally{s.value=!1}}async function r(m,f){var w,V;s.value=!0,_.value=null;try{const g=new URLSearchParams;f!=null&&f.status&&g.set("status",f.status),f!=null&&f.location_id&&g.set("location_id",String(f.location_id)),f!=null&&f.discrepancies_only&&g.set("discrepancies_only","1");const b=await R().get(q(`/counts/${m}/entries?${g}`));o.value=b.data.data}catch(g){throw _.value=((V=(w=g.response)==null?void 0:w.data)==null?void 0:V.message)||"Failed to load entries",g}finally{s.value=!1}}async function d(m,f,w,V){var g,b;_.value=null;try{const $=(await R().post(q(`/counts/${m}/entries/${f}/count`),{counted_quantity:w,notes:V})).data.data,F=o.value.findIndex(k=>k.id===f);return F!==-1&&(o.value[F]=$),$}catch(x){throw _.value=((b=(g=x.response)==null?void 0:g.data)==null?void 0:b.message)||"Failed to submit count",x}}async function p(m,f){var w,V;_.value=null;try{const b=(await R().post(q(`/counts/${m}/entries/${f}/verify`))).data.data,x=o.value.findIndex($=>$.id===f);return x!==-1&&(o.value[x]=b),b}catch(g){throw _.value=((V=(w=g.response)==null?void 0:w.data)==null?void 0:V.message)||"Failed to verify entry",g}}async function v(m){var f,w;s.value=!0,_.value=null;try{return(await R().post(q(`/counts/${m}/apply`))).data}catch(V){throw _.value=((w=(f=V.response)==null?void 0:f.data)==null?void 0:w.message)||"Failed to apply session",V}finally{s.value=!1}}async function u(m){var f,w;s.value=!0,_.value=null;try{const V=await R().get(q(`/counts/${m}/report`));return h.value=V.data,V.data}catch(V){throw _.value=((w=(f=V.response)==null?void 0:f.data)==null?void 0:w.message)||"Failed to load report",V}finally{s.value=!1}}return{sessions:t,currentSession:n,entries:o,report:h,loading:s,error:_,fetchSessions:y,createSession:i,fetchSession:l,updateStatus:c,generateEntries:a,fetchEntries:r,submitCount:d,verifyEntry:p,applySession:v,fetchReport:u}}function pe(){const t=e.ref([]),n=e.ref(!1),o=e.ref(null);async function h(i){var l,c;n.value=!0,o.value=null;try{const a=new URLSearchParams;i!=null&&i.reason&&a.set("reason",i.reason),i!=null&&i.from_date&&a.set("from_date",i.from_date),i!=null&&i.to_date&&a.set("to_date",i.to_date);const r=await R().get(q(`/movements?${a}`));t.value=r.data.data}catch(a){throw o.value=((c=(l=a.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",a}finally{n.value=!1}}async function s(i){var l,c;n.value=!0,o.value=null;try{const a=await R().get(q(`/locations/${i}/movements`));t.value=a.data.data}catch(a){throw o.value=((c=(l=a.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",a}finally{n.value=!1}}async function _(i){var l,c;n.value=!0,o.value=null;try{const a=await R().get(q(`/products/${i}/movements`));t.value=a.data.data}catch(a){throw o.value=((c=(l=a.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",a}finally{n.value=!1}}async function y(){var i,l;n.value=!0,o.value=null;try{const c=await R().get(q("/dashboard/recent-movements"));t.value=c.data.data}catch(c){throw o.value=((l=(i=c.response)==null?void 0:i.data)==null?void 0:l.message)||"Failed to load movements",c}finally{n.value=!1}}return{movements:t,loading:n,error:o,fetchAll:h,fetchByLocation:s,fetchByProduct:_,fetchRecent:y}}function _e(){const t=e.ref(null),n=e.ref(!1),o=e.ref(null);async function h(i,l="standard"){var c,a;n.value=!0,o.value=null;try{const r=await R().get(q(`/locations/${i}/label?format=${l}`));return t.value=r.data,r.data}catch(r){throw o.value=((a=(c=r.response)==null?void 0:c.data)==null?void 0:a.message)||"Failed to load label",r}finally{n.value=!1}}async function s(i,l="standard"){var c,a;n.value=!0,o.value=null;try{const r=await R().post(q(`/locations/${i}/label/print?format=${l}`));y(r.data)}catch(r){throw o.value=((a=(c=r.response)==null?void 0:c.data)==null?void 0:a.message)||"Failed to print label",r}finally{n.value=!1}}async function _(i,l="standard"){var c,a;n.value=!0,o.value=null;try{const r=await R().post(q("/labels/batch"),{location_ids:i,format:l});y(r.data)}catch(r){throw o.value=((a=(c=r.response)==null?void 0:c.data)==null?void 0:a.message)||"Failed to print batch",r}finally{n.value=!1}}function y(i){const l=window.open("","_blank");l&&(l.document.write(i),l.document.close(),l.onload=()=>{l.print(),setTimeout(()=>l.close(),1e3)})}return{labelData:t,loading:n,error:o,fetchLabel:h,printLabel:s,printBatch:_}}function Ae(){const t=e.ref([]);function n(h){t.value=h}function o(h){const s=e.inject("router",null);s&&s.push({name:"inventory-location",params:{code:h.full_code}})}return{breadcrumbs:t,setBreadcrumbs:n,navigateTo:o}}const Re={class:"inv-card__header-content"},qe={key:0,class:"inv-card__title"},Ue={key:1,class:"inv-card__subtitle"},He={key:0,class:"inv-card__actions"},je=["id","aria-labelledby"],Oe={key:0,class:"inv-card__loading-overlay","aria-live":"polite"},Ke=e.defineComponent({__name:"InvCard",props:{title:{},subtitle:{},loading:{type:Boolean,default:!1},collapsible:{type:Boolean,default:!1},collapsed:{type:Boolean,default:!1},noPadding:{type:Boolean,default:!1},compact:{type:Boolean,default:!1}},emits:["toggle"],setup(t,{emit:n}){const o=t,h=n,s=e.useId(),_=e.computed(()=>`inv-card-content-${s}`),y=e.computed(()=>`inv-card-title-${s}`),i=e.ref(o.collapsed);e.watch(()=>o.collapsed,c=>{i.value=c});function l(){i.value=!i.value,h("toggle",i.value)}return(c,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["inv-card",{"inv-card--compact":t.compact,"inv-card--no-padding":t.noPadding}])},[t.title||c.$slots.actions?(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["inv-card__header",{"inv-card__header--collapsible":t.collapsible}])},[e.createElementVNode("div",Re,[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(t.collapsible?"button":"div"),{class:e.normalizeClass(["inv-card__title-area",{"inv-card__title-button":t.collapsible}]),type:t.collapsible?"button":void 0,"aria-expanded":t.collapsible?!i.value:void 0,"aria-controls":t.collapsible?_.value:void 0,onClick:a[0]||(a[0]=r=>t.collapsible?l():void 0)},{default:e.withCtx(()=>[t.collapsible?(e.openBlock(),e.createElementBlock("svg",{key:0,class:e.normalizeClass(["inv-card__chevron",{"inv-card__chevron--collapsed":i.value}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[...a[1]||(a[1]=[e.createElementVNode("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2)):e.createCommentVNode("",!0),e.createElementVNode("div",null,[t.title?(e.openBlock(),e.createElementBlock("h3",qe,e.toDisplayString(t.title),1)):e.createCommentVNode("",!0),t.subtitle?(e.openBlock(),e.createElementBlock("p",Ue,e.toDisplayString(t.subtitle),1)):e.createCommentVNode("",!0)])]),_:1},8,["class","type","aria-expanded","aria-controls"]))]),c.$slots.actions?(e.openBlock(),e.createElementBlock("div",He,[e.renderSlot(c.$slots,"actions",{},void 0,!0)])):e.createCommentVNode("",!0)],2)):e.createCommentVNode("",!0),e.withDirectives(e.createElementVNode("div",{id:_.value,class:"inv-card__body",role:"region","aria-labelledby":t.title?y.value:void 0},[t.loading?(e.openBlock(),e.createElementBlock("div",Oe,[...a[2]||(a[2]=[e.createElementVNode("div",{class:"inv-card__shimmer"},null,-1),e.createElementVNode("div",{class:"inv-card__shimmer inv-card__shimmer--short"},null,-1),e.createElementVNode("div",{class:"inv-card__shimmer inv-card__shimmer--medium"},null,-1),e.createElementVNode("span",{class:"sr-only"},"Loading...",-1)])])):e.renderSlot(c.$slots,"default",{key:1},void 0,!0)],8,je),[[e.vShow,!i.value]])],2))}}),H=(t,n)=>{const o=t.__vccOpts||t;for(const[h,s]of n)o[h]=s;return o},j=H(Ke,[["__scopeId","data-v-11729604"]]),Qe=["type","disabled","aria-busy"],Ge={key:0,class:"inv-btn__spinner","aria-hidden":"true"},We={key:1,class:"inv-btn__icon inv-btn__icon--left"},Ze={class:"inv-btn__label"},Je={key:2,class:"inv-btn__icon inv-btn__icon--right"},Xe=e.defineComponent({__name:"InvButton",props:{variant:{default:"primary"},size:{default:"md"},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},type:{default:"button"}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("button",{class:e.normalizeClass(["inv-btn",[`inv-btn--${t.variant}`,`inv-btn--${t.size}`,{"inv-btn--loading":t.loading,"inv-btn--disabled":t.disabled||t.loading}]]),type:t.type,disabled:t.disabled||t.loading,"aria-busy":t.loading||void 0},[t.loading?(e.openBlock(),e.createElementBlock("span",Ge,[...o[0]||(o[0]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},[e.createElementVNode("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round",opacity:"0.25"}),e.createElementVNode("path",{d:"M14 8A6 6 0 0 0 8 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])])):n.$slots["icon-left"]?(e.openBlock(),e.createElementBlock("span",We,[e.renderSlot(n.$slots,"icon-left",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("span",Ze,[e.renderSlot(n.$slots,"default",{},void 0,!0)]),n.$slots["icon-right"]?(e.openBlock(),e.createElementBlock("span",Je,[e.renderSlot(n.$slots,"icon-right",{},void 0,!0)])):e.createCommentVNode("",!0)],10,Qe))}}),T=H(Xe,[["__scopeId","data-v-6f9fc98e"]]),Ye={class:"inv-dashboard"},et={class:"inv-dashboard__stats"},tt={class:"inv-dashboard__stat-card inv-dashboard__stat-card--primary"},ot={key:0,class:"inv-dashboard__stat-shimmer"},nt={class:"inv-dashboard__stat-value"},at={class:"inv-dashboard__stat-card inv-dashboard__stat-card--success"},lt={key:0,class:"inv-dashboard__stat-shimmer"},st={class:"inv-dashboard__stat-value"},rt={class:"inv-dashboard__stat-card inv-dashboard__stat-card--info"},it={key:0,class:"inv-dashboard__stat-shimmer"},ct={class:"inv-dashboard__stat-value"},dt={class:"inv-dashboard__stat-card inv-dashboard__stat-card--warning"},ut={key:0,class:"inv-dashboard__stat-shimmer"},mt={class:"inv-dashboard__stat-value"},pt={class:"inv-dashboard__type-grid"},vt={class:"inv-dashboard__type-count"},_t={class:"inv-dashboard__type-label"},ht={class:"inv-dashboard__actions-grid"},ft=["onClick"],yt=["innerHTML"],kt={class:"inv-dashboard__action-label"},gt={key:0,class:"inv-dashboard__activity-list",role:"list"},Vt=["onClick"],bt={class:"inv-dashboard__activity-info"},Nt={class:"inv-dashboard__activity-product"},wt={class:"inv-dashboard__activity-location"},Et={class:"inv-dashboard__activity-time"},Ct={key:1,class:"inv-dashboard__no-activity"},Bt={class:"inv-dashboard__bottom-row"},$t={key:0,class:"inv-dashboard__unlocated-content"},xt={class:"inv-dashboard__unlocated-text"},St={key:1,class:"inv-dashboard__unlocated-none"},Lt={key:0},Dt={class:"inv-dashboard__count-info"},zt={class:"inv-dashboard__count-name"},It=["aria-valuenow"],Mt={class:"inv-dashboard__count-progress-track"},Tt={class:"inv-dashboard__count-pct"},Ft={key:1,class:"inv-dashboard__no-counts"},Pt=e.defineComponent({__name:"InventoryDashboard",setup(t){const n=ae.useRouter(),{movements:o,loading:h,fetchRecent:s}=pe(),{sessions:_,fetchSessions:y}=se(),i=e.ref(null),l=e.ref(!0),c=e.ref(0),a=[{label:"Scan Location",route:"inventory-scan",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><rect x="3" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/><rect x="14" y="3" width="7" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/><rect x="3" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/><rect x="14" y="14" width="7" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/></svg>'},{label:"Add Location",route:"inventory-locations",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="16" height="16" rx="2" stroke="currentColor" stroke-width="1.5"/><path d="M12 8V16M8 12H16" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>'},{label:"Find Product",route:"inventory-locations",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><circle cx="11" cy="11" r="7" stroke="currentColor" stroke-width="1.5"/><path d="M16 16L20 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>'},{label:"Start Count",route:"inventory-counts",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><rect x="4" y="4" width="16" height="16" rx="2" stroke="currentColor" stroke-width="1.5"/><path d="M8 8h2v2H8V8zm4 0h2v2h-2V8zm-4 4h2v2H8v-2zm4 0h2v2h-2v-2z" fill="currentColor"/></svg>'},{label:"Print Labels",route:"inventory-labels",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><rect x="6" y="2" width="12" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/><rect x="3" y="9" width="18" height="9" rx="1" stroke="currentColor" stroke-width="1.5"/><rect x="7" y="15" width="10" height="7" rx="1" stroke="currentColor" stroke-width="1.5"/></svg>'},{label:"Browse Locations",route:"inventory-locations",icon:'<svg width="24" height="24" viewBox="0 0 24 24" fill="none"><path d="M3 7H21M3 12H21M3 17H21" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>'}];e.onMounted(()=>{r(),s(),y("in_progress"),d()});async function r(){l.value=!0;try{const V=await R().get(q("/dashboard/stats"));i.value=V.data}catch{}finally{l.value=!1}}async function d(){var V,g;try{const b=await R().get(q("/dashboard/unlocated-products?limit=1"));c.value=((V=b.data.meta)==null?void 0:V.total)??((g=b.data.data)==null?void 0:g.length)??0}catch{}}function p(V){n.push({name:V})}function v(V){const g=V.to_location||V.from_location;g&&n.push({name:"inventory-location",params:{code:g.full_code}})}function u(V){return{placed:"+",moved:"↔",picked:"-",adjusted:"⟳",counted:"#",received:"+",returned:"↩"}[V]??"?"}function m(V){const g=Date.now(),b=new Date(V).getTime(),x=g-b,$=Math.floor(x/1e3);if($<60)return"just now";const F=Math.floor($/60);if(F<60)return`${F} min ago`;const k=Math.floor(F/60);if(k<24)return`${k}h ago`;const E=Math.floor(k/24);return E===1?"yesterday":`${E}d ago`}function f(V){return V.toLocaleString("en-US")}function w(V){return V.charAt(0).toUpperCase()+V.slice(1)+"s"}return(V,g)=>{var b,x,$,F;return e.openBlock(),e.createElementBlock("div",Ye,[g[8]||(g[8]=e.createElementVNode("h1",{class:"inv-dashboard__title"},"Inventory Dashboard",-1)),e.createElementVNode("div",et,[e.createElementVNode("div",tt,[l.value?(e.openBlock(),e.createElementBlock("div",ot)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("span",nt,e.toDisplayString(((b=i.value)==null?void 0:b.total_locations)??0),1),g[1]||(g[1]=e.createElementVNode("span",{class:"inv-dashboard__stat-label"},"Total Locations",-1))],64))]),e.createElementVNode("div",at,[l.value?(e.openBlock(),e.createElementBlock("div",lt)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("span",st,e.toDisplayString(f(((x=i.value)==null?void 0:x.total_products_tracked)??0)),1),g[2]||(g[2]=e.createElementVNode("span",{class:"inv-dashboard__stat-label"},"Products Tracked",-1))],64))]),e.createElementVNode("div",rt,[l.value?(e.openBlock(),e.createElementBlock("div",it)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("span",ct,e.toDisplayString((($=i.value)==null?void 0:$.locations_with_products)??0),1),g[3]||(g[3]=e.createElementVNode("span",{class:"inv-dashboard__stat-label"},"In Use",-1))],64))]),e.createElementVNode("div",dt,[l.value?(e.openBlock(),e.createElementBlock("div",ut)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("span",mt,e.toDisplayString(((F=i.value)==null?void 0:F.empty_leaf_locations)??0),1),g[4]||(g[4]=e.createElementVNode("span",{class:"inv-dashboard__stat-label"},"Empty",-1))],64))])]),i.value&&Object.keys(i.value.locations_by_type).length>0?(e.openBlock(),e.createBlock(j,{key:0,title:"Locations by Type",compact:"",class:"inv-dashboard__by-type"},{default:e.withCtx(()=>[e.createElementVNode("div",pt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value.locations_by_type,(k,E)=>(e.openBlock(),e.createElementBlock("div",{key:E,class:"inv-dashboard__type-item"},[e.createElementVNode("span",vt,e.toDisplayString(k),1),e.createElementVNode("span",_t,e.toDisplayString(w(E)),1)]))),128))])]),_:1})):e.createCommentVNode("",!0),e.createVNode(j,{title:"Quick Actions",compact:"",class:"inv-dashboard__quick-actions"},{default:e.withCtx(()=>[e.createElementVNode("div",ht,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(a,k=>e.createElementVNode("button",{key:k.label,type:"button",class:"inv-dashboard__action-btn",onClick:E=>p(k.route)},[e.createElementVNode("span",{class:"inv-dashboard__action-icon",innerHTML:k.icon},null,8,yt),e.createElementVNode("span",kt,e.toDisplayString(k.label),1)],8,ft)),64))])]),_:1}),e.createVNode(j,{title:"Recent Activity",class:"inv-dashboard__activity",loading:e.unref(h)},{default:e.withCtx(()=>[e.unref(o).length>0?(e.openBlock(),e.createElementBlock("div",gt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(o),k=>(e.openBlock(),e.createElementBlock("button",{key:k.id,type:"button",role:"listitem",class:"inv-dashboard__activity-row",onClick:E=>v(k)},[e.createElementVNode("span",{class:e.normalizeClass(["inv-dashboard__activity-icon",`inv-dashboard__activity-icon--${k.reason}`]),"aria-hidden":"true"},e.toDisplayString(u(k.reason)),3),e.createElementVNode("div",bt,[e.createElementVNode("span",Nt,e.toDisplayString(k.product_name),1),e.createElementVNode("span",wt,[k.reason==="moved"&&k.from_location&&k.to_location?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[e.createTextVNode(e.toDisplayString(k.from_location.full_code)+" → "+e.toDisplayString(k.to_location.full_code),1)],64)):k.to_location?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createTextVNode(" → "+e.toDisplayString(k.to_location.full_code),1)],64)):k.from_location?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createTextVNode(" ← "+e.toDisplayString(k.from_location.full_code),1)],64)):e.createCommentVNode("",!0)])]),e.createElementVNode("span",Et,e.toDisplayString(m(k.performed_at)),1)],8,Vt))),128))])):e.unref(h)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Ct," No recent activity "))]),_:1},8,["loading"]),e.createElementVNode("div",Bt,[e.createVNode(j,{title:"Unlocated Products",compact:"",class:"inv-dashboard__unlocated-widget"},{default:e.withCtx(()=>[c.value>0?(e.openBlock(),e.createElementBlock("div",$t,[e.createElementVNode("p",xt,[e.createElementVNode("strong",null,e.toDisplayString(c.value),1),g[5]||(g[5]=e.createTextVNode(" products have no assigned location ",-1))]),e.createVNode(T,{variant:"secondary",size:"sm",onClick:g[0]||(g[0]=k=>e.unref(n).push({name:"inventory-unlocated"}))},{default:e.withCtx(()=>[...g[6]||(g[6]=[e.createTextVNode(" View All ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",St," All products have assigned locations "))]),_:1}),e.createVNode(j,{title:"Active Counts",compact:"",class:"inv-dashboard__counts-widget"},{default:e.withCtx(()=>[e.unref(_).length>0?(e.openBlock(),e.createElementBlock("div",Lt,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(_),k=>(e.openBlock(),e.createElementBlock("div",{key:k.id,class:"inv-dashboard__count-row"},[e.createElementVNode("div",Dt,[e.createElementVNode("span",zt,e.toDisplayString(k.name),1),e.createElementVNode("div",{class:"inv-dashboard__count-progress",role:"progressbar","aria-valuenow":k.progress.percent_complete,"aria-valuemin":"0","aria-valuemax":"100"},[e.createElementVNode("div",Mt,[e.createElementVNode("div",{class:"inv-dashboard__count-progress-fill",style:e.normalizeStyle({width:`${k.progress.percent_complete}%`})},null,4)]),e.createElementVNode("span",Tt,e.toDisplayString(k.progress.percent_complete)+"% ",1)],8,It)]),e.createVNode(T,{variant:"secondary",size:"sm",onClick:E=>e.unref(n).push({name:"inventory-count-detail",params:{id:k.id}})},{default:e.withCtx(()=>[...g[7]||(g[7]=[e.createTextVNode(" Continue ",-1)])]),_:1},8,["onClick"])]))),128))])):(e.openBlock(),e.createElementBlock("p",Ft," No active count sessions "))]),_:1})])])}}}),At=H(Pt,[["__scopeId","data-v-e4d4cfb7"]]),Rt={class:"inv-empty-state",role:"status"},qt={class:"inv-empty-state__title"},Ut={key:0,class:"inv-empty-state__description"},Ht={key:1,class:"inv-empty-state__action"},jt=e.defineComponent({__name:"InvEmptyState",props:{title:{},description:{},actionLabel:{}},emits:["action"],setup(t,{emit:n}){const o=n;return(h,s)=>(e.openBlock(),e.createElementBlock("div",Rt,[s[1]||(s[1]=e.createStaticVNode('<svg class="inv-empty-state__icon" width="48" height="48" viewBox="0 0 48 48" fill="none" aria-hidden="true" data-v-c60a887a><rect x="6" y="10" width="36" height="28" rx="4" stroke="currentColor" stroke-width="2" fill="none" data-v-c60a887a></rect><path d="M6 18H42" stroke="currentColor" stroke-width="2" data-v-c60a887a></path><circle cx="12" cy="14" r="1.5" fill="currentColor" data-v-c60a887a></circle><circle cx="17" cy="14" r="1.5" fill="currentColor" data-v-c60a887a></circle><circle cx="22" cy="14" r="1.5" fill="currentColor" data-v-c60a887a></circle><path d="M18 28L22 24L26 28L30 22" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" opacity="0.4" data-v-c60a887a></path></svg>',1)),e.createElementVNode("h3",qt,e.toDisplayString(t.title),1),t.description?(e.openBlock(),e.createElementBlock("p",Ut,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),h.$slots.action||t.actionLabel?(e.openBlock(),e.createElementBlock("div",Ht,[e.renderSlot(h.$slots,"action",{},()=>[t.actionLabel?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"inv-empty-state__btn",onClick:s[0]||(s[0]=_=>o("action"))},e.toDisplayString(t.actionLabel),1)):e.createCommentVNode("",!0)],!0)])):e.createCommentVNode("",!0)]))}}),Y=H(jt,[["__scopeId","data-v-c60a887a"]]),Ee={site:{viewBox:"0 0 24 24",path:"M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7zm0 9.5a2.5 2.5 0 010-5 2.5 2.5 0 010 5z"},building:{viewBox:"0 0 24 24",path:"M4 2v20h16V2H4zm4 18H6v-2h2v2zm0-4H6v-2h2v2zm0-4H6V8h2v4zm0-6H6V4h2v2zm4 14h-2v-2h2v2zm0-4h-2v-2h2v2zm0-4h-2V8h2v4zm0-6h-2V4h2v2zm6 14h-4v-4h4v4zm0-6h-2v-2h2v2zm0-4h-2V8h2v4zm0-6h-2V4h2v2z"},container:{viewBox:"0 0 24 24",path:"M2 4v16h20V4H2zm18 14H4V6h16v12zM6 8h2v8H6V8zm4 0h2v8h-2V8zm4 0h2v8h-2V8z"},zone:{viewBox:"0 0 24 24",path:"M3 3v18h18V3H3zm16 16H5V5h14v14zM7 7h4v4H7V7zm6 0h4v4h-4V7zm-6 6h4v4H7v-4zm6 0h4v4h-4v-4z"},aisle:{viewBox:"0 0 24 24",path:"M7 2v20h2V2H7zm8 0v20h2V2h-2zM11 6h2v2h-2V6zm0 4h2v2h-2v-2zm0 4h2v2h-2v-2zm0 4h2v2h-2v-2z"},rack:{viewBox:"0 0 24 24",path:"M3 2v20h2v-7h14v7h2V2H3zm16 4H5V4h14v2zm0 5H5V9h14v2z"},shelf:{viewBox:"0 0 24 24",path:"M3 10h18v2H3v-2zm0-4h18v2H3V6zm2 8h4v6H5v-6zm6 0h4v6h-4v-6zm6 0h4v6h-4v-6z"},bin:{viewBox:"0 0 24 24",path:"M5 4v16h14V4H5zm12 14H7V8h10v10zm-8-8h2v2H9V10zm4 0h2v2h-2v-2z"},pallet:{viewBox:"0 0 24 24",path:"M2 18h2v2H2v-2zm4 0h2v2H6v-2zm4 0h2v2h-2v-2zm4 0h2v2h-2v-2zm4 0h2v2h-2v-2zM2 14h20v2H2v-2zm1-4h4v3H3v-3zm7 0h4v3h-4v-3zm7 0h4v3h-4v-3z"}};function Ot(t){return Ee[t]||Ee.building}const Kt=["width","height","viewBox"],Qt=["d"],Gt=e.defineComponent({__name:"LocationTypeIcon",props:{type:{},size:{default:"md"}},setup(t){const n=t,o={sm:16,md:20,lg:24},h=e.computed(()=>Ot(n.type));return(s,_)=>(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["location-type-icon",[`location-type-icon--${t.size}`]]),width:o[t.size],height:o[t.size],viewBox:h.value.viewBox,fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:h.value.path,fill:"currentColor"},null,8,Qt)],10,Kt))}}),re=H(Gt,[["__scopeId","data-v-e96e218e"]]),Wt={class:"location-search__input-wrapper"},Zt=["value","placeholder","aria-expanded","aria-activedescendant"],Jt={key:1,class:"location-search__spinner","aria-hidden":"true"},Xt=["aria-label"],Yt={key:0,class:"location-search__dropdown-item location-search__dropdown-item--loading",role:"presentation"},eo={key:1,class:"location-search__dropdown-item location-search__dropdown-item--empty",role:"presentation"},to=["id","aria-selected","onMousedown","onMouseenter"],oo={class:"location-search__result-info"},no={class:"location-search__result-name"},ao={class:"location-search__result-code"},lo=e.defineComponent({__name:"LocationSearchInput",props:{modelValue:{},placeholder:{default:"Search locations..."},autofocus:{type:Boolean,default:!1}},emits:["update:modelValue","select"],setup(t,{emit:n}){const o=t,h=n,_=`location-search-listbox-${e.useId()}`,y=e.ref(null),i=e.ref(null),l=e.ref(-1),c=e.ref(!1),a=ie(),r=e.computed(()=>!c.value||o.modelValue.length<2?!1:a.loading.value?!0:a.results.value.length>0||o.modelValue.length>=2),d=e.computed(()=>{if(!(l.value<0))return`${_}-option-${l.value}`});e.watch(()=>o.modelValue,g=>{l.value=-1,a.search(g)});function p(g){const b=g.target;h("update:modelValue",b.value)}function v(){c.value=!0,o.modelValue.length>=2&&a.search(o.modelValue)}function u(){setTimeout(()=>{c.value=!1,l.value=-1},150)}function m(){var g;h("update:modelValue",""),a.clear(),l.value=-1,(g=y.value)==null||g.focus()}function f(g){h("select",g),h("update:modelValue",""),a.clear(),l.value=-1,c.value=!1}function w(g){const b=a.results.value;if(!r.value||b.length===0){g.key==="Escape"&&m();return}switch(g.key){case"ArrowDown":g.preventDefault(),l.value=Math.min(l.value+1,b.length-1),V();break;case"ArrowUp":g.preventDefault(),l.value=Math.max(l.value-1,0),V();break;case"Enter":g.preventDefault(),l.value>=0&&l.value<b.length&&f(b[l.value]);break;case"Escape":g.preventDefault(),c.value=!1,l.value=-1;break}}function V(){if(!i.value||l.value<0)return;const b=i.value.querySelectorAll('[role="option"]')[l.value];b&&b.scrollIntoView({block:"nearest"})}return e.onMounted(()=>{o.autofocus&&y.value&&y.value.focus()}),(g,b)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["location-search",{"location-search--open":r.value}])},[e.createElementVNode("div",Wt,[b[2]||(b[2]=e.createElementVNode("svg",{class:"location-search__icon",width:"18",height:"18",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M21 21L16.65 16.65M19 11C19 15.4183 15.4183 19 11 19C6.58172 19 3 15.4183 3 11C3 6.58172 6.58172 3 11 3C15.4183 3 19 6.58172 19 11Z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),e.createElementVNode("input",{ref_key:"inputRef",ref:y,type:"search",class:"location-search__input",value:t.modelValue,placeholder:t.placeholder,role:"combobox","aria-autocomplete":"list","aria-expanded":r.value,"aria-controls":_,"aria-activedescendant":d.value,onInput:p,onKeydown:w,onFocus:v,onBlur:u},null,40,Zt),t.modelValue?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"location-search__clear","aria-label":"Clear search",onMousedown:e.withModifiers(m,["prevent"])},[...b[0]||(b[0]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],32)):e.createCommentVNode("",!0),e.unref(a).loading.value?(e.openBlock(),e.createElementBlock("span",Jt,[...b[1]||(b[1]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none"},[e.createElementVNode("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor","stroke-width":"2",opacity:"0.25"}),e.createElementVNode("path",{d:"M14 8A6 6 0 0 0 8 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])])):e.createCommentVNode("",!0)]),e.createVNode(e.Transition,{name:"location-search-dropdown"},{default:e.withCtx(()=>[r.value?(e.openBlock(),e.createElementBlock("ul",{key:0,id:_,ref_key:"listboxRef",ref:i,class:"location-search__dropdown",role:"listbox","aria-label":t.placeholder},[e.unref(a).loading.value&&e.unref(a).results.value.length===0?(e.openBlock(),e.createElementBlock("li",Yt,[...b[3]||(b[3]=[e.createElementVNode("span",null,"Searching...",-1)])])):!e.unref(a).loading.value&&e.unref(a).results.value.length===0&&t.modelValue.length>=2?(e.openBlock(),e.createElementBlock("li",eo,[...b[4]||(b[4]=[e.createElementVNode("span",null,"No locations found",-1)])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(a).results.value,(x,$)=>(e.openBlock(),e.createElementBlock("li",{id:`${_}-option-${$}`,key:x.id,class:e.normalizeClass(["location-search__dropdown-item",{"location-search__dropdown-item--active":$===l.value}]),role:"option","aria-selected":$===l.value,onMousedown:e.withModifiers(F=>f(x),["prevent"]),onMouseenter:F=>l.value=$},[e.createVNode(re,{type:x.type,size:"sm"},null,8,["type"]),e.createElementVNode("div",oo,[e.createElementVNode("span",no,e.toDisplayString(x.name),1),e.createElementVNode("span",ao,e.toDisplayString(x.full_code),1)])],42,to))),128))],8,Xt)):e.createCommentVNode("",!0)]),_:1})],2))}}),De=H(lo,[["__scopeId","data-v-6191a2a0"]]);function so(t,n=2,o="-"){const h=t.split(o);return h.length<=n?t:"…"+h.slice(-n).join(o)}function Ce(t){return Number.isInteger(t)?String(t):t.toFixed(2).replace(/\.?0+$/,"")}function ro(t){const n=new Date(t),h=Math.floor((new Date().getTime()-n.getTime())/1e3);if(h<60)return"just now";const s=Math.floor(h/60);if(s<60)return`${s}m ago`;const _=Math.floor(s/60);if(_<24)return`${_}h ago`;const y=Math.floor(_/24);return y<7?`${y}d ago`:n.toLocaleDateString()}const io=["title"],co=e.defineComponent({__name:"LocationCodeBadge",props:{code:{},truncate:{type:Boolean,default:!1},maxSegments:{default:2}},setup(t){const n=t,o=e.computed(()=>n.truncate?so(n.code,n.maxSegments):n.code);return(h,s)=>(e.openBlock(),e.createElementBlock("span",{class:"location-code-badge",title:t.code},e.toDisplayString(o.value),9,io))}}),J=H(co,[["__scopeId","data-v-62592fe1"]]),uo=["data-testid"],mo=["aria-expanded","aria-selected","aria-level"],po=["aria-label"],vo={key:0,class:"tree-node__spinner",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},_o={key:1,class:"tree-node__toggle-spacer","aria-hidden":"true"},ho={class:"tree-node__name"},fo=["aria-label"],yo={key:0,role:"group"},ko=e.defineComponent({__name:"LocationTreeNode",props:{location:{},depth:{default:0},selectedId:{default:null}},emits:["select","toggle"],setup(t,{emit:n}){const o=t,h=n,s=le(),{fetchChildren:_}=ee(),y=e.ref(!1),i=e.ref(o.location.children||[]),l=e.computed(()=>!!(o.location.children&&o.location.children.length>0||o.location.children_count&&o.location.children_count>0)),c=e.computed(()=>s.isExpanded(o.location.id));e.watch(c,async p=>{if(p&&i.value.length===0&&l.value){y.value=!0;try{i.value=await _(o.location.id)}catch{}finally{y.value=!1}}}),e.watch(()=>o.location.children,p=>{p&&p.length>0&&(i.value=p)});function a(){h("select",o.location)}function r(){s.toggleExpand(o.location.id),h("toggle",o.location.id)}function d(p){switch(p.key){case"Enter":case" ":p.preventDefault(),a();break;case"ArrowRight":p.preventDefault(),l.value&&!c.value&&r();break;case"ArrowLeft":p.preventDefault(),c.value&&r();break}}return(p,v)=>{const u=e.resolveComponent("LocationTreeNode",!0);return e.openBlock(),e.createElementBlock("div",{class:"tree-node","data-testid":`tree-node-${t.location.full_code}`},[e.createElementVNode("div",{class:e.normalizeClass(["tree-node__row",{"tree-node__row--selected":t.selectedId===t.location.id}]),style:e.normalizeStyle({paddingLeft:`${t.depth*20}px`}),role:"treeitem","aria-expanded":l.value?c.value:void 0,"aria-selected":t.selectedId===t.location.id,"aria-level":t.depth+1,tabindex:"0",onClick:a,onKeydown:d},[l.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"tree-node__toggle","aria-label":c.value?`Collapse ${t.location.name}`:`Expand ${t.location.name}`,tabindex:"-1",onClick:e.withModifiers(r,["stop"])},[y.value?(e.openBlock(),e.createElementBlock("svg",vo,[...v[2]||(v[2]=[e.createElementVNode("circle",{cx:"8",cy:"8",r:"6",stroke:"currentColor","stroke-width":"2",opacity:"0.25"},null,-1),e.createElementVNode("path",{d:"M14 8A6 6 0 0 0 8 2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"},null,-1)])])):(e.openBlock(),e.createElementBlock("svg",{key:1,class:e.normalizeClass(["tree-node__chevron",{"tree-node__chevron--expanded":c.value}]),width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[...v[3]||(v[3]=[e.createElementVNode("path",{d:"M6 4L10 8L6 12",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))],8,po)):(e.openBlock(),e.createElementBlock("span",_o)),e.createVNode(re,{type:t.location.type,size:"sm"},null,8,["type"]),e.createElementVNode("span",ho,e.toDisplayString(t.location.name),1),e.createVNode(J,{code:t.location.full_code,truncate:"","max-segments":2},null,8,["code"]),t.location.product_count!=null&&t.location.product_count>0?(e.openBlock(),e.createElementBlock("span",{key:2,class:"tree-node__count","aria-label":`${t.location.product_count} products`},e.toDisplayString(t.location.product_count),9,fo)):e.createCommentVNode("",!0)],46,mo),c.value&&i.value.length>0?(e.openBlock(),e.createElementBlock("div",yo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,m=>(e.openBlock(),e.createBlock(u,{key:m.id,location:m,depth:t.depth+1,"selected-id":t.selectedId,onSelect:v[0]||(v[0]=f=>h("select",f)),onToggle:v[1]||(v[1]=f=>h("toggle",f))},null,8,["location","depth","selected-id"]))),128))])):e.createCommentVNode("",!0)],8,uo)}}}),go=H(ko,[["__scopeId","data-v-b2045bb5"]]),Vo={class:"location-tree",role:"tree","aria-label":"Location hierarchy"},bo={key:0,class:"location-tree__loading","aria-live":"polite"},No={key:2},wo=e.defineComponent({__name:"LocationTree",emits:["select","create"],setup(t,{emit:n}){const o=n,h=le(),{fetchRoots:s}=ee(),_=e.ref(!1);async function y(){if(!(h.roots.length>0)){_.value=!0;try{await s()}catch{}finally{_.value=!1}}}function i(c){h.selectLocation(c.id),o("select",c)}function l(c){}return e.onMounted(()=>{y()}),(c,a)=>(e.openBlock(),e.createElementBlock("div",Vo,[_.value?(e.openBlock(),e.createElementBlock("div",bo,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(5,r=>e.createElementVNode("div",{key:r,class:"location-tree__skeleton-row",style:e.normalizeStyle({paddingLeft:`${r%3*20}px`})},[...a[1]||(a[1]=[e.createElementVNode("div",{class:"location-tree__skeleton-bar location-tree__skeleton-bar--icon"},null,-1),e.createElementVNode("div",{class:"location-tree__skeleton-bar location-tree__skeleton-bar--name"},null,-1),e.createElementVNode("div",{class:"location-tree__skeleton-bar location-tree__skeleton-bar--code"},null,-1)])],4)),64)),a[2]||(a[2]=e.createElementVNode("span",{class:"sr-only"},"Loading locations...",-1))])):e.unref(h).roots.length===0?(e.openBlock(),e.createBlock(Y,{key:1,title:"No locations yet",description:"Create your first warehouse or storage location to start organizing inventory.","action-label":"Create Location",onAction:a[0]||(a[0]=r=>o("create"))})):(e.openBlock(),e.createElementBlock("div",No,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(h).roots,r=>(e.openBlock(),e.createBlock(go,{key:r.id,location:r,depth:0,"selected-id":e.unref(h).selectedLocationId,onSelect:i,onToggle:l},null,8,["location","selected-id"]))),128))]))]))}}),ze=H(wo,[["__scopeId","data-v-e21f92ca"]]),Eo={class:"inv-table-wrapper"},Co=["aria-busy"],Bo={class:"inv-table__head"},$o=["aria-sort"],xo=["onClick"],So={class:"inv-table__sort-icon",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"},Lo={key:0,d:"M7 3L11 8H3L7 3Z",fill:"currentColor"},Do={key:1,d:"M7 11L3 6H11L7 11Z",fill:"currentColor"},zo={key:1},Io={class:"inv-table__body"},Mo={key:1},To=["colspan"],Fo={class:"inv-table__empty-text"},Po=["tabindex","role","onClick","onKeydown"],Ao=e.defineComponent({__name:"InvTable",props:{columns:{},data:{},loading:{type:Boolean,default:!1},sortKey:{},sortDir:{},emptyMessage:{default:"No data to display."},clickable:{type:Boolean,default:!1}},emits:["sort","row-click"],setup(t,{emit:n}){const o=t,h=n;function s(y){if(y.sortable)return o.sortKey!==y.key?"none":o.sortDir==="asc"?"ascending":"descending"}function _(y){if(!y.sortable)return;let i;o.sortKey===y.key?i=o.sortDir==="asc"?"desc":"asc":i="asc",h("sort",{key:y.key,direction:i})}return(y,i)=>(e.openBlock(),e.createElementBlock("div",Eo,[e.createElementVNode("table",{class:"inv-table",role:"grid","aria-busy":t.loading},[e.createElementVNode("thead",Bo,[e.createElementVNode("tr",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,l=>(e.openBlock(),e.createElementBlock("th",{key:l.key,class:e.normalizeClass(["inv-table__th",[`inv-table__th--${l.align||"left"}`,{"inv-table__th--sortable":l.sortable}]]),style:e.normalizeStyle(l.width?{width:l.width}:void 0),"aria-sort":s(l),scope:"col"},[l.sortable?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["inv-table__sort-btn",{"inv-table__sort-btn--active":t.sortKey===l.key}]),onClick:c=>_(l)},[e.createElementVNode("span",null,e.toDisplayString(l.label),1),(e.openBlock(),e.createElementBlock("svg",So,[t.sortKey===l.key&&t.sortDir==="asc"?(e.openBlock(),e.createElementBlock("path",Lo)):t.sortKey===l.key&&t.sortDir==="desc"?(e.openBlock(),e.createElementBlock("path",Do)):(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[i[0]||(i[0]=e.createElementVNode("path",{d:"M7 3L10 7H4L7 3Z",fill:"currentColor",opacity:"0.3"},null,-1)),i[1]||(i[1]=e.createElementVNode("path",{d:"M7 11L4 7H10L7 11Z",fill:"currentColor",opacity:"0.3"},null,-1))],64))]))],10,xo)):(e.openBlock(),e.createElementBlock("span",zo,e.toDisplayString(l.label),1))],14,$o))),128))])]),e.createElementVNode("tbody",Io,[t.loading?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},e.renderList(5,l=>e.createElementVNode("tr",{key:`skeleton-${l}`,class:"inv-table__row inv-table__row--skeleton"},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,c=>(e.openBlock(),e.createElementBlock("td",{key:`skeleton-${l}-${c.key}`,class:"inv-table__td"},[...i[2]||(i[2]=[e.createElementVNode("div",{class:"inv-table__skeleton-bar"},null,-1)])]))),128))])),64)):t.data.length===0?(e.openBlock(),e.createElementBlock("tr",Mo,[e.createElementVNode("td",{colspan:t.columns.length,class:"inv-table__td inv-table__td--empty"},[e.renderSlot(y.$slots,"empty",{},()=>[e.createElementVNode("span",Fo,e.toDisplayString(t.emptyMessage),1)],!0)],8,To)])):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:2},e.renderList(t.data,(l,c)=>(e.openBlock(),e.createElementBlock("tr",{key:c,class:e.normalizeClass(["inv-table__row",{"inv-table__row--clickable":t.clickable}]),tabindex:t.clickable?0:void 0,role:t.clickable?"button":void 0,onClick:a=>t.clickable?h("row-click",l):void 0,onKeydown:[e.withKeys(a=>t.clickable?h("row-click",l):void 0,["enter"]),e.withKeys(e.withModifiers(a=>t.clickable?h("row-click",l):void 0,["prevent"]),["space"])]},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,a=>(e.openBlock(),e.createElementBlock("td",{key:a.key,class:e.normalizeClass(["inv-table__td",[`inv-table__td--${a.align||"left"}`]])},[e.renderSlot(y.$slots,`cell-${a.key}`,{row:l,value:l[a.key]},()=>[e.createTextVNode(e.toDisplayString(l[a.key]??""),1)],!0)],2))),128))],42,Po))),128))])],8,Co)]))}}),ne=H(Ao,[["__scopeId","data-v-59a6e64b"]]),Ro=e.defineComponent({__name:"InvBadge",props:{variant:{default:"default"},size:{default:"sm"}},setup(t){return(n,o)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(["inv-badge",[`inv-badge--${t.variant}`,`inv-badge--${t.size}`]])},[e.renderSlot(n.$slots,"default",{},void 0,!0)],2))}}),Z=H(Ro,[["__scopeId","data-v-f0803bf2"]]),qo=["aria-describedby"],Uo={class:"inv-modal__header"},Ho={class:"inv-modal__body"},jo={key:0,class:"inv-modal__footer"},Oo=e.defineComponent({__name:"InvModal",props:{show:{type:Boolean},title:{},description:{},size:{default:"md"},initialFocusSelector:{}},emits:["update:show","close"],setup(t,{emit:n}){const o=t,h=n,s=e.useId(),_=`inv-modal-title-${s}`,y=`inv-modal-desc-${s}`,i=e.ref(null);let l=null;function c(){if(!i.value)return[];const v=["a[href]","button:not([disabled])","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'];return Array.from(i.value.querySelectorAll(v.join(",")))}function a(v){const u=c();if(u.length===0)return;const m=u[0],f=u[u.length-1];v.shiftKey?document.activeElement===m&&(v.preventDefault(),f.focus()):document.activeElement===f&&(v.preventDefault(),m.focus())}function r(v){v.key==="Escape"?(v.stopPropagation(),d()):v.key==="Tab"&&a(v)}function d(){h("update:show",!1),h("close")}function p(){d()}return e.watch(()=>o.show,async v=>{var u;if(v){if(l=document.activeElement,document.body.style.overflow="hidden",await e.nextTick(),await e.nextTick(),o.initialFocusSelector&&i.value){const f=i.value.querySelector(o.initialFocusSelector);if(f){f.focus();return}}const m=c();m.length>0?m[0].focus():(u=i.value)==null||u.focus()}else document.body.style.overflow="",l&&(l.focus(),l=null)}),e.onBeforeUnmount(()=>{document.body.style.overflow=""}),(v,u)=>(e.openBlock(),e.createBlock(e.Teleport,{to:"body"},[e.createVNode(e.Transition,{name:"inv-modal"},{default:e.withCtx(()=>[t.show?(e.openBlock(),e.createElementBlock("div",{key:0,class:"inv-modal__backdrop",onMousedown:e.withModifiers(p,["self"])},[e.createElementVNode("div",{ref_key:"dialogRef",ref:i,class:e.normalizeClass(["inv-modal__dialog",[`inv-modal__dialog--${t.size}`]]),role:"dialog","aria-modal":"true","aria-labelledby":_,"aria-describedby":t.description?y:void 0,onKeydown:r},[e.createElementVNode("div",Uo,[e.createElementVNode("div",null,[e.createElementVNode("h2",{id:_,class:"inv-modal__title"},e.toDisplayString(t.title),1),t.description?(e.openBlock(),e.createElementBlock("p",{key:0,id:y,class:"inv-modal__description"},e.toDisplayString(t.description),1)):e.createCommentVNode("",!0)]),e.createElementVNode("button",{type:"button",class:"inv-modal__close","aria-label":"Close dialog",onClick:d},[...u[0]||(u[0]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M15 5L5 15M5 5L15 15",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])])]),e.createElementVNode("div",Ho,[e.renderSlot(v.$slots,"default",{},void 0,!0)]),v.$slots.footer?(e.openBlock(),e.createElementBlock("div",jo,[e.renderSlot(v.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],42,qo)],32)):e.createCommentVNode("",!0)]),_:3})]))}}),he=H(Oo,[["__scopeId","data-v-7484015c"]]),Ko={class:"location-breadcrumb","aria-label":"Location path"},Qo={class:"location-breadcrumb__list"},Go={key:0,class:"location-breadcrumb__separator","aria-hidden":"true"},Wo=["aria-label","onClick"],Zo={key:2,class:"location-breadcrumb__current","aria-current":"location"},Be=3,Jo=e.defineComponent({__name:"LocationBreadcrumb",props:{path:{}},emits:["navigate"],setup(t,{emit:n}){const o=t,h=n,s=e.computed(()=>o.path.length>Be),_=e.computed(()=>s.value?o.path.slice(-Be):o.path);function y(i){return i===_.value.length-1}return(i,l)=>(e.openBlock(),e.createElementBlock("nav",Ko,[e.createElementVNode("ol",Qo,[s.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[l[0]||(l[0]=e.createElementVNode("li",{class:"location-breadcrumb__item location-breadcrumb__item--ellipsis"},[e.createElementVNode("span",{class:"location-breadcrumb__ellipsis","aria-hidden":"true"},"…")],-1)),l[1]||(l[1]=e.createElementVNode("li",{class:"location-breadcrumb__item","aria-hidden":"true"},[e.createElementVNode("span",{class:"location-breadcrumb__separator"},"›")],-1))],64)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(_.value,(c,a)=>(e.openBlock(),e.createElementBlock("li",{key:c.id,class:"location-breadcrumb__item"},[a>0||s.value?(e.openBlock(),e.createElementBlock("span",Go,"›")):e.createCommentVNode("",!0),y(a)?(e.openBlock(),e.createElementBlock("span",Zo,e.toDisplayString(c.name),1)):(e.openBlock(),e.createElementBlock("button",{key:1,type:"button",class:"location-breadcrumb__link","aria-label":`Navigate to ${c.name}`,onClick:r=>h("navigate",c)},e.toDisplayString(c.name),9,Wo))]))),128))])]))}}),fe=H(Jo,[["__scopeId","data-v-911e6f70"]]),Xo=["type","value","placeholder","disabled","aria-invalid","aria-describedby"],Yo=e.defineComponent({__name:"InvInput",props:{modelValue:{},label:{},placeholder:{},type:{default:"text"},error:{},disabled:{type:Boolean,default:!1},autofocus:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,h=n,s=e.useId(),_=`inv-input-${s}`,y=`inv-input-error-${s}`,i=e.ref(null);function l(c){const a=c.target;o.type==="number"?h("update:modelValue",a.valueAsNumber):h("update:modelValue",a.value)}return e.onMounted(()=>{o.autofocus&&i.value&&i.value.focus()}),(c,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["inv-input",{"inv-input--error":!!t.error,"inv-input--disabled":t.disabled}])},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:_,class:"inv-input__label"},e.toDisplayString(t.label),1)):e.createCommentVNode("",!0),e.createElementVNode("input",{id:_,ref_key:"inputRef",ref:i,class:"inv-input__field",type:t.type,value:t.modelValue,placeholder:t.placeholder,disabled:t.disabled,"aria-invalid":!!t.error||void 0,"aria-describedby":t.error?y:void 0,onInput:l},null,40,Xo),t.error?(e.openBlock(),e.createElementBlock("p",{key:1,id:y,class:"inv-input__error",role:"alert"},e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)],2))}}),me=H(Yo,[["__scopeId","data-v-b681751f"]]),en={class:"inv-select__wrapper"},tn=["value","disabled","aria-invalid","aria-describedby"],on={key:0,value:"",disabled:""},nn=["value"],an=e.defineComponent({__name:"InvSelect",props:{modelValue:{},options:{},label:{},placeholder:{},error:{},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:n}){const o=t,h=n,s=e.useId(),_=`inv-select-${s}`,y=`inv-select-error-${s}`;function i(l){const c=l.target,a=o.options.find(r=>String(r.value)===c.value);a?h("update:modelValue",a.value):h("update:modelValue",c.value)}return(l,c)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["inv-select",{"inv-select--error":!!t.error,"inv-select--disabled":t.disabled}])},[t.label?(e.openBlock(),e.createElementBlock("label",{key:0,for:_,class:"inv-select__label"},e.toDisplayString(t.label),1)):e.createCommentVNode("",!0),e.createElementVNode("div",en,[e.createElementVNode("select",{id:_,class:"inv-select__field",value:t.modelValue,disabled:t.disabled,"aria-invalid":!!t.error||void 0,"aria-describedby":t.error?y:void 0,onChange:i},[t.placeholder?(e.openBlock(),e.createElementBlock("option",on,e.toDisplayString(t.placeholder),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,a=>(e.openBlock(),e.createElementBlock("option",{key:a.value,value:a.value},e.toDisplayString(a.label),9,nn))),128))],40,tn),c[0]||(c[0]=e.createElementVNode("svg",{class:"inv-select__chevron",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1))]),t.error?(e.openBlock(),e.createElementBlock("p",{key:1,id:y,class:"inv-select__error",role:"alert"},e.toDisplayString(t.error),1)):e.createCommentVNode("",!0)],2))}}),oe=H(an,[["__scopeId","data-v-40ea769b"]]),ln={class:"location-form__field"},sn={key:0,class:"location-form__code-preview"},rn={class:"location-form__field"},cn=e.defineComponent({__name:"LocationForm",props:{show:{type:Boolean},location:{default:null},parentId:{default:null}},emits:["update:show","saved"],setup(t,{emit:n}){const o=t,h=n,_=`location-form-desc-${e.useId()}`,{create:y,update:i,fetchTypes:l}=ee(),c=e.ref(!1),a=e.ref([]),r=e.reactive({name:"",type:"",code:"",description:"",sort_order:0}),d=e.reactive({name:"",type:"",code:""}),p=e.computed(()=>!!o.location),v=e.computed(()=>{var k,E;if((k=o.location)!=null&&k.full_code&&((E=o.location)!=null&&E.code)){const N=o.location.full_code,D=o.location.code;if(N.endsWith(D))return N.slice(0,N.length-D.length).replace(/-$/,"")}return null}),u=e.computed(()=>{const k=r.code.trim();return k?v.value?`${v.value}-${k}`:k:""}),m=e.computed(()=>a.value.map(k=>({value:k.value,label:k.label}))),f=/^[a-zA-Z0-9-]*$/;function w(k){const E=String(k);f.test(E)?d.code="":d.code="Only letters, numbers, and hyphens allowed"}function V(k){d[k]=""}function g(){let k=!0;return r.name.trim()?r.name.trim().length>255&&(d.name="Name must be 255 characters or less",k=!1):(d.name="Name is required",k=!1),!p.value&&!r.type&&(d.type="Type is required",k=!1),r.code&&!f.test(r.code)&&(d.code="Only letters, numbers, and hyphens allowed",k=!1),k}async function b(){var k,E;if(g()){c.value=!0;try{let N;if(p.value&&o.location){const D={name:r.name.trim(),description:r.description.trim()||void 0,sort_order:r.sort_order};r.code.trim()&&(D.code=r.code.trim()),N=await i(o.location.id,D)}else{const D={name:r.name.trim(),type:r.type,code:r.code.trim()||void 0,description:r.description.trim()||void 0,parent_id:o.parentId,sort_order:r.sort_order};N=await y(D)}h("saved",N),h("update:show",!1),$()}catch(N){if((E=(k=N.response)==null?void 0:k.data)!=null&&E.errors){const D=N.response.data.errors;D.name&&(d.name=D.name[0]),D.type&&(d.type=D.type[0]),D.code&&(d.code=D.code[0])}}finally{c.value=!1}}}function x(){h("update:show",!1),$()}function $(){r.name="",r.type="",r.code="",r.description="",r.sort_order=0,d.name="",d.type="",d.code=""}function F(k){r.name=k.name,r.type=k.type,r.code=k.code,r.description=k.description||"",r.sort_order=k.sort_order}return e.watch(()=>o.show,async k=>{if(k){if(a.value.length===0)try{a.value=await l()}catch{}o.location?F(o.location):$()}}),(k,E)=>(e.openBlock(),e.createBlock(he,{show:t.show,title:p.value?"Edit Location":"Create Location",description:p.value?"Update this location's details.":"Add a new location to your inventory hierarchy.",size:"md","initial-focus-selector":"input[data-field='name']","onUpdate:show":E[7]||(E[7]=N=>h("update:show",N)),onClose:x},{footer:e.withCtx(()=>[e.createVNode(T,{variant:"secondary",onClick:x},{default:e.withCtx(()=>[...E[9]||(E[9]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(T,{variant:"primary",loading:c.value,disabled:c.value,onClick:b},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(p.value?"Save Changes":"Create Location"),1)]),_:1},8,["loading","disabled"])]),default:e.withCtx(()=>[e.createElementVNode("form",{class:"location-form",onSubmit:e.withModifiers(b,["prevent"])},[e.createVNode(me,{modelValue:r.name,"onUpdate:modelValue":[E[0]||(E[0]=N=>r.name=N),E[1]||(E[1]=N=>V("name"))],label:"Name",placeholder:"e.g. Warehouse 1, Rack A, Shelf 01",error:d.name,"data-field":"name"},null,8,["modelValue","error"]),e.createVNode(oe,{modelValue:r.type,"onUpdate:modelValue":[E[2]||(E[2]=N=>r.type=N),E[3]||(E[3]=N=>V("type"))],label:"Type",placeholder:"Select location type...",options:m.value,error:d.type,disabled:p.value},null,8,["modelValue","options","error","disabled"]),e.createElementVNode("div",ln,[e.createVNode(me,{modelValue:r.code,"onUpdate:modelValue":[E[4]||(E[4]=N=>r.code=N),w],label:"Code (optional)",placeholder:"Auto-generated if blank",error:d.code},null,8,["modelValue","error"]),u.value?(e.openBlock(),e.createElementBlock("p",sn,[E[8]||(E[8]=e.createTextVNode(" Full code: ",-1)),e.createElementVNode("code",null,e.toDisplayString(u.value),1)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",rn,[e.createElementVNode("label",{for:_,class:"location-form__label"}," Description "),e.withDirectives(e.createElementVNode("textarea",{id:_,"onUpdate:modelValue":E[5]||(E[5]=N=>r.description=N),class:"location-form__textarea",placeholder:"Optional notes about this location...",rows:"3"},null,512),[[e.vModelText,r.description]])]),e.createVNode(me,{modelValue:r.sort_order,"onUpdate:modelValue":E[6]||(E[6]=N=>r.sort_order=N),label:"Sort order",type:"number",placeholder:"0"},null,8,["modelValue"])],32)]),_:1},8,["show","title","description"]))}}),be=H(cn,[["__scopeId","data-v-7b871a38"]]),dn={class:"location-detail"},un={key:0,class:"location-detail__loading","aria-live":"polite"},mn={class:"location-detail__header"},pn={class:"location-detail__title-row"},vn={class:"location-detail__title-area"},_n={class:"location-detail__name"},hn={class:"location-detail__actions"},fn={class:"location-detail__info-grid"},yn={key:0,class:"location-detail__info-item"},kn={class:"location-detail__info-value"},gn={class:"location-detail__info-item"},Vn={class:"location-detail__info-value"},bn={class:"location-detail__info-item"},Nn={class:"location-detail__info-value"},wn={key:1,class:"location-detail__info-item"},En={class:"location-detail__child-cell"},Cn={class:"location-detail__count"},Bn={class:"location-detail__product-count-label"},$n={key:0,class:"location-detail__loading-inline"},xn={key:1,class:"location-detail__empty-inline"},Sn={class:"location-detail__product-cell"},Ln={class:"location-detail__product-name"},Dn={key:0,class:"location-detail__product-sku"},zn={key:0,class:"location-detail__loading-inline"},In={key:1,class:"location-detail__empty-inline"},Mn={key:2,class:"location-detail__movements-list"},Tn={width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Fn={key:0,d:"M12 5v14M5 12l7 7 7-7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Pn={key:1,d:"M12 19V5M5 12l7-7 7 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},An={key:2,d:"M5 12h14M12 5l7 7-7 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Rn={key:3,d:"M4 4l16 16M20 4L4 20",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.6"},qn={class:"location-detail__movement-info"},Un={class:"location-detail__movement-primary"},Hn={class:"location-detail__movement-qty"},jn={class:"location-detail__movement-meta"},On={key:0,class:"location-detail__label-preview"},Kn=["innerHTML"],Qn={class:"location-detail__label-info"},Gn={class:"location-detail__label-code"},Wn={class:"location-detail__label-path"},Zn={key:1,class:"location-detail__empty-inline"},Jn={class:"location-detail__delete-warning"},Xn=e.defineComponent({__name:"LocationDetail",props:{locationCode:{default:void 0},locationId:{default:void 0}},emits:["navigate","deleted"],setup(t,{emit:n}){const o=t,h=n,s=le(),{fetchLocation:_,fetchChildren:y,remove:i}=ee(),{fetchProducts:l}=te(),{fetchByLocation:c}=pe(),{fetchLabel:a,printLabel:r}=_e(),d=e.ref(null),p=e.ref(!1),v=e.ref(null),u=e.ref([]),m=e.ref(!1),f=e.ref([]),w=e.ref(!1),V=e.ref([]),g=e.ref(!1),b=e.ref(null),x=e.ref(!1),$=e.ref(!1),F=e.ref(!1),k=e.ref(!1),E=e.ref(!1),N=[{key:"name",label:"Name"},{key:"type_label",label:"Type",width:"100px"},{key:"full_code",label:"Code",width:"140px"},{key:"product_count",label:"Products",width:"90px",align:"right"}],D=[{key:"product_name",label:"Product"},{key:"quantity",label:"Qty",width:"80px",align:"right"},{key:"is_primary",label:"Primary",width:"90px",align:"center"}];function S(K){return new Date(K).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}async function C(){var K,B;if(!(!o.locationId&&!o.locationCode)){p.value=!0,v.value=null;try{let W;if(o.locationId)W=await _(o.locationId);else if(o.locationCode){const M=L(o.locationCode);if(M)W=await _(M.id);else{v.value="Location not found";return}}else return;d.value=W,s.selectLocation(W.id),await Promise.allSettled([G(W.id),P(W.id),z(W.id)])}catch(W){v.value=((B=(K=W.response)==null?void 0:K.data)==null?void 0:B.message)||"Failed to load location"}finally{p.value=!1}}}function L(K){const B=W=>{for(const M of W){if(M.full_code===K)return M;if(M.children){const de=B(M.children);if(de)return de}}return null};return B(s.roots)}async function G(K){m.value=!0;try{u.value=await y(K)}catch{u.value=[]}finally{m.value=!1}}async function P(K){w.value=!0;try{const{fetchProducts:B}=te();await B(K);const W=te();await W.fetchProducts(K),f.value=W.products.value}catch{f.value=[]}finally{w.value=!1}}async function z(K){g.value=!0;try{const B=pe();await B.fetchByLocation(K),V.value=B.movements.value.slice(0,10)}catch{V.value=[]}finally{g.value=!1}}async function I(){if(d.value){x.value=!0;try{const K=await a(d.value.id);b.value=K}catch{}finally{x.value=!1}}}function O(K){const B=s.findInTree(K.id);B&&h("navigate",B)}function X(K){h("navigate",K)}async function ce(){if(d.value)try{await r(d.value.id)}catch{}}function ye(){k.value=!0}async function ke(){if(d.value){E.value=!0;try{await i(d.value.id),k.value=!1,h("deleted")}catch{}finally{E.value=!1}}}function ge(K){d.value=K,$.value=!1}async function Ve(K){F.value=!1,d.value&&await G(d.value.id)}return e.watch(()=>[o.locationId,o.locationCode],()=>{b.value=null,C()}),e.onMounted(()=>{C()}),(K,B)=>{var W;return e.openBlock(),e.createElementBlock("div",dn,[p.value?(e.openBlock(),e.createElementBlock("div",un,[...B[6]||(B[6]=[e.createStaticVNode('<div class="location-detail__loading-header" data-v-388046b7><div class="location-detail__skeleton location-detail__skeleton--breadcrumb" data-v-388046b7></div><div class="location-detail__skeleton location-detail__skeleton--title" data-v-388046b7></div><div class="location-detail__skeleton location-detail__skeleton--badges" data-v-388046b7></div></div><div class="location-detail__skeleton location-detail__skeleton--card" data-v-388046b7></div><div class="location-detail__skeleton location-detail__skeleton--card" data-v-388046b7></div><span class="sr-only" data-v-388046b7>Loading location details...</span>',4)])])):v.value?(e.openBlock(),e.createBlock(Y,{key:1,title:"Failed to load location",description:v.value,"action-label":"Retry",onAction:C},null,8,["description"])):d.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("header",mn,[d.value.path&&d.value.path.length>0?(e.openBlock(),e.createBlock(fe,{key:0,path:d.value.path,onNavigate:O},null,8,["path"])):e.createCommentVNode("",!0),e.createElementVNode("div",pn,[e.createElementVNode("div",vn,[e.createVNode(re,{type:d.value.type,size:"lg"},null,8,["type"]),e.createElementVNode("h1",_n,e.toDisplayString(d.value.name),1),e.createVNode(J,{code:d.value.full_code},null,8,["code"]),e.createVNode(Z,{variant:"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.value.type_label),1)]),_:1}),e.createVNode(Z,{variant:d.value.is_active?"success":"error",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(d.value.is_active?"Active":"Inactive"),1)]),_:1},8,["variant"])]),e.createElementVNode("div",hn,[e.createVNode(T,{variant:"secondary",size:"sm",onClick:B[0]||(B[0]=M=>$.value=!0)},{"icon-left":e.withCtx(()=>[...B[7]||(B[7]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M11 4H4a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e.createElementVNode("path",{d:"M18.5 2.5a2.121 2.121 0 013 3L12 15l-4 1 1-4 9.5-9.5z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:e.withCtx(()=>[B[8]||(B[8]=e.createTextVNode(" Edit ",-1))]),_:1}),e.createVNode(T,{variant:"secondary",size:"sm",onClick:ce},{"icon-left":e.withCtx(()=>[...B[9]||(B[9]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M6 9V2h12v7M6 18H4a2 2 0 01-2-2v-5a2 2 0 012-2h16a2 2 0 012 2v5a2 2 0 01-2 2h-2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e.createElementVNode("rect",{x:"6",y:"14",width:"12",height:"8",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:e.withCtx(()=>[B[10]||(B[10]=e.createTextVNode(" Print Label ",-1))]),_:1}),e.createVNode(T,{variant:"danger",size:"sm",onClick:ye},{"icon-left":e.withCtx(()=>[...B[11]||(B[11]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M3 6h18M19 6v14a2 2 0 01-2 2H7a2 2 0 01-2-2V6m3 0V4a2 2 0 012-2h4a2 2 0 012 2v2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:e.withCtx(()=>[B[12]||(B[12]=e.createTextVNode(" Delete ",-1))]),_:1})])])]),d.value.description||d.value.metadata?(e.openBlock(),e.createBlock(j,{key:0,title:"Details",compact:""},{default:e.withCtx(()=>[e.createElementVNode("div",fn,[d.value.description?(e.openBlock(),e.createElementBlock("div",yn,[B[13]||(B[13]=e.createElementVNode("span",{class:"location-detail__info-label"},"Description",-1)),e.createElementVNode("p",kn,e.toDisplayString(d.value.description),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",gn,[B[14]||(B[14]=e.createElementVNode("span",{class:"location-detail__info-label"},"Created",-1)),e.createElementVNode("span",Vn,e.toDisplayString(S(d.value.created_at)),1)]),e.createElementVNode("div",bn,[B[15]||(B[15]=e.createElementVNode("span",{class:"location-detail__info-label"},"Last Updated",-1)),e.createElementVNode("span",Nn,e.toDisplayString(S(d.value.updated_at)),1)]),d.value.is_mobile?(e.openBlock(),e.createElementBlock("div",wn,[B[17]||(B[17]=e.createElementVNode("span",{class:"location-detail__info-label"},"Mobile",-1)),e.createVNode(Z,{variant:"info",size:"sm"},{default:e.withCtx(()=>[...B[16]||(B[16]=[e.createTextVNode("Mobile Location",-1)])]),_:1})])):e.createCommentVNode("",!0)])]),_:1})):e.createCommentVNode("",!0),u.value.length>0||d.value.children_count?(e.openBlock(),e.createBlock(j,{key:1,title:"Child Locations",compact:"","no-padding":""},{actions:e.withCtx(()=>[e.createVNode(T,{variant:"ghost",size:"sm",onClick:B[1]||(B[1]=M=>F.value=!0)},{default:e.withCtx(()=>[...B[18]||(B[18]=[e.createTextVNode(" + Add Child ",-1)])]),_:1})]),default:e.withCtx(()=>[e.createVNode(ne,{columns:N,data:u.value,loading:m.value,clickable:"","empty-message":"No child locations.",onRowClick:X},{"cell-name":e.withCtx(({row:M})=>[e.createElementVNode("div",En,[e.createVNode(re,{type:M.type,size:"sm"},null,8,["type"]),e.createElementVNode("span",null,e.toDisplayString(M.name),1)])]),"cell-type_label":e.withCtx(({value:M})=>[e.createVNode(Z,{variant:"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(M),1)]),_:2},1024)]),"cell-full_code":e.withCtx(({value:M})=>[e.createVNode(J,{code:M},null,8,["code"])]),"cell-product_count":e.withCtx(({value:M})=>[e.createElementVNode("span",Cn,e.toDisplayString(M??0),1)]),_:1},8,["data","loading"])]),_:1})):e.createCommentVNode("",!0),e.createVNode(j,{title:"Products",compact:"","no-padding":""},{actions:e.withCtx(()=>[e.createElementVNode("span",Bn,e.toDisplayString(f.value.length)+" "+e.toDisplayString(f.value.length===1?"product":"products"),1)]),default:e.withCtx(()=>[w.value?(e.openBlock(),e.createElementBlock("div",$n,[...B[19]||(B[19]=[e.createElementVNode("div",{class:"location-detail__skeleton location-detail__skeleton--row"},null,-1),e.createElementVNode("div",{class:"location-detail__skeleton location-detail__skeleton--row"},null,-1),e.createElementVNode("div",{class:"location-detail__skeleton location-detail__skeleton--row"},null,-1)])])):f.value.length===0?(e.openBlock(),e.createElementBlock("div",xn,[...B[20]||(B[20]=[e.createElementVNode("p",null,"No products at this location.",-1)])])):(e.openBlock(),e.createBlock(ne,{key:2,columns:D,data:f.value,"empty-message":"No products at this location."},{"cell-product_name":e.withCtx(({row:M})=>[e.createElementVNode("div",Sn,[e.createElementVNode("span",Ln,e.toDisplayString(M.product_name),1),M.product_sku?(e.openBlock(),e.createElementBlock("span",Dn,e.toDisplayString(M.product_sku),1)):e.createCommentVNode("",!0)])]),"cell-quantity":e.withCtx(({value:M})=>[e.createElementVNode("strong",null,e.toDisplayString(e.unref(Ce)(M)),1)]),"cell-is_primary":e.withCtx(({value:M})=>[M?(e.openBlock(),e.createBlock(Z,{key:0,variant:"default",size:"sm"},{default:e.withCtx(()=>[...B[21]||(B[21]=[e.createTextVNode("Primary",-1)])]),_:1})):e.createCommentVNode("",!0)]),_:1},8,["data"]))]),_:1}),e.createVNode(j,{title:"Recent Movements",compact:"","no-padding":"",collapsible:""},{default:e.withCtx(()=>[g.value?(e.openBlock(),e.createElementBlock("div",zn,[...B[22]||(B[22]=[e.createElementVNode("div",{class:"location-detail__skeleton location-detail__skeleton--row"},null,-1),e.createElementVNode("div",{class:"location-detail__skeleton location-detail__skeleton--row"},null,-1)])])):V.value.length===0?(e.openBlock(),e.createElementBlock("div",In,[...B[23]||(B[23]=[e.createElementVNode("p",null,"No recent movements.",-1)])])):(e.openBlock(),e.createElementBlock("div",Mn,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(V.value,M=>(e.openBlock(),e.createElementBlock("div",{key:M.id,class:"location-detail__movement"},[e.createElementVNode("div",{class:e.normalizeClass(["location-detail__movement-icon",`location-detail__movement-icon--${M.reason}`])},[(e.openBlock(),e.createElementBlock("svg",Tn,[M.reason==="placed"||M.reason==="received"?(e.openBlock(),e.createElementBlock("path",Fn)):M.reason==="picked"?(e.openBlock(),e.createElementBlock("path",Pn)):M.reason==="moved"?(e.openBlock(),e.createElementBlock("path",An)):(e.openBlock(),e.createElementBlock("path",Rn))]))],2),e.createElementVNode("div",qn,[e.createElementVNode("span",Un,[e.createElementVNode("strong",null,e.toDisplayString(M.reason_label),1),e.createTextVNode(" "+e.toDisplayString(M.product_name)+" ",1),e.createElementVNode("span",Hn," (qty: "+e.toDisplayString(e.unref(Ce)(M.quantity))+") ",1)]),e.createElementVNode("span",jn,e.toDisplayString(M.performer_name||"System")+" · "+e.toDisplayString(e.unref(ro)(M.performed_at)),1)])]))),128))]))]),_:1}),e.createVNode(j,{title:"Label Preview",compact:"",collapsible:"",collapsed:!0},{actions:e.withCtx(()=>[e.createVNode(T,{variant:"ghost",size:"sm",onClick:ce},{default:e.withCtx(()=>[...B[24]||(B[24]=[e.createTextVNode(" Print ",-1)])]),_:1})]),default:e.withCtx(()=>[b.value?(e.openBlock(),e.createElementBlock("div",On,[b.value.qr_code_svg?(e.openBlock(),e.createElementBlock("div",{key:0,class:"location-detail__label-qr",innerHTML:b.value.qr_code_svg},null,8,Kn)):e.createCommentVNode("",!0),e.createElementVNode("div",Qn,[e.createElementVNode("strong",null,e.toDisplayString(b.value.location.name),1),e.createElementVNode("span",Gn,e.toDisplayString(b.value.location.full_code),1),e.createElementVNode("span",Wn,e.toDisplayString(b.value.path),1)])])):(e.openBlock(),e.createElementBlock("div",Zn,[e.createElementVNode("p",null,[e.createVNode(T,{variant:"secondary",size:"sm",loading:x.value,onClick:I},{default:e.withCtx(()=>[...B[25]||(B[25]=[e.createTextVNode(" Load Label Preview ",-1)])]),_:1},8,["loading"])])]))]),_:1})],64)):e.createCommentVNode("",!0),e.createVNode(be,{show:$.value,location:d.value,"onUpdate:show":B[2]||(B[2]=M=>$.value=M),onSaved:ge},null,8,["show","location"]),e.createVNode(be,{show:F.value,"parent-id":((W=d.value)==null?void 0:W.id)||null,"onUpdate:show":B[3]||(B[3]=M=>F.value=M),onSaved:Ve},null,8,["show","parent-id"]),e.createVNode(he,{show:k.value,title:"Delete Location",description:"This action cannot be undone. All child locations and product associations will be removed.",size:"sm","onUpdate:show":B[5]||(B[5]=M=>k.value=M)},{footer:e.withCtx(()=>[e.createVNode(T,{variant:"secondary",onClick:B[4]||(B[4]=M=>k.value=!1)},{default:e.withCtx(()=>[...B[28]||(B[28]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(T,{variant:"danger",loading:E.value,onClick:ke},{default:e.withCtx(()=>[...B[29]||(B[29]=[e.createTextVNode(" Delete Location ",-1)])]),_:1},8,["loading"])]),default:e.withCtx(()=>{var M;return[e.createElementVNode("p",Jn,[B[26]||(B[26]=e.createTextVNode(" Are you sure you want to delete ",-1)),e.createElementVNode("strong",null,e.toDisplayString((M=d.value)==null?void 0:M.name),1),B[27]||(B[27]=e.createTextVNode("? ",-1))])]}),_:1},8,["show"])])}}}),Ie=H(Xn,[["__scopeId","data-v-388046b7"]]),Yn={class:"inv-shell"},ea={class:"inv-shell__header"},ta={class:"inv-shell__header-left"},oa=["aria-label","aria-expanded"],na={class:"inv-shell__header-actions"},aa={class:"inv-shell__search-wrapper"},la={class:"inv-shell__body"},sa=["aria-hidden"],ra={class:"inv-shell__detail"},ia=e.defineComponent({__name:"InventoryLocatorShell",setup(t){const n=le(),o=e.inject("router",null),h=e.inject("route",null),s=e.ref(""),_=e.ref(!1),y=e.ref(!0),i=e.ref(typeof window<"u"?window.innerWidth:1200),l=e.computed(()=>i.value<1024);function c(){i.value=window.innerWidth,l.value||(y.value=!0)}function a(x){s.value="",m(x)}function r(x){m(x),l.value&&(y.value=!1)}function d(x){m(x)}function p(){n.selectLocation(null),w(null)}function v(x){_.value=!1,m(x)}function u(){o&&o.push({name:"inventory-scan"})}function m(x){n.selectLocation(x.id),f(x),w(x.full_code)}function f(x){if(x.path)for(const $ of x.path)n.expandedNodeIds.has($.id)||n.toggleExpand($.id)}function w(x){if(o)try{x?o.replace({name:"inventory-location",params:{code:x}}):o.replace({name:"inventory-locations"})}catch{}}function V(){var x;return(x=h==null?void 0:h.params)!=null&&x.code?h.params.code:null}function g(){const x=V();if(x){const $=b(x);$&&(n.selectLocation($.id),f($))}}function b(x){const $=F=>{for(const k of F){if(k.full_code===x)return k;if(k.children){const E=$(k.children);if(E)return E}}return null};return $(n.roots)}return h&&e.watch(()=>{var x;return(x=h.params)==null?void 0:x.code},x=>{if(x){const $=b(x);$&&(n.selectLocation($.id),f($))}}),e.onMounted(()=>{window.addEventListener("resize",c),c(),g()}),e.onUnmounted(()=>{window.removeEventListener("resize",c)}),(x,$)=>(e.openBlock(),e.createElementBlock("div",Yn,[e.createElementVNode("header",ea,[e.createElementVNode("div",ta,[e.createElementVNode("button",{type:"button",class:"inv-shell__menu-toggle","aria-label":y.value?"Close sidebar":"Open sidebar","aria-expanded":y.value,onClick:$[0]||($[0]=F=>y.value=!y.value)},[...$[6]||($[6]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M3 12h18M3 6h18M3 18h18",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])],8,oa),$[7]||($[7]=e.createElementVNode("h1",{class:"inv-shell__title"},"Inventory Locations",-1))]),e.createElementVNode("div",na,[e.createElementVNode("div",aa,[e.createVNode(De,{modelValue:s.value,"onUpdate:modelValue":$[1]||($[1]=F=>s.value=F),placeholder:"Search locations...",onSelect:a},null,8,["modelValue"])]),e.createVNode(T,{variant:"primary",size:"sm",onClick:$[2]||($[2]=F=>_.value=!0)},{"icon-left":e.withCtx(()=>[...$[8]||($[8]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 5v14M5 12h14",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),default:e.withCtx(()=>[$[9]||($[9]=e.createTextVNode(" New ",-1))]),_:1}),e.createVNode(T,{variant:"secondary",size:"sm",onClick:u},{"icon-left":e.withCtx(()=>[...$[10]||($[10]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M3 7V5a2 2 0 012-2h2M17 3h2a2 2 0 012 2v2M21 17v2a2 2 0 01-2 2h-2M7 21H5a2 2 0 01-2-2v-2",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}),e.createElementVNode("path",{d:"M7 8h10M7 12h10M7 16h6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])]),default:e.withCtx(()=>[$[11]||($[11]=e.createTextVNode(" Scan ",-1))]),_:1})])]),e.createElementVNode("div",la,[e.createVNode(e.Transition,{name:"inv-shell-backdrop"},{default:e.withCtx(()=>[y.value&&l.value?(e.openBlock(),e.createElementBlock("div",{key:0,class:"inv-shell__backdrop",onClick:$[3]||($[3]=F=>y.value=!1)})):e.createCommentVNode("",!0)]),_:1}),e.createElementVNode("aside",{class:e.normalizeClass(["inv-shell__sidebar",{"inv-shell__sidebar--open":y.value,"inv-shell__sidebar--compact":l.value}]),"aria-hidden":l.value&&!y.value?"true":void 0},[e.createVNode(ze,{onSelect:r,onCreate:$[4]||($[4]=F=>_.value=!0)})],10,sa),e.createElementVNode("main",ra,[e.unref(n).selectedLocationId?(e.openBlock(),e.createBlock(Ie,{key:0,"location-id":e.unref(n).selectedLocationId,onNavigate:d,onDeleted:p},null,8,["location-id"])):(e.openBlock(),e.createBlock(Y,{key:1,title:"Select a location",description:"Choose a location from the tree to view its details, products, and movements."}))])]),e.createVNode(be,{show:_.value,"onUpdate:show":$[5]||($[5]=F=>_.value=F),onSaved:v},null,8,["show"])]))}}),ca=H(ia,[["__scopeId","data-v-e77a95d2"]]),da={class:"scan-result__body"},ua={key:0,class:"scan-result__path"},ma={class:"scan-result__location-info"},pa={key:1,class:"scan-result__products"},va={class:"scan-result__products-label"},_a={class:"scan-result__product-list",role:"list"},ha={class:"scan-result__product-name"},fa={class:"scan-result__product-qty"},ya={key:0,class:"scan-result__products-more"},ka={key:2,class:"scan-result__no-products"},ga={class:"scan-result__actions"},Va=e.defineComponent({__name:"ScanResult",props:{location:{},show:{type:Boolean}},emits:["close","navigate","scan-again"],setup(t,{emit:n}){const o=t,h=n,_=`scan-result-title-${e.useId()}`,y=e.ref(null),i=e.computed(()=>o.location.products?o.location.products.slice(0,5):[]);e.watch(()=>o.show,async c=>{var a;c&&(await e.nextTick(),(a=y.value)==null||a.focus())});function l(c){h("navigate",{...o.location,full_code:c.full_code})}return(c,a)=>(e.openBlock(),e.createBlock(e.Transition,{name:"scan-result"},{default:e.withCtx(()=>[t.show?(e.openBlock(),e.createElementBlock("div",{key:0,class:"scan-result__backdrop",onMousedown:a[4]||(a[4]=e.withModifiers(r=>h("close"),["self"]))},[e.createElementVNode("div",{ref_key:"sheetRef",ref:y,class:"scan-result",role:"dialog","aria-modal":"true","aria-labelledby":_,onKeydown:a[3]||(a[3]=e.withKeys(r=>h("close"),["escape"]))},[a[10]||(a[10]=e.createElementVNode("div",{class:"scan-result__handle","aria-hidden":"true"},[e.createElementVNode("span",{class:"scan-result__handle-bar"})],-1)),e.createElementVNode("div",{class:"scan-result__header"},[a[5]||(a[5]=e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true",class:"scan-result__check-icon"},[e.createElementVNode("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor","stroke-width":"2"}),e.createElementVNode("path",{d:"M8 12L11 15L16 9",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)),e.createElementVNode("h2",{id:_,class:"scan-result__title"},"Location Found")]),e.createElementVNode("div",da,[t.location.path&&t.location.path.length>0?(e.openBlock(),e.createElementBlock("div",ua,[e.createVNode(fe,{path:t.location.path,onNavigate:l},null,8,["path"])])):e.createCommentVNode("",!0),e.createElementVNode("div",ma,[e.createVNode(J,{code:t.location.full_code},null,8,["code"]),e.createVNode(Z,{variant:"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(t.location.type_label),1)]),_:1})]),t.location.products&&t.location.products.length>0?(e.openBlock(),e.createElementBlock("div",pa,[e.createElementVNode("p",va," Products: "+e.toDisplayString(t.location.products.length)+" item"+e.toDisplayString(t.location.products.length!==1?"s":""),1),e.createElementVNode("ul",_a,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,r=>(e.openBlock(),e.createElementBlock("li",{key:r.id,class:"scan-result__product-item"},[e.createElementVNode("span",ha,e.toDisplayString(r.product_name),1),e.createElementVNode("span",fa,"qty: "+e.toDisplayString(r.quantity),1)]))),128))]),t.location.products.length>5?(e.openBlock(),e.createElementBlock("p",ya," + "+e.toDisplayString(t.location.products.length-5)+" more ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",ka,[...a[6]||(a[6]=[e.createElementVNode("p",{class:"scan-result__no-products-text"},"No products at this location",-1)])]))]),e.createElementVNode("div",ga,[e.createVNode(T,{variant:"primary",size:"md",onClick:a[0]||(a[0]=r=>h("navigate",t.location))},{default:e.withCtx(()=>[...a[7]||(a[7]=[e.createTextVNode(" View Details ",-1)])]),_:1}),e.createVNode(T,{variant:"secondary",size:"md",onClick:a[1]||(a[1]=r=>h("navigate",t.location))},{default:e.withCtx(()=>[...a[8]||(a[8]=[e.createTextVNode(" Add Product ",-1)])]),_:1}),e.createVNode(T,{variant:"ghost",size:"md",onClick:a[2]||(a[2]=r=>h("scan-again"))},{default:e.withCtx(()=>[...a[9]||(a[9]=[e.createTextVNode(" Scan Again ",-1)])]),_:1})])],544)],32)):e.createCommentVNode("",!0)]),_:1}))}}),Me=H(Va,[["__scopeId","data-v-575ebb3b"]]),ba={key:0,class:"scan-history"},Na={class:"scan-history__list",role:"list"},wa=["aria-label","onClick"],Ea={class:"scan-history__code"},Ca={class:"scan-history__name"},Ba={class:"scan-history__time"},$a=e.defineComponent({__name:"ScanHistory",props:{limit:{default:10}},setup(t){const n=t,o=ae.useRouter(),h=we();e.onMounted(()=>{h.loadFromSession()});const s=e.computed(()=>h.history.slice(0,n.limit));function _(i){o.push({name:"inventory-location",params:{code:i.code}})}function y(i){const l=Date.now(),c=new Date(i).getTime(),a=l-c,r=Math.floor(a/1e3);if(r<60)return"just now";const d=Math.floor(r/60);if(d<60)return`${d} min ago`;const p=Math.floor(d/60);if(p<24)return`${p}h ago`;const v=Math.floor(p/24);return v===1?"yesterday":`${v}d ago`}return(i,l)=>s.value.length>0?(e.openBlock(),e.createElementBlock("div",ba,[l[0]||(l[0]=e.createElementVNode("p",{class:"scan-history__title"},"Recent scans",-1)),e.createElementVNode("ul",Na,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.value,c=>(e.openBlock(),e.createElementBlock("li",{key:c.code+c.scannedAt,class:"scan-history__item"},[e.createElementVNode("button",{type:"button",class:"scan-history__link","aria-label":`Navigate to ${c.locationName} (${c.code})`,onClick:a=>_(c)},[e.createElementVNode("span",Ea,e.toDisplayString(c.code),1),e.createElementVNode("span",Ca,e.toDisplayString(c.locationName),1),e.createElementVNode("span",Ba,e.toDisplayString(y(c.scannedAt)),1)],8,wa)]))),128))])])):e.createCommentVNode("",!0)}}),Te=H($a,[["__scopeId","data-v-2eaec2d3"]]),xa={class:"scanner-overlay"},Sa={key:0,class:"scanner-overlay__counting-banner",role:"status"},La={class:"scanner-overlay__counting-text"},Da={class:"scanner-overlay__header"},za=["aria-label","aria-pressed"],Ia={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Ma=["fill"],Ta={key:1,class:"scanner-overlay__camera-area"},Fa={key:0,class:"scanner-overlay__scan-guide","aria-hidden":"true"},Pa={key:1,class:"scanner-overlay__starting",role:"status"},Aa={key:2,class:"scanner-overlay__error",role:"alert"},Ra={key:2,class:"scanner-overlay__no-camera",role:"status"},qa={key:3,class:"scanner-overlay__instruction"},Ua={"aria-live":"polite",class:"sr-only"},Ha={key:0},ja={key:1},Oa={key:2},Ka={key:4,class:"scanner-overlay__toast scanner-overlay__toast--error",role:"alert"},Qa={class:"scanner-overlay__manual"},Ga={class:"scanner-overlay__manual-row"},Wa=["disabled"],$e="inv-scanner-feed",Za=e.defineComponent({__name:"ScannerOverlay",setup(t){const n=ae.useRouter(),o=Le(),h=ee(),s=we(),_=ve(),y=e.ref(""),i=e.ref(null),l=e.ref(!1),c=e.ref(null);e.onMounted(async()=>{s.loadFromSession(),o.isSupported.value&&await a()}),e.onBeforeUnmount(async()=>{await o.stopScanning()});async function a(){c.value=null,await o.startScanning($e,d)}async function r(){o.error.value=null,await a()}async function d(g){await o.stopScanning(),await v(g)}async function p(){const g=y.value.trim();g&&await v(g)}async function v(g){l.value=!0,c.value=null;try{const b=await h.scanLookup(g);b?(i.value=b,s.addToHistory({code:b.full_code,locationName:b.name,locationId:b.id})):(c.value=`No location found for code "${g}"`,o.isSupported.value&&await a())}catch{c.value="Could not look up location. Check connection.",o.isSupported.value&&await a()}finally{l.value=!1}}function u(){c.value=null}function m(){i.value=null}function f(g){i.value=null,n.push({name:"inventory-location",params:{code:g.full_code}})}async function w(){i.value=null,y.value="",o.isSupported.value&&await a()}function V(){n.back()}return(g,b)=>(e.openBlock(),e.createElementBlock("div",xa,[e.unref(_).isCountingMode?(e.openBlock(),e.createElementBlock("div",Sa,[b[2]||(b[2]=e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"2",y:"2",width:"14",height:"14",rx:"2",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("path",{d:"M6 6h2v2H6V6zm4 0h2v2h-2V6zm-4 4h2v2H6v-2zm4 0h2v2h-2v-2z",fill:"currentColor"})],-1)),e.createElementVNode("span",La," Counting: Session #"+e.toDisplayString(e.unref(_).activeSessionId),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Da,[e.createElementVNode("button",{type:"button",class:"scanner-overlay__close-btn","aria-label":"Close scanner",onClick:V},[...b[3]||(b[3]=[e.createElementVNode("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M18 6L6 18M6 6L18 18",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1)])]),e.unref(o).isScanning.value&&e.unref(o).isSupported.value?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:e.normalizeClass(["scanner-overlay__flash-btn",{"scanner-overlay__flash-btn--active":e.unref(o).flashOn.value}]),"aria-label":e.unref(o).flashOn.value?"Turn off flash":"Turn on flash","aria-pressed":e.unref(o).flashOn.value,onClick:b[0]||(b[0]=x=>e.unref(o).toggleFlash())},[(e.openBlock(),e.createElementBlock("svg",Ia,[e.createElementVNode("path",{d:"M13 2L3 14h9l-1 8 10-12h-9l1-8z",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",fill:e.unref(o).flashOn.value?"currentColor":"none"},null,8,Ma)]))],10,za)):e.createCommentVNode("",!0)]),e.unref(o).isSupported.value?(e.openBlock(),e.createElementBlock("div",Ta,[e.withDirectives(e.createElementVNode("div",{id:$e,class:"scanner-overlay__camera-feed"},null,512),[[e.vShow,e.unref(o).isScanning.value&&!i.value]]),e.unref(o).isScanning.value&&!i.value?(e.openBlock(),e.createElementBlock("div",Fa,[...b[4]||(b[4]=[e.createStaticVNode('<div class="scanner-overlay__scan-box" data-v-e0f50099><span class="scanner-overlay__scan-corner scanner-overlay__scan-corner--tl" data-v-e0f50099></span><span class="scanner-overlay__scan-corner scanner-overlay__scan-corner--tr" data-v-e0f50099></span><span class="scanner-overlay__scan-corner scanner-overlay__scan-corner--bl" data-v-e0f50099></span><span class="scanner-overlay__scan-corner scanner-overlay__scan-corner--br" data-v-e0f50099></span></div>',1)])])):e.createCommentVNode("",!0),!e.unref(o).isScanning.value&&!e.unref(o).error.value&&!i.value?(e.openBlock(),e.createElementBlock("div",Pa,[...b[5]||(b[5]=[e.createElementVNode("div",{class:"scanner-overlay__spinner","aria-hidden":"true"},null,-1),e.createElementVNode("p",{class:"scanner-overlay__starting-text"},"Starting camera...",-1)])])):e.createCommentVNode("",!0),e.unref(o).error.value&&!i.value?(e.openBlock(),e.createElementBlock("div",Aa,[b[7]||(b[7]=e.createStaticVNode('<svg width="32" height="32" viewBox="0 0 24 24" fill="none" aria-hidden="true" data-v-e0f50099><circle cx="12" cy="12" r="10" stroke="currentColor" stroke-width="2" data-v-e0f50099></circle><path d="M15 9L9 15M9 9L15 15" stroke="currentColor" stroke-width="2" stroke-linecap="round" data-v-e0f50099></path></svg><p class="scanner-overlay__error-title" data-v-e0f50099>Camera access is required for scanning</p><p class="scanner-overlay__error-desc" data-v-e0f50099> Enable camera access in your browser or device settings, or use manual entry below. </p>',3)),e.createVNode(T,{variant:"secondary",size:"sm",onClick:r},{default:e.withCtx(()=>[...b[6]||(b[6]=[e.createTextVNode(" Try Again ",-1)])]),_:1})])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Ra,[...b[8]||(b[8]=[e.createStaticVNode('<svg width="48" height="48" viewBox="0 0 24 24" fill="none" aria-hidden="true" data-v-e0f50099><rect x="2" y="6" width="20" height="14" rx="2" stroke="currentColor" stroke-width="1.5" data-v-e0f50099></rect><circle cx="12" cy="13" r="4" stroke="currentColor" stroke-width="1.5" data-v-e0f50099></circle><path d="M2 8L22 8" stroke="currentColor" stroke-width="1.5" data-v-e0f50099></path><path d="M3 3L21 21" stroke="currentColor" stroke-width="2" stroke-linecap="round" data-v-e0f50099></path></svg><p class="scanner-overlay__no-camera-text" data-v-e0f50099> No camera detected. Use manual entry to look up locations. </p>',2)])])),e.unref(o).isSupported.value&&e.unref(o).isScanning.value&&!i.value?(e.openBlock(),e.createElementBlock("p",qa," Point camera at QR code or barcode ")):e.createCommentVNode("",!0),e.createElementVNode("div",Ua,[l.value?(e.openBlock(),e.createElementBlock("span",Ha,"Looking up scanned code...")):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",ja,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",Oa,"Location found: "+e.toDisplayString(i.value.name),1)):e.createCommentVNode("",!0)]),c.value?(e.openBlock(),e.createElementBlock("div",Ka,[e.createElementVNode("span",null,e.toDisplayString(c.value),1),e.createElementVNode("button",{type:"button",class:"scanner-overlay__toast-dismiss","aria-label":"Dismiss error",onClick:u},[...b[9]||(b[9]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M12 4L4 12M4 4L12 12",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])])])):e.createCommentVNode("",!0),e.createElementVNode("div",Qa,[b[11]||(b[11]=e.createElementVNode("label",{for:"scanner-manual-input",class:"scanner-overlay__manual-label"}," Or enter code manually: ",-1)),e.createElementVNode("div",Ga,[e.withDirectives(e.createElementVNode("input",{id:"scanner-manual-input","onUpdate:modelValue":b[1]||(b[1]=x=>y.value=x),type:"text",class:"scanner-overlay__manual-input",placeholder:"e.g. WH1-A-01",disabled:l.value,onKeydown:e.withKeys(p,["enter"])},null,40,Wa),[[e.vModelText,y.value]]),e.createVNode(T,{variant:"primary",size:"md",loading:l.value,disabled:!y.value.trim(),onClick:p},{default:e.withCtx(()=>[...b[10]||(b[10]=[e.createTextVNode(" Go ",-1)])]),_:1},8,["loading","disabled"])])]),i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Te,{key:5,limit:5,class:"scanner-overlay__history"})),i.value?(e.openBlock(),e.createBlock(Me,{key:6,location:i.value,show:!!i.value,onClose:m,onNavigate:f,onScanAgain:w},null,8,["location","show"])):e.createCommentVNode("",!0)]))}}),Ja=H(Za,[["__scopeId","data-v-e0f50099"]]),Xa={class:"count-session-list"},Ya={class:"count-session-list__header"},el={class:"count-session-list__create-fields"},tl={class:"count-session-list__scope-field"},ol={class:"count-session-list__scope-input"},nl={key:0,class:"count-session-list__scope-results",role:"listbox","aria-label":"Scope location results"},al=["aria-selected","onClick"],ll={key:1,class:"count-session-list__scope-selected"},sl={class:"count-session-list__create-actions"},rl={key:0,class:"count-session-list__loading"},il={key:1,class:"count-session-list__section"},cl={class:"count-session-list__cards"},dl={class:"count-session-list__card-header"},ul={class:"count-session-list__card-name"},ml=["aria-valuenow","aria-label"],pl={class:"count-session-list__progress-track"},vl={class:"count-session-list__progress-label"},_l={class:"count-session-list__card-stats"},hl={key:0,class:"count-session-list__card-meta"},fl={class:"count-session-list__card-actions"},yl={key:2,class:"count-session-list__section"},kl={class:"count-session-list__completed"},gl=["onClick"],Vl={class:"count-session-list__completed-info"},bl={class:"count-session-list__completed-name"},Nl={class:"count-session-list__completed-meta"},wl={key:0},El={key:1},Cl={key:2},Bl=e.defineComponent({__name:"CountSessionList",setup(t){const n=ae.useRouter(),{sessions:o,loading:h,fetchSessions:s,createSession:_}=se(),y=ie(),i=e.ref(!1),l=e.ref(""),c=e.ref(void 0),a=e.ref(!1),r=e.ref(""),d=e.ref([]),p=e.ref(null);e.onMounted(async()=>{await s()});const v=e.computed(()=>o.value.filter(k=>k.status==="pending"||k.status==="in_progress")),u=e.computed(()=>o.value.filter(k=>k.status==="completed"||k.status==="cancelled"));function m(k){return k>=90?"count-session-list__progress-fill--success":k>=50?"count-session-list__progress-fill--primary":"count-session-list__progress-fill--warning"}function f(){p.value||(y.search(r.value),d.value=y.results.value)}function w(k){p.value=k,r.value="",d.value=[]}function V(){p.value=null,r.value="",d.value=[]}function g(){i.value=!1,l.value="",c.value=void 0,V()}async function b(){var E,N,D;const k=l.value.trim();if(!k){c.value="Name is required";return}a.value=!0,c.value=void 0;try{const S=await _(k,(E=p.value)==null?void 0:E.id);i.value=!1,l.value="",V(),x(S.id)}catch(S){c.value=((D=(N=S==null?void 0:S.response)==null?void 0:N.data)==null?void 0:D.message)||"Failed to create session"}finally{a.value=!1}}function x(k){n.push({name:"inventory-count-detail",params:{id:k}})}function $(k){n.push({name:"inventory-count-entry",params:{id:k}})}function F(k){return new Date(k).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}return(k,E)=>(e.openBlock(),e.createElementBlock("div",Xa,[e.createElementVNode("div",Ya,[E[6]||(E[6]=e.createElementVNode("h1",{class:"count-session-list__title"},"Cycle Counts",-1)),e.createVNode(T,{variant:"primary",size:"md",onClick:E[0]||(E[0]=N=>i.value=!i.value)},{"icon-left":e.withCtx(()=>[...E[4]||(E[4]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M8 3V13M3 8H13",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round"})],-1)])]),default:e.withCtx(()=>[E[5]||(E[5]=e.createTextVNode(" New ",-1))]),_:1})]),e.createVNode(e.Transition,{name:"count-create"},{default:e.withCtx(()=>[i.value?(e.openBlock(),e.createBlock(j,{key:0,title:"New Count Session",class:"count-session-list__create"},{default:e.withCtx(()=>[e.createElementVNode("form",{onSubmit:e.withModifiers(b,["prevent"])},[e.createElementVNode("div",el,[e.createVNode(me,{modelValue:l.value,"onUpdate:modelValue":E[1]||(E[1]=N=>l.value=N),label:"Session Name",placeholder:"e.g. Full Warehouse Count - March 2026",error:c.value,autofocus:""},null,8,["modelValue","error"]),e.createElementVNode("div",tl,[E[8]||(E[8]=e.createElementVNode("label",{class:"count-session-list__scope-label"}," Scope (optional) ",-1)),E[9]||(E[9]=e.createElementVNode("p",{class:"count-session-list__scope-hint"}," Limit count to a specific location and its children ",-1)),e.createElementVNode("div",ol,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[2]||(E[2]=N=>r.value=N),type:"search",class:"count-session-list__scope-search",placeholder:"Search locations...",onInput:f},null,544),[[e.vModelText,r.value]]),d.value.length>0?(e.openBlock(),e.createElementBlock("div",nl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,N=>{var D,S;return e.openBlock(),e.createElementBlock("button",{key:N.id,type:"button",role:"option","aria-selected":((D=p.value)==null?void 0:D.id)===N.id,class:e.normalizeClass(["count-session-list__scope-option",{"count-session-list__scope-option--selected":((S=p.value)==null?void 0:S.id)===N.id}]),onClick:C=>w(N)},[e.createVNode(J,{code:N.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(N.name),1)],10,al)}),128))])):e.createCommentVNode("",!0),p.value?(e.openBlock(),e.createElementBlock("div",ll,[e.createVNode(J,{code:p.value.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(p.value.name),1),e.createElementVNode("button",{type:"button",class:"count-session-list__scope-clear","aria-label":"Clear scope selection",onClick:V},[...E[7]||(E[7]=[e.createElementVNode("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M10 4L4 10M4 4L10 10",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])])])):e.createCommentVNode("",!0)])])]),e.createElementVNode("div",sl,[e.createVNode(T,{variant:"ghost",size:"sm",onClick:g},{default:e.withCtx(()=>[...E[10]||(E[10]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(T,{variant:"primary",size:"sm",type:"submit",loading:a.value,disabled:!l.value.trim()},{default:e.withCtx(()=>[...E[11]||(E[11]=[e.createTextVNode(" Create Session ",-1)])]),_:1},8,["loading","disabled"])])],32)]),_:1})):e.createCommentVNode("",!0)]),_:1}),e.unref(h)&&e.unref(o).length===0?(e.openBlock(),e.createElementBlock("div",rl,[e.createVNode(j,{loading:""}),e.createVNode(j,{loading:""})])):e.createCommentVNode("",!0),v.value.length>0?(e.openBlock(),e.createElementBlock("section",il,[E[14]||(E[14]=e.createElementVNode("h2",{class:"count-session-list__section-title"},"Active",-1)),e.createElementVNode("div",cl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,N=>(e.openBlock(),e.createBlock(j,{key:N.id,class:"count-session-list__active-card"},{default:e.withCtx(()=>[e.createElementVNode("div",dl,[e.createElementVNode("h3",ul,e.toDisplayString(N.name),1),e.createVNode(Z,{variant:N.status==="in_progress"?"default":"muted"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.status==="in_progress"?"In Progress":"Pending"),1)]),_:2},1032,["variant"])]),e.createElementVNode("div",{class:"count-session-list__progress",role:"progressbar","aria-valuenow":N.progress.percent_complete,"aria-valuemin":"0","aria-valuemax":"100","aria-label":`Counting progress: ${N.progress.percent_complete}%`},[e.createElementVNode("div",pl,[e.createElementVNode("div",{class:e.normalizeClass(["count-session-list__progress-fill",m(N.progress.percent_complete)]),style:e.normalizeStyle({width:`${N.progress.percent_complete}%`})},null,6)]),e.createElementVNode("span",vl,e.toDisplayString(N.progress.percent_complete)+"% ",1)],8,ml),e.createElementVNode("p",_l,e.toDisplayString(N.progress.counted)+"/"+e.toDisplayString(N.progress.total)+" locations counted, "+e.toDisplayString(N.progress.discrepancies)+" discrepancies ",1),N.started_at?(e.openBlock(),e.createElementBlock("div",hl," Started: "+e.toDisplayString(F(N.started_at)),1)):e.createCommentVNode("",!0),e.createElementVNode("div",fl,[N.status==="in_progress"?(e.openBlock(),e.createBlock(T,{key:0,variant:"primary",size:"sm",onClick:D=>$(N.id)},{default:e.withCtx(()=>[...E[12]||(E[12]=[e.createTextVNode(" Continue Counting ",-1)])]),_:1},8,["onClick"])):e.createCommentVNode("",!0),e.createVNode(T,{variant:"secondary",size:"sm",onClick:D=>x(N.id)},{default:e.withCtx(()=>[...E[13]||(E[13]=[e.createTextVNode(" View ",-1)])]),_:1},8,["onClick"])])]),_:2},1024))),128))])])):e.createCommentVNode("",!0),u.value.length>0?(e.openBlock(),e.createElementBlock("section",yl,[E[15]||(E[15]=e.createElementVNode("h2",{class:"count-session-list__section-title"},"Recent",-1)),e.createElementVNode("div",kl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,N=>(e.openBlock(),e.createElementBlock("button",{key:N.id,type:"button",class:"count-session-list__completed-row",onClick:D=>x(N.id)},[e.createElementVNode("div",Vl,[e.createElementVNode("span",bl,e.toDisplayString(N.name),1),e.createVNode(Z,{variant:N.status==="completed"?"success":"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(N.status==="completed"?"Completed":"Cancelled"),1)]),_:2},1032,["variant"])]),e.createElementVNode("div",Nl,[N.status==="completed"&&N.progress?(e.openBlock(),e.createElementBlock("span",wl," Accuracy: "+e.toDisplayString(N.progress.total>0?((N.progress.total-N.progress.discrepancies)/N.progress.total*100).toFixed(1):"0.0")+"% ",1)):e.createCommentVNode("",!0),N.completed_at?(e.openBlock(),e.createElementBlock("span",El,e.toDisplayString(F(N.completed_at)),1)):N.updated_at?(e.openBlock(),e.createElementBlock("span",Cl,e.toDisplayString(F(N.updated_at)),1)):e.createCommentVNode("",!0)])],8,gl))),128))])])):e.createCommentVNode("",!0),!e.unref(h)&&e.unref(o).length===0?(e.openBlock(),e.createBlock(Y,{key:3,title:"No count sessions",description:"Create a cycle count session to track inventory accuracy.","action-label":"Create Session",onAction:E[3]||(E[3]=N=>i.value=!0)})):e.createCommentVNode("",!0)]))}}),$l=H(Bl,[["__scopeId","data-v-900e6502"]]),xl={class:"count-detail"},Sl={class:"count-detail__header"},Ll={class:"count-detail__header-info"},Dl={class:"count-detail__title"},zl={class:"count-detail__meta"},Il={key:0,class:"count-detail__meta-item"},Ml={key:1,class:"count-detail__meta-item"},Tl=["aria-valuenow","aria-label"],Fl={class:"count-detail__progress-track"},Pl={class:"count-detail__progress-pct"},Al={class:"count-detail__stats-grid"},Rl={class:"count-detail__stat"},ql={class:"count-detail__stat-value"},Ul={class:"count-detail__stat"},Hl={class:"count-detail__stat-value"},jl={class:"count-detail__stat"},Ol={class:"count-detail__stat-value"},Kl={class:"count-detail__stat"},Ql={class:"count-detail__stat-value count-detail__stat-value--pending"},Gl={class:"count-detail__stat"},Wl={class:"count-detail__stat-value count-detail__stat-value--warning"},Zl={class:"count-detail__action-grid"},Jl={class:"count-detail__filters"},Xl={class:"count-detail__discrepancy-toggle"},Yl=["title"],es={class:"count-detail__entry-product"},ts={class:"count-detail__entry-qty"},os={key:0,class:"count-detail__entry-disc"},ns={key:1,class:"count-detail__entry-pending"},as=e.defineComponent({__name:"CountSessionDetail",props:{sessionId:{}},setup(t){const n=t,o=ae.useRouter(),h=ve(),{currentSession:s,entries:_,loading:y,error:i,fetchSession:l,fetchEntries:c,generateEntries:a,updateStatus:r,applySession:d,verifyEntry:p}=se(),v=e.ref(!1),u=e.ref(!1),m=e.ref(!1),f=e.ref(""),w=e.ref(!1),V=e.ref(!1),g=e.ref(""),b=e.ref(""),x=e.ref(""),$=e.ref(!1),F=e.ref(!1);let k=null;const E=[{key:"status",label:"Status",width:"60px",align:"center"},{key:"product_name",label:"Product"},{key:"expected_quantity",label:"Expected",width:"100px",align:"right"},{key:"counted_quantity",label:"Counted",width:"140px",align:"right"}],N=[{value:"",label:"All Statuses"},{value:"pending",label:"Pending"},{value:"counted",label:"Counted"},{value:"verified",label:"Verified"},{value:"adjusted",label:"Adjusted"}],D=e.computed(()=>s.value?{pending:"muted",in_progress:"default",completed:"success",cancelled:"error"}[s.value.status]??"muted":"muted"),S=e.computed(()=>s.value?{pending:"Pending",in_progress:"In Progress",completed:"Completed",cancelled:"Cancelled"}[s.value.status]??s.value.status:""),C=e.computed(()=>{if(!s.value)return"";const U=s.value.progress.percent_complete;return U>=90?"count-detail__progress-fill--success":U>=50?"count-detail__progress-fill--primary":"count-detail__progress-fill--warning"}),L=e.computed(()=>{var U;return((U=s.value)==null?void 0:U.status)==="pending"&&_.value.length===0}),G=e.computed(()=>s.value&&(s.value.status==="pending"||s.value.status==="in_progress")&&_.value.length>0),P=e.computed(()=>_.value.some(U=>U.status!=="pending")),z=e.computed(()=>_.value.some(U=>U.status==="verified"&&U.discrepancy!==null&&U.discrepancy!==0)),I=e.computed(()=>{let U=_.value;return f.value&&(U=U.filter(A=>A.status===f.value)),w.value&&(U=U.filter(A=>A.discrepancy!==null&&A.discrepancy!==0)),U});e.onMounted(()=>O());async function O(){try{await l(n.sessionId),await X()}catch{}}async function X(){v.value=!0;try{await c(n.sessionId)}finally{v.value=!1}}async function ce(){u.value=!0;try{await a(n.sessionId),await X(),await l(n.sessionId)}finally{u.value=!1}}function ye(){h.startCounting(n.sessionId),o.push({name:"inventory-count-entry",params:{id:n.sessionId}})}function ke(){w.value=!w.value}function ge(){g.value="Apply Adjustments",b.value="This will adjust inventory quantities based on verified counts. This action cannot be undone.",x.value="Apply",$.value=!1,k=async()=>{m.value=!0;try{await d(n.sessionId),await l(n.sessionId),await X()}finally{m.value=!1}},V.value=!0}function Ve(){g.value="Cancel Session",b.value="Are you sure you want to cancel this count session? Uncounted entries will be discarded.",x.value="Cancel Session",$.value=!0,k=async()=>{await r(n.sessionId,"cancelled"),await l(n.sessionId)},V.value=!0}async function K(){if(k){F.value=!0;try{await k(),V.value=!1}finally{F.value=!1}}}function B(){o.push({name:"inventory-count-report",params:{id:n.sessionId}})}function W(U){U.status==="counted"&&U.discrepancy!==null&&U.discrepancy!==0&&p(n.sessionId,U.id).then(()=>X())}function M(U){return{pending:"⏳",counted:"✓",verified:"✅",adjusted:"🔧"}[U]??U}function de(U){return{pending:"Pending",counted:"Counted",verified:"Verified",adjusted:"Adjusted"}[U]??U}function Fe(U){return new Date(U).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}return(U,A)=>(e.openBlock(),e.createElementBlock("div",xl,[e.unref(y)&&!e.unref(s)?(e.openBlock(),e.createBlock(j,{key:0,loading:""})):e.unref(i)&&!e.unref(s)?(e.openBlock(),e.createBlock(Y,{key:1,title:"Could not load session",description:e.unref(i),"action-label":"Retry",onAction:O},null,8,["description"])):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Sl,[e.createElementVNode("div",Ll,[e.createElementVNode("h1",Dl,e.toDisplayString(e.unref(s).name),1),e.createElementVNode("div",zl,[e.createVNode(Z,{variant:D.value},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(S.value),1)]),_:1},8,["variant"]),e.unref(s).started_at?(e.openBlock(),e.createElementBlock("span",Il," Started: "+e.toDisplayString(Fe(e.unref(s).started_at)),1)):e.createCommentVNode("",!0),e.unref(s).scope_location_id?(e.openBlock(),e.createElementBlock("span",Ml," Scope: Location #"+e.toDisplayString(e.unref(s).scope_location_id),1)):e.createCommentVNode("",!0)])])]),e.createVNode(j,{title:"Progress",class:"count-detail__progress-card"},{default:e.withCtx(()=>[e.createElementVNode("div",{class:"count-detail__progress-bar",role:"progressbar","aria-valuenow":e.unref(s).progress.percent_complete,"aria-valuemin":"0","aria-valuemax":"100","aria-label":`${e.unref(s).progress.percent_complete}% complete`},[e.createElementVNode("div",Fl,[e.createElementVNode("div",{class:e.normalizeClass(["count-detail__progress-fill",C.value]),style:e.normalizeStyle({width:`${e.unref(s).progress.percent_complete}%`})},null,6)]),e.createElementVNode("span",Pl,e.toDisplayString(e.unref(s).progress.percent_complete)+"% ",1)],8,Tl),e.createElementVNode("div",Al,[e.createElementVNode("div",Rl,[e.createElementVNode("span",ql,e.toDisplayString(e.unref(s).progress.total),1),A[5]||(A[5]=e.createElementVNode("span",{class:"count-detail__stat-label"},"Total",-1))]),e.createElementVNode("div",Ul,[e.createElementVNode("span",Hl,e.toDisplayString(e.unref(s).progress.counted),1),A[6]||(A[6]=e.createElementVNode("span",{class:"count-detail__stat-label"},"Counted",-1))]),e.createElementVNode("div",jl,[e.createElementVNode("span",Ol,e.toDisplayString(e.unref(s).progress.verified),1),A[7]||(A[7]=e.createElementVNode("span",{class:"count-detail__stat-label"},"Verified",-1))]),e.createElementVNode("div",Kl,[e.createElementVNode("span",Ql,e.toDisplayString(e.unref(s).progress.total-e.unref(s).progress.counted),1),A[8]||(A[8]=e.createElementVNode("span",{class:"count-detail__stat-label"},"Pending",-1))]),e.createElementVNode("div",Gl,[e.createElementVNode("span",Wl,e.toDisplayString(e.unref(s).progress.discrepancies),1),A[9]||(A[9]=e.createElementVNode("span",{class:"count-detail__stat-label"},"Discrepancies",-1))])])]),_:1}),e.createVNode(j,{title:"Actions",class:"count-detail__actions-card"},{default:e.withCtx(()=>[e.createElementVNode("div",Zl,[L.value?(e.openBlock(),e.createBlock(T,{key:0,variant:"secondary",size:"md",loading:u.value,onClick:ce},{default:e.withCtx(()=>[...A[10]||(A[10]=[e.createTextVNode(" Generate Entries ",-1)])]),_:1},8,["loading"])):e.createCommentVNode("",!0),G.value?(e.openBlock(),e.createBlock(T,{key:1,variant:"primary",size:"md",onClick:ye},{default:e.withCtx(()=>[...A[11]||(A[11]=[e.createTextVNode(" Start Counting ",-1)])]),_:1})):e.createCommentVNode("",!0),P.value?(e.openBlock(),e.createBlock(T,{key:2,variant:"secondary",size:"md",onClick:ke},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.value?"Show All":"Review Discrepancies"),1)]),_:1})):e.createCommentVNode("",!0),z.value?(e.openBlock(),e.createBlock(T,{key:3,variant:"primary",size:"md",loading:m.value,onClick:ge},{default:e.withCtx(()=>[...A[12]||(A[12]=[e.createTextVNode(" Apply Adjustments ",-1)])]),_:1},8,["loading"])):e.createCommentVNode("",!0),e.unref(s).status==="completed"?(e.openBlock(),e.createBlock(T,{key:4,variant:"secondary",size:"md",onClick:B},{default:e.withCtx(()=>[...A[13]||(A[13]=[e.createTextVNode(" View Report ",-1)])]),_:1})):e.createCommentVNode("",!0),e.unref(s).status!=="completed"&&e.unref(s).status!=="cancelled"?(e.openBlock(),e.createBlock(T,{key:5,variant:"danger",size:"md",onClick:Ve},{default:e.withCtx(()=>[...A[14]||(A[14]=[e.createTextVNode(" Cancel ",-1)])]),_:1})):e.createCommentVNode("",!0)])]),_:1}),e.createVNode(j,{title:"Entries",class:"count-detail__entries-card","no-padding":""},{actions:e.withCtx(()=>[e.createElementVNode("div",Jl,[e.createVNode(oe,{modelValue:f.value,"onUpdate:modelValue":A[0]||(A[0]=Q=>f.value=Q),options:N,placeholder:"All Statuses"},null,8,["modelValue"]),e.createElementVNode("label",Xl,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=Q=>w.value=Q),type:"checkbox",class:"count-detail__discrepancy-checkbox"},null,512),[[e.vModelCheckbox,w.value]]),A[15]||(A[15]=e.createElementVNode("span",null,"Discrepancies only",-1))])])]),default:e.withCtx(()=>[e.createVNode(ne,{columns:E,data:I.value,loading:v.value,clickable:"","empty-message":"No entries. Generate entries to start counting.",onRowClick:W},{"cell-status":e.withCtx(({value:Q})=>[e.createElementVNode("span",{class:"count-detail__entry-status",title:de(Q)},e.toDisplayString(M(Q)),9,Yl)]),"cell-product_name":e.withCtx(({value:Q})=>[e.createElementVNode("span",es,e.toDisplayString(Q),1)]),"cell-expected_quantity":e.withCtx(({value:Q})=>[e.createElementVNode("span",ts,e.toDisplayString(Q??"-"),1)]),"cell-counted_quantity":e.withCtx(({row:Q})=>[Q.counted_quantity!==null?(e.openBlock(),e.createElementBlock("span",{key:0,class:e.normalizeClass(["count-detail__entry-qty",{"count-detail__entry-qty--match":Q.discrepancy===0,"count-detail__entry-qty--discrepancy":Q.discrepancy!==null&&Q.discrepancy!==0}])},[e.createTextVNode(e.toDisplayString(Q.counted_quantity)+" ",1),Q.discrepancy!==null&&Q.discrepancy!==0?(e.openBlock(),e.createElementBlock("span",os," ("+e.toDisplayString(Q.discrepancy>0?"+":"")+e.toDisplayString(Q.discrepancy)+") ",1)):e.createCommentVNode("",!0)],2)):(e.openBlock(),e.createElementBlock("span",ns,"pending"))]),_:1},8,["data","loading"])]),_:1})],64)):e.createCommentVNode("",!0),e.createVNode(he,{show:V.value,title:g.value,description:b.value,size:"sm","onUpdate:show":A[3]||(A[3]=Q=>V.value=Q),onClose:A[4]||(A[4]=Q=>V.value=!1)},{footer:e.withCtx(()=>[e.createVNode(T,{variant:"ghost",size:"sm",onClick:A[2]||(A[2]=Q=>V.value=!1)},{default:e.withCtx(()=>[...A[16]||(A[16]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(T,{variant:$.value?"danger":"primary",size:"sm",loading:F.value,onClick:K},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(x.value),1)]),_:1},8,["variant","loading"])]),_:1},8,["show","title","description"])]))}}),ls=H(as,[["__scopeId","data-v-faf8e3d1"]]),ss={class:"count-entry"},rs={class:"count-entry__header"},is={key:0,class:"count-entry__session-name"},cs={key:1,class:"count-entry__location-count"},ds={key:0,class:"count-entry__connectivity-dot count-entry__connectivity-dot--online","aria-hidden":"true"},us={key:1,class:"count-entry__connectivity-dot count-entry__connectivity-dot--offline","aria-hidden":"true"},ms={key:0,class:"count-entry__no-location"},ps={class:"count-entry__no-location-actions"},vs={class:"count-entry__search-row"},_s={key:0,class:"count-entry__search-results",role:"listbox","aria-label":"Location search results"},hs=["onClick"],fs={class:"count-entry__location-card"},ys={class:"count-entry__location-details"},ks={class:"count-entry__location-name"},gs={class:"count-entry__products",role:"list","aria-label":"Products to count"},Vs={key:0,class:"count-entry__no-entries"},bs=["onClick"],Ns={class:"count-entry__product-info"},ws={class:"count-entry__product-name"},Es={class:"count-entry__product-expected"},Cs={class:"count-entry__product-count"},Bs=["for"],$s=["id","value","onFocus"],xs={key:0,class:"count-entry__status-icon count-entry__status-icon--match","aria-label":"Match"},Ss={key:1,class:"count-entry__status-icon count-entry__status-icon--discrepancy","aria-label":"Discrepancy"},Ls={class:"count-entry__keypad",role:"group","aria-label":"Numeric keypad"},Ds=["aria-label","disabled","onClick"],zs={class:"count-entry__bottom-actions"},Is=e.defineComponent({__name:"CountEntryForm",props:{sessionId:{},locationId:{}},setup(t){const n=t,o=ae.useRouter(),h=ve(),{currentSession:s,entries:_,fetchSession:y,fetchEntries:i,submitCount:l}=se(),c=ee(),a=ie(),r=e.ref(null),d=e.ref(null),p=e.ref([]),v={},u=e.ref(!1),m=e.ref(navigator.onLine),f=e.ref(""),w=e.ref([]),V=[{label:"7",value:"7"},{label:"8",value:"8"},{label:"9",value:"9"},{label:"4",value:"4"},{label:"5",value:"5"},{label:"6",value:"6"},{label:"1",value:"1"},{label:"2",value:"2"},{label:"3",value:"3"},{label:".",value:".",ariaLabel:"Decimal point"},{label:"0",value:"0"},{label:"⌫",value:"backspace",ariaLabel:"Backspace"}],g=e.computed(()=>r.value?_.value.filter(P=>P.location_id===r.value.id):[]),b=e.computed(()=>g.value.length===0?!1:p.value.every(P=>P!==""));e.onMounted(async()=>{if(h.loadQueue(),window.addEventListener("online",x),window.addEventListener("offline",$),await y(n.sessionId),await i(n.sessionId),n.locationId)try{const P=await c.fetchLocation(n.locationId);k(P)}catch{}}),e.onBeforeUnmount(()=>{window.removeEventListener("online",x),window.removeEventListener("offline",$)}),e.watch(g,P=>{p.value=P.map(z=>z.counted_quantity!==null?String(z.counted_quantity):""),d.value=P.findIndex(z=>z.counted_quantity===null),d.value===-1&&P.length>0&&(d.value=0)});function x(){m.value=!0,F()}function $(){m.value=!1}async function F(){await h.syncPendingCounts(async P=>{await l(P.sessionId,P.entryId,P.countedQuantity,P.notes)})}function k(P){r.value=P,h.setCurrentLocation(P.id)}function E(P){d.value=P,e.nextTick(()=>{var z;(z=v[P])==null||z.focus()})}function N(P){if(d.value===null)return;const z=d.value;let I=p.value[z];if(P==="backspace"){p.value[z]=I.slice(0,-1);return}if(P==="."){if(I.includes("."))return;p.value[z]=I+".";return}const O=g.value[z];if(O.counted_quantity!==null&&I===String(O.counted_quantity)){p.value[z]=P;return}p.value[z]=I+P}async function D(){u.value=!0;try{for(let P=0;P<g.value.length;P++){const z=p.value[P];if(z==="")continue;const I=g.value[P],O=parseFloat(z);if(!isNaN(O)&&!(I.counted_quantity!==null&&I.counted_quantity===O))if(m.value)try{await l(n.sessionId,I.id,O)}catch{h.queueCount({sessionId:n.sessionId,entryId:I.id,countedQuantity:O})}else h.queueCount({sessionId:n.sessionId,entryId:I.id,countedQuantity:O})}await i(n.sessionId),await y(n.sessionId)}finally{u.value=!1}}function S(){o.push({name:"inventory-scan"})}function C(){o.push({name:"inventory-count-detail",params:{id:n.sessionId}})}function L(){a.search(f.value),w.value=a.results.value}async function G(P){const z=await c.fetchLocation(P.id);k(z),f.value="",w.value=[]}return(P,z)=>(e.openBlock(),e.createElementBlock("div",ss,[e.createElementVNode("div",rs,[e.createElementVNode("button",{type:"button",class:"count-entry__back-btn","aria-label":"Go back",onClick:C},[...z[1]||(z[1]=[e.createElementVNode("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M13 4L7 10L13 16",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"})],-1),e.createElementVNode("span",null,"Back",-1)])]),e.unref(s)?(e.openBlock(),e.createElementBlock("span",is,e.toDisplayString(e.unref(s).name),1)):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createElementBlock("span",cs,e.toDisplayString(e.unref(s).progress.counted)+"/"+e.toDisplayString(e.unref(s).progress.total)+" locations ",1)):e.createCommentVNode("",!0)]),e.createElementVNode("div",{class:e.normalizeClass(["count-entry__connectivity",{"count-entry__connectivity--offline":!m.value}]),role:"status"},[m.value?(e.openBlock(),e.createElementBlock("span",ds)):(e.openBlock(),e.createElementBlock("span",us)),e.createElementVNode("span",null,e.toDisplayString(m.value?"Online":"Offline -- counts will sync when connected"),1)],2),r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",ms,[e.createVNode(j,{title:"Select Location"},{default:e.withCtx(()=>[z[4]||(z[4]=e.createElementVNode("p",{class:"count-entry__no-location-text"}," Scan a QR code or search for a location to begin counting. ",-1)),e.createElementVNode("div",ps,[e.createVNode(T,{variant:"primary",size:"lg",onClick:S},{"icon-left":e.withCtx(()=>[...z[2]||(z[2]=[e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"2",y:"2",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"11",y:"2",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"2",y:"11",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"11",y:"11",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"})],-1)])]),default:e.withCtx(()=>[z[3]||(z[3]=e.createTextVNode(" Scan QR Code ",-1))]),_:1}),e.createElementVNode("div",vs,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":z[0]||(z[0]=I=>f.value=I),type:"search",class:"count-entry__search-input",placeholder:"Search location by code...",onInput:L},null,544),[[e.vModelText,f.value]])]),w.value.length>0?(e.openBlock(),e.createElementBlock("ul",_s,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(w.value,I=>(e.openBlock(),e.createElementBlock("li",{key:I.id,role:"option","aria-selected":!1},[e.createElementVNode("button",{type:"button",class:"count-entry__search-result-btn",onClick:O=>G(I)},[e.createVNode(J,{code:I.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(I.name),1)],8,hs)]))),128))])):e.createCommentVNode("",!0)])]),_:1})])),r.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",fs,[e.createVNode(J,{code:r.value.full_code},null,8,["code"]),e.createElementVNode("div",ys,[e.createElementVNode("h2",ks,e.toDisplayString(r.value.name),1),r.value.path&&r.value.path.length>0?(e.openBlock(),e.createBlock(fe,{key:0,path:r.value.path,onNavigate:()=>{}},null,8,["path"])):e.createCommentVNode("",!0)])]),e.createElementVNode("div",gs,[g.value.length===0?(e.openBlock(),e.createElementBlock("p",Vs," No entries for this location. Generate entries first. ")):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(g.value,(I,O)=>(e.openBlock(),e.createElementBlock("div",{key:I.id,role:"listitem",class:e.normalizeClass(["count-entry__product-row",{"count-entry__product-row--selected":d.value===O,"count-entry__product-row--match":I.counted_quantity!==null&&I.discrepancy===0,"count-entry__product-row--discrepancy":I.counted_quantity!==null&&I.discrepancy!==null&&I.discrepancy!==0}]),onClick:X=>E(O)},[e.createElementVNode("div",Ns,[e.createElementVNode("span",ws,e.toDisplayString(I.product_name),1),e.createElementVNode("span",Es," Expected: "+e.toDisplayString(I.expected_quantity??"-"),1)]),e.createElementVNode("div",Cs,[e.createElementVNode("label",{for:`count-input-${I.id}`,class:"sr-only"}," Counted quantity for "+e.toDisplayString(I.product_name),9,Bs),e.createElementVNode("input",{id:`count-input-${I.id}`,ref_for:!0,ref:X=>{X&&(v[O]=X)},type:"text",inputmode:"decimal",class:e.normalizeClass(["count-entry__count-input",{"count-entry__count-input--match":p.value[O]!==""&&Number(p.value[O])===I.expected_quantity,"count-entry__count-input--discrepancy":p.value[O]!==""&&Number(p.value[O])!==I.expected_quantity}]),value:p.value[O],readonly:"",onFocus:X=>E(O)},null,42,$s),I.counted_quantity!==null&&I.discrepancy===0?(e.openBlock(),e.createElementBlock("span",xs," ✓ ")):I.counted_quantity!==null&&I.discrepancy!==null&&I.discrepancy!==0?(e.openBlock(),e.createElementBlock("span",Ss," ⚠ ")):e.createCommentVNode("",!0)])],10,bs))),128))]),e.createElementVNode("div",Ls,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(V,I=>e.createElementVNode("button",{key:I.label,type:"button",class:"count-entry__key","aria-label":I.ariaLabel||I.label,disabled:d.value===null,onClick:O=>N(I.value)},e.toDisplayString(I.label),9,Ds)),64))]),e.createElementVNode("div",zs,[e.createVNode(T,{variant:"primary",size:"lg",disabled:!b.value,loading:u.value,class:"count-entry__complete-btn",onClick:D},{default:e.withCtx(()=>[...z[5]||(z[5]=[e.createTextVNode(" Complete Location ",-1)])]),_:1},8,["disabled","loading"]),e.createVNode(T,{variant:"secondary",size:"lg",class:"count-entry__scan-next-btn",onClick:S},{"icon-left":e.withCtx(()=>[...z[6]||(z[6]=[e.createElementVNode("svg",{width:"18",height:"18",viewBox:"0 0 18 18",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"2",y:"2",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"11",y:"2",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"2",y:"11",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"11",y:"11",width:"5",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"})],-1)])]),default:e.withCtx(()=>[z[7]||(z[7]=e.createTextVNode(" Scan Next Location ",-1))]),_:1})])],64)):e.createCommentVNode("",!0)]))}}),Ms=H(Is,[["__scopeId","data-v-b11de393"]]),Ts={class:"count-report"},Fs={class:"count-report__header"},Ps={class:"count-report__title"},As={class:"count-report__actions"},Rs={class:"count-report__summary-grid"},qs={class:"count-report__summary-stat"},Us={class:"count-report__summary-value"},Hs={class:"count-report__summary-stat"},js={class:"count-report__summary-value"},Os={class:"count-report__summary-stat"},Ks={class:"count-report__summary-value"},Qs={class:"count-report__summary-stat"},Gs={class:"count-report__summary-value count-report__summary-value--muted"},Ws={class:"count-report__summary-stat"},Zs={class:"count-report__summary-stat"},Js={class:"count-report__totals"},Xs={class:"count-report__total-row"},Ys={class:"count-report__total-value"},er={class:"count-report__total-row"},tr={class:"count-report__total-value"},or={class:"count-report__total-row count-report__total-row--net"},nr={class:"count-report__disc-location"},ar={class:"count-report__disc-product"},lr={class:"count-report__disc-qty"},sr={class:"count-report__disc-qty"},rr=e.defineComponent({__name:"CountReport",props:{sessionId:{}},setup(t){const n=t,{report:o,loading:h,error:s,fetchReport:_}=se(),y=[{key:"location",label:"Location"},{key:"product",label:"Product"},{key:"expected",label:"Expected",align:"right",width:"100px"},{key:"counted",label:"Counted",align:"right",width:"100px"},{key:"discrepancy",label:"Δ",align:"right",width:"80px",sortable:!0}];e.onMounted(()=>i());async function i(){try{await _(n.sessionId)}catch{}}function l(r){return r.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}function c(){if(!o.value)return;const d=[["Location","Product","Expected","Counted","Discrepancy"],...o.value.top_discrepancies.map(m=>[m.location,m.product,String(m.expected),String(m.counted),String(m.discrepancy)])].map(m=>m.map(f=>`"${f.replace(/"/g,'""')}"`).join(",")).join(`
|
|
2
|
+
`),p=new Blob([d],{type:"text/csv;charset=utf-8;"}),v=URL.createObjectURL(p),u=document.createElement("a");u.href=v,u.download=`count-report-${n.sessionId}.csv`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(v)}function a(){window.print()}return(r,d)=>(e.openBlock(),e.createElementBlock("div",Ts,[e.unref(h)&&!e.unref(o)?(e.openBlock(),e.createBlock(j,{key:0,loading:""})):e.unref(s)&&!e.unref(o)?(e.openBlock(),e.createBlock(Y,{key:1,title:"Could not load report",description:e.unref(s)||"An unknown error occurred","action-label":"Retry",onAction:i},null,8,["description"])):e.createCommentVNode("",!0),e.unref(o)?(e.openBlock(),e.createElementBlock(e.Fragment,{key:2},[e.createElementVNode("div",Fs,[e.createElementVNode("h1",Ps," Count Report: "+e.toDisplayString(e.unref(o).session.name),1),e.createElementVNode("div",As,[e.createVNode(T,{variant:"secondary",size:"sm",onClick:c},{"icon-left":e.withCtx(()=>[...d[0]||(d[0]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("path",{d:"M4 10L8 14L12 10",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),e.createElementVNode("path",{d:"M8 14V2",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round"})],-1)])]),default:e.withCtx(()=>[d[1]||(d[1]=e.createTextVNode(" Export CSV ",-1))]),_:1}),e.createVNode(T,{variant:"secondary",size:"sm",onClick:a},{"icon-left":e.withCtx(()=>[...d[2]||(d[2]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"4",y:"1",width:"8",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"2",y:"6",width:"12",height:"6",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"5",y:"10",width:"6",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"})],-1)])]),default:e.withCtx(()=>[d[3]||(d[3]=e.createTextVNode(" Print Report ",-1))]),_:1})])]),e.createVNode(j,{title:"Summary",class:"count-report__summary"},{default:e.withCtx(()=>[e.createElementVNode("div",Rs,[e.createElementVNode("div",qs,[e.createElementVNode("span",Us,e.toDisplayString(e.unref(o).summary.total_entries),1),d[4]||(d[4]=e.createElementVNode("span",{class:"count-report__summary-label"},"Total Items",-1))]),e.createElementVNode("div",Hs,[e.createElementVNode("span",js,e.toDisplayString(e.unref(o).summary.counted),1),d[5]||(d[5]=e.createElementVNode("span",{class:"count-report__summary-label"},"Counted",-1))]),e.createElementVNode("div",Os,[e.createElementVNode("span",Ks,e.toDisplayString(e.unref(o).summary.verified),1),d[6]||(d[6]=e.createElementVNode("span",{class:"count-report__summary-label"},"Verified",-1))]),e.createElementVNode("div",Qs,[e.createElementVNode("span",Gs,e.toDisplayString(e.unref(o).summary.pending),1),d[7]||(d[7]=e.createElementVNode("span",{class:"count-report__summary-label"},"Pending",-1))]),e.createElementVNode("div",Ws,[e.createElementVNode("span",{class:e.normalizeClass(["count-report__summary-value",e.unref(o).summary.with_discrepancies>0?"count-report__summary-value--warning":"count-report__summary-value--success"])},e.toDisplayString(e.unref(o).summary.with_discrepancies),3),d[8]||(d[8]=e.createElementVNode("span",{class:"count-report__summary-label"},"Discrepancies",-1))]),e.createElementVNode("div",Zs,[e.createElementVNode("span",{class:e.normalizeClass(["count-report__summary-value",e.unref(o).summary.accuracy_percent>=95?"count-report__summary-value--success":e.unref(o).summary.accuracy_percent>=90?"count-report__summary-value--warning":"count-report__summary-value--error"])},e.toDisplayString(e.unref(o).summary.accuracy_percent.toFixed(1))+"% ",3),d[9]||(d[9]=e.createElementVNode("span",{class:"count-report__summary-label"},"Accuracy",-1))])]),e.createElementVNode("div",Js,[e.createElementVNode("div",Xs,[d[10]||(d[10]=e.createElementVNode("span",{class:"count-report__total-label"},"Total Expected",-1)),e.createElementVNode("span",Ys,e.toDisplayString(l(e.unref(o).summary.total_expected)),1)]),e.createElementVNode("div",er,[d[11]||(d[11]=e.createElementVNode("span",{class:"count-report__total-label"},"Total Counted",-1)),e.createElementVNode("span",tr,e.toDisplayString(l(e.unref(o).summary.total_counted)),1)]),e.createElementVNode("div",or,[d[12]||(d[12]=e.createElementVNode("span",{class:"count-report__total-label"},"Net Discrepancy",-1)),e.createElementVNode("span",{class:e.normalizeClass(["count-report__total-value",{"count-report__total-value--positive":e.unref(o).summary.net_discrepancy>0,"count-report__total-value--negative":e.unref(o).summary.net_discrepancy<0}])},e.toDisplayString(e.unref(o).summary.net_discrepancy>0?"+":"")+e.toDisplayString(l(e.unref(o).summary.net_discrepancy)),3)])])]),_:1}),e.createVNode(j,{title:"Top Discrepancies",class:"count-report__discrepancies","no-padding":""},{default:e.withCtx(()=>[e.createVNode(ne,{columns:y,data:e.unref(o).top_discrepancies,"empty-message":"No discrepancies found."},{"cell-location":e.withCtx(({value:p})=>[e.createElementVNode("span",nr,e.toDisplayString(p),1)]),"cell-product":e.withCtx(({value:p})=>[e.createElementVNode("span",ar,e.toDisplayString(p),1)]),"cell-expected":e.withCtx(({value:p})=>[e.createElementVNode("span",lr,e.toDisplayString(p),1)]),"cell-counted":e.withCtx(({value:p})=>[e.createElementVNode("span",sr,e.toDisplayString(p),1)]),"cell-discrepancy":e.withCtx(({value:p})=>[e.createElementVNode("span",{class:e.normalizeClass(["count-report__disc-delta",{"count-report__disc-delta--positive":p>0,"count-report__disc-delta--negative":p<0}])},e.toDisplayString(p>0?"+":"")+e.toDisplayString(p),3)]),_:1},8,["data"])]),_:1})],64)):e.createCommentVNode("",!0)]))}}),ir=H(rr,[["__scopeId","data-v-e12a8dba"]]),cr={class:"label-batch"},dr={class:"label-batch__format"},ur={class:"label-batch__quick-selectors"},mr=["onClick"],pr={class:"label-batch__filter-row"},vr=["onClick"],_r=["checked","indeterminate","aria-label","onClick"],hr={class:"label-batch__group-name"},fr={class:"label-batch__group-count"},yr={class:"label-batch__group-items"},kr=["checked","onChange"],gr={class:"label-batch__location-name"},Vr={key:3,class:"label-batch__footer"},br={class:"label-batch__selected-count"},Nr={class:"label-batch__footer-actions"},wr=e.defineComponent({__name:"LabelBatchPrint",setup(t){const{fetchRoots:n,locations:o}=ee(),{printBatch:h}=_e(),s=e.ref("standard"),_=e.reactive(new Set),y=e.reactive(new Set),i=e.ref(!0),l=e.ref(!1),c=e.ref(""),a=e.ref(""),r=e.ref([]),d=[{value:"standard",label:"Standard"},{value:"small",label:"Small"},{value:"pallet",label:"Pallet"}],p=e.computed(()=>{const S=new Set(r.value.map(L=>L.type)),C=[{value:"",label:"All Types"}];return S.forEach(L=>{C.push({value:L,label:L.charAt(0).toUpperCase()+L.slice(1)})}),C}),v=e.computed(()=>{const S=new Set;r.value.forEach(L=>{L.path&&L.path.length>0&&S.add(L.path[0].name)});const C=[{value:"",label:"All Buildings"}];return S.forEach(L=>{C.push({value:L,label:L})}),C}),u=e.computed(()=>{let S=r.value;return a.value&&(S=S.filter(C=>C.type===a.value)),c.value&&(S=S.filter(C=>C.path&&C.path.length>0&&C.path[0].name===c.value)),S}),m=e.computed(()=>{const S=new Map;for(const C of u.value){const L=C.path&&C.path.length>=2?C.path[C.path.length-2].name:C.path&&C.path.length===1?C.path[0].name:"Ungrouped";S.has(L)||S.set(L,[]),S.get(L).push(C)}return Array.from(S.entries()).map(([C,L])=>({parentName:C,locations:L})).sort((C,L)=>C.parentName.localeCompare(L.parentName))}),f=e.computed(()=>[{label:"All Shelves",action:()=>F("shelf")},{label:"All Racks",action:()=>F("rack")},{label:"All Bins",action:()=>F("bin")},{label:"Select All",action:k},{label:"Deselect All",action:E}]);e.onMounted(async()=>{i.value=!0;try{await n(),r.value=w(o.value),m.value.forEach(S=>y.add(S.parentName))}finally{i.value=!1}});function w(S){const C=[];function L(G,P){for(const z of G){const I=[...P||[],{id:z.id,name:z.name,code:z.code,full_code:z.full_code,type:z.type}];z.children&&z.children.length>0?L(z.children,I):C.push({...z,path:I})}}return L(S,[]),C}function V(S){y.has(S)?y.delete(S):y.add(S)}function g(S){_.has(S)?_.delete(S):_.add(S)}function b(S){return S.locations.every(C=>_.has(C.id))}function x(S){const C=S.locations.filter(L=>_.has(L.id)).length;return C>0&&C<S.locations.length}function $(S){b(S)?S.locations.forEach(C=>_.delete(C.id)):S.locations.forEach(C=>_.add(C.id))}function F(S){u.value.filter(C=>C.type===S).forEach(C=>_.add(C.id))}function k(){u.value.forEach(S=>_.add(S.id))}function E(){_.clear()}async function N(){if(_.size!==0){l.value=!0;try{await h(Array.from(_),s.value)}finally{l.value=!1}}}function D(){N()}return(S,C)=>(e.openBlock(),e.createElementBlock("div",cr,[C[6]||(C[6]=e.createElementVNode("div",{class:"label-batch__header"},[e.createElementVNode("h1",{class:"label-batch__title"},"Print Labels")],-1)),e.createElementVNode("div",dr,[e.createVNode(oe,{modelValue:s.value,"onUpdate:modelValue":C[0]||(C[0]=L=>s.value=L),options:d,label:"Format"},null,8,["modelValue"])]),e.createVNode(j,{title:"Select locations to print",class:"label-batch__selectors"},{default:e.withCtx(()=>[e.createElementVNode("div",ur,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,L=>(e.openBlock(),e.createElementBlock("button",{key:L.label,type:"button",class:"label-batch__quick-btn",onClick:L.action},e.toDisplayString(L.label),9,mr))),128))]),e.createElementVNode("div",pr,[e.createVNode(oe,{modelValue:c.value,"onUpdate:modelValue":C[1]||(C[1]=L=>c.value=L),options:v.value,placeholder:"By Building"},null,8,["modelValue","options"]),e.createVNode(oe,{modelValue:a.value,"onUpdate:modelValue":C[2]||(C[2]=L=>a.value=L),options:p.value,placeholder:"By Type"},null,8,["modelValue","options"])])]),_:1}),i.value?(e.openBlock(),e.createBlock(j,{key:0,loading:""})):m.value.length>0?(e.openBlock(),e.createBlock(j,{key:1,class:"label-batch__locations","no-padding":""},{default:e.withCtx(()=>[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(m.value,L=>(e.openBlock(),e.createElementBlock("div",{key:L.parentName,class:"label-batch__group"},[e.createElementVNode("button",{type:"button",class:"label-batch__group-header",onClick:G=>V(L.parentName)},[e.createElementVNode("input",{type:"checkbox",checked:b(L),indeterminate:x(L),class:"label-batch__checkbox","aria-label":`Select all in ${L.parentName}`,onClick:e.withModifiers(G=>$(L),["stop"])},null,8,_r),e.createElementVNode("span",hr,e.toDisplayString(L.parentName),1),e.createElementVNode("span",fr,e.toDisplayString(L.locations.length),1),(e.openBlock(),e.createElementBlock("svg",{class:e.normalizeClass(["label-batch__group-chevron",{"label-batch__group-chevron--collapsed":!y.has(L.parentName)}]),width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[...C[3]||(C[3]=[e.createElementVNode("path",{d:"M4 6L8 10L12 6",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])],2))],8,vr),e.withDirectives(e.createElementVNode("div",yr,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(L.locations,G=>(e.openBlock(),e.createElementBlock("label",{key:G.id,class:"label-batch__location-row"},[e.createElementVNode("input",{type:"checkbox",checked:_.has(G.id),class:"label-batch__checkbox",onChange:P=>g(G.id)},null,40,kr),e.createVNode(J,{code:G.full_code},null,8,["code"]),e.createElementVNode("span",gr,e.toDisplayString(G.name),1),e.createVNode(Z,{variant:"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(G.type_label),1)]),_:2},1024)]))),128))],512),[[e.vShow,y.has(L.parentName)]])]))),128))]),_:1})):i.value?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(Y,{key:2,title:"No locations found",description:"Create locations first to generate labels."})),_.size>0?(e.openBlock(),e.createElementBlock("div",Vr,[e.createElementVNode("span",br," Selected: "+e.toDisplayString(_.size)+" label"+e.toDisplayString(_.size!==1?"s":""),1),e.createElementVNode("div",Nr,[e.createVNode(T,{variant:"secondary",size:"md",onClick:D},{default:e.withCtx(()=>[...C[4]||(C[4]=[e.createTextVNode(" Preview All ",-1)])]),_:1}),e.createVNode(T,{variant:"primary",size:"md",loading:l.value,onClick:N},{"icon-left":e.withCtx(()=>[...C[5]||(C[5]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"4",y:"1",width:"8",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"2",y:"6",width:"12",height:"6",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"5",y:"10",width:"6",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"})],-1)])]),default:e.withCtx(()=>[e.createTextVNode(" Print "+e.toDisplayString(_.size)+" Labels ",1)]),_:1},8,["loading"])])])):e.createCommentVNode("",!0)]))}}),Er=H(wr,[["__scopeId","data-v-1eb7f5c2"]]),Cr=["aria-label","onClick"],Br={class:"pll-location-path"},$r={class:"pll-quantity"},xr={key:0,class:"pll-primary-star",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Primary location"},Sr={key:1,class:"pll-no-primary","aria-label":"Not primary location"},Lr={class:"pll-footer"},Dr={class:"pll-total-value"},zr=e.defineComponent({__name:"ProductLocationList",props:{productId:{}},emits:["navigate"],setup(t,{emit:n}){const o=t,h=n,{loading:s,fetchProductLocations:_}=te(),y=e.ref([]),i=[{key:"path",label:"Location",sortable:!1},{key:"code",label:"Code",sortable:!1,width:"120px"},{key:"quantity",label:"Qty",sortable:!1,width:"80px",align:"right"},{key:"is_primary",label:"Primary",sortable:!1,width:"80px",align:"center"}],l=e.computed(()=>y.value.reduce((p,v)=>p+v.quantity,0));function c(p){return Number.isInteger(p)?p.toFixed(0):p.toFixed(2)}function a(p){var v,u;return(v=p.location)!=null&&v.path?p.location.path.map(m=>m.name).concat([p.location.name]).join(" > "):((u=p.location)==null?void 0:u.name)??"Unknown location"}function r(p){p.location&&h("navigate",p.location)}async function d(){try{y.value=await _(o.productId)}catch{y.value=[]}}return e.watch(()=>o.productId,p=>{p&&d()},{immediate:!0}),(p,v)=>(e.openBlock(),e.createBlock(j,{title:"Locations",loading:e.unref(s),"no-padding":""},{default:e.withCtx(()=>[!e.unref(s)&&y.value.length===0?(e.openBlock(),e.createBlock(Y,{key:0,title:"No locations tracked",description:"This product is not currently tracked at any location."})):e.unref(s)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createVNode(ne,{columns:i,data:y.value,"empty-message":"No locations found."},{"cell-path":e.withCtx(({row:u})=>{var m;return[e.createElementVNode("button",{type:"button",class:"pll-location-link","aria-label":`Navigate to ${((m=u.location)==null?void 0:m.name)??"location"}`,onClick:f=>r(u)},[e.createElementVNode("span",Br,e.toDisplayString(a(u)),1)],8,Cr)]}),"cell-code":e.withCtx(({row:u})=>{var m,f;return[(m=u.location)!=null&&m.full_code?(e.openBlock(),e.createBlock(Z,{key:0,variant:"default",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.location.full_code),1)]),_:2},1024)):(f=u.location)!=null&&f.code?(e.openBlock(),e.createBlock(Z,{key:1,variant:"default",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(u.location.code),1)]),_:2},1024)):e.createCommentVNode("",!0)]}),"cell-quantity":e.withCtx(({row:u})=>[e.createElementVNode("span",$r,e.toDisplayString(c(u.quantity)),1)]),"cell-is_primary":e.withCtx(({row:u})=>[u.is_primary?(e.openBlock(),e.createElementBlock("svg",xr,[...v[0]||(v[0]=[e.createElementVNode("path",{d:"M9 1.5L11.3 6.2L16.5 6.9L12.75 10.55L13.6 15.75L9 13.3L4.4 15.75L5.25 10.55L1.5 6.9L6.7 6.2L9 1.5Z",fill:"currentColor",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"},null,-1)])])):(e.openBlock(),e.createElementBlock("span",Sr))]),_:1},8,["data"]),e.createElementVNode("div",Lr,[v[1]||(v[1]=e.createElementVNode("span",{class:"pll-total-label"},"Total:",-1)),e.createElementVNode("span",Dr,e.toDisplayString(c(l.value))+" across "+e.toDisplayString(y.value.length)+" location"+e.toDisplayString(y.value.length!==1?"s":""),1)])],64))]),_:1},8,["loading"]))}}),Ir=H(zr,[["__scopeId","data-v-47c4cd6e"]]),Mr={class:"label-preview"},Tr={class:"label-preview__controls"},Fr={key:0,class:"label-preview__loading",role:"status"},Pr={key:1,class:"label-preview__error",role:"alert"},Ar={class:"label-preview__error-text"},Rr={key:2,class:"label-preview__container"},qr={class:"label-preview__path"},Ur={class:"label-preview__code"},Hr={class:"label-preview__name"},jr=["innerHTML"],Or=["innerHTML"],Kr={key:3,class:"label-preview__print"},Qr=e.defineComponent({__name:"LabelPreview",props:{locationId:{},format:{default:"standard"}},emits:["print"],setup(t,{emit:n}){const o=t,h=n,{labelData:s,loading:_,error:y,fetchLabel:i,printLabel:l}=_e(),c=e.ref(o.format),a=e.ref(!1),r=[{value:"standard",label:"Standard"},{value:"small",label:"Small"},{value:"pallet",label:"Pallet"}],d=e.computed(()=>{var u;return(u=s.value)!=null&&u.size?{width:s.value.size.width,height:s.value.size.height}:{}});e.onMounted(()=>p()),e.watch(c,()=>p());async function p(){try{await i(o.locationId,c.value)}catch{}}async function v(){a.value=!0;try{await l(o.locationId,c.value),h("print")}catch{}finally{a.value=!1}}return(u,m)=>(e.openBlock(),e.createElementBlock("div",Mr,[e.createElementVNode("div",Tr,[e.createVNode(oe,{modelValue:c.value,"onUpdate:modelValue":m[0]||(m[0]=f=>c.value=f),options:r,label:"Format"},null,8,["modelValue"])]),e.unref(_)?(e.openBlock(),e.createElementBlock("div",Fr,[...m[1]||(m[1]=[e.createElementVNode("div",{class:"label-preview__loading-spinner","aria-hidden":"true"},null,-1),e.createElementVNode("span",{class:"sr-only"},"Loading label...",-1)])])):e.unref(y)?(e.openBlock(),e.createElementBlock("div",Pr,[e.createElementVNode("p",Ar,e.toDisplayString(e.unref(y)),1),e.createVNode(T,{variant:"secondary",size:"sm",onClick:p},{default:e.withCtx(()=>[...m[2]||(m[2]=[e.createTextVNode(" Retry ",-1)])]),_:1})])):e.unref(s)?(e.openBlock(),e.createElementBlock("div",Rr,[e.createElementVNode("div",{class:"label-preview__label",style:e.normalizeStyle(d.value)},[e.createElementVNode("p",qr,e.toDisplayString(e.unref(s).path),1),e.createElementVNode("p",Ur,e.toDisplayString(e.unref(s).location.full_code),1),e.createElementVNode("p",Hr,e.toDisplayString(e.unref(s).location.name),1),e.unref(s).barcode_svg?(e.openBlock(),e.createElementBlock("div",{key:0,class:"label-preview__barcode","aria-label":"Barcode",innerHTML:e.unref(s).barcode_svg},null,8,jr)):e.createCommentVNode("",!0),e.unref(s).qr_code_svg?(e.openBlock(),e.createElementBlock("div",{key:1,class:"label-preview__qr","aria-label":"QR code",innerHTML:e.unref(s).qr_code_svg},null,8,Or)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createElementBlock("div",Kr,[e.createVNode(T,{variant:"primary",size:"md",loading:a.value,onClick:v},{"icon-left":e.withCtx(()=>[...m[3]||(m[3]=[e.createElementVNode("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},[e.createElementVNode("rect",{x:"4",y:"1",width:"8",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"2",y:"6",width:"12",height:"6",rx:"1",stroke:"currentColor","stroke-width":"1.5"}),e.createElementVNode("rect",{x:"5",y:"10",width:"6",height:"5",rx:"1",stroke:"currentColor","stroke-width":"1.5"})],-1)])]),default:e.withCtx(()=>[m[4]||(m[4]=e.createTextVNode(" Print Label ",-1))]),_:1},8,["loading"])])):e.createCommentVNode("",!0)]))}}),Gr=H(Qr,[["__scopeId","data-v-c9c4e755"]]),Wr={class:"unlocated-products"},Zr={class:"unlocated-products__header"},Jr={key:0,class:"unlocated-products__subtitle"},Xr={class:"unlocated-products__product-name"},Yr={key:0,class:"unlocated-products__sku"},ei={key:1,class:"unlocated-products__no-sku"},ti={key:0,class:"unlocated-products__load-more"},oi={class:"unlocated-products__showing"},ni={class:"unlocated-products__locate-form"},ai={class:"unlocated-products__locate-search"},li={key:0,class:"unlocated-products__locate-results",role:"listbox","aria-label":"Location search results"},si=["aria-selected"],ri=["onClick"],ii={class:"unlocated-products__locate-option-name"},ci={key:1,class:"unlocated-products__locate-no-results"},di={key:2,class:"unlocated-products__locate-selected"},ui=e.defineComponent({__name:"UnlocatedProducts",props:{limit:{default:50}},emits:["locate"],setup(t,{emit:n}){const o=t,h=n,s=ie(),{addProduct:_}=te(),y=e.ref([]),i=e.ref(0),l=e.ref(!1),c=e.ref(!1),a=e.ref(1),r=e.ref(!1),d=e.ref(null),p=e.ref(""),v=e.ref([]),u=e.ref(null),m=e.ref(!1),f=e.ref(!1),w=[{key:"name",label:"Product"},{key:"sku",label:"SKU",width:"150px"},{key:"actions",label:"",width:"100px",align:"right"}],V=e.computed(()=>y.value.length<i.value);e.onMounted(()=>g());async function g(N=!1){var D;N?c.value=!0:l.value=!0;try{const S=await R().get(q(`/dashboard/unlocated-products?limit=${o.limit}&page=${a.value}`)),C=S.data.data||S.data;i.value=((D=S.data.meta)==null?void 0:D.total)??C.length,N?y.value.push(...C):y.value=C}catch{}finally{l.value=!1,c.value=!1}}function b(){a.value++,g(!0)}function x(N){d.value=N,r.value=!0,p.value="",v.value=[],u.value=null,h("locate",{id:N.id,name:N.name})}function $(){m.value=!0,s.search(p.value);const N=setInterval(()=>{s.loading.value||(v.value=s.results.value,m.value=!1,clearInterval(N))},100);setTimeout(()=>{clearInterval(N),m.value=!1,v.value=s.results.value},2e3)}function F(N){u.value=N,v.value=[],p.value=""}function k(){r.value=!1,d.value=null,u.value=null,p.value="",v.value=[]}async function E(){if(!(!u.value||!d.value)){f.value=!0;try{await _(u.value.id,{product_id:d.value.id,quantity:1}),y.value=y.value.filter(N=>N.id!==d.value.id),i.value=Math.max(0,i.value-1),k()}catch{}finally{f.value=!1}}}return(N,D)=>{var S;return e.openBlock(),e.createElementBlock("div",Wr,[e.createElementVNode("div",Zr,[e.createElementVNode("div",null,[D[2]||(D[2]=e.createElementVNode("h2",{class:"unlocated-products__title"},"Unlocated Products",-1)),i.value>0?(e.openBlock(),e.createElementBlock("p",Jr,e.toDisplayString(i.value)+" product"+e.toDisplayString(i.value!==1?"s":"")+" have no assigned warehouse location ",1)):e.createCommentVNode("",!0)])]),l.value&&y.value.length===0?(e.openBlock(),e.createBlock(j,{key:0,loading:""})):y.value.length>0?(e.openBlock(),e.createBlock(j,{key:1,"no-padding":""},{default:e.withCtx(()=>[e.createVNode(ne,{columns:w,data:y.value,"empty-message":"All products have assigned locations."},{"cell-name":e.withCtx(({row:C})=>[e.createElementVNode("span",Xr,e.toDisplayString(C.name),1)]),"cell-sku":e.withCtx(({row:C})=>[C.sku?(e.openBlock(),e.createElementBlock("span",Yr,e.toDisplayString(C.sku),1)):(e.openBlock(),e.createElementBlock("span",ei,"no SKU"))]),"cell-actions":e.withCtx(({row:C})=>[e.createVNode(T,{variant:"primary",size:"sm",onClick:L=>x(C)},{default:e.withCtx(()=>[...D[3]||(D[3]=[e.createTextVNode(" Locate ",-1)])]),_:1},8,["onClick"])]),_:1},8,["data"]),V.value?(e.openBlock(),e.createElementBlock("div",ti,[e.createElementVNode("p",oi," Showing "+e.toDisplayString(y.value.length)+" of "+e.toDisplayString(i.value),1),e.createVNode(T,{variant:"ghost",size:"sm",loading:c.value,onClick:b},{default:e.withCtx(()=>[...D[4]||(D[4]=[e.createTextVNode(" Load More ",-1)])]),_:1},8,["loading"])])):e.createCommentVNode("",!0)]),_:1})):(e.openBlock(),e.createBlock(Y,{key:2,title:"All products located",description:"Every product in inventory has an assigned warehouse location."})),e.createVNode(he,{show:r.value,title:`Locate: ${((S=d.value)==null?void 0:S.name)??""}`,description:"Search for a location to assign this product.",size:"md","onUpdate:show":D[1]||(D[1]=C=>r.value=C),onClose:k},{footer:e.withCtx(()=>[e.createVNode(T,{variant:"ghost",size:"sm",onClick:k},{default:e.withCtx(()=>[...D[7]||(D[7]=[e.createTextVNode(" Cancel ",-1)])]),_:1}),e.createVNode(T,{variant:"primary",size:"sm",disabled:!u.value,loading:f.value,onClick:E},{default:e.withCtx(()=>[...D[8]||(D[8]=[e.createTextVNode(" Assign Location ",-1)])]),_:1},8,["disabled","loading"])]),default:e.withCtx(()=>[e.createElementVNode("div",ni,[e.createElementVNode("div",ai,[D[5]||(D[5]=e.createElementVNode("label",{for:"locate-search-input",class:"unlocated-products__locate-label"}," Location ",-1)),e.withDirectives(e.createElementVNode("input",{id:"locate-search-input","onUpdate:modelValue":D[0]||(D[0]=C=>p.value=C),type:"search",class:"unlocated-products__locate-input",placeholder:"Search by code or name...",onInput:$},null,544),[[e.vModelText,p.value]])]),v.value.length>0?(e.openBlock(),e.createElementBlock("ul",li,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,C=>{var L,G;return e.openBlock(),e.createElementBlock("li",{key:C.id,role:"option","aria-selected":((L=u.value)==null?void 0:L.id)===C.id},[e.createElementVNode("button",{type:"button",class:e.normalizeClass(["unlocated-products__locate-option",{"unlocated-products__locate-option--selected":((G=u.value)==null?void 0:G.id)===C.id}]),onClick:P=>F(C)},[e.createVNode(J,{code:C.full_code},null,8,["code"]),e.createElementVNode("span",ii,e.toDisplayString(C.name),1),e.createVNode(Z,{variant:"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(C.type_label),1)]),_:2},1024)],10,ri)],8,si)}),128))])):e.createCommentVNode("",!0),p.value.length>=2&&v.value.length===0&&!m.value?(e.openBlock(),e.createElementBlock("p",ci," No locations found ")):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",di,[D[6]||(D[6]=e.createElementVNode("span",{class:"unlocated-products__locate-selected-label"},"Assign to:",-1)),e.createVNode(J,{code:u.value.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(u.value.name),1)])):e.createCommentVNode("",!0)])]),_:1},8,["show","title"])])}}}),mi=H(ui,[["__scopeId","data-v-9a21fb9b"]]),pi={install(t,n={}){Se({prefix:n.apiPrefix||"/api/inventory-locator/v1"})}};exports.CountEntryForm=Ms;exports.CountReport=ir;exports.CountSessionDetail=ls;exports.CountSessionList=$l;exports.InventoryDashboard=At;exports.InventoryLocatorPlugin=pi;exports.InventoryLocatorShell=ca;exports.LabelBatchPrint=Er;exports.LabelPreview=Gr;exports.LocationBreadcrumb=fe;exports.LocationCodeBadge=J;exports.LocationDetail=Ie;exports.LocationSearchInput=De;exports.LocationTree=ze;exports.LocationTypeIcon=re;exports.ProductLocationList=Ir;exports.ScanHistory=Te;exports.ScanResult=Me;exports.ScannerOverlay=Ja;exports.UnlocatedProducts=mi;exports.configureApiClient=Se;exports.useCountSessions=se;exports.useCountStore=ve;exports.useLabelPrinting=_e;exports.useLocationBreadcrumbs=Ae;exports.useLocationProducts=te;exports.useLocationSearch=ie;exports.useLocationStore=le;exports.useLocations=ee;exports.useMovements=pe;exports.useScanner=Le;exports.useScannerStore=we;
|