@codingfactory/inventory-locator-client 0.1.0 → 0.1.2

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.cjs ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("vue"),we=require("pinia"),Pe=require("axios"),ne=require("vue-router"),le=we.defineStore("inventoryLocation",()=>{const t=e.ref([]),a=e.ref(null),o=e.ref(new Set),h=e.ref(new Map),s=e.ref(!1);function _(u){const p=f=>{for(const N of f){if(N.id===u)return N;if(N.children){const b=p(N.children);if(b)return b}}return null};return p(t.value)}const y=e.computed(()=>a.value?_(a.value):null),i=e.computed(()=>u=>o.value.has(u));function l(u){t.value=u}function c(u){a.value=u}function n(u){o.value.has(u)?o.value.delete(u):o.value.add(u)}function r(u,p){h.value.set(u,p)}function d(u){const p=f=>{for(let N=0;N<f.length;N++){if(f[N].id===u.id)return f[N]={...f[N],...u},!0;if(f[N].children&&p(f[N].children))return!0}return!1};p(t.value)}function m(u){const p=f=>{const N=f.findIndex(b=>b.id===u);if(N!==-1)return f.splice(N,1),!0;for(const b of f)if(b.children&&p(b.children))return!0;return!1};p(t.value),a.value===u&&(a.value=null)}function v(){t.value=[],a.value=null,o.value.clear(),h.value.clear()}return{roots:t,selectedLocationId:a,expandedNodeIds:o,childrenCache:h,loading:s,selectedLocation:y,isExpanded:i,setRoots:l,selectLocation:c,toggleExpand:n,cacheChildren:r,updateLocationInTree:d,removeLocationFromTree:m,findInTree:_,reset:v}}),Ne=we.defineStore("inventoryScanner",()=>{const t=e.ref([]),a=e.ref(null);function o(_){t.value.unshift({..._,scannedAt:new Date().toISOString()}),t.value.length>20&&(t.value=t.value.slice(0,20)),a.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=[],a.value=null,sessionStorage.removeItem("inv-scan-history")}return{history:t,lastScannedCode:a,addToHistory:o,loadFromSession:h,clearHistory:s}}),ve=we.defineStore("inventoryCount",()=>{const t=e.ref(null),a=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,a.value=null}function l(v){a.value=v}function c(v){o.value.push({...v,queuedAt:new Date().toISOString()}),r()}function n(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 m(v){const u=[...o.value];for(const p of u)try{await v(p),n(p.entryId)}catch{break}}return{activeSessionId:t,currentLocationId:a,pendingSubmissions:o,isOnline:h,hasPendingSubmissions:s,isCountingMode:_,startCounting:y,stopCounting:i,setCurrentLocation:l,queueCount:c,removeFromQueue:n,persistQueue:r,loadQueue:d,syncPendingCounts:m}});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([]),a=e.ref(!1),o=e.ref(null),h=le();async function s(){var v,u;a.value=!0,o.value=null;try{const f=(await R().get(q("/locations"))).data.data;return h.setRoots(f),t.value=f,f}catch(p){throw o.value=((u=(v=p.response)==null?void 0:v.data)==null?void 0:u.message)||"Failed to load locations",p}finally{a.value=!1}}async function _(v){var u,p;a.value=!0,o.value=null;try{return(await R().get(q(`/locations/${v}?include_path=1`))).data.data}catch(f){throw o.value=((p=(u=f.response)==null?void 0:u.data)==null?void 0:p.message)||"Failed to load location",f}finally{a.value=!1}}async function y(v){var p,f;const u=h.childrenCache.get(v);if(u)return u;try{const b=(await R().get(q(`/locations/${v}`))).data.data.children||[];return h.cacheChildren(v,b),b}catch(N){throw o.value=((f=(p=N.response)==null?void 0:p.data)==null?void 0:f.message)||"Failed to load children",N}}async function i(v){var u,p;a.value=!0,o.value=null;try{return(await R().get(q(`/locations/${v}/tree`))).data}catch(f){throw o.value=((p=(u=f.response)==null?void 0:u.data)==null?void 0:p.message)||"Failed to load tree",f}finally{a.value=!1}}async function l(v){var u,p;a.value=!0,o.value=null;try{const N=(await R().post(q("/locations"),v)).data.data;return await s(),N}catch(f){throw o.value=((p=(u=f.response)==null?void 0:u.data)==null?void 0:p.message)||"Failed to create location",f}finally{a.value=!1}}async function c(v,u){var p,f;a.value=!0,o.value=null;try{const b=(await R().put(q(`/locations/${v}`),u)).data.data;return h.updateLocationInTree(b),b}catch(N){throw o.value=((f=(p=N.response)==null?void 0:p.data)==null?void 0:f.message)||"Failed to update location",N}finally{a.value=!1}}async function n(v){var u,p;a.value=!0,o.value=null;try{await R().delete(q(`/locations/${v}`)),h.removeLocationFromTree(v)}catch(f){throw o.value=((p=(u=f.response)==null?void 0:u.data)==null?void 0:p.message)||"Failed to delete location",f}finally{a.value=!1}}async function r(v,u){var p,f;a.value=!0,o.value=null;try{const b=(await R().post(q(`/locations/${v}/move`),{parent_id:u})).data.data;return await s(),b}catch(N){throw o.value=((f=(p=N.response)==null?void 0:p.data)==null?void 0:f.message)||"Failed to move location",N}finally{a.value=!1}}async function d(){var v,u;try{return(await R().get(q("/locations/types"))).data}catch(p){throw o.value=((u=(v=p.response)==null?void 0:v.data)==null?void 0:u.message)||"Failed to load types",p}}async function m(v){var u;try{return(await R().get(q(`/scan/${encodeURIComponent(v)}`))).data.data}catch(p){if(((u=p.response)==null?void 0:u.status)===404)return null;throw p}}return{locations:t,loading:a,error:o,fetchRoots:s,fetchLocation:_,fetchChildren:y,fetchTree:i,create:l,update:c,remove:n,move:r,fetchTypes:d,scanLookup:m}}function te(){const t=e.ref([]),a=e.ref(!1),o=e.ref(null);async function h(n){var r,d;a.value=!0,o.value=null;try{const m=await R().get(q(`/locations/${n}/products`));t.value=m.data.data}catch(m){throw o.value=((d=(r=m.response)==null?void 0:r.data)==null?void 0:d.message)||"Failed to load products",m}finally{a.value=!1}}async function s(n,r){var d,m;a.value=!0,o.value=null;try{const u=(await R().post(q(`/locations/${n}/products`),r)).data.data;return await h(n),u}catch(v){throw o.value=((m=(d=v.response)==null?void 0:d.data)==null?void 0:m.message)||"Failed to add product",v}finally{a.value=!1}}async function _(n,r,d){var m,v;a.value=!0,o.value=null;try{const p=(await R().patch(q(`/locations/${n}/products/${r}`),d)).data.data,f=t.value.findIndex(N=>N.product_id===r);return f!==-1&&(t.value[f]=p),p}catch(u){throw o.value=((v=(m=u.response)==null?void 0:m.data)==null?void 0:v.message)||"Failed to update product",u}finally{a.value=!1}}async function y(n,r,d){var m,v;a.value=!0,o.value=null;try{const u=d!==void 0?`?quantity=${d}`:"";await R().delete(q(`/locations/${n}/products/${r}${u}`)),t.value=t.value.filter(p=>p.product_id!==r)}catch(u){throw o.value=((v=(m=u.response)==null?void 0:m.data)==null?void 0:v.message)||"Failed to remove product",u}finally{a.value=!1}}async function i(n,r){var d,m;a.value=!0,o.value=null;try{await R().post(q(`/products/${n}/move`),r)}catch(v){throw o.value=((m=(d=v.response)==null?void 0:d.data)==null?void 0:m.message)||"Failed to move product",v}finally{a.value=!1}}async function l(n,r){var d,m;a.value=!0,o.value=null;try{await R().post(q(`/locations/${n}/products/bulk`),{items:r}),await h(n)}catch(v){throw o.value=((m=(d=v.response)==null?void 0:d.data)==null?void 0:m.message)||"Failed to bulk add products",v}finally{a.value=!1}}async function c(n){var r,d;a.value=!0,o.value=null;try{return(await R().get(q(`/products/${n}/locations`))).data.data}catch(m){throw o.value=((d=(r=m.response)==null?void 0:r.data)==null?void 0:d.message)||"Failed to load product locations",m}finally{a.value=!1}}return{products:t,loading:a,error:o,fetchProducts:h,addProduct:s,updateProduct:_,removeProduct:y,moveProduct:i,bulkAdd:l,fetchProductLocations:c}}function ie(){const t=e.ref([]),a=e.ref(""),o=e.ref(!1),h=e.ref(null);let s=null;function _(i,l){if(a.value=i,s&&clearTimeout(s),!i||i.length<2){t.value=[];return}s=setTimeout(async()=>{var c,n;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=((n=(c=r.response)==null?void 0:c.data)==null?void 0:n.message)||"Search failed"}finally{o.value=!1}},300)}function y(){a.value="",t.value=[],s&&clearTimeout(s)}return{results:t,query:a,loading:o,error:h,search:_,clear:y}}function Le(){var n;const t=e.ref(!1),a=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"&&!!((n=navigator.mediaDevices)!=null&&n.getUserMedia);async function i(r,d){if(!h.value){o.value="Camera scanning not supported in this browser";return}try{const{Html5Qrcode:m,Html5QrcodeSupportedFormats:v}=await Promise.resolve().then(()=>require("./index-D6KBu_HL.cjs"));y=new m(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=>{a.value=u,navigator.vibrate&&navigator.vibrate(100),d(u)},()=>{})}catch(m){o.value=(m==null?void 0:m.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:a,error:o,isSupported:h,hasFlash:s,flashOn:_,startScanning:i,stopScanning:l,toggleFlash:c}}function se(){const t=e.ref([]),a=e.ref(null),o=e.ref([]),h=e.ref(null),s=e.ref(!1),_=e.ref(null);async function y(p){var f,N;s.value=!0,_.value=null;try{const b=p?`?status=${p}`:"",g=await R().get(q(`/counts${b}`));t.value=g.data.data}catch(b){throw _.value=((N=(f=b.response)==null?void 0:f.data)==null?void 0:N.message)||"Failed to load sessions",b}finally{s.value=!1}}async function i(p,f){var N,b;s.value=!0,_.value=null;try{const V=(await R().post(q("/counts"),{name:p,scope_location_id:f||null})).data.data;return t.value.unshift(V),V}catch(g){throw _.value=((b=(N=g.response)==null?void 0:N.data)==null?void 0:b.message)||"Failed to create session",g}finally{s.value=!1}}async function l(p){var f,N;s.value=!0,_.value=null;try{const b=await R().get(q(`/counts/${p}`));return a.value=b.data.data,b.data.data}catch(b){throw _.value=((N=(f=b.response)==null?void 0:f.data)==null?void 0:N.message)||"Failed to load session",b}finally{s.value=!1}}async function c(p,f){var N,b;s.value=!0,_.value=null;try{const g=await R().patch(q(`/counts/${p}`),{status:f});a.value=g.data.data}catch(g){throw _.value=((b=(N=g.response)==null?void 0:N.data)==null?void 0:b.message)||"Failed to update session",g}finally{s.value=!1}}async function n(p){var f,N;s.value=!0,_.value=null;try{return(await R().post(q(`/counts/${p}/generate`))).data}catch(b){throw _.value=((N=(f=b.response)==null?void 0:f.data)==null?void 0:N.message)||"Failed to generate entries",b}finally{s.value=!1}}async function r(p,f){var N,b;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 V=await R().get(q(`/counts/${p}/entries?${g}`));o.value=V.data.data}catch(g){throw _.value=((b=(N=g.response)==null?void 0:N.data)==null?void 0:b.message)||"Failed to load entries",g}finally{s.value=!1}}async function d(p,f,N,b){var g,V;_.value=null;try{const $=(await R().post(q(`/counts/${p}/entries/${f}/count`),{counted_quantity:N,notes:b})).data.data,F=o.value.findIndex(k=>k.id===f);return F!==-1&&(o.value[F]=$),$}catch(x){throw _.value=((V=(g=x.response)==null?void 0:g.data)==null?void 0:V.message)||"Failed to submit count",x}}async function m(p,f){var N,b;_.value=null;try{const V=(await R().post(q(`/counts/${p}/entries/${f}/verify`))).data.data,x=o.value.findIndex($=>$.id===f);return x!==-1&&(o.value[x]=V),V}catch(g){throw _.value=((b=(N=g.response)==null?void 0:N.data)==null?void 0:b.message)||"Failed to verify entry",g}}async function v(p){var f,N;s.value=!0,_.value=null;try{return(await R().post(q(`/counts/${p}/apply`))).data}catch(b){throw _.value=((N=(f=b.response)==null?void 0:f.data)==null?void 0:N.message)||"Failed to apply session",b}finally{s.value=!1}}async function u(p){var f,N;s.value=!0,_.value=null;try{const b=await R().get(q(`/counts/${p}/report`));return h.value=b.data,b.data}catch(b){throw _.value=((N=(f=b.response)==null?void 0:f.data)==null?void 0:N.message)||"Failed to load report",b}finally{s.value=!1}}return{sessions:t,currentSession:a,entries:o,report:h,loading:s,error:_,fetchSessions:y,createSession:i,fetchSession:l,updateStatus:c,generateEntries:n,fetchEntries:r,submitCount:d,verifyEntry:m,applySession:v,fetchReport:u}}function me(){const t=e.ref([]),a=e.ref(!1),o=e.ref(null);async function h(i){var l,c;a.value=!0,o.value=null;try{const n=new URLSearchParams;i!=null&&i.reason&&n.set("reason",i.reason),i!=null&&i.from_date&&n.set("from_date",i.from_date),i!=null&&i.to_date&&n.set("to_date",i.to_date);const r=await R().get(q(`/movements?${n}`));t.value=r.data.data}catch(n){throw o.value=((c=(l=n.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",n}finally{a.value=!1}}async function s(i){var l,c;a.value=!0,o.value=null;try{const n=await R().get(q(`/locations/${i}/movements`));t.value=n.data.data}catch(n){throw o.value=((c=(l=n.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",n}finally{a.value=!1}}async function _(i){var l,c;a.value=!0,o.value=null;try{const n=await R().get(q(`/products/${i}/movements`));t.value=n.data.data}catch(n){throw o.value=((c=(l=n.response)==null?void 0:l.data)==null?void 0:c.message)||"Failed to load movements",n}finally{a.value=!1}}async function y(){var i,l;a.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{a.value=!1}}return{movements:t,loading:a,error:o,fetchAll:h,fetchByLocation:s,fetchByProduct:_,fetchRecent:y}}function _e(){const t=e.ref(null),a=e.ref(!1),o=e.ref(null);async function h(i,l="standard"){var c,n;a.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=((n=(c=r.response)==null?void 0:c.data)==null?void 0:n.message)||"Failed to load label",r}finally{a.value=!1}}async function s(i,l="standard"){var c,n;a.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=((n=(c=r.response)==null?void 0:c.data)==null?void 0:n.message)||"Failed to print label",r}finally{a.value=!1}}async function _(i,l="standard"){var c,n;a.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=((n=(c=r.response)==null?void 0:c.data)==null?void 0:n.message)||"Failed to print batch",r}finally{a.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:a,error:o,fetchLabel:h,printLabel:s,printBatch:_}}function Ae(){const t=e.ref([]);function a(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:a,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:a}){const o=t,h=a,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,n)=>(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:n[0]||(n[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"},[...n[1]||(n[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,[...n[2]||(n[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,a)=>{const o=t.__vccOpts||t;for(const[h,s]of a)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(a,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)])])):a.$slots["icon-left"]?(e.openBlock(),e.createElementBlock("span",We,[e.renderSlot(a.$slots,"icon-left",{},void 0,!0)])):e.createCommentVNode("",!0),e.createElementVNode("span",Ze,[e.renderSlot(a.$slots,"default",{},void 0,!0)]),a.$slots["icon-right"]?(e.openBlock(),e.createElementBlock("span",Je,[e.renderSlot(a.$slots,"icon-right",{},void 0,!0)])):e.createCommentVNode("",!0)],10,Qe))}}),T=H(Xe,[["__scopeId","data-v-6f9fc98e"]]),Ye={class:"inv-dashboard","data-testid":"page-inventory-dashboard"},et={class:"inv-dashboard__stats","data-testid":"panel-dashboard-stats"},tt={class:"inv-dashboard__stat-card inv-dashboard__stat-card--primary","data-testid":"stat-total-locations"},ot={key:0,class:"inv-dashboard__stat-shimmer"},at={class:"inv-dashboard__stat-value"},nt={class:"inv-dashboard__stat-card inv-dashboard__stat-card--success","data-testid":"stat-products-tracked"},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","data-testid":"stat-in-use"},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","data-testid":"stat-empty-locations"},ut={key:0,class:"inv-dashboard__stat-shimmer"},pt={class:"inv-dashboard__stat-value"},mt={class:"inv-dashboard__type-grid","data-testid":"panel-locations-by-type"},vt=["data-testid"],_t={class:"inv-dashboard__type-count"},ht={class:"inv-dashboard__type-label"},ft={class:"inv-dashboard__actions-grid"},yt=["data-testid","onClick"],kt=["innerHTML"],gt={class:"inv-dashboard__action-label"},bt={key:0,class:"inv-dashboard__activity-list",role:"list","data-testid":"list-recent-movements"},Vt=["data-testid","aria-label","onClick"],wt={class:"inv-dashboard__activity-info"},Nt={class:"inv-dashboard__activity-product"},Et={class:"inv-dashboard__activity-location"},Ct={class:"inv-dashboard__activity-time"},Bt={key:1,class:"inv-dashboard__no-activity"},$t={class:"inv-dashboard__bottom-row"},xt={key:0,class:"inv-dashboard__unlocated-content"},St={class:"inv-dashboard__unlocated-text"},Lt={"data-testid":"status-unlocated-count"},Dt={key:1,class:"inv-dashboard__unlocated-none","data-testid":"status-all-located"},zt={key:0},It=["data-testid"],Mt={class:"inv-dashboard__count-info"},Tt={class:"inv-dashboard__count-name"},Ft=["aria-valuenow"],Pt={class:"inv-dashboard__count-progress-track"},At={class:"inv-dashboard__count-pct"},Rt={key:1,class:"inv-dashboard__no-counts"},qt=e.defineComponent({__name:"InventoryDashboard",setup(t){const a=ne.useRouter(),{movements:o,loading:h,fetchRecent:s}=me(),{sessions:_,fetchSessions:y}=se(),i=e.ref(null),l=e.ref(!0),c=e.ref(0),n=[{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-package-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 b=await R().get(q("/dashboard/stats"));i.value=b.data}catch{}finally{l.value=!1}}async function d(){var b,g;try{const V=await R().get(q("/dashboard/unlocated-products?limit=1"));c.value=((b=V.data.meta)==null?void 0:b.total)??((g=V.data.data)==null?void 0:g.length)??0}catch{}}function m(b){a.push({name:b})}function v(b){const g=b.to_location||b.from_location;g&&a.push({name:"inventory-location",params:{code:g.full_code}})}function u(b){return{placed:"+",moved:"↔",picked:"-",adjusted:"⟳",counted:"#",received:"+",returned:"↩"}[b]??"?"}function p(b){const g=Date.now(),V=new Date(b).getTime(),x=g-V,$=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(b){return b.toLocaleString("en-US")}function N(b){const g={shelf:"Shelves"},V=b.toLowerCase();return g[V]?g[V]:b.charAt(0).toUpperCase()+b.slice(1)+"s"}return(b,g)=>{var V,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",at,e.toDisplayString(((V=i.value)==null?void 0:V.total_locations)??0),1),g[1]||(g[1]=e.createElementVNode("span",{class:"inv-dashboard__stat-label"},"Total Locations",-1))],64))]),e.createElementVNode("div",nt,[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",pt,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",mt,[(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","data-testid":`item-type-${E}`},[e.createElementVNode("span",_t,e.toDisplayString(k),1),e.createElementVNode("span",ht,e.toDisplayString(N(E)),1)],8,vt))),128))])]),_:1})):e.createCommentVNode("",!0),e.createVNode(j,{title:"Quick Actions",compact:"",class:"inv-dashboard__quick-actions","data-testid":"panel-quick-actions"},{default:e.withCtx(()=>[e.createElementVNode("div",ft,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(n,k=>e.createElementVNode("button",{key:k.label,type:"button",class:"inv-dashboard__action-btn","data-testid":`btn-action-${k.route}`,onClick:E=>m(k.route)},[e.createElementVNode("span",{class:"inv-dashboard__action-icon",innerHTML:k.icon,"aria-hidden":"true"},null,8,kt),e.createElementVNode("span",gt,e.toDisplayString(k.label),1)],8,yt)),64))])]),_:1}),e.createVNode(j,{title:"Recent Activity",class:"inv-dashboard__activity",loading:e.unref(h),"data-testid":"panel-recent-activity"},{default:e.withCtx(()=>[e.unref(o).length>0?(e.openBlock(),e.createElementBlock("div",bt,[(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","data-testid":`item-movement-${k.id}`,"aria-label":`${k.product_name} — ${k.reason}`,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",wt,[e.createElementVNode("span",Nt,e.toDisplayString(k.product_name),1),e.createElementVNode("span",Et,[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",Ct,e.toDisplayString(p(k.performed_at)),1)],8,Vt))),128))])):e.unref(h)?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("p",Bt," No recent activity "))]),_:1},8,["loading"]),e.createElementVNode("div",$t,[e.createVNode(j,{title:"Unlocated Products",compact:"",class:"inv-dashboard__unlocated-widget","data-testid":"panel-unlocated-products"},{default:e.withCtx(()=>[c.value>0?(e.openBlock(),e.createElementBlock("div",xt,[e.createElementVNode("p",St,[e.createElementVNode("strong",Lt,e.toDisplayString(c.value),1),g[5]||(g[5]=e.createTextVNode(" products have no assigned location ",-1))]),e.createVNode(T,{variant:"secondary",size:"sm","data-testid":"btn-view-unlocated",onClick:g[0]||(g[0]=k=>e.unref(a).push({name:"inventory-unlocated"}))},{default:e.withCtx(()=>[...g[6]||(g[6]=[e.createTextVNode(" View All ",-1)])]),_:1})])):(e.openBlock(),e.createElementBlock("p",Dt," All products have assigned locations "))]),_:1}),e.createVNode(j,{title:"Active Counts",compact:"",class:"inv-dashboard__counts-widget","data-testid":"panel-active-counts"},{default:e.withCtx(()=>[e.unref(_).length>0?(e.openBlock(),e.createElementBlock("div",zt,[(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","data-testid":`item-count-${k.id}`},[e.createElementVNode("div",Mt,[e.createElementVNode("span",Tt,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",Pt,[e.createElementVNode("div",{class:"inv-dashboard__count-progress-fill",style:e.normalizeStyle({width:`${k.progress.percent_complete}%`})},null,4)]),e.createElementVNode("span",At,e.toDisplayString(k.progress.percent_complete)+"% ",1)],8,Ft)]),e.createVNode(T,{variant:"secondary",size:"sm",onClick:E=>e.unref(a).push({name:"inventory-count-detail",params:{id:k.id}})},{default:e.withCtx(()=>[...g[7]||(g[7]=[e.createTextVNode(" Continue ",-1)])]),_:1},8,["onClick"])],8,It))),128))])):(e.openBlock(),e.createElementBlock("p",Rt," No active count sessions "))]),_:1})])])}}}),Ut=H(qt,[["__scopeId","data-v-bb9b566d"]]),Ht={class:"inv-empty-state",role:"status"},jt={class:"inv-empty-state__title"},Ot={key:0,class:"inv-empty-state__description"},Kt={key:1,class:"inv-empty-state__action"},Qt=e.defineComponent({__name:"InvEmptyState",props:{title:{},description:{},actionLabel:{}},emits:["action"],setup(t,{emit:a}){const o=a;return(h,s)=>(e.openBlock(),e.createElementBlock("div",Ht,[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",jt,e.toDisplayString(t.title),1),t.description?(e.openBlock(),e.createElementBlock("p",Ot,e.toDisplayString(t.description),1)):e.createCommentVNode("",!0),h.$slots.action||t.actionLabel?(e.openBlock(),e.createElementBlock("div",Kt,[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(Qt,[["__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 Gt(t){return Ee[t]||Ee.building}const Wt=["width","height","viewBox"],Zt=["d"],Jt=e.defineComponent({__name:"LocationTypeIcon",props:{type:{},size:{default:"md"}},setup(t){const a=t,o={sm:16,md:20,lg:24},h=e.computed(()=>Gt(a.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,Zt)],10,Wt))}}),re=H(Jt,[["__scopeId","data-v-e96e218e"]]),Xt={class:"location-search__input-wrapper"},Yt=["value","placeholder","aria-expanded","aria-activedescendant"],eo={key:1,class:"location-search__spinner","aria-hidden":"true"},to=["aria-label"],oo={key:0,class:"location-search__dropdown-item location-search__dropdown-item--loading",role:"presentation"},ao={key:1,class:"location-search__dropdown-item location-search__dropdown-item--empty",role:"presentation"},no=["id","aria-selected","onMousedown","onMouseenter"],lo={class:"location-search__result-info"},so={class:"location-search__result-name"},ro={class:"location-search__result-code"},io=e.defineComponent({__name:"LocationSearchInput",props:{modelValue:{},placeholder:{default:"Search locations..."},autofocus:{type:Boolean,default:!1}},emits:["update:modelValue","select"],setup(t,{emit:a}){const o=t,h=a,_=`location-search-listbox-${e.useId()}`,y=e.ref(null),i=e.ref(null),l=e.ref(-1),c=e.ref(!1),n=ie(),r=e.computed(()=>!c.value||o.modelValue.length<2?!1:n.loading.value?!0:n.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,n.search(g)});function m(g){const V=g.target;h("update:modelValue",V.value)}function v(){c.value=!0,o.modelValue.length>=2&&n.search(o.modelValue)}function u(){setTimeout(()=>{c.value=!1,l.value=-1},150)}function p(){var g;h("update:modelValue",""),n.clear(),l.value=-1,(g=y.value)==null||g.focus()}function f(g){h("select",g),h("update:modelValue",""),n.clear(),l.value=-1,c.value=!1}function N(g){const V=n.results.value;if(!r.value||V.length===0){g.key==="Escape"&&p();return}switch(g.key){case"ArrowDown":g.preventDefault(),l.value=Math.min(l.value+1,V.length-1),b();break;case"ArrowUp":g.preventDefault(),l.value=Math.max(l.value-1,0),b();break;case"Enter":g.preventDefault(),l.value>=0&&l.value<V.length&&f(V[l.value]);break;case"Escape":g.preventDefault(),c.value=!1,l.value=-1;break}}function b(){if(!i.value||l.value<0)return;const V=i.value.querySelectorAll('[role="option"]')[l.value];V&&V.scrollIntoView({block:"nearest"})}return e.onMounted(()=>{o.autofocus&&y.value&&y.value.focus()}),(g,V)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["location-search",{"location-search--open":r.value}])},[e.createElementVNode("div",Xt,[V[2]||(V[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:m,onKeydown:N,onFocus:v,onBlur:u},null,40,Yt),t.modelValue?(e.openBlock(),e.createElementBlock("button",{key:0,type:"button",class:"location-search__clear","aria-label":"Clear search",onMousedown:e.withModifiers(p,["prevent"])},[...V[0]||(V[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(n).loading.value?(e.openBlock(),e.createElementBlock("span",eo,[...V[1]||(V[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(n).loading.value&&e.unref(n).results.value.length===0?(e.openBlock(),e.createElementBlock("li",oo,[...V[3]||(V[3]=[e.createElementVNode("span",null,"Searching...",-1)])])):!e.unref(n).loading.value&&e.unref(n).results.value.length===0&&t.modelValue.length>=2?(e.openBlock(),e.createElementBlock("li",ao,[...V[4]||(V[4]=[e.createElementVNode("span",null,"No locations found",-1)])])):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(n).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",lo,[e.createElementVNode("span",so,e.toDisplayString(x.name),1),e.createElementVNode("span",ro,e.toDisplayString(x.full_code),1)])],42,no))),128))],8,to)):e.createCommentVNode("",!0)]),_:1})],2))}}),De=H(io,[["__scopeId","data-v-6191a2a0"]]);function co(t,a=2,o="-"){const h=t.split(o);return h.length<=a?t:"…"+h.slice(-a).join(o)}function Ce(t){return Number.isInteger(t)?String(t):t.toFixed(2).replace(/\.?0+$/,"")}function uo(t){const a=new Date(t),h=Math.floor((new Date().getTime()-a.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`:a.toLocaleDateString()}const po=["title"],mo=e.defineComponent({__name:"LocationCodeBadge",props:{code:{},truncate:{type:Boolean,default:!1},maxSegments:{default:2}},setup(t){const a=t,o=e.computed(()=>a.truncate?co(a.code,a.maxSegments):a.code);return(h,s)=>(e.openBlock(),e.createElementBlock("span",{class:"location-code-badge",title:t.code},e.toDisplayString(o.value),9,po))}}),J=H(mo,[["__scopeId","data-v-62592fe1"]]),vo=["data-testid"],_o=["aria-expanded","aria-selected","aria-level"],ho=["aria-label"],fo={key:0,class:"tree-node__spinner",width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true"},yo={key:1,class:"tree-node__toggle-spacer","aria-hidden":"true"},ko={class:"tree-node__name"},go=["aria-label"],bo={key:0,role:"group"},Vo=e.defineComponent({__name:"LocationTreeNode",props:{location:{},depth:{default:0},selectedId:{default:null}},emits:["select","toggle"],setup(t,{emit:a}){const o=t,h=a,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 m=>{if(m&&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,m=>{m&&m.length>0&&(i.value=m)});function n(){h("select",o.location)}function r(){s.toggleExpand(o.location.id),h("toggle",o.location.id)}function d(m){switch(m.key){case"Enter":case" ":m.preventDefault(),n();break;case"ArrowRight":m.preventDefault(),l.value&&!c.value&&r();break;case"ArrowLeft":m.preventDefault(),c.value&&r();break}}return(m,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:n,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",fo,[...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,ho)):(e.openBlock(),e.createElementBlock("span",yo)),e.createVNode(re,{type:t.location.type,size:"sm"},null,8,["type"]),e.createElementVNode("span",ko,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,go)):e.createCommentVNode("",!0)],46,_o),c.value&&i.value.length>0?(e.openBlock(),e.createElementBlock("div",bo,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,p=>(e.openBlock(),e.createBlock(u,{key:p.id,location:p,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,vo)}}}),wo=H(Vo,[["__scopeId","data-v-b2045bb5"]]),No={class:"location-tree",role:"tree","aria-label":"Location hierarchy"},Eo={key:0,class:"location-tree__loading","aria-live":"polite"},Co={key:2},Bo=e.defineComponent({__name:"LocationTree",emits:["select","create"],setup(t,{emit:a}){const o=a,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,n)=>(e.openBlock(),e.createElementBlock("div",No,[_.value?(e.openBlock(),e.createElementBlock("div",Eo,[(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`})},[...n[1]||(n[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)),n[2]||(n[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:n[0]||(n[0]=r=>o("create"))})):(e.openBlock(),e.createElementBlock("div",Co,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(e.unref(h).roots,r=>(e.openBlock(),e.createBlock(wo,{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(Bo,[["__scopeId","data-v-e21f92ca"]]),$o={class:"inv-table-wrapper"},xo=["aria-busy"],So={class:"inv-table__head"},Lo=["aria-sort"],Do=["onClick"],zo={class:"inv-table__sort-icon",width:"14",height:"14",viewBox:"0 0 14 14",fill:"none","aria-hidden":"true"},Io={key:0,d:"M7 3L11 8H3L7 3Z",fill:"currentColor"},Mo={key:1,d:"M7 11L3 6H11L7 11Z",fill:"currentColor"},To={key:1},Fo={class:"inv-table__body"},Po={key:1},Ao=["colspan"],Ro={class:"inv-table__empty-text"},qo=["tabindex","role","onClick","onKeydown"],Uo=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:a}){const o=t,h=a;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",$o,[e.createElementVNode("table",{class:"inv-table",role:"grid","aria-busy":t.loading},[e.createElementVNode("thead",So,[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",zo,[t.sortKey===l.key&&t.sortDir==="asc"?(e.openBlock(),e.createElementBlock("path",Io)):t.sortKey===l.key&&t.sortDir==="desc"?(e.openBlock(),e.createElementBlock("path",Mo)):(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,Do)):(e.openBlock(),e.createElementBlock("span",To,e.toDisplayString(l.label),1))],14,Lo))),128))])]),e.createElementVNode("tbody",Fo,[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",Po,[e.createElementVNode("td",{colspan:t.columns.length,class:"inv-table__td inv-table__td--empty"},[e.renderSlot(y.$slots,"empty",{},()=>[e.createElementVNode("span",Ro,e.toDisplayString(t.emptyMessage),1)],!0)],8,Ao)])):(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:n=>t.clickable?h("row-click",l):void 0,onKeydown:[e.withKeys(n=>t.clickable?h("row-click",l):void 0,["enter"]),e.withKeys(e.withModifiers(n=>t.clickable?h("row-click",l):void 0,["prevent"]),["space"])]},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.columns,n=>(e.openBlock(),e.createElementBlock("td",{key:n.key,class:e.normalizeClass(["inv-table__td",[`inv-table__td--${n.align||"left"}`]])},[e.renderSlot(y.$slots,`cell-${n.key}`,{row:l,value:l[n.key]},()=>[e.createTextVNode(e.toDisplayString(l[n.key]??""),1)],!0)],2))),128))],42,qo))),128))])],8,xo)]))}}),ae=H(Uo,[["__scopeId","data-v-59a6e64b"]]),Ho=e.defineComponent({__name:"InvBadge",props:{variant:{default:"default"},size:{default:"sm"}},setup(t){return(a,o)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(["inv-badge",[`inv-badge--${t.variant}`,`inv-badge--${t.size}`]])},[e.renderSlot(a.$slots,"default",{},void 0,!0)],2))}}),Z=H(Ho,[["__scopeId","data-v-f0803bf2"]]),jo=["aria-describedby"],Oo={class:"inv-modal__header"},Ko={class:"inv-modal__body"},Qo={key:0,class:"inv-modal__footer"},Go=e.defineComponent({__name:"InvModal",props:{show:{type:Boolean},title:{},description:{},size:{default:"md"},initialFocusSelector:{}},emits:["update:show","close"],setup(t,{emit:a}){const o=t,h=a,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 n(v){const u=c();if(u.length===0)return;const p=u[0],f=u[u.length-1];v.shiftKey?document.activeElement===p&&(v.preventDefault(),f.focus()):document.activeElement===f&&(v.preventDefault(),p.focus())}function r(v){v.key==="Escape"?(v.stopPropagation(),d()):v.key==="Tab"&&n(v)}function d(){h("update:show",!1),h("close")}function m(){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 p=c();p.length>0?p[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(m,["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",Oo,[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",Ko,[e.renderSlot(v.$slots,"default",{},void 0,!0)]),v.$slots.footer?(e.openBlock(),e.createElementBlock("div",Qo,[e.renderSlot(v.$slots,"footer",{},void 0,!0)])):e.createCommentVNode("",!0)],42,jo)],32)):e.createCommentVNode("",!0)]),_:3})]))}}),he=H(Go,[["__scopeId","data-v-7484015c"]]),Wo={class:"location-breadcrumb","aria-label":"Location path"},Zo={class:"location-breadcrumb__list"},Jo={key:0,class:"location-breadcrumb__separator","aria-hidden":"true"},Xo=["aria-label","onClick"],Yo={key:2,class:"location-breadcrumb__current","aria-current":"location"},Be=3,ea=e.defineComponent({__name:"LocationBreadcrumb",props:{path:{}},emits:["navigate"],setup(t,{emit:a}){const o=t,h=a,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",Wo,[e.createElementVNode("ol",Zo,[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,n)=>(e.openBlock(),e.createElementBlock("li",{key:c.id,class:"location-breadcrumb__item"},[n>0||s.value?(e.openBlock(),e.createElementBlock("span",Jo,"›")):e.createCommentVNode("",!0),y(n)?(e.openBlock(),e.createElementBlock("span",Yo,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,Xo))]))),128))])]))}}),fe=H(ea,[["__scopeId","data-v-911e6f70"]]),ta=["type","value","placeholder","disabled","aria-invalid","aria-describedby"],oa=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:a}){const o=t,h=a,s=e.useId(),_=`inv-input-${s}`,y=`inv-input-error-${s}`,i=e.ref(null);function l(c){const n=c.target;o.type==="number"?h("update:modelValue",n.valueAsNumber):h("update:modelValue",n.value)}return e.onMounted(()=>{o.autofocus&&i.value&&i.value.focus()}),(c,n)=>(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,ta),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))}}),pe=H(oa,[["__scopeId","data-v-b681751f"]]),aa={class:"inv-select__wrapper"},na=["value","disabled","aria-invalid","aria-describedby"],la={key:0,value:"",disabled:""},sa=["value"],ra=e.defineComponent({__name:"InvSelect",props:{modelValue:{},options:{},label:{},placeholder:{},error:{},disabled:{type:Boolean,default:!1}},emits:["update:modelValue"],setup(t,{emit:a}){const o=t,h=a,s=e.useId(),_=`inv-select-${s}`,y=`inv-select-error-${s}`;function i(l){const c=l.target,n=o.options.find(r=>String(r.value)===c.value);n?h("update:modelValue",n.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",aa,[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",la,e.toDisplayString(t.placeholder),1)):e.createCommentVNode("",!0),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.options,n=>(e.openBlock(),e.createElementBlock("option",{key:n.value,value:n.value},e.toDisplayString(n.label),9,sa))),128))],40,na),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(ra,[["__scopeId","data-v-40ea769b"]]),ia={class:"location-form__field"},ca={key:0,class:"location-form__code-preview"},da={class:"location-form__field"},ua=e.defineComponent({__name:"LocationForm",props:{show:{type:Boolean},location:{default:null},parentId:{default:null}},emits:["update:show","saved"],setup(t,{emit:a}){const o=t,h=a,_=`location-form-desc-${e.useId()}`,{create:y,update:i,fetchTypes:l}=ee(),c=e.ref(!1),n=e.ref([]),r=e.reactive({name:"",type:"",code:"",description:"",sort_order:0}),d=e.reactive({name:"",type:"",code:""}),m=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 w=o.location.full_code,D=o.location.code;if(w.endsWith(D))return w.slice(0,w.length-D.length).replace(/-$/,"")}return null}),u=e.computed(()=>{const k=r.code.trim();return k?v.value?`${v.value}-${k}`:k:""}),p=e.computed(()=>n.value.map(k=>({value:k.value,label:k.label}))),f=/^[a-zA-Z0-9-]*$/;function N(k){const E=String(k);f.test(E)?d.code="":d.code="Only letters, numbers, and hyphens allowed"}function b(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),!m.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 V(){var k,E;if(g()){c.value=!0;try{let w;if(m.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()),w=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};w=await y(D)}h("saved",w),h("update:show",!1),$()}catch(w){if((E=(k=w.response)==null?void 0:k.data)!=null&&E.errors){const D=w.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(n.value.length===0)try{n.value=await l()}catch{}o.location?F(o.location):$()}}),(k,E)=>(e.openBlock(),e.createBlock(he,{show:t.show,title:m.value?"Edit Location":"Create Location",description:m.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]=w=>h("update:show",w)),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:V},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(m.value?"Save Changes":"Create Location"),1)]),_:1},8,["loading","disabled"])]),default:e.withCtx(()=>[e.createElementVNode("form",{class:"location-form",onSubmit:e.withModifiers(V,["prevent"])},[e.createVNode(pe,{modelValue:r.name,"onUpdate:modelValue":[E[0]||(E[0]=w=>r.name=w),E[1]||(E[1]=w=>b("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]=w=>r.type=w),E[3]||(E[3]=w=>b("type"))],label:"Type",placeholder:"Select location type...",options:p.value,error:d.type,disabled:m.value},null,8,["modelValue","options","error","disabled"]),e.createElementVNode("div",ia,[e.createVNode(pe,{modelValue:r.code,"onUpdate:modelValue":[E[4]||(E[4]=w=>r.code=w),N],label:"Code (optional)",placeholder:"Auto-generated if blank",error:d.code},null,8,["modelValue","error"]),u.value?(e.openBlock(),e.createElementBlock("p",ca,[E[8]||(E[8]=e.createTextVNode(" Full code: ",-1)),e.createElementVNode("code",null,e.toDisplayString(u.value),1)])):e.createCommentVNode("",!0)]),e.createElementVNode("div",da,[e.createElementVNode("label",{for:_,class:"location-form__label"}," Description "),e.withDirectives(e.createElementVNode("textarea",{id:_,"onUpdate:modelValue":E[5]||(E[5]=w=>r.description=w),class:"location-form__textarea",placeholder:"Optional notes about this location...",rows:"3"},null,512),[[e.vModelText,r.description]])]),e.createVNode(pe,{modelValue:r.sort_order,"onUpdate:modelValue":E[6]||(E[6]=w=>r.sort_order=w),label:"Sort order",type:"number",placeholder:"0"},null,8,["modelValue"])],32)]),_:1},8,["show","title","description"]))}}),Ve=H(ua,[["__scopeId","data-v-7b871a38"]]),pa={class:"location-detail"},ma={key:0,class:"location-detail__loading","aria-live":"polite"},va={class:"location-detail__header"},_a={class:"location-detail__title-row"},ha={class:"location-detail__title-area"},fa={class:"location-detail__name"},ya={class:"location-detail__actions"},ka={class:"location-detail__info-grid"},ga={key:0,class:"location-detail__info-item"},ba={class:"location-detail__info-value"},Va={class:"location-detail__info-item"},wa={class:"location-detail__info-value"},Na={class:"location-detail__info-item"},Ea={class:"location-detail__info-value"},Ca={key:1,class:"location-detail__info-item"},Ba={class:"location-detail__child-cell"},$a={class:"location-detail__count"},xa={class:"location-detail__product-count-label"},Sa={key:0,class:"location-detail__loading-inline"},La={key:1,class:"location-detail__empty-inline"},Da={class:"location-detail__product-cell"},za={class:"location-detail__product-name"},Ia={key:0,class:"location-detail__product-sku"},Ma={key:0,class:"location-detail__loading-inline"},Ta={key:1,class:"location-detail__empty-inline"},Fa={key:2,class:"location-detail__movements-list"},Pa={width:"14",height:"14",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Aa={key:0,d:"M12 5v14M5 12l7 7 7-7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Ra={key:1,d:"M12 19V5M5 12l7-7 7 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},qa={key:2,d:"M5 12h14M12 5l7 7-7 7",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Ua={key:3,d:"M4 4l16 16M20 4L4 20",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.6"},Ha={class:"location-detail__movement-info"},ja={class:"location-detail__movement-primary"},Oa={class:"location-detail__movement-qty"},Ka={class:"location-detail__movement-meta"},Qa={key:0,class:"location-detail__label-preview"},Ga=["innerHTML"],Wa={class:"location-detail__label-info"},Za={class:"location-detail__label-code"},Ja={class:"location-detail__label-path"},Xa={key:1,class:"location-detail__empty-inline"},Ya={class:"location-detail__delete-warning"},en=e.defineComponent({__name:"LocationDetail",props:{locationCode:{default:void 0},locationId:{default:void 0}},emits:["navigate","deleted"],setup(t,{emit:a}){const o=t,h=a,s=le(),{fetchLocation:_,fetchChildren:y,remove:i}=ee(),{fetchProducts:l}=te(),{fetchByLocation:c}=me(),{fetchLabel:n,printLabel:r}=_e(),d=e.ref(null),m=e.ref(!1),v=e.ref(null),u=e.ref([]),p=e.ref(!1),f=e.ref([]),N=e.ref(!1),b=e.ref([]),g=e.ref(!1),V=e.ref(null),x=e.ref(!1),$=e.ref(!1),F=e.ref(!1),k=e.ref(!1),E=e.ref(!1),w=[{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)){m.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{m.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){p.value=!0;try{u.value=await y(K)}catch{u.value=[]}finally{p.value=!1}}async function P(K){N.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{N.value=!1}}async function z(K){g.value=!0;try{const B=me();await B.fetchByLocation(K),b.value=B.movements.value.slice(0,10)}catch{b.value=[]}finally{g.value=!1}}async function I(){if(d.value){x.value=!0;try{const K=await n(d.value.id);V.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 be(K){F.value=!1,d.value&&await G(d.value.id)}return e.watch(()=>[o.locationId,o.locationCode],()=>{V.value=null,C()}),e.onMounted(()=>{C()}),(K,B)=>{var W;return e.openBlock(),e.createElementBlock("div",pa,[m.value?(e.openBlock(),e.createElementBlock("div",ma,[...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",va,[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",_a,[e.createElementVNode("div",ha,[e.createVNode(re,{type:d.value.type,size:"lg"},null,8,["type"]),e.createElementVNode("h1",fa,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",ya,[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",ka,[d.value.description?(e.openBlock(),e.createElementBlock("div",ga,[B[13]||(B[13]=e.createElementVNode("span",{class:"location-detail__info-label"},"Description",-1)),e.createElementVNode("p",ba,e.toDisplayString(d.value.description),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Va,[B[14]||(B[14]=e.createElementVNode("span",{class:"location-detail__info-label"},"Created",-1)),e.createElementVNode("span",wa,e.toDisplayString(S(d.value.created_at)),1)]),e.createElementVNode("div",Na,[B[15]||(B[15]=e.createElementVNode("span",{class:"location-detail__info-label"},"Last Updated",-1)),e.createElementVNode("span",Ea,e.toDisplayString(S(d.value.updated_at)),1)]),d.value.is_mobile?(e.openBlock(),e.createElementBlock("div",Ca,[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(ae,{columns:w,data:u.value,loading:p.value,clickable:"","empty-message":"No child locations.",onRowClick:X},{"cell-name":e.withCtx(({row:M})=>[e.createElementVNode("div",Ba,[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",$a,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",xa,e.toDisplayString(f.value.length)+" "+e.toDisplayString(f.value.length===1?"product":"products"),1)]),default:e.withCtx(()=>[N.value?(e.openBlock(),e.createElementBlock("div",Sa,[...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",La,[...B[20]||(B[20]=[e.createElementVNode("p",null,"No products at this location.",-1)])])):(e.openBlock(),e.createBlock(ae,{key:2,columns:D,data:f.value,"empty-message":"No products at this location."},{"cell-product_name":e.withCtx(({row:M})=>[e.createElementVNode("div",Da,[e.createElementVNode("span",za,e.toDisplayString(M.product_name),1),M.product_sku?(e.openBlock(),e.createElementBlock("span",Ia,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",Ma,[...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)])])):b.value.length===0?(e.openBlock(),e.createElementBlock("div",Ta,[...B[23]||(B[23]=[e.createElementVNode("p",null,"No recent movements.",-1)])])):(e.openBlock(),e.createElementBlock("div",Fa,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(b.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",Pa,[M.reason==="placed"||M.reason==="received"?(e.openBlock(),e.createElementBlock("path",Aa)):M.reason==="picked"?(e.openBlock(),e.createElementBlock("path",Ra)):M.reason==="moved"?(e.openBlock(),e.createElementBlock("path",qa)):(e.openBlock(),e.createElementBlock("path",Ua))]))],2),e.createElementVNode("div",Ha,[e.createElementVNode("span",ja,[e.createElementVNode("strong",null,e.toDisplayString(M.reason_label),1),e.createTextVNode(" "+e.toDisplayString(M.product_name)+" ",1),e.createElementVNode("span",Oa," (qty: "+e.toDisplayString(e.unref(Ce)(M.quantity))+") ",1)]),e.createElementVNode("span",Ka,e.toDisplayString(M.performer_name||"System")+" · "+e.toDisplayString(e.unref(uo)(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(()=>[V.value?(e.openBlock(),e.createElementBlock("div",Qa,[V.value.qr_code_svg?(e.openBlock(),e.createElementBlock("div",{key:0,class:"location-detail__label-qr",innerHTML:V.value.qr_code_svg},null,8,Ga)):e.createCommentVNode("",!0),e.createElementVNode("div",Wa,[e.createElementVNode("strong",null,e.toDisplayString(V.value.location.name),1),e.createElementVNode("span",Za,e.toDisplayString(V.value.location.full_code),1),e.createElementVNode("span",Ja,e.toDisplayString(V.value.path),1)])])):(e.openBlock(),e.createElementBlock("div",Xa,[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(Ve,{show:$.value,location:d.value,"onUpdate:show":B[2]||(B[2]=M=>$.value=M),onSaved:ge},null,8,["show","location"]),e.createVNode(Ve,{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:be},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",Ya,[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(en,[["__scopeId","data-v-388046b7"]]),tn={class:"inv-shell"},on={class:"inv-shell__header"},an={class:"inv-shell__header-left"},nn=["aria-label","aria-expanded"],ln={class:"inv-shell__header-actions"},sn={class:"inv-shell__search-wrapper"},rn={class:"inv-shell__body"},cn=["aria-hidden"],dn={class:"inv-shell__detail"},un=e.defineComponent({__name:"InventoryLocatorShell",setup(t){const a=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 n(x){s.value="",p(x)}function r(x){p(x),l.value&&(y.value=!1)}function d(x){p(x)}function m(){a.selectLocation(null),N(null)}function v(x){_.value=!1,p(x)}function u(){o&&o.push({name:"inventory-scan"})}function p(x){a.selectLocation(x.id),f(x),N(x.full_code)}function f(x){if(x.path)for(const $ of x.path)a.expandedNodeIds.has($.id)||a.toggleExpand($.id)}function N(x){if(o)try{x?o.replace({name:"inventory-location",params:{code:x}}):o.replace({name:"inventory-locations"})}catch{}}function b(){var x;return(x=h==null?void 0:h.params)!=null&&x.code?h.params.code:null}function g(){const x=b();if(x){const $=V(x);$&&(a.selectLocation($.id),f($))}}function V(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 $(a.roots)}return h&&e.watch(()=>{var x;return(x=h.params)==null?void 0:x.code},x=>{if(x){const $=V(x);$&&(a.selectLocation($.id),f($))}}),e.onMounted(()=>{window.addEventListener("resize",c),c(),g()}),e.onUnmounted(()=>{window.removeEventListener("resize",c)}),(x,$)=>(e.openBlock(),e.createElementBlock("div",tn,[e.createElementVNode("header",on,[e.createElementVNode("div",an,[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,nn),$[7]||($[7]=e.createElementVNode("h1",{class:"inv-shell__title"},"Inventory Locations",-1))]),e.createElementVNode("div",ln,[e.createElementVNode("div",sn,[e.createVNode(De,{modelValue:s.value,"onUpdate:modelValue":$[1]||($[1]=F=>s.value=F),placeholder:"Search locations...",onSelect:n},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",rn,[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,cn),e.createElementVNode("main",dn,[e.unref(a).selectedLocationId?(e.openBlock(),e.createBlock(Ie,{key:0,"location-id":e.unref(a).selectedLocationId,onNavigate:d,onDeleted:m},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(Ve,{show:_.value,"onUpdate:show":$[5]||($[5]=F=>_.value=F),onSaved:v},null,8,["show"])]))}}),pn=H(un,[["__scopeId","data-v-e77a95d2"]]),mn={class:"scan-result__body"},vn={key:0,class:"scan-result__path"},_n={class:"scan-result__location-info"},hn={key:1,class:"scan-result__products"},fn={class:"scan-result__products-label"},yn={class:"scan-result__product-list",role:"list"},kn={class:"scan-result__product-name"},gn={class:"scan-result__product-qty"},bn={key:0,class:"scan-result__products-more"},Vn={key:2,class:"scan-result__no-products"},wn={class:"scan-result__actions"},Nn=e.defineComponent({__name:"ScanResult",props:{location:{},show:{type:Boolean}},emits:["close","navigate","scan-again"],setup(t,{emit:a}){const o=t,h=a,_=`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 n;c&&(await e.nextTick(),(n=y.value)==null||n.focus())});function l(c){h("navigate",{...o.location,full_code:c.full_code})}return(c,n)=>(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:n[4]||(n[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:n[3]||(n[3]=e.withKeys(r=>h("close"),["escape"]))},[n[10]||(n[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"},[n[5]||(n[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",mn,[t.location.path&&t.location.path.length>0?(e.openBlock(),e.createElementBlock("div",vn,[e.createVNode(fe,{path:t.location.path,onNavigate:l},null,8,["path"])])):e.createCommentVNode("",!0),e.createElementVNode("div",_n,[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",hn,[e.createElementVNode("p",fn," Products: "+e.toDisplayString(t.location.products.length)+" item"+e.toDisplayString(t.location.products.length!==1?"s":""),1),e.createElementVNode("ul",yn,[(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",kn,e.toDisplayString(r.product_name),1),e.createElementVNode("span",gn,"qty: "+e.toDisplayString(r.quantity),1)]))),128))]),t.location.products.length>5?(e.openBlock(),e.createElementBlock("p",bn," + "+e.toDisplayString(t.location.products.length-5)+" more ",1)):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Vn,[...n[6]||(n[6]=[e.createElementVNode("p",{class:"scan-result__no-products-text"},"No products at this location",-1)])]))]),e.createElementVNode("div",wn,[e.createVNode(T,{variant:"primary",size:"md",onClick:n[0]||(n[0]=r=>h("navigate",t.location))},{default:e.withCtx(()=>[...n[7]||(n[7]=[e.createTextVNode(" View Details ",-1)])]),_:1}),e.createVNode(T,{variant:"secondary",size:"md",onClick:n[1]||(n[1]=r=>h("navigate",t.location))},{default:e.withCtx(()=>[...n[8]||(n[8]=[e.createTextVNode(" Add Product ",-1)])]),_:1}),e.createVNode(T,{variant:"ghost",size:"md",onClick:n[2]||(n[2]=r=>h("scan-again"))},{default:e.withCtx(()=>[...n[9]||(n[9]=[e.createTextVNode(" Scan Again ",-1)])]),_:1})])],544)],32)):e.createCommentVNode("",!0)]),_:1}))}}),Me=H(Nn,[["__scopeId","data-v-575ebb3b"]]),En={key:0,class:"scan-history"},Cn={class:"scan-history__list",role:"list"},Bn=["aria-label","onClick"],$n={class:"scan-history__code"},xn={class:"scan-history__name"},Sn={class:"scan-history__time"},Ln=e.defineComponent({__name:"ScanHistory",props:{limit:{default:10}},setup(t){const a=t,o=ne.useRouter(),h=Ne();e.onMounted(()=>{h.loadFromSession()});const s=e.computed(()=>h.history.slice(0,a.limit));function _(i){o.push({name:"inventory-location",params:{code:i.code}})}function y(i){const l=Date.now(),c=new Date(i).getTime(),n=l-c,r=Math.floor(n/1e3);if(r<60)return"just now";const d=Math.floor(r/60);if(d<60)return`${d} min ago`;const m=Math.floor(d/60);if(m<24)return`${m}h ago`;const v=Math.floor(m/24);return v===1?"yesterday":`${v}d ago`}return(i,l)=>s.value.length>0?(e.openBlock(),e.createElementBlock("div",En,[l[0]||(l[0]=e.createElementVNode("p",{class:"scan-history__title"},"Recent scans",-1)),e.createElementVNode("ul",Cn,[(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:n=>_(c)},[e.createElementVNode("span",$n,e.toDisplayString(c.code),1),e.createElementVNode("span",xn,e.toDisplayString(c.locationName),1),e.createElementVNode("span",Sn,e.toDisplayString(y(c.scannedAt)),1)],8,Bn)]))),128))])])):e.createCommentVNode("",!0)}}),Te=H(Ln,[["__scopeId","data-v-2eaec2d3"]]),Dn={class:"scanner-overlay"},zn={key:0,class:"scanner-overlay__counting-banner",role:"status"},In={class:"scanner-overlay__counting-text"},Mn={class:"scanner-overlay__header"},Tn=["aria-label","aria-pressed"],Fn={width:"24",height:"24",viewBox:"0 0 24 24",fill:"none","aria-hidden":"true"},Pn=["fill"],An={key:1,class:"scanner-overlay__camera-area"},Rn={key:0,class:"scanner-overlay__scan-guide","aria-hidden":"true"},qn={key:1,class:"scanner-overlay__starting",role:"status"},Un={key:2,class:"scanner-overlay__error",role:"alert"},Hn={key:2,class:"scanner-overlay__no-camera",role:"status"},jn={key:3,class:"scanner-overlay__instruction"},On={"aria-live":"polite",class:"sr-only"},Kn={key:0},Qn={key:1},Gn={key:2},Wn={key:4,class:"scanner-overlay__toast scanner-overlay__toast--error",role:"alert"},Zn={class:"scanner-overlay__manual"},Jn={class:"scanner-overlay__manual-row"},Xn=["disabled"],$e="inv-scanner-feed",Yn=e.defineComponent({__name:"ScannerOverlay",setup(t){const a=ne.useRouter(),o=Le(),h=ee(),s=Ne(),_=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 n()}),e.onBeforeUnmount(async()=>{await o.stopScanning()});async function n(){c.value=null,await o.startScanning($e,d)}async function r(){o.error.value=null,await n()}async function d(g){await o.stopScanning(),await v(g)}async function m(){const g=y.value.trim();g&&await v(g)}async function v(g){l.value=!0,c.value=null;try{const V=await h.scanLookup(g);V?(i.value=V,s.addToHistory({code:V.full_code,locationName:V.name,locationId:V.id})):(c.value=`No location found for code "${g}"`,o.isSupported.value&&await n())}catch{c.value="Could not look up location. Check connection.",o.isSupported.value&&await n()}finally{l.value=!1}}function u(){c.value=null}function p(){i.value=null}function f(g){i.value=null,a.push({name:"inventory-location",params:{code:g.full_code}})}async function N(){i.value=null,y.value="",o.isSupported.value&&await n()}function b(){a.back()}return(g,V)=>(e.openBlock(),e.createElementBlock("div",Dn,[e.unref(_).isCountingMode?(e.openBlock(),e.createElementBlock("div",zn,[V[2]||(V[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",In," Counting: Session #"+e.toDisplayString(e.unref(_).activeSessionId),1)])):e.createCommentVNode("",!0),e.createElementVNode("div",Mn,[e.createElementVNode("button",{type:"button",class:"scanner-overlay__close-btn","aria-label":"Close scanner",onClick:b},[...V[3]||(V[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:V[0]||(V[0]=x=>e.unref(o).toggleFlash())},[(e.openBlock(),e.createElementBlock("svg",Fn,[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,Pn)]))],10,Tn)):e.createCommentVNode("",!0)]),e.unref(o).isSupported.value?(e.openBlock(),e.createElementBlock("div",An,[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",Rn,[...V[4]||(V[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",qn,[...V[5]||(V[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",Un,[V[7]||(V[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(()=>[...V[6]||(V[6]=[e.createTextVNode(" Try Again ",-1)])]),_:1})])):e.createCommentVNode("",!0)])):(e.openBlock(),e.createElementBlock("div",Hn,[...V[8]||(V[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",jn," Point camera at QR code or barcode ")):e.createCommentVNode("",!0),e.createElementVNode("div",On,[l.value?(e.openBlock(),e.createElementBlock("span",Kn,"Looking up scanned code...")):e.createCommentVNode("",!0),c.value?(e.openBlock(),e.createElementBlock("span",Qn,e.toDisplayString(c.value),1)):e.createCommentVNode("",!0),i.value?(e.openBlock(),e.createElementBlock("span",Gn,"Location found: "+e.toDisplayString(i.value.name),1)):e.createCommentVNode("",!0)]),c.value?(e.openBlock(),e.createElementBlock("div",Wn,[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},[...V[9]||(V[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",Zn,[V[11]||(V[11]=e.createElementVNode("label",{for:"scanner-manual-input",class:"scanner-overlay__manual-label"}," Or enter code manually: ",-1)),e.createElementVNode("div",Jn,[e.withDirectives(e.createElementVNode("input",{id:"scanner-manual-input","onUpdate:modelValue":V[1]||(V[1]=x=>y.value=x),type:"text",class:"scanner-overlay__manual-input",placeholder:"e.g. WH1-A-01",disabled:l.value,onKeydown:e.withKeys(m,["enter"])},null,40,Xn),[[e.vModelText,y.value]]),e.createVNode(T,{variant:"primary",size:"md",loading:l.value,disabled:!y.value.trim(),onClick:m},{default:e.withCtx(()=>[...V[10]||(V[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:p,onNavigate:f,onScanAgain:N},null,8,["location","show"])):e.createCommentVNode("",!0)]))}}),el=H(Yn,[["__scopeId","data-v-e0f50099"]]),tl={class:"count-session-list"},ol={class:"count-session-list__header"},al={class:"count-session-list__create-fields"},nl={class:"count-session-list__scope-field"},ll={class:"count-session-list__scope-input"},sl={key:0,class:"count-session-list__scope-results",role:"listbox","aria-label":"Scope location results"},rl=["aria-selected","onClick"],il={key:1,class:"count-session-list__scope-selected"},cl={class:"count-session-list__create-actions"},dl={key:0,class:"count-session-list__loading"},ul={key:1,class:"count-session-list__section"},pl={class:"count-session-list__cards"},ml={class:"count-session-list__card-header"},vl={class:"count-session-list__card-name"},_l=["aria-valuenow","aria-label"],hl={class:"count-session-list__progress-track"},fl={class:"count-session-list__progress-label"},yl={class:"count-session-list__card-stats"},kl={key:0,class:"count-session-list__card-meta"},gl={class:"count-session-list__card-actions"},bl={key:2,class:"count-session-list__section"},Vl={class:"count-session-list__completed"},wl=["onClick"],Nl={class:"count-session-list__completed-info"},El={class:"count-session-list__completed-name"},Cl={class:"count-session-list__completed-meta"},Bl={key:0},$l={key:1},xl={key:2},Sl=e.defineComponent({__name:"CountSessionList",setup(t){const a=ne.useRouter(),{sessions:o,loading:h,fetchSessions:s,createSession:_}=se(),y=ie(),i=e.ref(!1),l=e.ref(""),c=e.ref(void 0),n=e.ref(!1),r=e.ref(""),d=e.ref([]),m=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 p(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(){m.value||(y.search(r.value),d.value=y.results.value)}function N(k){m.value=k,r.value="",d.value=[]}function b(){m.value=null,r.value="",d.value=[]}function g(){i.value=!1,l.value="",c.value=void 0,b()}async function V(){var E,w,D;const k=l.value.trim();if(!k){c.value="Name is required";return}n.value=!0,c.value=void 0;try{const S=await _(k,(E=m.value)==null?void 0:E.id);i.value=!1,l.value="",b(),x(S.id)}catch(S){c.value=((D=(w=S==null?void 0:S.response)==null?void 0:w.data)==null?void 0:D.message)||"Failed to create session"}finally{n.value=!1}}function x(k){a.push({name:"inventory-count-detail",params:{id:k}})}function $(k){a.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",tl,[e.createElementVNode("div",ol,[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]=w=>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(V,["prevent"])},[e.createElementVNode("div",al,[e.createVNode(pe,{modelValue:l.value,"onUpdate:modelValue":E[1]||(E[1]=w=>l.value=w),label:"Session Name",placeholder:"e.g. Full Warehouse Count - March 2026",error:c.value,autofocus:""},null,8,["modelValue","error"]),e.createElementVNode("div",nl,[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",ll,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":E[2]||(E[2]=w=>r.value=w),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",sl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(d.value,w=>{var D,S;return e.openBlock(),e.createElementBlock("button",{key:w.id,type:"button",role:"option","aria-selected":((D=m.value)==null?void 0:D.id)===w.id,class:e.normalizeClass(["count-session-list__scope-option",{"count-session-list__scope-option--selected":((S=m.value)==null?void 0:S.id)===w.id}]),onClick:C=>N(w)},[e.createVNode(J,{code:w.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(w.name),1)],10,rl)}),128))])):e.createCommentVNode("",!0),m.value?(e.openBlock(),e.createElementBlock("div",il,[e.createVNode(J,{code:m.value.full_code},null,8,["code"]),e.createElementVNode("span",null,e.toDisplayString(m.value.name),1),e.createElementVNode("button",{type:"button",class:"count-session-list__scope-clear","aria-label":"Clear scope selection",onClick:b},[...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",cl,[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:n.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",dl,[e.createVNode(j,{loading:""}),e.createVNode(j,{loading:""})])):e.createCommentVNode("",!0),v.value.length>0?(e.openBlock(),e.createElementBlock("section",ul,[E[14]||(E[14]=e.createElementVNode("h2",{class:"count-session-list__section-title"},"Active",-1)),e.createElementVNode("div",pl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(v.value,w=>(e.openBlock(),e.createBlock(j,{key:w.id,class:"count-session-list__active-card"},{default:e.withCtx(()=>[e.createElementVNode("div",ml,[e.createElementVNode("h3",vl,e.toDisplayString(w.name),1),e.createVNode(Z,{variant:w.status==="in_progress"?"default":"muted"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.status==="in_progress"?"In Progress":"Pending"),1)]),_:2},1032,["variant"])]),e.createElementVNode("div",{class:"count-session-list__progress",role:"progressbar","aria-valuenow":w.progress.percent_complete,"aria-valuemin":"0","aria-valuemax":"100","aria-label":`Counting progress: ${w.progress.percent_complete}%`},[e.createElementVNode("div",hl,[e.createElementVNode("div",{class:e.normalizeClass(["count-session-list__progress-fill",p(w.progress.percent_complete)]),style:e.normalizeStyle({width:`${w.progress.percent_complete}%`})},null,6)]),e.createElementVNode("span",fl,e.toDisplayString(w.progress.percent_complete)+"% ",1)],8,_l),e.createElementVNode("p",yl,e.toDisplayString(w.progress.counted)+"/"+e.toDisplayString(w.progress.total)+" locations counted, "+e.toDisplayString(w.progress.discrepancies)+" discrepancies ",1),w.started_at?(e.openBlock(),e.createElementBlock("div",kl," Started: "+e.toDisplayString(F(w.started_at)),1)):e.createCommentVNode("",!0),e.createElementVNode("div",gl,[w.status==="in_progress"?(e.openBlock(),e.createBlock(T,{key:0,variant:"primary",size:"sm",onClick:D=>$(w.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(w.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",bl,[E[15]||(E[15]=e.createElementVNode("h2",{class:"count-session-list__section-title"},"Recent",-1)),e.createElementVNode("div",Vl,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(u.value,w=>(e.openBlock(),e.createElementBlock("button",{key:w.id,type:"button",class:"count-session-list__completed-row",onClick:D=>x(w.id)},[e.createElementVNode("div",Nl,[e.createElementVNode("span",El,e.toDisplayString(w.name),1),e.createVNode(Z,{variant:w.status==="completed"?"success":"muted",size:"sm"},{default:e.withCtx(()=>[e.createTextVNode(e.toDisplayString(w.status==="completed"?"Completed":"Cancelled"),1)]),_:2},1032,["variant"])]),e.createElementVNode("div",Cl,[w.status==="completed"&&w.progress?(e.openBlock(),e.createElementBlock("span",Bl," Accuracy: "+e.toDisplayString(w.progress.total>0?((w.progress.total-w.progress.discrepancies)/w.progress.total*100).toFixed(1):"0.0")+"% ",1)):e.createCommentVNode("",!0),w.completed_at?(e.openBlock(),e.createElementBlock("span",$l,e.toDisplayString(F(w.completed_at)),1)):w.updated_at?(e.openBlock(),e.createElementBlock("span",xl,e.toDisplayString(F(w.updated_at)),1)):e.createCommentVNode("",!0)])],8,wl))),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]=w=>i.value=!0)})):e.createCommentVNode("",!0)]))}}),Ll=H(Sl,[["__scopeId","data-v-900e6502"]]),Dl={class:"count-detail"},zl={class:"count-detail__header"},Il={class:"count-detail__header-info"},Ml={class:"count-detail__title"},Tl={class:"count-detail__meta"},Fl={key:0,class:"count-detail__meta-item"},Pl={key:1,class:"count-detail__meta-item"},Al=["aria-valuenow","aria-label"],Rl={class:"count-detail__progress-track"},ql={class:"count-detail__progress-pct"},Ul={class:"count-detail__stats-grid"},Hl={class:"count-detail__stat"},jl={class:"count-detail__stat-value"},Ol={class:"count-detail__stat"},Kl={class:"count-detail__stat-value"},Ql={class:"count-detail__stat"},Gl={class:"count-detail__stat-value"},Wl={class:"count-detail__stat"},Zl={class:"count-detail__stat-value count-detail__stat-value--pending"},Jl={class:"count-detail__stat"},Xl={class:"count-detail__stat-value count-detail__stat-value--warning"},Yl={class:"count-detail__action-grid"},es={class:"count-detail__filters"},ts={class:"count-detail__discrepancy-toggle"},os=["title"],as={class:"count-detail__entry-product"},ns={class:"count-detail__entry-qty"},ls={key:0,class:"count-detail__entry-disc"},ss={key:1,class:"count-detail__entry-pending"},rs=e.defineComponent({__name:"CountSessionDetail",props:{sessionId:{}},setup(t){const a=t,o=ne.useRouter(),h=ve(),{currentSession:s,entries:_,loading:y,error:i,fetchSession:l,fetchEntries:c,generateEntries:n,updateStatus:r,applySession:d,verifyEntry:m}=se(),v=e.ref(!1),u=e.ref(!1),p=e.ref(!1),f=e.ref(""),N=e.ref(!1),b=e.ref(!1),g=e.ref(""),V=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"}],w=[{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)),N.value&&(U=U.filter(A=>A.discrepancy!==null&&A.discrepancy!==0)),U});e.onMounted(()=>O());async function O(){try{await l(a.sessionId),await X()}catch{}}async function X(){v.value=!0;try{await c(a.sessionId)}finally{v.value=!1}}async function ce(){u.value=!0;try{await n(a.sessionId),await X(),await l(a.sessionId)}finally{u.value=!1}}function ye(){h.startCounting(a.sessionId),o.push({name:"inventory-count-entry",params:{id:a.sessionId}})}function ke(){N.value=!N.value}function ge(){g.value="Apply Adjustments",V.value="This will adjust inventory quantities based on verified counts. This action cannot be undone.",x.value="Apply",$.value=!1,k=async()=>{p.value=!0;try{await d(a.sessionId),await l(a.sessionId),await X()}finally{p.value=!1}},b.value=!0}function be(){g.value="Cancel Session",V.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(a.sessionId,"cancelled"),await l(a.sessionId)},b.value=!0}async function K(){if(k){F.value=!0;try{await k(),b.value=!1}finally{F.value=!1}}}function B(){o.push({name:"inventory-count-report",params:{id:a.sessionId}})}function W(U){U.status==="counted"&&U.discrepancy!==null&&U.discrepancy!==0&&m(a.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",Dl,[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",zl,[e.createElementVNode("div",Il,[e.createElementVNode("h1",Ml,e.toDisplayString(e.unref(s).name),1),e.createElementVNode("div",Tl,[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",Fl," Started: "+e.toDisplayString(Fe(e.unref(s).started_at)),1)):e.createCommentVNode("",!0),e.unref(s).scope_location_id?(e.openBlock(),e.createElementBlock("span",Pl," 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",Rl,[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",ql,e.toDisplayString(e.unref(s).progress.percent_complete)+"% ",1)],8,Al),e.createElementVNode("div",Ul,[e.createElementVNode("div",Hl,[e.createElementVNode("span",jl,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",Ol,[e.createElementVNode("span",Kl,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",Ql,[e.createElementVNode("span",Gl,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",Wl,[e.createElementVNode("span",Zl,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",Jl,[e.createElementVNode("span",Xl,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",Yl,[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(N.value?"Show All":"Review Discrepancies"),1)]),_:1})):e.createCommentVNode("",!0),z.value?(e.openBlock(),e.createBlock(T,{key:3,variant:"primary",size:"md",loading:p.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:be},{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",es,[e.createVNode(oe,{modelValue:f.value,"onUpdate:modelValue":A[0]||(A[0]=Q=>f.value=Q),options:w,placeholder:"All Statuses"},null,8,["modelValue"]),e.createElementVNode("label",ts,[e.withDirectives(e.createElementVNode("input",{"onUpdate:modelValue":A[1]||(A[1]=Q=>N.value=Q),type:"checkbox",class:"count-detail__discrepancy-checkbox"},null,512),[[e.vModelCheckbox,N.value]]),A[15]||(A[15]=e.createElementVNode("span",null,"Discrepancies only",-1))])])]),default:e.withCtx(()=>[e.createVNode(ae,{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,os)]),"cell-product_name":e.withCtx(({value:Q})=>[e.createElementVNode("span",as,e.toDisplayString(Q),1)]),"cell-expected_quantity":e.withCtx(({value:Q})=>[e.createElementVNode("span",ns,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",ls," ("+e.toDisplayString(Q.discrepancy>0?"+":"")+e.toDisplayString(Q.discrepancy)+") ",1)):e.createCommentVNode("",!0)],2)):(e.openBlock(),e.createElementBlock("span",ss,"pending"))]),_:1},8,["data","loading"])]),_:1})],64)):e.createCommentVNode("",!0),e.createVNode(he,{show:b.value,title:g.value,description:V.value,size:"sm","onUpdate:show":A[3]||(A[3]=Q=>b.value=Q),onClose:A[4]||(A[4]=Q=>b.value=!1)},{footer:e.withCtx(()=>[e.createVNode(T,{variant:"ghost",size:"sm",onClick:A[2]||(A[2]=Q=>b.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"])]))}}),is=H(rs,[["__scopeId","data-v-faf8e3d1"]]),cs={class:"count-entry"},ds={class:"count-entry__header"},us={key:0,class:"count-entry__session-name"},ps={key:1,class:"count-entry__location-count"},ms={key:0,class:"count-entry__connectivity-dot count-entry__connectivity-dot--online","aria-hidden":"true"},vs={key:1,class:"count-entry__connectivity-dot count-entry__connectivity-dot--offline","aria-hidden":"true"},_s={key:0,class:"count-entry__no-location"},hs={class:"count-entry__no-location-actions"},fs={class:"count-entry__search-row"},ys={key:0,class:"count-entry__search-results",role:"listbox","aria-label":"Location search results"},ks=["onClick"],gs={class:"count-entry__location-card"},bs={class:"count-entry__location-details"},Vs={class:"count-entry__location-name"},ws={class:"count-entry__products",role:"list","aria-label":"Products to count"},Ns={key:0,class:"count-entry__no-entries"},Es=["onClick"],Cs={class:"count-entry__product-info"},Bs={class:"count-entry__product-name"},$s={class:"count-entry__product-expected"},xs={class:"count-entry__product-count"},Ss=["for"],Ls=["id","value","onFocus"],Ds={key:0,class:"count-entry__status-icon count-entry__status-icon--match","aria-label":"Match"},zs={key:1,class:"count-entry__status-icon count-entry__status-icon--discrepancy","aria-label":"Discrepancy"},Is={class:"count-entry__keypad",role:"group","aria-label":"Numeric keypad"},Ms=["aria-label","disabled","onClick"],Ts={class:"count-entry__bottom-actions"},Fs=e.defineComponent({__name:"CountEntryForm",props:{sessionId:{},locationId:{}},setup(t){const a=t,o=ne.useRouter(),h=ve(),{currentSession:s,entries:_,fetchSession:y,fetchEntries:i,submitCount:l}=se(),c=ee(),n=ie(),r=e.ref(null),d=e.ref(null),m=e.ref([]),v={},u=e.ref(!1),p=e.ref(navigator.onLine),f=e.ref(""),N=e.ref([]),b=[{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):[]),V=e.computed(()=>g.value.length===0?!1:m.value.every(P=>P!==""));e.onMounted(async()=>{if(h.loadQueue(),window.addEventListener("online",x),window.addEventListener("offline",$),await y(a.sessionId),await i(a.sessionId),a.locationId)try{const P=await c.fetchLocation(a.locationId);k(P)}catch{}}),e.onBeforeUnmount(()=>{window.removeEventListener("online",x),window.removeEventListener("offline",$)}),e.watch(g,P=>{m.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(){p.value=!0,F()}function $(){p.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 w(P){if(d.value===null)return;const z=d.value;let I=m.value[z];if(P==="backspace"){m.value[z]=I.slice(0,-1);return}if(P==="."){if(I.includes("."))return;m.value[z]=I+".";return}const O=g.value[z];if(O.counted_quantity!==null&&I===String(O.counted_quantity)){m.value[z]=P;return}m.value[z]=I+P}async function D(){u.value=!0;try{for(let P=0;P<g.value.length;P++){const z=m.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(p.value)try{await l(a.sessionId,I.id,O)}catch{h.queueCount({sessionId:a.sessionId,entryId:I.id,countedQuantity:O})}else h.queueCount({sessionId:a.sessionId,entryId:I.id,countedQuantity:O})}await i(a.sessionId),await y(a.sessionId)}finally{u.value=!1}}function S(){o.push({name:"inventory-scan"})}function C(){o.push({name:"inventory-count-detail",params:{id:a.sessionId}})}function L(){n.search(f.value),N.value=n.results.value}async function G(P){const z=await c.fetchLocation(P.id);k(z),f.value="",N.value=[]}return(P,z)=>(e.openBlock(),e.createElementBlock("div",cs,[e.createElementVNode("div",ds,[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",us,e.toDisplayString(e.unref(s).name),1)):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createElementBlock("span",ps,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":!p.value}]),role:"status"},[p.value?(e.openBlock(),e.createElementBlock("span",ms)):(e.openBlock(),e.createElementBlock("span",vs)),e.createElementVNode("span",null,e.toDisplayString(p.value?"Online":"Offline -- counts will sync when connected"),1)],2),r.value?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",_s,[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",hs,[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",fs,[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]])]),N.value.length>0?(e.openBlock(),e.createElementBlock("ul",ys,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(N.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,ks)]))),128))])):e.createCommentVNode("",!0)])]),_:1})])),r.value?(e.openBlock(),e.createElementBlock(e.Fragment,{key:1},[e.createElementVNode("div",gs,[e.createVNode(J,{code:r.value.full_code},null,8,["code"]),e.createElementVNode("div",bs,[e.createElementVNode("h2",Vs,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",ws,[g.value.length===0?(e.openBlock(),e.createElementBlock("p",Ns," 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",Cs,[e.createElementVNode("span",Bs,e.toDisplayString(I.product_name),1),e.createElementVNode("span",$s," Expected: "+e.toDisplayString(I.expected_quantity??"-"),1)]),e.createElementVNode("div",xs,[e.createElementVNode("label",{for:`count-input-${I.id}`,class:"sr-only"}," Counted quantity for "+e.toDisplayString(I.product_name),9,Ss),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":m.value[O]!==""&&Number(m.value[O])===I.expected_quantity,"count-entry__count-input--discrepancy":m.value[O]!==""&&Number(m.value[O])!==I.expected_quantity}]),value:m.value[O],readonly:"",onFocus:X=>E(O)},null,42,Ls),I.counted_quantity!==null&&I.discrepancy===0?(e.openBlock(),e.createElementBlock("span",Ds," ✓ ")):I.counted_quantity!==null&&I.discrepancy!==null&&I.discrepancy!==0?(e.openBlock(),e.createElementBlock("span",zs," ⚠ ")):e.createCommentVNode("",!0)])],10,Es))),128))]),e.createElementVNode("div",Is,[(e.openBlock(),e.createElementBlock(e.Fragment,null,e.renderList(b,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=>w(I.value)},e.toDisplayString(I.label),9,Ms)),64))]),e.createElementVNode("div",Ts,[e.createVNode(T,{variant:"primary",size:"lg",disabled:!V.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)]))}}),Ps=H(Fs,[["__scopeId","data-v-b11de393"]]),As={class:"count-report"},Rs={class:"count-report__header"},qs={class:"count-report__title"},Us={class:"count-report__actions"},Hs={class:"count-report__summary-grid"},js={class:"count-report__summary-stat"},Os={class:"count-report__summary-value"},Ks={class:"count-report__summary-stat"},Qs={class:"count-report__summary-value"},Gs={class:"count-report__summary-stat"},Ws={class:"count-report__summary-value"},Zs={class:"count-report__summary-stat"},Js={class:"count-report__summary-value count-report__summary-value--muted"},Xs={class:"count-report__summary-stat"},Ys={class:"count-report__summary-stat"},er={class:"count-report__totals"},tr={class:"count-report__total-row"},or={class:"count-report__total-value"},ar={class:"count-report__total-row"},nr={class:"count-report__total-value"},lr={class:"count-report__total-row count-report__total-row--net"},sr={class:"count-report__disc-location"},rr={class:"count-report__disc-product"},ir={class:"count-report__disc-qty"},cr={class:"count-report__disc-qty"},dr=e.defineComponent({__name:"CountReport",props:{sessionId:{}},setup(t){const a=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 _(a.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(p=>[p.location,p.product,String(p.expected),String(p.counted),String(p.discrepancy)])].map(p=>p.map(f=>`"${f.replace(/"/g,'""')}"`).join(",")).join(`
2
+ `),m=new Blob([d],{type:"text/csv;charset=utf-8;"}),v=URL.createObjectURL(m),u=document.createElement("a");u.href=v,u.download=`count-report-${a.sessionId}.csv`,document.body.appendChild(u),u.click(),document.body.removeChild(u),URL.revokeObjectURL(v)}function n(){window.print()}return(r,d)=>(e.openBlock(),e.createElementBlock("div",As,[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",Rs,[e.createElementVNode("h1",qs," Count Report: "+e.toDisplayString(e.unref(o).session.name),1),e.createElementVNode("div",Us,[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:n},{"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",Hs,[e.createElementVNode("div",js,[e.createElementVNode("span",Os,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",Ks,[e.createElementVNode("span",Qs,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",Gs,[e.createElementVNode("span",Ws,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",Zs,[e.createElementVNode("span",Js,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",Xs,[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",Ys,[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",er,[e.createElementVNode("div",tr,[d[10]||(d[10]=e.createElementVNode("span",{class:"count-report__total-label"},"Total Expected",-1)),e.createElementVNode("span",or,e.toDisplayString(l(e.unref(o).summary.total_expected)),1)]),e.createElementVNode("div",ar,[d[11]||(d[11]=e.createElementVNode("span",{class:"count-report__total-label"},"Total Counted",-1)),e.createElementVNode("span",nr,e.toDisplayString(l(e.unref(o).summary.total_counted)),1)]),e.createElementVNode("div",lr,[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(ae,{columns:y,data:e.unref(o).top_discrepancies,"empty-message":"No discrepancies found."},{"cell-location":e.withCtx(({value:m})=>[e.createElementVNode("span",sr,e.toDisplayString(m),1)]),"cell-product":e.withCtx(({value:m})=>[e.createElementVNode("span",rr,e.toDisplayString(m),1)]),"cell-expected":e.withCtx(({value:m})=>[e.createElementVNode("span",ir,e.toDisplayString(m),1)]),"cell-counted":e.withCtx(({value:m})=>[e.createElementVNode("span",cr,e.toDisplayString(m),1)]),"cell-discrepancy":e.withCtx(({value:m})=>[e.createElementVNode("span",{class:e.normalizeClass(["count-report__disc-delta",{"count-report__disc-delta--positive":m>0,"count-report__disc-delta--negative":m<0}])},e.toDisplayString(m>0?"+":"")+e.toDisplayString(m),3)]),_:1},8,["data"])]),_:1})],64)):e.createCommentVNode("",!0)]))}}),ur=H(dr,[["__scopeId","data-v-e12a8dba"]]),pr={class:"label-batch"},mr={class:"label-batch__format"},vr={class:"label-batch__quick-selectors"},_r=["onClick"],hr={class:"label-batch__filter-row"},fr=["onClick"],yr=["checked","indeterminate","aria-label","onClick"],kr={class:"label-batch__group-name"},gr={class:"label-batch__group-count"},br={class:"label-batch__group-items"},Vr=["checked","onChange"],wr={class:"label-batch__location-name"},Nr={key:3,class:"label-batch__footer"},Er={class:"label-batch__selected-count"},Cr={class:"label-batch__footer-actions"},Br=e.defineComponent({__name:"LabelBatchPrint",setup(t){const{fetchRoots:a,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(""),n=e.ref(""),r=e.ref([]),d=[{value:"standard",label:"Standard"},{value:"small",label:"Small"},{value:"pallet",label:"Pallet"}],m=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 n.value&&(S=S.filter(C=>C.type===n.value)),c.value&&(S=S.filter(C=>C.path&&C.path.length>0&&C.path[0].name===c.value)),S}),p=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 a(),r.value=N(o.value),p.value.forEach(S=>y.add(S.parentName))}finally{i.value=!1}});function N(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 b(S){y.has(S)?y.delete(S):y.add(S)}function g(S){_.has(S)?_.delete(S):_.add(S)}function V(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){V(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 w(){if(_.size!==0){l.value=!0;try{await h(Array.from(_),s.value)}finally{l.value=!1}}}function D(){w()}return(S,C)=>(e.openBlock(),e.createElementBlock("div",pr,[C[6]||(C[6]=e.createElementVNode("div",{class:"label-batch__header"},[e.createElementVNode("h1",{class:"label-batch__title"},"Print Labels")],-1)),e.createElementVNode("div",mr,[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",vr,[(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,_r))),128))]),e.createElementVNode("div",hr,[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:n.value,"onUpdate:modelValue":C[2]||(C[2]=L=>n.value=L),options:m.value,placeholder:"By Type"},null,8,["modelValue","options"])])]),_:1}),i.value?(e.openBlock(),e.createBlock(j,{key:0,loading:""})):p.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(p.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=>b(L.parentName)},[e.createElementVNode("input",{type:"checkbox",checked:V(L),indeterminate:x(L),class:"label-batch__checkbox","aria-label":`Select all in ${L.parentName}`,onClick:e.withModifiers(G=>$(L),["stop"])},null,8,yr),e.createElementVNode("span",kr,e.toDisplayString(L.parentName),1),e.createElementVNode("span",gr,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,fr),e.withDirectives(e.createElementVNode("div",br,[(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,Vr),e.createVNode(J,{code:G.full_code},null,8,["code"]),e.createElementVNode("span",wr,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",Nr,[e.createElementVNode("span",Er," Selected: "+e.toDisplayString(_.size)+" label"+e.toDisplayString(_.size!==1?"s":""),1),e.createElementVNode("div",Cr,[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:w},{"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)]))}}),$r=H(Br,[["__scopeId","data-v-1eb7f5c2"]]),xr=["aria-label","onClick"],Sr={class:"pll-location-path"},Lr={class:"pll-quantity"},Dr={key:0,class:"pll-primary-star",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",role:"img","aria-label":"Primary location"},zr={key:1,class:"pll-no-primary","aria-label":"Not primary location"},Ir={class:"pll-footer"},Mr={class:"pll-total-value"},Tr=e.defineComponent({__name:"ProductLocationList",props:{productId:{}},emits:["navigate"],setup(t,{emit:a}){const o=t,h=a,{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((m,v)=>m+v.quantity,0));function c(m){return Number.isInteger(m)?m.toFixed(0):m.toFixed(2)}function n(m){var v,u;return(v=m.location)!=null&&v.path?m.location.path.map(p=>p.name).concat([m.location.name]).join(" > "):((u=m.location)==null?void 0:u.name)??"Unknown location"}function r(m){m.location&&h("navigate",m.location)}async function d(){try{y.value=await _(o.productId)}catch{y.value=[]}}return e.watch(()=>o.productId,m=>{m&&d()},{immediate:!0}),(m,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(ae,{columns:i,data:y.value,"empty-message":"No locations found."},{"cell-path":e.withCtx(({row:u})=>{var p;return[e.createElementVNode("button",{type:"button",class:"pll-location-link","aria-label":`Navigate to ${((p=u.location)==null?void 0:p.name)??"location"}`,onClick:f=>r(u)},[e.createElementVNode("span",Sr,e.toDisplayString(n(u)),1)],8,xr)]}),"cell-code":e.withCtx(({row:u})=>{var p,f;return[(p=u.location)!=null&&p.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",Lr,e.toDisplayString(c(u.quantity)),1)]),"cell-is_primary":e.withCtx(({row:u})=>[u.is_primary?(e.openBlock(),e.createElementBlock("svg",Dr,[...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",zr))]),_:1},8,["data"]),e.createElementVNode("div",Ir,[v[1]||(v[1]=e.createElementVNode("span",{class:"pll-total-label"},"Total:",-1)),e.createElementVNode("span",Mr,e.toDisplayString(c(l.value))+" across "+e.toDisplayString(y.value.length)+" location"+e.toDisplayString(y.value.length!==1?"s":""),1)])],64))]),_:1},8,["loading"]))}}),Fr=H(Tr,[["__scopeId","data-v-47c4cd6e"]]),Pr={class:"label-preview"},Ar={class:"label-preview__controls"},Rr={key:0,class:"label-preview__loading",role:"status"},qr={key:1,class:"label-preview__error",role:"alert"},Ur={class:"label-preview__error-text"},Hr={key:2,class:"label-preview__container"},jr={class:"label-preview__path"},Or={class:"label-preview__code"},Kr={class:"label-preview__name"},Qr=["innerHTML"],Gr=["innerHTML"],Wr={key:3,class:"label-preview__print"},Zr=e.defineComponent({__name:"LabelPreview",props:{locationId:{},format:{default:"standard"}},emits:["print"],setup(t,{emit:a}){const o=t,h=a,{labelData:s,loading:_,error:y,fetchLabel:i,printLabel:l}=_e(),c=e.ref(o.format),n=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(()=>m()),e.watch(c,()=>m());async function m(){try{await i(o.locationId,c.value)}catch{}}async function v(){n.value=!0;try{await l(o.locationId,c.value),h("print")}catch{}finally{n.value=!1}}return(u,p)=>(e.openBlock(),e.createElementBlock("div",Pr,[e.createElementVNode("div",Ar,[e.createVNode(oe,{modelValue:c.value,"onUpdate:modelValue":p[0]||(p[0]=f=>c.value=f),options:r,label:"Format"},null,8,["modelValue"])]),e.unref(_)?(e.openBlock(),e.createElementBlock("div",Rr,[...p[1]||(p[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",qr,[e.createElementVNode("p",Ur,e.toDisplayString(e.unref(y)),1),e.createVNode(T,{variant:"secondary",size:"sm",onClick:m},{default:e.withCtx(()=>[...p[2]||(p[2]=[e.createTextVNode(" Retry ",-1)])]),_:1})])):e.unref(s)?(e.openBlock(),e.createElementBlock("div",Hr,[e.createElementVNode("div",{class:"label-preview__label",style:e.normalizeStyle(d.value)},[e.createElementVNode("p",jr,e.toDisplayString(e.unref(s).path),1),e.createElementVNode("p",Or,e.toDisplayString(e.unref(s).location.full_code),1),e.createElementVNode("p",Kr,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,Qr)):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,Gr)):e.createCommentVNode("",!0)],4)])):e.createCommentVNode("",!0),e.unref(s)?(e.openBlock(),e.createElementBlock("div",Wr,[e.createVNode(T,{variant:"primary",size:"md",loading:n.value,onClick:v},{"icon-left":e.withCtx(()=>[...p[3]||(p[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(()=>[p[4]||(p[4]=e.createTextVNode(" Print Label ",-1))]),_:1},8,["loading"])])):e.createCommentVNode("",!0)]))}}),Jr=H(Zr,[["__scopeId","data-v-c9c4e755"]]),Xr={class:"unlocated-products"},Yr={class:"unlocated-products__header"},ei={key:0,class:"unlocated-products__subtitle"},ti={class:"unlocated-products__product-name"},oi={key:0,class:"unlocated-products__sku"},ai={key:1,class:"unlocated-products__no-sku"},ni={key:0,class:"unlocated-products__load-more"},li={class:"unlocated-products__showing"},si={class:"unlocated-products__locate-form"},ri={class:"unlocated-products__locate-search"},ii={key:0,class:"unlocated-products__locate-results",role:"listbox","aria-label":"Location search results"},ci=["aria-selected"],di=["onClick"],ui={class:"unlocated-products__locate-option-name"},pi={key:1,class:"unlocated-products__locate-no-results"},mi={key:2,class:"unlocated-products__locate-selected"},vi=e.defineComponent({__name:"UnlocatedProducts",props:{limit:{default:50}},emits:["locate"],setup(t,{emit:a}){const o=t,h=a,s=ie(),{addProduct:_}=te(),y=e.ref([]),i=e.ref(0),l=e.ref(!1),c=e.ref(!1),n=e.ref(1),r=e.ref(!1),d=e.ref(null),m=e.ref(""),v=e.ref([]),u=e.ref(null),p=e.ref(!1),f=e.ref(!1),N=[{key:"name",label:"Product"},{key:"sku",label:"SKU",width:"150px"},{key:"actions",label:"",width:"100px",align:"right"}],b=e.computed(()=>y.value.length<i.value);e.onMounted(()=>g());async function g(w=!1){var D;w?c.value=!0:l.value=!0;try{const S=await R().get(q(`/dashboard/unlocated-products?limit=${o.limit}&page=${n.value}`)),C=S.data.data||S.data;i.value=((D=S.data.meta)==null?void 0:D.total)??C.length,w?y.value.push(...C):y.value=C}catch{}finally{l.value=!1,c.value=!1}}function V(){n.value++,g(!0)}function x(w){d.value=w,r.value=!0,m.value="",v.value=[],u.value=null,h("locate",{id:w.id,name:w.name})}function $(){p.value=!0,s.search(m.value);const w=setInterval(()=>{s.loading.value||(v.value=s.results.value,p.value=!1,clearInterval(w))},100);setTimeout(()=>{clearInterval(w),p.value=!1,v.value=s.results.value},2e3)}function F(w){u.value=w,v.value=[],m.value=""}function k(){r.value=!1,d.value=null,u.value=null,m.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(w=>w.id!==d.value.id),i.value=Math.max(0,i.value-1),k()}catch{}finally{f.value=!1}}}return(w,D)=>{var S;return e.openBlock(),e.createElementBlock("div",Xr,[e.createElementVNode("div",Yr,[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",ei,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(ae,{columns:N,data:y.value,"empty-message":"All products have assigned locations."},{"cell-name":e.withCtx(({row:C})=>[e.createElementVNode("span",ti,e.toDisplayString(C.name),1)]),"cell-sku":e.withCtx(({row:C})=>[C.sku?(e.openBlock(),e.createElementBlock("span",oi,e.toDisplayString(C.sku),1)):(e.openBlock(),e.createElementBlock("span",ai,"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"]),b.value?(e.openBlock(),e.createElementBlock("div",ni,[e.createElementVNode("p",li," Showing "+e.toDisplayString(y.value.length)+" of "+e.toDisplayString(i.value),1),e.createVNode(T,{variant:"ghost",size:"sm",loading:c.value,onClick:V},{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",si,[e.createElementVNode("div",ri,[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=>m.value=C),type:"search",class:"unlocated-products__locate-input",placeholder:"Search by code or name...",onInput:$},null,544),[[e.vModelText,m.value]])]),v.value.length>0?(e.openBlock(),e.createElementBlock("ul",ii,[(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",ui,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,di)],8,ci)}),128))])):e.createCommentVNode("",!0),m.value.length>=2&&v.value.length===0&&!p.value?(e.openBlock(),e.createElementBlock("p",pi," No locations found ")):e.createCommentVNode("",!0),u.value?(e.openBlock(),e.createElementBlock("div",mi,[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"])])}}}),_i=H(vi,[["__scopeId","data-v-9a21fb9b"]]),hi={install(t,a={}){Se({prefix:a.apiPrefix||"/api/inventory-locator/v1"})}};exports.CountEntryForm=Ps;exports.CountReport=ur;exports.CountSessionDetail=is;exports.CountSessionList=Ll;exports.InventoryDashboard=Ut;exports.InventoryLocatorPlugin=hi;exports.InventoryLocatorShell=pn;exports.LabelBatchPrint=$r;exports.LabelPreview=Jr;exports.LocationBreadcrumb=fe;exports.LocationCodeBadge=J;exports.LocationDetail=Ie;exports.LocationSearchInput=De;exports.LocationTree=ze;exports.LocationTypeIcon=re;exports.ProductLocationList=Fr;exports.ScanHistory=Te;exports.ScanResult=Me;exports.ScannerOverlay=el;exports.UnlocatedProducts=_i;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=me;exports.useScanner=Le;exports.useScannerStore=Ne;