PageSourceSearch

https://restaurant-app-production.web.app/assets/PrepLabels-BUKh3rNE.js

js restaurant-app-production.web.app collected 2026-10-03 12:36:13 UTC 46,539 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/prepLabelQr-YXb1X51B.js","assets/inventoryPricing-BG1OXYxN.js","assets/textMemo-DFhgwZKR.js","assets/shelfTags-BDO1auPp.js","assets/rolldown-runtime-b3L32Ng1.js","assets/module-B8BOkXXh.js","assets/inventoryScanPilot--vmuhv5b.js","assets/main-BpGFkDZX.js","assets/app-DWbpOmbp.js","assets/app-BgbWr5OS.css","assets/moduleDeepLinks-CTVFNwbL.js","assets/teamCodeLength-DGY5Lk48.js","assets/dashboardFilterState-C5qGIQV9.js","assets/holdWaste-BTR-8Tz1.js","assets/yoyComparison-CgmkAllW.js","assets/dashboardTenantTimeZone-BQw3VcsB.js","assets/scheduling-BVuHXc_1.js","assets/corporateRooms-B79eNrff.js","assets/corporateHubWorkspaces-Bt8JmPRN.js","assets/inventoryCosting-DM2tQe4Y.js","assets/inventoryUnits-DLMYb9tw.js","assets/recipeGraph-DVwIz8GK.js","assets/vendor-react-jCs7ns5R.js","assets/SettingsSection-CVVpvcV-.js","assets/posCollections-CmaUJtF4.js","assets/posSalesRowFilters-DbvrU1o-.js","assets/productMixNormalizer-BPpq6jtf.js","assets/recipeSalesBindings-DuBGC6Dx.js","assets/main-JoZZYyzg.css"])))=>i.map(i=>d[i]);
2import{r as Ot}from"./rolldown-runtime-b3L32Ng1.js";import{a as $e}from"./app-DWbpOmbp.js";import{$t as At,Cn as tt,Ct as Mt,F as fe,Lt as Ee,On as $t,P as _t,Tn as st,Vt as rt,_ as Ht,bn as nt,cn as Te,d as Bt,fn as ge,h,hn as at,kn as Oe,nr as Kt,on as Rt,p as Ft,qt as G,un as Vt,vn as lt}from"./module-B8BOkXXh.js";import{t as C}from"./teamCodeLength-DGY5Lk48.js";import{n as qt,t as Ut}from"./PremiumShell-B_wt6ND8.js";import{n as Gt}from"./useFlashMessage-C0m2H5IT.js";import{i as Wt,n as Qt,o as Yt,s as it,t as Xt}from"./inventoryScanPilot--vmuhv5b.js";import{L as Jt}from"./operatorAI-B_bUNpA3.js";import{f as Zt}from"./kitchenLogRules-DlfrEwbd.js";import{i as es}from"./HoldTimerViews-C3jmqS2U.js";var o=Ot(Kt(),1),e=Mt();function ot({onAdd:n}){const{t:a}=$e();return(0,e.jsx)("div",{"data-testid":"prep-labels-empty-state",children:(0,e.jsx)(Ft,{icon:"Tag",title:a("prep.empty.title"),description:a("prep.empty.description"),actionLabel:a("prep.empty.addFirst"),onAction:n})})}var ts="employeeId|rosterVersion|storeKey|verifiedAt";function mt(n){return!!(n&&typeof n=="object"&&Object.keys(n).sort().join("|")===ts&&n.employeeId&&n.verifiedAt!==void 0&&n.verifiedAt!==null)}function ss(n,a=[],i=""){const d=(0,C.acceptedTeamCodeOrEmpty)(n);if(!d)return null;const m=String(i||"");return(a||[]).find(u=>(0,C.acceptedTeamCodeOrEmpty)(u.prepCode)===d&&(u.primaryStore===m||!m))||null}function pt(n=[]){return(Array.isArray(n)?n:[]).map(a=>[String(a.id||""),(0,C.acceptedTeamCodeOrEmpty)(a.prepCode),String(a.primaryStore||a.store||"")].join(":")).sort().join("|")}function xt(n,a,i="",d="",m=Date.now()){return n?.id?{employeeId:String(n.id),storeKey:String(i||n.primaryStore||n.store||""),rosterVersion:String(d||""),verifiedAt:m}:null}function ie(n,a=[]){if(!mt(n))return null;const i=String(n.employeeId),d=String(n.storeKey||"");return(Array.isArray(a)?a:[]).find(m=>String(m?.id||"")===i&&(!d||String(m.primaryStore||m.store||"")===d)&&(0,C.isAcceptedTeamCode)(m?.prepCode)&&!["inactive","terminated","deleted"].includes(String(m?.status||"active").trim().toLowerCase()))||null}function rs(n,a,i="",d="",m=null){if(!mt(n)||String(i||"")&&String(n.storeKey||"")!==String(i||"")||String(n.rosterVersion||"")!==String(d||""))return null;if(Array.isArray(m)){const u=ie(n,m);if(!u||a&&(0,C.acceptedTeamCodeOrEmpty)(u.prepCode)!==(0,C.acceptedTeamCodeOrEmpty)(a))return null}return n}function le(n,a,i,d){const m=rs(n,a,i,pt(d),d);return m&&ie(m,d)?m:null}function ns(n,a,i){return(0,C.isAcceptedTeamCode)(n)?i?!0:(0,C.shouldAutoSubmitTeamCode)(n,a):!1}function as(n,a,i,d="",m=""){if(String(n||"")!==String(a||""))return{ignored:!0,employee:null,error:""};const u=xt(i,n,d,m);return u?{ignored:!1,employee:u,error:""}:{ignored:!1,employee:null,error:"Invalid code"}}var ye="mg_prep_labels",B=[{key:"4 hour label",labelKey:"prep.cat.fourHourLabel",icon:"Timer",color:"red"},{key:"Dairy",labelKey:"prep.cat.dairy",icon:"Milk",color:"blue"},{key:"Dough",labelKey:"prep.cat.dough",icon:"Circle",color:"amber"},{key:"Dry Goods",labelKey:"prep.cat.dryGoods",icon:"Package",color:"stone"},{key:"Nuts",labelKey:"prep.cat.nuts",icon:"Nut",color:"yellow"},{key:"Produce",labelKey:"prep.cat.produce",icon:"Leaf",color:"emerald"},{key:"Proteins",labelKey:"prep.cat.proteins",icon:"Beef",color:"rose"},{key:"Sauces",labelKey:"prep.cat.sauces",icon:"Droplets",color:"orange"},{key:"Seasonings",labelKey:"prep.cat.seasonings",icon:"Sparkles",color:"purple"}],Ae=Object.fromEntries(B.map(n=>[n.key,n])),ls={"4 hour label":"94aa89",Dairy:"73db6f",Dough:"f24a00","Dry Goods":"4ebf73",
2Nuts:"c79f3b",Produce:"22b573",Proteins:"acb1b9",Sauces:"e75e96",Seasonings:"25ef99",Pasta:"777861",Refrigerated:"0cd91e"},is={red:"bg-red-500/10 text-red-400 border-red-500/20",blue:"bg-blue-500/10 text-blue-400 border-blue-500/20",amber:"bg-amber-500/10 text-amber-400 border-amber-500/20",stone:"bg-stone-500/10 text-stone-400 border-stone-500/20",yellow:"bg-yellow-500/10 text-yellow-400 border-yellow-500/20",emerald:"bg-emerald-500/10 text-emerald-400 border-emerald-500/20",rose:"bg-rose-500/10 text-rose-400 border-rose-500/20",orange:"bg-orange-500/10 text-orange-400 border-orange-500/20",purple:"bg-purple-500/10 text-purple-400 border-purple-500/20"},os={red:"text-red-400",blue:"text-blue-400",amber:"text-amber-400",stone:"text-stone-400",yellow:"text-yellow-400",emerald:"text-emerald-400",rose:"text-rose-400",orange:"text-orange-400",purple:"text-purple-400"},cs=[{id:"labels",label:"Labels"},{id:"batches",label:"Batches"},{id:"categories",label:"Categories"},{id:"templates",label:"Templates"},{id:"labelPrep",label:"Label Prep"},{id:"optionSets",label:"Option Sets"}],Me=n=>{const a=n instanceof Date?n:new Date(n);return`${a.getFullYear()}-${String(a.getMonth()+1).padStart(2,"0")}-${String(a.getDate()).padStart(2,"0")}`},oe=n=>new Date(n+"T00:00:00").toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"}),ds=(n,a)=>{const i=n>=12?"PM":"AM";return`${n%12||12}:${String(a).padStart(2,"0")} ${i}`},ms=(n,a)=>{const i=new Date(n+"T00:00:00");return i.setDate(i.getDate()+a),Me(i)},ps=(n,a,i)=>{const d=new Date(n+"T"+a+":00");return d.setHours(d.getHours()+i),d},W=n=>{if(!n)return 0;if(typeof n?.toDate=="function")return n.toDate().getTime();if(typeof n=="number")return n;const a=Date.parse(n);return Number.isFinite(a)?a:0},ct=n=>{const a=W(n);return a?new Date(a).toLocaleString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"}):"—"};function xs(n,a){return n.map(i=>{const d=Ae[i.category],m=d?.labelKey?a(d.labelKey):i.category,u=i.useBy.isHourBased?`${oe(i.useBy.date)} @ ${i.useBy.time}`:`${oe(i.useBy.date)}${i.useBy.time==="EOD"?" ("+a("prep.label.eod")+")":""}`;return{name:i.name,unit:i.unit,category:i.category,categoryLabel:m,prepDateText:oe(i.prepDate),useByText:u,employeeName:i.employeeName}})}function us(n){const a=document.getElementById("mg-print-frame");a&&a.remove();const i=document.createElement("iframe");i.id="mg-print-frame",i.style.cssText="position:fixed;top:-9999px;left:-9999px;width:0;height:0;border:none;",document.body.appendChild(i);const d=i.contentDocument||i.contentWindow.document;return d.open(),d.write(n),d.close(),i.onload=()=>{try{i.contentWindow.focus(),i.contentWindow.print()}catch{window.print()}},setTimeout(()=>{try{i.contentWindow.focus(),i.contentWindow.print()}catch{}},300),i}function Ss({user:n,profile:a,isManagerOnly:i,userStore:d,isOwner:m}){const u=_t(),w=(0,o.useMemo)(()=>Zt(u),[u]),f=u?.tenantId||a?.tenantId,{t:l}=$e(),M=u?.tenantName||u?.name||u?.settings?.brandName||"Restaurant",O=Xt({tenantId:f,tenant:u,profile:a}),v=!!(m||a?.role==="admin"||a?.role==="super_admin"),N=a?.role==="team_member",A=String(a?.role||"").trim().toLowerCase()==="team_lead",T=String(a?.employeeDocId||a?.employeeId||"").trim(),[g,k]=(0,o.useState)("labelPrep"),[S,y]=(0,o.useState)([]),[ut,_e]=(0,o.useState)(!0),[He,je]=(0,o.useState)(""),[$,Q]=(0,o.useState)(!1),[ce,bt]=(0,o.useState)(!1),[de,ht]=(0,o.useState)(""),[me,ft]=(0,o.useState)(""),[gt,Be]=(0,o.useState)(!1),[b,Y]=(0,o.useState)([]),[pe,yt]=(0,o.useState)(Me(new Date)),[Ke,jt]=(0,o.useState)(()=>{const t=new Date;return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}),[_,Nt]=(0,o.useState)(""),[P,K]=(0,o.useState)(null),[Ne,R]=(0,o.useState)(""),te=(0,o.useRef)(""),F=(0,o.useRef)(0),ve=(0,C.readConfiguredTeamCodeLength)(u),[X,se]=(0,o.useState)(""),[L,re]=(0,o.useState)([]),Re=(0,o.useRef)([]),[J,Fe]=(0,o.useState)("all"),[ne,vt]=(0,o.useState)(""),[Ve,qe]=(0,o.useState)("3x2"),[Ue,Ge]=(0,o.useState)(()=>O);(0,o.useEffect)(()=>{O&&Ge(!0)},[O]);const[ze,we]=(0,o.useState)(null),[zt,Z]=(0,o.useState)(!1),[Se,Ce]=(0,o.useState)(null),[xe,wt]=(0,o.useState)("all"),[ue,St]=(0,o.useState)(""),{schedule:Ct}=Gt(),j=t=>{je(t),Ct(()=>je(""),6e3)};(0,o.useRef)(null);const Le=(0,o.useMemo)(()=>{const t=String(d||a?.store||a?.primaryStore||"default-store").trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"default-store";return`mg-prep-label-stock:${f||"tenant"}:${t}`},[a?.primaryStore,a?.store,f,d]);(0,o.useEffect)(()=>
2{if(typeof window>"u")return;const t=window.localStorage?.getItem(Le);qe(it(t||"3x2").id)},[Le]);const Lt=t=>{const s=it(t).id;qe(s);try{window.localStorage?.setItem(Le,s)}catch{}};(0,o.useEffect)(()=>{v||g!=="labelPrep"&&k("labelPrep")},[v,g]),(0,o.useEffect)(()=>{if(!f)return;(async()=>{_e(!0);try{const s=(await lt(tt(Te(G,ye),Oe("tenantId","==",f),nt(1e3)))).docs.map(r=>({id:r.id,...r.data()}));s.sort((r,c)=>(r.name||"").localeCompare(c.name||"")),y(s),Be(!1)}catch(s){y([]),Be(!0),j(l("prep.error.loadingItems")+". "+fe(s))}_e(!1)})()},[f]),(0,o.useEffect)(()=>{if(!f)return;(async()=>{try{if(N){if(!T){re([]),se("");return}const r=await at(ge(G,Ee.employees,T)),c=r.exists()?{id:r.id,...r.data()}:null;re(c?.status==="active"&&c?.prepCode?[c]:[]),se("");return}if(A){re([]),se("");return}const s=[Oe("tenantId","==",f),...i&&d?[Oe("primaryStore","==",d)]:[],nt(2e3)];re((await lt(tt(Te(G,Ee.employees),...s))).docs.map(r=>({id:r.id,...r.data()})).filter(r=>r.status==="active"&&r.prepCode)),se("")}catch{re([]),se("Could not load employee Toast POS codes. Reload the page and try again.")}})()},[i,A,N,T,f,d]);const be=pt(L);(0,o.useEffect)(()=>{if(!N||!T)return;const t=L.find(s=>s.id===T);if(!t){F.current+=1,K(null),R("");return}if(P&&!le(P,"",d,L)){F.current+=1,K(null),R("");return}P||(K(xt(t,t.prepCode,d,be)),R(""))},[N,T,be,L,d,P]),te.current=_,Re.current=L;const We=(t,s)=>{if(!ns(t,ve,s))return;const r=ss(t,L,d),c=as(t,te.current,r,d,be);c.ignored||(K(c.employee),R(c.error))};(0,o.useEffect)(()=>{if(!N){if(X){F.current+=1,K(null),R("");return}le(P,_,d,L)||(P&&(F.current+=1,K(null),R("")),!N&&(0,C.shouldAutoSubmitTeamCode)(_,ve)&&We(_,!1))}},[ve,_,X,N,be,L,d,P]);const It=async t=>{if(f){if(!v){j("Only owner/admin can customize labels.");return}Q(!0);try{const s={tenantId:f,name:t.name.trim(),category:t.category,shelfLifeDays:parseInt(t.shelfLifeDays)||0,shelfLifeHours:parseInt(t.shelfLifeHours)||0,expiresEOD:t.expiresEOD!==!1,active:!0,createdAt:st(),createdBy:n?.email||""},r=await Rt(Te(G,ye),s);y(c=>[...c,{id:r.id,...s}].sort((p,x)=>p.name.localeCompare(x.name))),Z(!1),j(l("prep.success.itemAdded",{name:t.name})),rt("prep_label_item_added",{item:t.name,category:t.category},n,a,f)}catch(s){j(l("prep.error.addingItem")+". "+fe(s))}Q(!1)}},kt=async(t,s)=>{if(!v){j("Only owner/admin can customize labels.");return}Q(!0);try{await $t(ge(G,ye,t),{name:s.name.trim(),category:s.category,shelfLifeDays:parseInt(s.shelfLifeDays)||0,shelfLifeHours:parseInt(s.shelfLifeHours)||0,expiresEOD:s.expiresEOD!==!1,updatedAt:st()}),y(r=>r.map(c=>c.id===t?{...c,...s}:c).sort((c,p)=>c.name.localeCompare(p.name))),we(null),j(l("prep.success.itemUpdated",{name:s.name}))}catch(r){j(l("prep.error.updatingItem")+". "+fe(r))}Q(!1)},Pt=async t=>{if(!v){j("Only owner/admin can customize labels.");return}Q(!0);try{const s=S.find(r=>r.id===t)?.name||"Item";await Vt(ge(G,ye,t)),y(r=>r.filter(c=>c.id!==t)),Ce(null),Y(r=>r.filter(c=>c.itemId!==t)),j(l("prep.success.itemDeleted",{name:s}))}catch(s){j(l("prep.error.deletingItem")+". "+fe(s))}Q(!1)},I=(0,o.useMemo)(()=>S.filter(t=>t.active!==!1),[S]),Qe=!gt&&S.length===0,V=(0,o.useMemo)(()=>{let t=I;if(J!=="all"&&(t=t.filter(s=>s.category===J)),ne.trim()){const s=ne.toLowerCase();t=t.filter(r=>r.name.toLowerCase().includes(s))}return t},[I,J,ne]),Ye=(0,o.useMemo)(()=>{let t=S;if(xe!=="all"&&(t=t.filter(s=>s.category===xe)),ue.trim()){const s=ue.toLowerCase();t=t.filter(r=>r.name.toLowerCase().includes(s))}return t},[S,xe,ue]),ae=(0,o.useMemo)(()=>{const t={};for(const s of I){const r=s.category||"Uncategorized";if(!t[r]){const p=Ae[r];t[r]={name:r,label:p?.labelKey?l(p.labelKey):r,colorHex:ls[r]||"6b7280",count:0,latest:0}}t[r].count+=1;const c=Math.max(W(s.updatedAt),W(s.createdAt));c>t[r].latest&&(t[r].latest=c)}return Object.values(t).filter(s=>de.trim()?s.label.toLowerCase().includes(de.trim().toLowerCase()):!0).sort((s,r)=>s.label.localeCompare(r.label))},[I,de,l]),Dt=(0,o.useMemo)(()=>{const t=I.filter(x=>(x.shelfLifeHours||0)>0&&(x.shelfLifeDays||0)===0),s=I.filter(x=>!((x.shelfLifeHours||0)>0&&(x.shelfLifeDays||0)===0)),r=t.reduce((x,D)=>
2Math.max(x,W(D.updatedAt),W(D.createdAt)),0),c=[{name:"2x1 EOD",owner:M,items:"Print Date, Print Time, Duration Date, Text Field, Employee, Label Name",size:"2x1",lastEdited:s.reduce((x,D)=>Math.max(x,W(D.updatedAt),W(D.createdAt)),0)},{name:"2x1 Hourly",owner:M,items:"Print Date, Print Time, Duration Date, Text Field, Duration Time, Employee, Label Name",size:"2x1",lastEdited:r}];if(!me.trim())return c;const p=me.trim().toLowerCase();return c.filter(x=>x.name.toLowerCase().includes(p)||x.items.toLowerCase().includes(p))},[I,M,me]),Et=t=>{Y(s=>s.findIndex(r=>r.itemId===t)>=0?s.filter(r=>r.itemId!==t):[...s,{itemId:t,qty:1}])},Ie=(t,s)=>{Y(r=>r.map(c=>c.itemId===t?{...c,qty:Math.max(1,parseInt(s)||1)}:c))},ke=t=>b.some(s=>s.itemId===t),Pe=t=>b.find(s=>s.itemId===t)?.qty||1,Xe=t=>{if(t.shelfLifeHours>0&&!t.shelfLifeDays){const s=ps(pe,Ke,t.shelfLifeHours);return{date:Me(s),time:ds(s.getHours(),s.getMinutes()),isHourBased:!0}}return{date:ms(pe,t.shelfLifeDays),time:t.expiresEOD?"EOD":null,isHourBased:!1}},Tt=()=>{const t=V.map(s=>s.id);t.every(s=>ke(s))?Y(s=>s.filter(r=>!t.includes(r.itemId))):Y(s=>{const r=new Set(s.map(p=>p.itemId)),c=t.filter(p=>!r.has(p)).map(p=>({itemId:p,qty:1}));return[...s,...c]})},Je=async()=>{if(A){j(l("prep.teamLeadPrint.description"));return}const t=ie(le(P,N?"":_,d,L),L);if(!t){j("Enter a valid Toast POS code to print");return}const s=F.current,r=Yt({selectedItems:b,employeeLoadError:X,verifiedEmployee:t});if(r==="select_item"){j(l("prep.error.selectItem"));return}if(r==="employee_load_error"){j(X);return}if(r==="employee_code_required"){j("Enter a valid Toast POS code to print");return}const c=`${t.firstName||""} ${t.lastName||""}`.trim(),p=[];for(const E of b){const H=S.find(ee=>ee.id===E.itemId);if(!H)continue;const De=Xe(H);for(let ee=0;ee<E.qty;ee++)p.push({name:H.name,unit:H.unit||H.uom||"",category:H.category,prepDate:pe,useBy:De,employeeName:c})}if(!p.length){j(l("prep.error.noLabels"));return}let x=xs(p,l);if(O&&Ue)try{const E=await at(ge(G,Ee.inventoryPriceBooks,f)),H=E.exists()?E.data()||{}:{},{addInventoryQrToPrepLabels:De}=await At(async()=>{const{addInventoryQrToPrepLabels:ee}=await import("./prepLabelQr-YXb1X51B.js");return{addInventoryQrToPrepLabels:ee}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28]));x=await De(x,H,f)}catch{}if(F.current!==s)return;const D=Re.current,U=ie(le(P,N?"":te.current,d,D),D);if(!U)return;const he=`${U.firstName||""} ${U.lastName||""}`.trim();x=x.map(E=>({...E,employeeName:he})),us(Wt(x,Ve)),rt("prep_labels_printed",{labelCount:p.length,itemCount:b.length,employeeId:U.employeeId||U.id,employeeName:he},n,a,f),j(l("prep.success.labelsPrinted",{count:p.length}))},Ze=(0,o.useMemo)(()=>{const t={};for(const r of V){const c=r.category||"Uncategorized";t[c]||(t[c]=[]),t[c].push(r)}const s=[];for(const r of B)t[r.key]&&s.push({...r,items:t[r.key]});return t.Uncategorized&&s.push({key:"Uncategorized",label:"Other",icon:"HelpCircle",color:"stone",items:t.Uncategorized}),s},[V]),q=(0,o.useMemo)(()=>b.reduce((t,s)=>t+s.qty,0),[b]),z=ie(le(P,N?"":_,d,L),L),et=J!=="all"||!!ne.trim();return(0,o.useMemo)(()=>Jt({view:g,selectedItemCount:b.length,selectedLabelCount:q,filteredItemCount:V.length,hasFilters:et,verifiedEmployee:!!z,printerGuideOpen:ce,isTeamMemberSession:N}),[g,b.length,q,V.length,et,P,ce,N]),(0,o.useMemo)(()=>g==="labelPrep"?[{label:"Active Labels",value:I.length,helper:"Ready to print right now",icon:"Tag",tone:"info"},{label:"Selected Items",value:b.length,helper:"Current prep batch items",icon:"CheckCircle",tone:b.length?"success":"neutral"},{label:"Total Labels",value:q,helper:"Labels queued for this run",icon:"Printer",tone:b.length?"warning":"neutral"}]:g==="labels"?[{label:"All Items",value:S.length,helper:"Label definitions for this restaurant",icon:"List",tone:"info"},{label:"Active Labels",value:I.length,helper:"Available in label prep",icon:"Tag",tone:"success"},{label:"Categories",value:ae.length,helper:"Shelf-life groups in use",icon:"Package",tone:"neutral"}]:[],[g,I.length,b.length,q,S.length,ae.length]),ut||$?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center py-16 gap-3 animate-fade-in",children:[(0,e.jsx)("div",{className:"w-6 h-6 border-2 border-brand-500 border-t-transparent roun
2ded-full animate-spin"}),$&&(0,e.jsx)("p",{className:"text-zinc-400 text-sm",children:l("prep.button.saving")})]}):(0,e.jsxs)("div",{className:"space-y-6 animate-fade-in",children:[He&&(0,e.jsxs)("div",{className:"fixed top-4 left-1/2 -translate-x-1/2 z-50 px-6 py-3 rounded-xl bg-brand-600 text-white text-sm font-semibold shadow-lg shadow-brand-600/30 animate-fade-in flex items-center gap-3",children:[(0,e.jsx)("span",{className:"flex-1",children:He}),(0,e.jsx)("button",{onClick:()=>je(""),className:"no-min-tap p-1 rounded-lg hover:bg-white/20 transition-colors flex-shrink-0","aria-label":l("a11y.dismissMessage"),children:(0,e.jsx)(h,{name:"X",size:14})})]}),(0,e.jsx)(qt,{icon:"Tag",eyebrow:"Prep Labels",title:"Prep Labels",description:"Print clean prep labels fast, keep shelf-life rules obvious, and make line use simple on phone, tablet, or desktop.",chips:[{label:M,icon:"Building2",tone:"neutral"}]}),A&&(0,e.jsxs)("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-900 shadow-sm","data-testid":"prep-label-team-lead-print-restriction",role:"status",children:[(0,e.jsx)("p",{className:"text-sm font-semibold",children:l("prep.teamLeadPrint.title")}),(0,e.jsx)("p",{className:"mt-1 text-sm leading-5",children:l("prep.teamLeadPrint.description")})]}),(0,e.jsx)(Ut,{tabs:cs.filter(t=>v||t.id==="labelPrep").map(t=>({id:t.id,label:t.label})),activeId:g,onChange:k}),g==="categories"&&(0,e.jsxs)("div",{className:"card p-4 space-y-4",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative flex-1 min-w-[240px]",children:[(0,e.jsx)(h,{name:"Search",size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-zinc-500"}),(0,e.jsx)("input",{value:de,onChange:t=>ht(t.target.value),placeholder:"Search categories",className:"w-full pl-9 pr-10 py-2 rounded-lg border bg-zinc-900 text-white border-zinc-700 text-sm placeholder-zinc-600"}),(0,e.jsx)("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800","aria-label":l("a11y.filterPrepLabelCategories"),children:(0,e.jsx)(h,{name:"Filter",size:14})})]}),(0,e.jsx)("button",{onClick:()=>{v&&(k("labels"),Z(!0))},disabled:!v,className:"px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-semibold transition-colors",children:"New Category"})]}),(0,e.jsx)("div",{className:"rounded-lg border border-zinc-800 overflow-hidden",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{className:"bg-zinc-900/80",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Name"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Owner"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"# of Labels"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Color"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Last Edited"})]})}),(0,e.jsxs)("tbody",{children:[ae.map(t=>(0,e.jsxs)("tr",{className:"border-t border-zinc-800 hover:bg-zinc-900/40 transition-colors",children:[(0,e.jsx)("td",{className:"px-3 py-2 text-white",children:t.label}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-300",children:M}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-300",children:t.count}),(0,e.jsx)("td",{className:"px-3 py-2",children:(0,e.jsx)("span",{className:"inline-flex items-center px-2 py-1 rounded-md text-xs font-bold text-zinc-900",style:{backgroundColor:`#${t.colorHex}`},children:t.colorHex})}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-400",children:ct(t.latest)})]},t.name)),ae.length===0&&(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"px-3 py-8 text-center text-zinc-500",children:"No categories found"})})]})]})})]}),g==="templates"&&(0,e.jsxs)("div",{className:"card p-4 space-y-4",children:[O?(0,e.jsxs)("label",{className:"flex min-h-11 items-center gap-3 rounded-xl border border-zinc-200 bg-white px-3 text-sm font-semibold text-zinc-800",children:[(0,e.jsx)("input",{type:"checkbox",checked:Ue,onChange:t=>Ge(t.target.checked),className:"h-6 w-6"}),l("prep.templates.inventoryQr")]}):null,(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsxs)("div",{className:"relative flex-1 min-w-[240px]",children:[(0,e.jsx)(h,{name:"Search",size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-zinc-500"}),(0,e.jsx)("input",{value:me,onChange:t=>ft(t.target.value),placeholder:"Search templates",className:"w-full pl-9 pr-10 py-2 rounded-lg border bg-zinc-900 text-white border-zinc-700 text-sm placeholder-zinc-600"}),(0,e.jsx)("button",{className:"absolute right-2 top-1/2 -translate-y-1/2 p-1.5 rounded text-zinc-500 hover:text-zinc-300 hover:bg-zinc-800","aria-label":l("a11y.filterPrepLabelTemplates"),children:(0,e.jsx)(h,{name:"Filter",size:14})})]}),(0,e.jsx)("button",{onClick:()=>k("labelPrep"),disabled:!v,className:"px-4 py-2 rounded-lg bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-semibold transition-colors",children:"New Template"})]}),(0,e.jsx)("div",{className:"rounded-lg border border-zinc-800 overflow-hidden",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{className:"bg-zinc-900/80",children:(0,e.jsxs)("tr",{children:[(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Name"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Owner"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Items"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Size"}),(0,e.jsx)("th",{className:"text-left px-3 py-2 text-zinc-400 font-semibold",children:"Last Edited"})]})}),(0,e.jsx)("tbody",{children:Dt.map(t=>(0,e.jsxs)("tr",{className:"border-t border-zinc-800 hover:bg-zinc-900/40 transition-colors",children:[(0,e.jsx)("td",{className:"px-3 py-2 text-white",children:t.name}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-300",children:t.owner}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-400",children:t.items}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-300",children:t.size}),(0,e.jsx)("td",{className:"px-3 py-2 text-zinc-400",children:ct(t.lastEdited)})]},t.name))})]})})]}),g==="batches"&&(0,e.jsxs)("div",{className:"card p-8 text-center",children:[(0,e.jsx)(h,{name:"Package",size:22,className:"mx-auto text-zinc-600 mb-2"}),(0,e.jsx)("p",{className:"text-zinc-400 font-medium",children:"No batches yet"}),(0,e.jsx)("p",{className:"text-zinc-600 text-sm mt-1",children:"Printed batches will appear here as this module evolves."})]}),g==="optionSets"&&(0,e.jsxs)("div",{className:"card p-6",children:[(0,e.jsx)("h3",{className:"text-white font-semibold mb-3",children:"Option Sets"}),(0,e.jsx)("p",{className:"text-zinc-500 text-sm mb-4",children:"Using category-based defaults from your label inventory."}),(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:ae.map(t=>(0,e.jsxs)("div",{className:"rounded-lg border border-zinc-800 px-3 py-2 bg-zinc-900/40 flex items-center justify-between",children:[(0,e.jsx)("span",{className:"text-zinc-300 text-sm",children:t.label}),(0,e.jsxs)("span",{className:"text-zinc-500 text-xs",children:[t.count," labels"]})]},t.name))})]}),g==="labelPrep"&&(Qe?(0,e.jsx)(ot,{onAdd:()=>Z(!0)}):(0,e.jsxs)("div",{className:"space-y-4",children:[v&&(0,e.jsxs)("div",{className:"card p-3 flex items-center justify-between",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-white text-sm font-semibold",children:"Customize Labels"}),(0,e.jsx)("p",{className:"text-zinc-500 text-xs",children:"Manage categories, templates, and label items."})]}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("button",{onClick:()=>k("labels"),className:"px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs",children:"Items"}),(0,e.jsx)("button",{onClick:()=>k("categories"),className:"px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs",children:"Categories"}),(0,e.jsx)("button",{onClick:()=>k("templates"),className:"px-3 py-1.5 rounded-lg bg-zinc-800 hover:bg-zinc-700 text-zinc-200 text-xs",children:"Templates"})]})]}),(0,e.jsxs)("div",{className:"rounded-2xl border border-zinc-200 bg-white/95 shadow-sm overflow-hidden",children:[(0,e.jsxs)("button",{onClick:()=>bt(t=>!t),className:"flex w-full items-center justify-between gap-3 px-4 py-3 text-left cursor-pointer transition-colors hover:bg-zinc-50/50",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(h,{name:"Printer",size:16,className:"text-brand-500"}),(0,e.jsx)("span",{className:"text-sm font-semibold text-zinc-700",children:"Need printer setup?"}),(0,e.jsx)("span",{className:"text-xs text-zinc-400",children:"First time only. Most teams can skip this."})]}),(0,e.jsx)(h,{name:ce?"ChevronUp":"ChevronDown",size:14,className:"text-zinc-400"})]}),ce&&(0,e.jsxs)("div",{className:"border-t border-zinc-100 px-4 py-4 space-y-4",children:[(0,e.jsx)("p",{className:"text-sm text-zinc-500",children:"Follow these steps to set up any thermal label printer (Rollo, DYMO, Brother, or similar) with MarginGains prep labels."}),[{num:1,title:"Get a Thermal Label Printer",detail:"We recommend the Rollo Wireless Printer or Rollo X1040. Both work with direct thermal labels — no ink needed. Use the Label Size selector in MarginGains to match the roll loaded in the printer."}
2,{num:2,title:"Load the Labels",detail:"Open the printer cover. Place the label roll so labels feed from underneath (print side faces up). Close the cover. The printer will auto-calibrate when you turn it on."},{num:3,title:"Connect to Your Computer or Tablet",detail:"Plug in the USB cable from the printer to your computer. On Mac, it appears automatically in System Settings → Printers. On Windows, the Rollo driver installer runs automatically. On iPad, use a USB-C adapter — most thermal printers support AirPrint."},{num:4,title:"Set the Label Size",detail:'Open your printer settings (System Settings → Printers on Mac, Devices → Printers on Windows). Set the paper size to match the selected MarginGains label size, such as 2" x 1", 2" x 3", or 4" x 6". Set orientation to Portrait.'},{num:5,title:"Print a Test Label",detail:'In MarginGains, select any prep item and tap "Print." A print dialog will appear — choose your label printer and hit Print. The first label may need a small alignment tweak in printer settings.'}].map(t=>(0,e.jsxs)("div",{className:"flex gap-3",children:[(0,e.jsx)("div",{className:"flex-shrink-0 w-7 h-7 rounded-full bg-brand-500/10 text-brand-600 flex items-center justify-center text-xs font-bold",children:t.num}),(0,e.jsxs)("div",{children:[(0,e.jsx)("p",{className:"text-sm font-semibold text-zinc-700",children:t.title}),(0,e.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5",children:t.detail})]})]},t.num)),(0,e.jsx)("div",{className:"rounded-xl border border-blue-200 bg-blue-50/80 p-3",children:(0,e.jsxs)("p",{className:"text-xs text-blue-700",children:[(0,e.jsx)("strong",{children:"Troubleshooting:"})," If labels print blank, flip the roll over — thermal paper only prints on one side. If labels are misaligned, run a calibration from your printer's settings menu. If nothing prints, check that the printer is selected as the default in your browser's print dialog."]})})]})]}),!A&&(0,e.jsx)("div",{className:"card p-4",children:(0,e.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-6 gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:l("prep.field.prepDate")}),(0,e.jsx)("input",{type:"date",value:pe,onChange:t=>yt(t.target.value),className:"w-full px-3 py-2 rounded-lg bg-zinc-800 border border-zinc-700 text-white text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:l("prep.field.prepTime")}),(0,e.jsx)("input",{type:"time",value:Ke,onChange:t=>jt(t.target.value),className:"w-full px-3 py-2 rounded-lg bg-zinc-800 border border-zinc-700 text-white text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:N?"Printing As":"Team Member Toast POS Code"}),N?(0,e.jsxs)("div",{className:"w-full rounded-lg border border-green-500/30 bg-green-500/10 px-3 py-2 text-sm text-white",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("span",{className:"font-semibold",children:z?`${z.firstName||""} ${z.lastName||""}`.trim():"Team Member verification unavailable"}),(0,e.jsx)("span",{className:"text-xs font-semibold text-green-300",children:"Verified"})]}),(0,e.jsx)("p",{className:"mt-1 text-xs text-zinc-300",children:"You already signed in with your Toast POS code. No second code is needed to print labels."})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)("input",{type:"text",value:_,onChange:t=>{const s=(0,C.limitTeamCodeInput)(t.target.value);F.current+=1,te.current=s,Nt(s),K(null),R("")},onKeyDown:t=>{(0,C.isTeamCodeConfirmKey)(t)&&(t.preventDefault(),We(te.current,!0))},placeholder:l("prep.placeholder.teamCode"),className:`w-full px-3 py-2 rounded-lg bg-zinc-800 border ${z?"border-green-500":Ne?"border-red-500":"border-zinc-700"} text-white text-sm font-mono tracking-widest focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20`,maxLength:C.TEAM_CODE_MAX_DIGITS,inputMode:"numeric",autoComplete:"off"}),z&&(0,e.jsxs)("p",{className:"text-green-400 text-xs mt-1 flex items-center gap-1",children:[(0,e.jsx)(h,{name:"CheckCircle",size:12})," ",z.firstName," ",z.lastName]}),Ne&&(0,e.jsx)("p",{className:"text-red-400 text-xs mt-1",children:Ne}),X&&(0,e.jsx)("p",{className:"text-red-400 text-xs mt-1",children:X})]})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:"Label Size"}),(0,e.jsx)("select",{value:Ve,onChange:t=>Lt(t.target.value),className:"w-full px-3 py-2 rounded-lg bg-zinc-800 border border-zinc-700 text-white text-sm focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20",children:Qt.map(t=>(0,e.jsx)("option",{value:t.id,children:t.label},t.id))}),(0,e.jsx)("p",{className:"mt-1 text-xs text-zinc-500",children:"Rollo prep labels default to 3 x 2 landscape. Match this selector to the roll loaded in the printer."})]}),(0,e.jsx)("div",{className:"flex items-end",children:(0,e.jsxs)("button",{onClick:Je,disabled:!b.length||!z||$,className:"w-full px-4 py-2 rounded-lg bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white text-sm font-bold transition-all flex items-center justify-center gap-2",children:[(0,e.jsx)(h,{name:"Printer",size:16}),"Print",b.length?` (${q})`:""]})}),(0,e.jsx)("div",{className:"flex items-end",children:(0,e.jsx)(es,{selectedItems:b,items:S,tenantId:f,store:d||a?.store||a?.primaryStore||"",actorName:z?`${z.firstName} ${z.lastName}`.trim():a?.name||"",role:a?.role||(m?"owner":""),allowedHours:w.holdTimerPresets,disabled:!b.length||!z||$,t
2:l,onStarted:()=>j(l("holdTimers.startedFromLabel")),onError:j})})]})}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center",children:[(0,e.jsxs)("button",{onClick:()=>Fe("all"),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${J==="all"?"bg-brand-600 text-white":"bg-zinc-800 text-zinc-400 hover:text-white"}`,children:[l("prep.filter.all")," (",I.length,")"]}),B.map(t=>{const s=I.filter(r=>r.category===t.key).length;return s?(0,e.jsxs)("button",{onClick:()=>Fe(t.key),className:`px-3 py-1.5 rounded-lg text-xs font-semibold transition-all ${J===t.key?"bg-brand-600 text-white":"bg-zinc-800 text-zinc-400 hover:text-white"}`,children:[l(t.labelKey)," (",s,")"]},t.key):null}),(0,e.jsxs)("div",{className:"relative w-full sm:ml-auto sm:w-auto",children:[(0,e.jsx)(h,{name:"Search",size:14,className:"absolute left-2.5 top-2 text-zinc-500"}),(0,e.jsx)("input",{value:ne,onChange:t=>vt(t.target.value),placeholder:l("prep.placeholder.searchItems"),className:"w-full rounded-lg border border-zinc-700 bg-zinc-800 pl-8 pr-3 py-1.5 text-xs text-white focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20 sm:w-48"})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center",children:[(0,e.jsx)("button",{onClick:Tt,className:"text-xs text-brand-400 hover:text-brand-300 font-semibold",children:V.length>0&&V.every(t=>ke(t.id))?l("prep.button.deselectAll"):l("prep.button.selectAll")}),b.length>0&&(0,e.jsxs)("button",{onClick:()=>Y([]),className:"text-xs text-zinc-500 hover:text-zinc-300",children:["Clear (",b.length,")"]})]}),Ze.length===0?(0,e.jsxs)("div",{className:"card p-8 text-center",children:[(0,e.jsx)(h,{name:"Search",size:24,className:"text-zinc-600 mx-auto mb-2"}),(0,e.jsx)("p",{className:"text-zinc-400 text-sm",children:l("prep.ui.noItemsMatch")})]}):(0,e.jsx)("div",{className:"space-y-4",children:Ze.map(t=>(0,e.jsxs)("div",{children:[(0,e.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,e.jsx)(h,{name:t.icon||"Tag",size:14,className:os[t.color]||"text-zinc-400"}),(0,e.jsx)("h3",{className:"text-sm font-bold text-zinc-300",children:t.labelKey?l(t.labelKey):t.label}),(0,e.jsxs)("span",{className:"text-xs text-zinc-600",children:["(",t.items.length,")"]})]}),(0,e.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2",children:t.items.map(s=>{const r=ke(s.id),c=r?Xe(s):null,p=parseInt(s.shelfLifeDays)||0,x=parseInt(s.shelfLifeHours)||0,D=x>0&&p===0,U=D?`${x}hr`:`${p}d`,he=D?`${x} hour`:`${p} day${p!==1?"s":""}`;return(0,e.jsx)("div",{className:`p-3 rounded-xl border transition-all cursor-pointer ${r?"bg-brand-600/10 border-brand-500/40":"bg-zinc-900/50 border-zinc-800 hover:border-zinc-700"}`,onClick:()=>Et(s.id),children:(0,e.jsxs)("div",{className:"flex items-start gap-3",children:[(0,e.jsx)("div",{className:`mt-0.5 w-5 h-5 rounded-md border-2 flex items-center justify-center flex-shrink-0 transition-all ${r?"bg-brand-600 border-brand-600":"border-zinc-600"}`,children:r&&(0,e.jsx)(h,{name:"Check",size:14,className:"text-white"})}),(0,e.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("p",{className:`text-sm font-semibold ${r?"text-white":"text-zinc-300"}`,children:s.name}),(0,e.jsx)("span",{className:`inline-flex px-1.5 py-0.5 rounded text-[10px] font-bold ${r?"bg-brand-500/20 text-brand-200":"bg-zinc-800 text-zinc-400"}`,children:U})]}),(0,e.jsx)("p",{className:"text-xs text-zinc-500 mt-0.5",children:he}),r&&c&&(0,e.jsxs)("p",{className:"text-xs mt-1 font-semibold text-red-400",children:[l("prep.ui.useBy"),": ",c.isHourBased?`${oe(c.date)} @ ${c.time}`:oe(c.date),c.time==="EOD"?" ("+l("prep.label.eod")+")":""]})]}),r&&(0,e.jsxs)("div",{className:"flex items-center gap-1 flex-shrink-0",onClick:E=>E.stopPropagation(),children:[(0,e.jsx)("button",{onClick:()=>Ie(s.id,Pe(s.id)-1),className:"w-6 h-6 rounded bg-zinc-700 hover:bg-zinc-600 flex items-center justify-center text-white text-xs font-bold",children:"-"}),(0,e.jsx)("input",{type:"number",value:Pe(s.id),onChange:E=>Ie(s.id,E.target.value),className:"w-10 h-6 rounded bg-zinc-800 border border-zinc-700 text-white text-xs text-center font-bold",min:1,max:50}),(0,e.jsx)("button",{onClick:()=>Ie(s.id,Pe(s.id)+1),className:"w-6 h-6 rounded bg-zinc-700 hover:bg-zinc-600 flex items-center justify-center text-white text-xs font-bold",children:"+"})]})]})},s.id)})})]},t.key))}),b.length>0&&!A&&(0,e.jsx)("div",{className:"sticky bottom-0 left-0 right-0 p-3 bg-zinc-900/95 backdrop-blur-sm border-t border-zinc-800 rounded-b-xl -mx-1",children:(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("div",{className:"text-sm text-zinc-300",children:[(0,e.jsx)("span",{className:"font-bold text-white",children:b.length})," ",l("prep.ui.itemsSelected",{count:b.length}),(0,e.jsx)("span",{className:"text-zinc-500 mx-2",children:"·"}),(0,e.jsx)("span",{className:"font-bold text-white",children:q})," ",l("prep.ui.totalLabels",{count:q})]}),(0,e.jsxs)("button",{onClick:Je,disabled:$||!z,className:"px-5 py-2.5 rounded-xl bg-brand-600 hover:bg-brand-500 disabled:opacity-50 text-white font-bold text-sm transition-all flex items-center gap-2",children:[(0,e.jsx)(h,{name:"Printer",size:16}),l("prep.button.printLabels")]})]})})]})),g==="labels"&&(Qe?(0,e.jsx)(ot,{onAdd:()=>Z(!0)}):(0,e.jsxs)("div",{className:"space-y-4",children:[!v&&(0,e.jsx)("div",{className:"card p-3 border border-amber-500/30 bg-amber-500/10 text-amber-300 text-sm",children:"Read-only: only owner/admin can customize label definitions."}),(0,e.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,e.jsxs)("button",{onClick:()=>v&&Z(!0),disabled:!v,className:"px-4 py-2 rounded-xl bg-brand-600 hover:bg-brand-500 text-white text-sm font-bold transition-all flex items-center gap-2",children:[(0,e.jsx)(h,{name:"Plus",size:16}),l("prep.button.addItem")]}),(0,e.jsxs)("div",{className:"ml-auto flex items-center gap-2",children:[(0,e.jsxs)("select",{value:xe,onChange:t=>wt(t.target.value),className:"px-3 py-2 rounded-lg bg-zinc-800 border border-zinc-700 text-white text-xs",children:[(0,e.jsx)("option",{value:"all",children:l("prep.filter.allCategories")}),B.map(t=>(0,e.jsx)("option",{value:t.key,children:l(t.labelKey)},t.key))]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsx)(h,{name:"Search",size:14,className:"absolute left-2.5 top-2 text-zinc-500"}),(0,e.jsx)("input",{value:ue,onChange:t=>St(t.target.value),placeholder:l("prep.placeholder.search"),className:"pl-8 pr-3 py-1.5 rounded-lg bg-zinc-800 border border-zinc-700 text-white text-xs w-40 focus:border-brand-500"})]})]})]}),(0,e.jsx)("div",{className:"card overflow-hidden",children:(0,e.jsxs)("table",{className:"w-full text-sm",children:[(0,e.jsx)("thead",{children:(0,e.jsxs)("tr",{className:"border-b border-zinc-800",children:[(0,e.jsx)("th",{className:"text-left px-4 py-3 text-zinc-400 font-semibold text-xs uppercase tracking-wider",children:l("prep.table.item")}),(0,e.jsx)("th",{className:"text-left px-4 py-3 text-zinc-400 font-semibold text-xs uppercase tracking-wider",children:l("prep.table.category")}),(0,e.jsx)("th",{className:"text-center px-4 py-3 text-zinc-400 font-semibold text-xs uppercase tracking-wider",children:l("prep.table.shelfLife")}),(0,e.jsx)("th",{className:"text-center px-4 py-3 text-zinc-400 font-semibold text-xs uppercase tracking-wider",children:l("prep.table.eod")}),(0,e.jsx)("th",{className:"text-right px-4 py-3 text-zinc-400 font-semibold text-xs uppercase tracking-wider",children:l("prep.table.actions")})]})}),(0,e.jsxs)("tbody",{children:[Ye.map(t=>{const s=Ae[t.category];return(0,e.jsxs)("tr",{className:"border-b border-zinc-800/50 hover:bg-zinc-800/30 transition-colors",children:[(0,e.jsx)("td",{className:"px-4 py-3",children:(0,e.jsx)("span",{className:"text-white font-medium",children:t.name})}),(0,e.jsx)("td",{className:"px-4 py-3",children:s&&(0,e.jsxs)("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-md text-xs font-semibold border ${is[s.color]||"bg-zinc-800 text-zinc-400 border-zinc-700"}`,children:[(0,e.jsx)(h,{name:s.icon||"Tag",size:10}),s.labelKey?l(s.labelKey):t.category]})}),(0,e.jsx)("td",{className:"px-4 py-3 text-center text-zinc-300",children:(()=>{const r=parseInt(t.shelfLifeDays)||0,c=parseInt(t.shelfLifeHours)||0;return c>0&&r===0?`${c} hour${c!==1?"s":""}`:`${r} day${r!==1?"s":""}`})()}),(0,e.jsx)("td",{className:"px-4 py-3 text-center",children:t.expiresEOD?(0,e.jsx)(h,{name:"Check",size:14,className:"text-emerald-400 mx-auto"}):(0,e.jsx)(h,{name:"X",size:14,className:"text-zinc-600 mx-auto"})}),(0,e.jsx)("td",{className:"px-4 py-3 text-right",children:v?(0,e.jsxs)("div",{className:"flex items-center justify-end gap-1",children:[(0,e.jsx)("button",{onClick:()=>we(t),className:"p-1.5 rounded-lg hover:bg-zinc-700 text-zinc-400 hover:text-white transition-colors",title:l("prep.button.edit"),"aria-label":`${l("prep.button.edit")} ${t.name}`,children:(0,e.jsx)(h,{name:"Pencil",size:14})}),(0,e.jsx)("button",{onClick:()=>Ce(t),className:"p-1.5 rounded-lg hover:bg-red-500/10 text-zinc-400 hover:text-red-400 transition-colors",title:l("prep.button.delete"),"aria-label":`${l("prep.button.delete")} ${t.name}`,children:(0,e.jsx)(h,{name:"Trash2",size:14})})]}):(0,e.jsx)("span",{className:"text-xs text-zinc-600",children:"Owner/Admin"})})]},t.id)}),Ye.length===0&&(0,e.jsx)("tr",{children:(0,e.jsx)("td",{colSpan:5,className:"px-4 py-8 text-center text-zinc-500 text-sm",children:l("prep.ui.noItemsMatch")})})]})]})})]})),(0,e.jsx)(dt,{isOpen:zt,title:l("prep.modal.addItem"),onClose:()=>Z(!1),onSave:It,saving:$}),(0,e.jsx)(dt,{isOpen:!!ze,title:l("prep.modal.editItem"),item:ze,onClose:()=>we(null),onSave:t=>kt(ze.id,t),saving:$}),(0,e.jsx)(Bt,{isOpen:!!Se,title:l("prep.modal.deleteItem"),message:l("prep.modal.deleteConfirm",{name:Se?.name}),confirmLabel:l("prep.button.delete"),onConfirm:()=>Pt(Se.id),onCancel:()=>Ce(null),loading:$})]})}function dt({isOpen:n,title:a,item:i,onClose:d,onSave:m,saving:u}){const{t:w}=$e(),[f,l]=(0,o.useState)(""),[M,O]=(0,o.useState)(B[0].key),[v,N]=(0,o.useState)("7"),[A,T]=(0,o.useState)("0"),[g,k]=(0,o.useState)(!0);(0,o.useEffect)(()=>{i?(l(i.name||""),O(i.category||B[0].key),N(String(i.shelfLifeDays||0)),T(String(i.shelfLifeHours||0)),k(i.expiresEOD!==!1)):(l(""),O(B[0].key),N("7"),T("0"),k(!0))},[i,n]);const S=()=>{f.trim()&&m({name:f,category:M,shelfLifeDays:parseInt(v)||0,shelfLifeHours:parseInt(A)||0,expiresEOD:g})};return(0,e.jsx)(Ht,{isOpen:n,onClose:d,title:a,size:"sm",children:(0,e.jsxs)("div",{className:"space-y-4",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:w("prep.field.itemName")}
2),(0,e.jsx)("input",{value:f,onChange:y=>l(y.target.value),placeholder:w("prep.placeholder.itemName"),className:"w-full px-4 py-3 rounded-xl bg-zinc-800 border border-zinc-700 text-white placeholder-zinc-500 focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20",autoFocus:!0,onKeyDown:y=>y.key==="Enter"&&S()})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:w("prep.field.category")}),(0,e.jsx)("select",{value:M,onChange:y=>O(y.target.value),className:"w-full px-4 py-3 rounded-xl bg-zinc-800 border border-zinc-700 text-white focus:border-brand-500",children:B.map(y=>(0,e.jsx)("option",{value:y.key,children:w(y.labelKey)},y.key))})]}),(0,e.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:w("prep.field.shelfLifeDays")}),(0,e.jsx)("input",{type:"number",value:v,onChange:y=>N(y.target.value),min:0,max:365,className:"w-full px-4 py-3 rounded-xl bg-zinc-800 border border-zinc-700 text-white focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20"})]}),(0,e.jsxs)("div",{children:[(0,e.jsx)("label",{className:"block text-xs font-semibold text-zinc-400 mb-1",children:w("prep.field.shelfLifeHours")}),(0,e.jsx)("input",{type:"number",value:A,onChange:y=>T(y.target.value),min:0,max:23,className:"w-full px-4 py-3 rounded-xl bg-zinc-800 border border-zinc-700 text-white focus:border-brand-500 focus:ring-2 focus:ring-brand-500/20"})]})]}),(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsx)("button",{onClick:()=>k(!g),className:`w-10 h-6 rounded-full transition-all ${g?"bg-brand-600":"bg-zinc-700"}`,children:(0,e.jsx)("div",{className:`w-4 h-4 rounded-full bg-white shadow-sm transition-all ${g?"ml-5":"ml-1"}`})}),(0,e.jsx)("label",{className:"text-sm text-zinc-300",children:w("prep.field.expiresEOD")})]}),(0,e.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,e.jsx)("button",{onClick:d,className:"flex-1 px-4 py-3 rounded-xl bg-zinc-800 text-zinc-300 font-semibold text-sm hover:bg-zinc-700 transition-all",children:w("prep.button.cancel")}),(0,e.jsx)("button",{onClick:S,disabled:!f.trim()||u,className:"flex-1 px-4 py-3 rounded-xl bg-brand-600 text-white font-semibold text-sm hover:bg-brand-500 disabled:opacity-50 transition-all",children:w(u?"prep.button.saving":i?"prep.button.update":"prep.button.addItem")})]})]})})}export{Ss as default,us as writePrepLabelPrintFrame};

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.