1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["chunks/CzEnu0pL.js","chunks/Dem1e8VV.js","entry/whq2ljq-.js","chunks/CNFvtpL4.js","chunks/phrJN640.js","assets/ifAoQj-C.css","chunks/BnZNklX7.js","chunks/Dh95b2SR.js","assets/DLG_ljTX.css","chunks/BF-IXPZj.js","chunks/DMbkGTRP.js","chunks/D_dW1Pkp.js","chunks/smHNvufX.js"])))=>i.map(i=>d[i]); 2import{d as b,eo as g,L as p,_ as j}from"./CNFvtpL4.js";import{j as e,r as _,b as k}from"./Dem1e8VV.js";import{u as h,cd as V,ay as Y,x as E,y as v,c1 as A,b$ as C,dM as L,cb as R,dN as D}from"../entry/whq2ljq-.js";import"./BnZNklX7.js";import"./phrJN640.js";import{a as T}from"./DQtLDZZe.js";import{u as P}from"./CMXx1Ur9.js";import{F}from"./CCYrGWqc.js";import{S as O}from"./8FnJlTTQ.js";import"./Dh95b2SR.js";import"./CQZj1FWu.js";import"./D_dW1Pkp.js";import"./CsoVWxaq.js";function G({groups:r}){const i=h();return r.length===0?e.jsx(T,{title:i("INVENTORY.SETTINGS_TITLE"),rows:[],empty:i("INVENTORY.READ.NO_REVENUE")}):e.jsx("div",{className:"flex flex-col gap-4",children:r.map(c=>{var t,d;const N=!!((t=c.metaInfo)!=null&&t.trackInventory),m=[{label:i("INVENTORY.READ.HOLDS_STOCK"),value:i(N?"INVENTORY.READ.YES":"INVENTORY.READ.NO")},{label:i("INVENTORY.READ.DAYS"),value:N?`${Number((d=c.metaInfo)==null?void 0:d.daysInInventory)||0} ${i("INVENTORY.READ.DAYS_UNIT",{raw:!0})}`:void 0}];return e.jsx(T,{title:c.title||i("INVENTORY.READ.UNNAMED"),rows:m},c._id)})})}const M=k.lazy(()=>j(()=>import("./CzEnu0pL.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])));function w(){return e.jsx("div",{className:"px-4 py-5",children:e.jsx(D,{})})}const te=()=>{const r=h(),i=V(),{humanizeCompactInteger:c}=Y(),m=P()("inventory"),{businessId:t}=b(),[d]=E("finance.groups",t?[t,"revenue"]:void 0),[l]=E("finance.group.items",t?[t,"cost",{}]:void 0),I=v(()=>{if(!t||!d||!l)return[];const s=A.find({businessId:t},{fields:{_id:1,title:1,"metaInfo.trackInventory":1,"metaInfo.startingInventory":1,"metaInfo.daysInInventory":1},sort:{position:1}});return((s==null?void 0:s.fetch())||[]).map(o=>{var a,n,f;return{...o,metaInfo:{...(a=o.metaInfo)!=null?a:{},trackInventory:(f=(n=o.metaInfo)==null?void 0:n.trackInventory)!=null?f:!1}}})},[t,d,l]),x=I.reduce((s,u)=>{var o,a;return s+((o=u.metaInfo)!=null&&o.trackInventory&&((a=u.metaInfo)==null?void 0:a.startingInventory)||0)},0),{cosMap:y,selectedCOS:S}=v(()=>{if(!t||!l)return{costOfSales:[],cosMap:{},selectedCOS:{}};const s=C.find({businessId:t},{fields:{groupId:1,"metaInfo.name":1,isExcluded:1,isExcludedInventory:1},sort:{position:1}}),u=((s==null?void 0:s.fetch())||[]).filter(n=>n.isExcluded!==!0),o={},a={};return u.forEach(n=>{o[n.groupId]||(o[n.groupId]={totalCOS:0,cos:[]}),a[n.groupId]||(a[n.groupId]=[]),o[n.groupId].totalCOS++,o[n.groupId].cos.push(n),n.isExcludedInventory||a[n.groupId].push(n)}),{cosMap:o,selectedCOS:a}},[t,d,l]);return!l||!d?e.jsx(L,{variant:"inventory"}):i?e.jsxs(O,{title:r("INVENTORY.TITLE"),children:[e.jsx(F,{type:"inventory",mode:"card"}),e.jsx("div",{className:"bg-surface relative rounded-lg border border-border h-fit",children:e.jsxs("div",{className:"flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-b border-border bg-muted/50",children:[e.jsx("div",{className:"bg-link/15 flex items-center justify-center p-1.5 rounded-lg",children:e.jsx(g,{className:"size-5 text-link","aria-hidden":!0})}),e.jsx("h2",{className:"flex-1 text-base font-bold text-foreground",children:r("INVENTORY.SETTINGS_TITLE")})]}),e.jsxs("div",{className:"flex flex-col divide-y divide-border",children:[e.jsx(_.Suspense,{fallback:e.jsx(w,{}),children:I.map(s=>e.jsx(M,{groupId:s._id,cosMap:y,selectedCOS:S},s._id))}),I.length===0&&l&&d&&e.jsxs("div",{className:"px-4 py-6 text-sm text-muted-foreground",children:[e.jsx("p",{children:r("INVENTORY.NO_REVENUE")}),e.jsx(p,{to:R(t,"revenue"),className:"mt-2 inline-block text-link hover:underline cursor-pointer",children:r("INVENTORY.NO_REVENUE_ACTION")})]}),m&&e.jsxs("div",{className:"border-t border-border px-4 py-3 text-sm text-muted-foreground",children:[r("INVENTORY.SEE_REPORT_INTRO")," ",e.jsx(p,{to:m,className:"text-link hover:underline cursor-pointer",children:r("INVENTORY.SEE_REPORT")})]}),x>0&&e.jsxs("div",{className:"border-t border-border px-4 py-3 text-sm text-muted-foreground",children:[r("INVENTORY.OPENING_STOCK_TOTAL",{amount:c(Math.round(x),2,!0)})," ",e.jsx(p,{to:R(t,"settings/starting-balance"),className:"text-link hover:underline cursor-pointer",children:r("INVENTORY.SEE_STARTING_BALANCE")})]})]})]})})]}):e.jsx(O,{title:r("INVENTORY.TITLE"),children:e.jsx(G,{groups:I})})};export{te as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.