PageSourceSearch

https://restaurantai.consulting/assets/sops-Dj43b7do.js

js restaurantai.consulting collected 2026-09-24 15:00:04 UTC 109,511 bytes, 218 lines download raw bytes

1import{j as e}from"./vendor-motion-CAS9Mrr8.js";import{a as i}from"./vendor-charts-CCcpKWTT.js";import{c as mt,Y as qs,J as us,K as xs,N as hs,aB as Ds,O as gs,r as Fs,P as H,Q as v,T as be,B as z,I as ts,R as K,A as pt,n as Rs,d as as,_ as ye,$ as fe,Z as Y,W as ut,U as ds,a0 as Ps,s as xt,D as ht,ag as gt}from"./index-CxC89PRg.js";import{Q as yt}from"./query-boundary-Dr31qkJy.js";import{B as L}from"./badge-DXnfPCD0.js";import{T as ft,a as bt,b as jt,c as ms}from"./tabs-B-n5hAmt.js";import{T as Me}from"./textarea-BZrH01Ga.js";import{S as I,a as O,b as $,c as A,d as n}from"./select-CaKL9gM6.js";import{S as ys}from"./sparkles-Ng7JCvrm.js";import{C as vt}from"./clipboard-check-DwWiHv34.js";import{S as Nt}from"./search-Ceq5iq3J.js";import{C as Ms}from"./clock-2yzUZvxM.js";import{C as ps}from"./circle-check-DI67LXtl.js";import{C as _s}from"./circle-x-nhZSNlVt.js";import{C as ue}from"./copy-yT2DELCk.js";import{S as je}from"./save-D3c5lxQy.js";import{R as wt}from"./refresh-cw-DKu0IaYb.js";import{P as fs}from"./printer-ClqLiZZ6.js";import{T as ls}from"./trash-2-DAItjZQU.js";import{C as ss}from"./calendar-vYmX8pTA.js";import{b as kt}from"./domain-DyRLSykR.js";import{P as Re}from"./phone-BVSyDMXj.js";import{P as Ls}from"./package-BJZd7r4E.js";import{S as St}from"./square-pen-CAC7tN06.js";import"./vendor-pdf-C9TCjkzL.js";import"./index-BdQq_4o_.js";import"./Combination-Bymh1jIy.js";import"./use-tier-access-DycmD0Wc.js";import"./upgrade-gate-mCiqKCUt.js";import"./skeleton-ZbgX6FFt.js";import"./en-US-9sl_A5dN.js";import"./endOfMonth-B37p0woh.js";import"./format-Dluiar8k.js";import"./chevron-left-DKIysnTN.js";import"./popover-DLZ_2OLV.js";import"./index-tsYMXB1t.js";import"./use-document-visible-DWoKgyOr.js";import"./link-2-CFNn1Rdz.js";import"./map-pin-BxtxPAf8.js";import"./facebook-Dic-bB_v.js";import"./avatar-BXZlFucr.js";import"./circle-alert-Bk2Ttv0Y.js";import"./upload-DeoBYkDW.js";import"./eye-BRfNH_fY.js";import"./trending-up-BjV9iP5n.js";import"./history-0Nf_RAiV.js";import"./wand-sparkles-B2BknuC3.js";import"./settings-HyLOzkhp.js";import"./send-C8KjI3V8.js";import"./info-ChcgE_OM.js";import"./lamplit-sheet-DBfx0skq.js";import"./index-rKuJWRrb.js";import"./square-check-big-Baf19B4G.js";import"./lightbulb-D-Lb647B.js";import"./log-out-7EEom-Pk.js";const Ct=mt("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]),Tt=["Daily","Per Shift","Weekly","Monthly","As Needed","On Hire","Emergency Only"],Et=[{value:"simple",label:"Simple (< 5 steps)"},{value:"standard",label:"Standard (5-15 steps)"},{value:"complex",label:"Complex (15+ steps)"}],It=["Front of House","Back of House","Bar","Host Stand","Expo","Office","Any"],Ot={"Front of House":"foh","Back of House":"kitchen",Bar:"bar","Host Stand":"foh",Expo:"kitchen",Office:"mgr",Any:"other"},$t=["Opening","Mid","Closing","All Shifts"],At=["Daily","Weekly","Monthly","Rarely","Never documented"],Pt=["Solo","2-5 staff","6-15 staff","16+ staff"];function Fa(){const[c]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem("sops_library")||"[]")}catch{}return[]}),[r]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem("checklists_library")||"[]")}catch{}return[]}),C=c.length>0?c.reduce((b,d)=>new Date(d.savedAt)<new Date(b.savedAt)?d:b,c[0]):null,x=C?Math.floor((Date.now()-new Date(C.savedAt).getTime())/(1e3*60*60*24)):0,q=b=>b,u=[{label:"SOPs Documented",value:c.length>0?`${c.length} SOPs saved`:"0 SOPs saved",muted:c.length===0,tone:q(c.length===0?"neutral":"ok")},{label:"Checklists Built",value:r.length>0?`${r.length} checklists saved`:"0 checklists saved",muted:r.length===0,tone:q(r.length===0?"neutral":"ok")},{label:"Last Audit Run",value:"No audit run yet",muted:!0,tone:q("neutral")},{label:"Oldest SOP",value:C?C.title:"--",sub:C&&x>90?"Review Due":C?`${x}d ago`:void 0,subColor:x>90?"#e0b24e":"#a99a82",muted:!C,tone:q(C?x>180?"bad":x>90?"warn":"ok":"neutral")}];return e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-2 mb-6 scrollbar-thin","data-testid":"sop-health-strip",children:u.map((b,d)=>e.jsxs("div",{className:"flex-shrink-0 min-w-[180px] rounded-[2px] p-3 border-l-[3px]",style:{background:"#241812",borderLeftColor:b.tone==="bad"?"hsl(var(--danger))":b.tone==="warn"?"hsl(var(--warning))":b.tone==="ok"?"hsl(var(--success))":"hsl(var(--border))"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-1",style:{color:"#a99a82"}
1,children:b.label}),e.jsx("p",{className:"text-sm font-semibold truncate",style:{color:b.muted?"#8a7d66":"#efe7d8"},"data-testid":`sop-strip-${d}`,children:b.value}),b.sub&&e.jsx("p",{className:"text-xs mt-0.5",style:{color:b.subColor},children:b.sub})]},d))})}function Ra(){const{toast:c}=qs(),[r,C]=i.useState("capture"),[x,q]=i.useState(""),[u,b]=i.useState(""),[d,F]=i.useState(""),[j,y]=i.useState(""),[f,ee]=i.useState("Daily"),[P,se]=i.useState("standard"),[D,ve]=i.useState("Any"),[T,Ne]=i.useState("All Shifts"),[N,te]=i.useState("Weekly"),[p,Ve]=i.useState("2-5 staff"),[_,Ce]=i.useState(""),[h,Te]=i.useState(null),[w,Ue]=i.useState(null),[m,Be]=i.useState(null),[ae,Ee]=i.useState(!1),[k,Ie]=i.useState(!1),[B,Oe]=i.useState(!1),[oe,We]=i.useState(!1),[ne,$e]=i.useState("sops"),[le,we]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem("sops_library")||"[]")}catch{}return[]}),[G,ke]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem("checklists_library")||"[]")}catch{}return[]}),Ae=a=>{try{const l=a.match(/\{[\s\S]*\}/);if(l)return JSON.parse(l[0])}catch{}return null},Se=async()=>{if(!x.trim()){c({title:"Please describe the workflow first",variant:"destructive"});return}Ee(!0),Ce(""),Te(null),Ue(null),Be(null),Oe(!1);try{let a="";r==="capture"?a=`You are an expert restaurant operations consultant specializing in SOP documentation.
2
3Convert the following workflow description into a structured SOP.
4
5TASK/PROCEDURE NAME: ${u||"Not specified"}
6ROLE OWNER: ${d||"To be assigned"}
7TRIGGER: ${j||"As needed"}
8FREQUENCY: ${f}
9COMPLEXITY: ${P}
10
11WORKFLOW DESCRIPTION:
12${x}
13
14You MUST respond with ONLY a valid JSON object in this exact format (no markdown, no extra text):
15{
16  "purpose": "One clear sentence explaining why this procedure exists",
17  "steps": ["Step 1 text", "Step 2 text"],
18  "failure_points": ["Common mistake 1", "Common mistake 2"],
19  "second_location_test": {
20    "passes": true,
21    "notes": "Brief explanation"
22  },
23  "estimated_training_time": "~5 min"
24}
25
26Make it practical, actionable, and ready to post at the workstation. Use clear action verbs. No fluff.`:r==="checklist"?a=`You are an expert restaurant operations consultant.
27
28Convert this workflow description into a structured checklist.
29
30CHECKLIST NAME: ${u||"Daily Task"}
31STATION/AREA: ${D}
32SHIFT: ${T}
33
34WORKFLOW DESCRIPTION:
35${x}
36
37You MUST respond with ONLY a valid JSON object in this exact format (no markdown, no extra text):
38{
39  "sections": [
40    {
41      "title": "PRE-SERVICE",
42      "items": ["Check item 1", "Check item 2"]
43    },
44    {
45      "title": "DURING SERVICE",
46      "items": ["Check item 3"]
47    },
48    {
49      "title": "CLOSE OUT",
50      "items": ["Check item 4"]
51    }
52  ],
53  "total_items": 10,
54  "estimated_completion_time": "~8 min"
55}
56
57Maximum 15 items total. Actionable verbs only. Ready to be posted at point of use.`:a=`You are an expert restaurant operations consultant.
58
59Audit this workflow description against the "Second Location Test" standards.
60
61WORKFLOW DESCRIPTION:
62${x}
63
64REVIEW FREQUENCY: ${N}
65TEAM SIZE: ${p}
66
67THE SECOND LOCATION TEST:
681. Could a new manager run this without calling the owner?
692. Could a new hire execute this using only what's written?
703. Does this rely on one person's memory or judgment?
714. Would this work tomorrow in a different building?
725. Is this documented — or just "how we do it"?
73
74You MUST respond with ONLY a valid JSON object in this exact format (no markdown, no extra text):
75{
76  "scalability_score": 74,
77  "second_location_test_passes": false,
78  "second_location_verdict": "One sentence verdict",
79  "gaps": ["Gap 1", "Gap 2"],
80  "strengths": ["Strength 1", "Strength 2"],
81  "recommended_fixes": ["Fix 1", "Fix 2"]
82}
83
84Be honest. If it's not scalable, say so. The scalability_score should be 0-100.`;const l=await fetch("/api/consultant/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:a}),credentials:"include"});if(!l.ok)throw new Error("Failed to generate SOP");const g=l.body?.getReader(),ce=new TextDecoder;if(g){let R="";for(;;){const{done:de,value:xe}=await g.read();if(de)break;const W=ce.decode(xe).split(`
85`).filter(V=>V.startsWith("data: "));for(const V of W)try{const me=JSON.parse(V.slice(6));me.content&&(R+=me.content,Ce(R))}catch{}}const M=Ae(R);M&&(r==="capture"&&M.purpose?Te(M):r==="checklist"&&M.sections?Ue(M):r==="audit"&&M.scalability_score!==void 0&&Be(M))}}catch{c({title:"Failed to generate",variant:"destructive"})}finally{Ee(!1)}},X=()=>{const a=h?Pe():w?re():m?_e():_;navigator.clipboard.writeText(a),Ie(!0),setTimeout(()=>Ie(!1),2e3)},Pe=()=>{if(!h)return _;let a=`SOP: ${u||"Untitled"}
86Owner: ${d||"TBD"} | Trigger: ${j||"As needed"}
87Frequency: ${f} | Complexity: ${P}
88
89PURPOSE:
90${h.purpose}
91
92STEPS:
93`;return h.steps?.forEach((l,g)=>{a+=`${g+1}. ${l}
94`}),a+=`
95FAILURE POINTS:
96`,h.failure_points?.forEach(l=>{a+=`- ${l}
97`}),a+=`
98SECOND LOCATION TEST: ${h.second_location_test?.passes?"PASSES":"FAILS"}
99${h.second_location_test?.notes||""}`,a},re=()=>{if(!w)return _;let a=`${u||"Checklist"}
100Station: ${D} | Shift: ${T}
101
102`;return w.sections?.forEach(l=>{a+=`${l.title}
103`,l.items?.forEach(g=>{a+=`[ ] ${g}
104`}),a+=`
105`}),a},_e=()=>{if(!m)return _;let a=`SCALABILITY AUDIT
106Score: ${m.scalability_score}/100
107
108Second Location Test: ${m.second_location_test_passes?"PASSES":"FAILS"}
109${m.second_location_verdict}
110
111GAPS:
112`;return m.gaps?.forEach(l=>{a+=`- ${l}
113`}),a+=`
114STRENGTHS:
115`,m.strengths?.forEach(l=>{a+=`- ${l}
116`}),a+=`
117RECOMMENDED FIXES:
118`,m.recommended_fixes?.forEach(l=>{a+=`- ${l}
119`}),a},ie=()=>{if(r==="capture"&&(h||_)){const a={id:Date.now().toString(),title:u||"Untitled SOP",role:d,trigger:j,frequency:f,complexity:P,content:h?JSON.stringify(h):_,savedAt:new Date().toISOString()},l=[a,...le];we(l),localStorage.setItem("sops_library",JSON.stringify(l)),(async()=>{try{const g=await fetch("/api/sops",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({title:a.title,content:_||a.content,category:f||"custom"})});if(!g.ok)throw new Error(String(g.status));
119Y.invalidateQueries({queryKey:["/api/sops"]})}catch{c({title:"Saved on this device only",description:"Couldn't reach the server, so this SOP won't appear on your other devices yet.",variant:"destructive"})}})()}else if(r==="checklist"&&(w||_)){const a={id:Date.now().toString(),title:u||"Untitled Checklist",station:D,shift:T,content:w?JSON.stringify(w):_,savedAt:new Date().toISOString()},l=[a,...G];ke(l),localStorage.setItem("checklists_library",JSON.stringify(l)),(async()=>{try{const g=await fetch("/api/checklists",{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({name:a.title,type:T==="Opening"?"open":T==="Closing"?"close":"other",area:Ot[D]??"other",sortOrder:0})});if(!g.ok)throw new Error(String(g.status));const R=(await g.json())?.id;if(!R)throw new Error("no id returned");const M=w?.sections??[],de=M.length>1,xe=[];for(const Q of M)for(const W of Q?.items??[])typeof W=="string"&&W.trim()&&xe.push(de&&Q?.title?`${String(Q.title).trim()}: ${W.trim()}`:W.trim());for(let Q=0;Q<xe.length;Q++)await fetch(`/api/checklists/${R}/items`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify({label:xe[Q].slice(0,500),sortOrder:Q})}).catch(()=>{});Y.invalidateQueries({queryKey:["/api/checklists"]})}catch{c({title:"Saved on this device only",description:"Couldn't reach the server, so this checklist won't appear for your staff yet.",variant:"destructive"})}})()}Oe(!0),setTimeout(()=>Oe(!1),2e3),c({title:`${r==="capture"?"SOP":"Checklist"} saved!`})},Le=a=>{const l=le.filter(g=>g.id!==a);we(l),localStorage.setItem("sops_library",JSON.stringify(l)),c({title:"SOP deleted"})},qe=a=>{const l=G.filter(g=>g.id!==a);ke(l),localStorage.setItem("checklists_library",JSON.stringify(l)),c({title:"Checklist deleted"})},He=a=>{const l=Math.floor((Date.now()-new Date(a).getTime())/864e5);return l>90?{label:`${l}d · Review Due`,color:"#e07a66",bg:"rgba(239,68,68,0.1)"}:l>30?{label:`${l}d ago`,color:"#e0b24e",bg:"rgba(245,158,11,0.1)"}:{label:`${l}d ago`,color:"#7E8A55",bg:"rgba(34,197,94,0.1)"}},ze=()=>{const a=window.open("","_blank");if(!a)return;let l="";w?(l=`<h1 style="font-size:20px;margin-bottom:4px;">${u||"Checklist"}</h1>
120        <p style="color:#666;font-size:12px;margin-bottom:16px;">Station: ${D} | Shift: ${T} | Date: _________ | Manager: _________</p>`,w.sections?.forEach(g=>{l+=`<h2 style="font-size:14px;text-transform:uppercase;letter-spacing:1px;margin:16px 0 8px;border-bottom:1px solid #ccc;padding-bottom:4px;">${g.title}</h2>`,g.items?.forEach(ce=>{l+=`<div style="display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px solid #eee;">
121            <span style="display:inline-block;width:18px;height:18px;border:2px solid #333;border-radius:2px;flex-shrink:0;"></span>
122            <span style="font-size:13px;">${ce}</span>
123            <span style="margin-left:auto;font-size:11px;color:#999;">Init: ___ Time: ___</span>
124          </div>`})}),l+='<div style="margin-top:24px;padding-top:12px;border-top:2px solid #333;font-size:13px;">VERIFIED BY: _____________ TIME: ___________</div>'):l=`<pre style="white-space:pre-wrap;font-size:12px;">${_}</pre>`,a.document.write(`<!DOCTYPE html><html><head><title>${u||"Checklist"}</title>
125      <style>body{font-family:Arial,sans-serif;padding:32px;max-width:700px;margin:0 auto;color:#000;background:#fff;}
126      @media print{body{padding:16px;}}</style></head><body>${l}</body></html>`),a.document.close(),a.print()},Ye=a=>a>=80?"#7E8A55":a>=60?"#e0b24e":"#e07a66";return e.jsxs(e.Fragment,{children:[e.jsxs(us,{className:"mb-8 relative overflow-hidden",style:{background:"#241812",borderColor:"#382019"},children:[e.jsx("div",{className:"absolute inset-0 rounded-lg pointer-events-none",style:{background:"linear-gradient(90deg, transparent 0%, rgba(200, 147, 78,0.08) 50%, transparent 100%)",backgroundSize:"200% 100%",animation:"shimmer 3s linear infinite"}}),e.jsxs(xs,{className:"relative",children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(ys,{className:"h-5 w-5",style:{color:"#c8934e"}}),e.jsx("span",{className:"text-white",children:"Smart SOP Capture"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-[3px] h-4 rounded-full",style:{background:"#c8934e"}}),e.jsx(Ds,{style:{color:"#a99a82"}
126,children:"Describe how a task is actually performed. It gets converted into standardized, transferable documentation."})]})]}),e.jsxs(gs,{className:"space-y-4 relative",children:[e.jsxs(ft,{value:r,onValueChange:a=>C(a),className:"w-full",children:[e.jsx("div",{className:"border-b",style:{borderColor:"#382019"},children:e.jsx(bt,{className:"grid w-full grid-cols-3 bg-transparent h-auto p-0",children:[{value:"capture",label:"Capture SOP",Icon:Fs},{value:"checklist",label:"Quick Checklist",Icon:vt},{value:"audit",label:"Audit",Icon:Nt}].map(a=>e.jsxs(jt,{value:a.value,"data-testid":`tab-sop-${a.value}`,className:"text-xs sm:text-sm py-2.5 px-1 rounded-none border-b-2 border-transparent data-[state=active]:border-b-0 data-[state=active]:bg-transparent",style:{color:r===a.value?"#efe7d8":"#a99a82",borderBottomColor:r===a.value?"#c8934e":"transparent"},children:[e.jsx(a.Icon,{className:"h-3.5 w-3.5 mr-1 hidden sm:inline-block"}),a.label]},a.value))})}),e.jsxs(ms,{value:"capture",className:"space-y-4 mt-4",children:[e.jsx("p",{className:"text-sm",style:{color:"#a99a82"},children:"Describe how your best performer does this task. It will be converted into a structured SOP."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{children:[e.jsx(H,{htmlFor:"taskName",className:"text-white",children:"Task/Procedure Name"}),e.jsx(v,{id:"taskName",placeholder:"e.g., Opening Cash Drawer",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},value:u,onChange:a=>b(a.target.value),"data-testid":"input-task-name"})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"roleOwner",className:"text-white",children:"Role Owner"}),e.jsx(v,{id:"roleOwner",placeholder:"e.g., Shift Lead",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},value:d,onChange:a=>F(a.target.value),"data-testid":"input-role-owner"})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"trigger",className:"text-white",children:"Trigger (When?)"}),e.jsxs("div",{className:"relative",children:[e.jsx(Ms,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4",style:{color:"#8a7d66"}}),e.jsx(v,{id:"trigger",placeholder:"e.g., Start of every shift",className:"mt-1 pl-9",style:{background:"#1f1310",borderColor:"#4a4030"},value:j,onChange:a=>y(a.target.value),"data-testid":"input-trigger"})]})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Frequency"}),e.jsxs(I,{value:f,onValueChange:ee,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},"data-testid":"select-frequency",children:e.jsx($,{})}),e.jsx(A,{children:Tt.map(a=>e.jsx(n,{value:a,children:a},a))})]})]}),e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Complexity"}),e.jsx("div",{className:"flex gap-1 mt-1",children:Et.map(a=>e.jsx("button",{onClick:()=>se(a.value),className:"flex-1 text-xs py-2 px-2 rounded-lg transition-colors","data-testid":`complexity-${a.value}`,style:{background:P===a.value?"#a9702f":"#1f1310",color:P===a.value?"#efe7d8":"#a99a82",border:`1px solid ${P===a.value?"#c8934e":"#4a4030"}`},children:a.label},a.value))})]})]})]}),e.jsxs(ms,{value:"checklist",className:"space-y-4 mt-4",children:[e.jsx("p",{className:"text-sm",style:{color:"#a99a82"},children:"Get a clean, printable checklist ready to post at the workstation."}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"checklistTaskName",className:"text-white",children:"Checklist Name"}),e.jsx(v,{id:"checklistTaskName",placeholder:"e.g., Closing Checklist",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},value:u,onChange:a=>b(a.target.value),"data-testid":"input-checklist-task-name"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Station/Area"}),e.jsxs(I,{value:D,onValueChange:ve,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},"data-testid":"select-station",children:e.jsx($,{})}),e.jsx(A,{children:It.map(a=>e.jsx(n,{value:a,children:a},a))})]})]}),e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Shift"}),e.jsx("div",{className:"flex gap-1 mt-1",children:$t.map(a=>e.jsx("button",{onClick:()=>Ne(a),className:"flex-1 text-xs py-2 px-2 rounded-lg transition-colors","data-testid":`shift-${a}`,style:{background:T===a?"#a9702f":"#1f1310",color:T===a?"#efe7d8":"#a99a82",border:`1px solid ${T===a?"#c8934e":"#4a4030"}`},children:a},a))})]})]})]}
126),e.jsxs(ms,{value:"audit",className:"space-y-4 mt-4",children:[e.jsx("p",{className:"text-sm",style:{color:"#a99a82"},children:'Test your workflow against the "Second Location Test." Would this survive turnover and expansion?'}),e.jsxs("div",{className:"p-3 rounded-lg border-l-[3px]",style:{background:"#1f1a0f",borderLeftColor:"#e0b24e"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(be,{className:"h-4 w-4",style:{color:"#e0b24e"}}),e.jsx("span",{className:"text-sm font-medium text-white",children:"SOP Freshness Check"})]}),e.jsx("p",{className:"text-xs",style:{color:"#a99a82"},children:"SOPs should be reviewed at least every 90 days. Run an audit on each SOP periodically to make sure your documentation reflects how things are actually done — not how they were done 6 months ago."})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Review Frequency"}),e.jsxs(I,{value:N,onValueChange:te,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},"data-testid":"select-audit-freq",children:e.jsx($,{})}),e.jsx(A,{children:At.map(a=>e.jsx(n,{value:a,children:a},a))})]})]}),e.jsxs("div",{children:[e.jsx(H,{className:"text-white",children:"Team Size"}),e.jsxs(I,{value:p,onValueChange:Ve,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030"},"data-testid":"select-team-size",children:e.jsx($,{})}),e.jsx(A,{children:Pt.map(a=>e.jsx(n,{value:a,children:a},a))})]})]})]})]})]}),e.jsxs("div",{children:[e.jsx(H,{htmlFor:"workflowDescription",className:"text-white",children:r==="capture"?"Describe the Workflow":r==="checklist"?"List the Steps":"Paste Your Current SOP or Describe the Process"}),e.jsxs("div",{className:"relative",children:[e.jsx(Me,{id:"workflowDescription",placeholder:r==="capture"?"e.g., First thing in the morning, the shift lead goes to the office and gets the cash drawer from the safe...":r==="checklist"?"e.g., Count starting cash, verify safe log, transport to register, test POS system...":"Paste your existing SOP or describe how the process currently works...",className:"mt-1 min-h-[160px]",style:{background:"#1f1310",borderColor:"#4a4030"},value:x,onChange:a=>q(a.target.value),maxLength:2e3,"data-testid":"textarea-workflow-description"}),e.jsxs("span",{className:"absolute bottom-2 right-3 text-[13px]",style:{color:"#8a7d66"},children:[x.length," / 2000"]})]})]}),e.jsx(z,{onClick:Se,disabled:ae||!x.trim(),className:"w-full h-[52px] text-white",style:{background:ae?"#4a4030":"#a9702f"},"data-testid":"btn-generate-sop",children:ae?e.jsxs("span",{className:"flex items-center gap-2 italic",style:{color:"#c8934e"},children:[e.jsx(ts,{className:"h-4 w-4 animate-spin"}),r==="capture"?"Structuring your SOP...":r==="checklist"?"Building checklist...":"Running scalability audit..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4 mr-2"}),r==="capture"?"Generate SOP":r==="checklist"?"Generate Checklist":"Run Scalability Audit"]})}),ae&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"h-4 rounded",style:{background:"#1f1310",animation:"shimmer 1.5s linear infinite",backgroundSize:"200% 100%",backgroundImage:"linear-gradient(90deg, #1f1310 0%, #241812 50%, #1f1310 100%)"}}),e.jsx("div",{className:"h-4 rounded w-3/4",style:{background:"#1f1310",animation:"shimmer 1.5s linear infinite 0.3s",backgroundSize:"200% 100%",backgroundImage:"linear-gradient(90deg, #1f1310 0%, #241812 50%, #1f1310 100%)"}})]}),h&&r==="capture"&&e.jsxs("div",{className:"mt-4 rounded-xl p-5",style:{background:"#241812",border:"1px solid #c8934e"},"data-testid":"sop-output-card",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-4",children:[e.jsx(L,{className:"text-[13px]",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e",borderColor:"rgba(200, 147, 78,0.3)"},children:"SOP GENERATED"}),e.jsxs("div",{className:"flex items-center gap-2",children:[d&&e.jsx(L,{className:"text-[13px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:d}),h.estimated_training_time&&e.jsxs(L,{className:"text-[13px]",style:{background:"#1f1310",color:"#c8934e",borderColor:"rgba(200, 147, 78,0.3)"},children:[h.estimated_training_time," to train"]})]})]}),e.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs flex-wrap",style:{color:"#a99a82"}
126,children:[e.jsxs("span",{children:["Task: ",e.jsx("strong",{className:"text-white",children:u||"Untitled"})]}),j&&e.jsxs("span",{children:["Trigger: ",e.jsx("strong",{className:"text-white",children:j})]}),e.jsxs("span",{children:["Frequency: ",e.jsx("strong",{className:"text-white",children:f})]})]}),e.jsxs("div",{className:"mb-4 py-3",style:{borderTop:"1px solid #382019",borderBottom:"1px solid #382019"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"PURPOSE"}),e.jsx("p",{className:"text-sm text-white",children:h.purpose})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"STEPS"}),e.jsx("div",{className:"space-y-1.5",children:h.steps?.map((a,l)=>e.jsxs("div",{className:"flex gap-2 text-sm",children:[e.jsxs("span",{className:"font-bold shrink-0",style:{color:"#c8934e"},children:[l+1,"."]}),e.jsx("span",{className:"text-white",children:a})]},l))})]}),h.failure_points?.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"FAILURE POINTS"}),e.jsx("div",{className:"space-y-1",children:h.failure_points.map((a,l)=>e.jsxs("div",{className:"flex gap-2 text-sm",children:[e.jsx(be,{className:"h-3.5 w-3.5 shrink-0 mt-0.5",style:{color:"#e0b24e"}}),e.jsx("span",{style:{color:"#a99a82"},children:a})]},l))})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"SECOND LOCATION TEST"}),e.jsxs("div",{className:"flex items-center gap-2",children:[h.second_location_test?.passes?e.jsx(ps,{className:"h-4 w-4",style:{color:"#7E8A55"}}):e.jsx(_s,{className:"h-4 w-4",style:{color:"#e07a66"}}),e.jsxs("span",{className:"text-sm",style:{color:h.second_location_test?.passes?"#7E8A55":"#e07a66"},children:[h.second_location_test?.passes?"PASSES":"FAILS"," — ",h.second_location_test?.notes]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-3",style:{borderTop:"1px solid #382019"},children:[e.jsx(z,{variant:"outline",size:"sm",onClick:X,className:"h-7 text-xs",style:{borderColor:k?"#7E8A55":"#c8934e",color:k?"#7E8A55":"#c8934e"},"data-testid":"btn-copy-sop",children:k?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Copy SOP"]})}),e.jsx(z,{size:"sm",onClick:ie,className:"h-7 text-xs text-white",style:B?{background:"#2f6b47"}:{background:"#a9702f"},"data-testid":"btn-save-sop",children:B?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Saved!"]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"h-3 w-3 mr-1"})," Save SOP"]})}),e.jsxs(z,{variant:"outline",size:"sm",onClick:Se,className:"h-7 text-xs",style:{borderColor:"#a99a82",color:"#a99a82"},"data-testid":"btn-regen-sop",children:[e.jsx(wt,{className:"h-3 w-3 mr-1"})," Regenerate"]})]})]}),w&&r==="checklist"&&e.jsxs("div",{className:"mt-4 rounded-xl p-5",style:{background:"#241812",border:"1px solid #c8934e"},"data-testid":"checklist-output-card",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2 mb-3",children:[e.jsx(L,{className:"text-[13px]",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e",borderColor:"rgba(200, 147, 78,0.3)"},children:"CHECKLIST READY"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(L,{className:"text-[13px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:D}),e.jsx(L,{className:"text-[13px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:T}),w.estimated_completion_time&&e.jsx(L,{className:"text-[13px]",style:{background:"#1f1310",color:"#c8934e",borderColor:"rgba(200, 147, 78,0.3)"},children:w.estimated_completion_time})]})]}),e.jsx("p",{className:"text-lg font-semibold text-white mb-4",children:u||"Checklist"}),w.sections?.map((a,l)=>e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:a.title}),e.jsx("div",{className:"space-y-1.5",children:a.items?.map((g,ce)=>e.jsxs("div",{className:"flex items-center gap-3 text-sm py-1",children:[e.jsx("span",{className:"w-4 h-4 rounded-sm shrink-0",style:{border:"1.5px solid #4a4030"}}),e.jsx("span",{className:"text-white",children:g})]},ce))})]},l)),e.jsxs("div",{className:"flex flex-wrap gap-2 pt-3",style:{borderTop:"1px solid #382019"},children:[e.jsx(z,{variant:"outline",size:"sm",onClick:X,className:"h-7 text-xs",style:{borderColor:k?"#7E8A55":"#c8934e",color:k?"#7E8A55":"#c8934e"},"data-testid":"btn-copy-checklist",children:k?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Copy"]})}),e.jsxs(z,{variant:"outline",size:"sm",onClick:ze,className:"h-7 text-xs",style:{borderColor:"#c8934e",color:"#c8934e"},"data-testid":"btn-print-checklist",children:[e.jsx(fs,{className:"h-3 w-3 mr-1"})," Print View"]}),e.jsx(z,{size:"sm",onClick:ie,className:"h-7 text-xs text-white",style:B?{background:"#2f6b47"}:{background:"#a9702f"},"data-testid":"btn-save-checklist",children:B?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Saved!"]}):e.jsxs(e.Fragment,{children:[e.jsx(je,{className:"h-3 w-3 mr-1"})," Save"]})})]})]}),m&&r==="audit"&&e.jsxs("div",{className:"mt-4 rounded-xl p-5",style:{background:"#241812",border:"1px solid #c8934e"},"data-testid":"audit-output-card",children:[e.jsx("div",{className:"flex items-center gap-2 mb-4",children:e.jsx(L,{className:"text-[13px]",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e",borderColor:"rgba(200, 147, 78,0.3)"},children:"AUDIT COMPLETE"})}),e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsx("p",{className:"text-sm text-white font-semibold",children:"Scalability Score"}),e.jsxs("p",{className:"text-lg font-bold",style:{color:Ye(m.scalability_score)},children:[m.scalability_score,"/100"]})]}),e.jsx("div",{className:"w-full h-3 rounded-full",style:{background:"#1f1310"},children:e.jsx("div",{className:"h-full rounded-full transition-all duration-500",style:{width:`${m.scalability_score}%`,background:Ye(m.scalability_score)}})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"SECOND LOCATION TEST"}),e.jsxs("div",{className:"flex items-center gap-2",children:[m.second_location_test_passes?e.jsx(ps,{className:"h-4 w-4",style:{color:"#7E8A55"}}):e.jsx(_s,{className:"h-4 w-4",style:{color:"#e07a66"}}),e.jsxs("span",{className:"text-sm",style:{color:m.second_location_test_passes?"#7E8A55":"#e07a66"},children:[m.second_location_test_passes?"PASSES":"FAILS"," — ",m.second_location_verdict]})]})]}),m.gaps?.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"GAPS FOUND"}),e.jsx(L,{className:"text-[12px]",style:{background:"rgba(239,68,68,0.15)",color:"#e07a66",borderColor:"rgba(239,68,68,0.3)"},children:m.gaps.length})]}),m.gaps.map((a,l)=>e.jsxs("div",{className:"flex gap-2 text-sm mb-1",children:[e.jsx(be,{className:"h-3.5 w-3.5 shrink-0 mt-0.5",style:{color:"#e0b24e"}}),e.jsx("span",{style:{color:"#a99a82"}
126,children:a})]},l))]}),m.strengths?.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"STRENGTHS"}),e.jsx(L,{className:"text-[12px]",style:{background:"rgba(34,197,94,0.15)",color:"#7E8A55",borderColor:"rgba(34,197,94,0.3)"},children:m.strengths.length})]}),m.strengths.map((a,l)=>e.jsxs("div",{className:"flex gap-2 text-sm mb-1",children:[e.jsx(ps,{className:"h-3.5 w-3.5 shrink-0 mt-0.5",style:{color:"#7E8A55"}}),e.jsx("span",{style:{color:"#a99a82"},children:a})]},l))]}),m.recommended_fixes?.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-2",style:{color:"#c8934e",letterSpacing:"0.08em"},children:"RECOMMENDED FIXES"}),m.recommended_fixes.map((a,l)=>e.jsxs("div",{className:"flex gap-2 text-sm mb-1",children:[e.jsx(pt,{className:"h-3.5 w-3.5 shrink-0 mt-0.5",style:{color:"#c8934e"}}),e.jsx("span",{className:"text-white",children:a})]},l))]}),e.jsx("div",{className:"flex flex-wrap gap-2 pt-3",style:{borderTop:"1px solid #382019"},children:e.jsx(z,{variant:"outline",size:"sm",onClick:X,className:"h-7 text-xs",style:{borderColor:k?"#7E8A55":"#c8934e",color:k?"#7E8A55":"#c8934e"},"data-testid":"btn-copy-audit",children:k?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Copy Report"]})})})]}),_&&!h&&!w&&!m&&e.jsxs("div",{className:"mt-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[e.jsxs(H,{
126className:"text-white",children:["Generated ",r==="capture"?"SOP":r==="checklist"?"Checklist":"Audit Report"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(z,{variant:"outline",size:"sm",onClick:ze,className:"h-7 text-xs",style:{borderColor:"#c8934e",color:"#c8934e"},"data-testid":"btn-print-sop",children:[e.jsx(fs,{className:"h-3 w-3 mr-1"})," Print"]}),e.jsx(z,{variant:"outline",size:"sm",onClick:X,className:"h-7 text-xs",style:{borderColor:k?"#7E8A55":"#c8934e",color:k?"#7E8A55":"#c8934e"},"data-testid":"btn-copy-sop-raw",children:k?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3 w-3 mr-1"})," Copied!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3 w-3 mr-1"})," Copy"]})})]})]}),e.jsx("div",{className:"p-4 rounded-lg whitespace-pre-wrap text-sm font-mono",style:{background:"#1f1310",color:"#efe7d8"},children:_})]})]})]}),e.jsxs(us,{className:"mb-8",style:{background:"#241812",borderColor:"#382019"},children:[e.jsx(xs,{className:"cursor-pointer",onClick:()=>We(!oe),children:e.jsxs(hs,{className:"flex items-center justify-between text-base",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(je,{className:"h-5 w-5",style:{color:"#c8934e"}}),e.jsx("span",{className:"text-white",children:"Saved SOPs & Checklists"})]}),e.jsx(Rs,{className:"h-4 w-4 transition-transform duration-300",style:{color:"#c8934e",transform:oe?"rotate(180deg)":"rotate(0deg)"}})]})}),oe&&e.jsxs(gs,{children:[e.jsx("div",{className:"flex gap-2 mb-4",children:["sops","checklists"].map(a=>e.jsxs("button",{onClick:()=>$e(a),className:"text-xs px-3 py-1.5 rounded-lg","data-testid":`lib-tab-${a}`,style:{background:ne===a?"#a9702f":"#1f1310",color:ne===a?"#efe7d8":"#a99a82",border:`1px solid ${ne===a?"#c8934e":"#4a4030"}`},children:[a==="sops"?"SOPs":"Checklists"," (",a==="sops"?le.length:G.length,")"]},a))}),ne==="sops"&&(le.length===0?e.jsx("p",{className:"text-sm py-4 text-center",style:{color:"#8a7d66"},children:"No SOPs saved yet — generate your first above"}):e.jsx("div",{className:"space-y-2",children:le.map(a=>{const l=He(a.savedAt);return e.jsxs("div",{className:"p-3 rounded-lg flex items-center justify-between gap-3",style:{background:"#1f1310",border:"1px solid #382019"},"data-testid":`saved-sop-${a.id}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[a.role&&e.jsx(L,{className:"text-[12px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:a.role}),a.frequency&&e.jsx(L,{className:"text-[12px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:a.frequency}),e.jsx(L,{className:"text-[12px]",style:{background:l.bg,color:l.color,borderColor:`${l.color}40`},children:l.label})]})]}),e.jsx(z,{variant:"ghost",size:"icon",onClick:()=>Le(a.id),"data-testid":`delete-sop-${a.id}`,children:e.jsx(ls,{className:"h-3.5 w-3.5",style:{color:"#e07a66"}})})]},a.id)})})),ne==="checklists"&&(G.length===0?e.jsx("p",{className:"text-sm py-4 text-center",style:{color:"#8a7d66"},children:"No checklists saved yet — generate your first above"}):e.jsx("div",{className:"space-y-2",children:G.map(a=>{const l=He(a.savedAt);return e.jsxs("div",{className:"p-3 rounded-lg flex items-center justify-between gap-3",style:{background:"#1f1310",border:"1px solid #382019"},"data-testid":`saved-checklist-${a.id}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-white truncate",children:a.title}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx(L,{className:"text-[12px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:a.station}),e.jsx(L,{className:"text-[12px]",style:{background:"#1f1310",color:"#a99a82",borderColor:"#4a4030"},children:a.shift}),e.jsx(L,{className:"text-[12px]",style:{background:l.bg,color:l.color,borderColor:`${l.color}40`},children:l.label})]})]}),e.jsx(z,{variant:"ghost",size:"icon",onClick:()=>qe(a.id),"data-testid":`delete-checklist-${a.id}
126`,children:e.jsx(ls,{className:"h-3.5 w-3.5",style:{color:"#e07a66"}})})]},a.id)})}))]})]})]})}const pe={equipment:"trc_facility_equipment",pmSchedules:"trc_facility_pm_schedules",issues:"trc_facility_issues"};function Ma(){const[c]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem(pe.equipment)||"[]")}catch{}return[]}),[r]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem(pe.pmSchedules)||"[]")}catch{}return[]}),[C]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem(pe.issues)||"[]")}catch{}return[]}),{data:x=[]}=as({queryKey:["/api/facility-issues"]}),q=x.filter(y=>y.status==="open"||y.status==="in_progress").length+C.filter(y=>y.status==="open"||y.status==="in_progress").length,u=new Date,b=new Date(u.getFullYear(),u.getMonth(),1),d=x.filter(y=>y.status==="resolved"&&new Date(y.resolvedAt||y.reportedAt)>=b).length+C.filter(y=>y.status==="resolved"&&new Date(y.resolvedAt)>=b).length,F=r.length>0?r[r.length-1]:null,j=[{label:"Open Issues",value:q>0?`${q} open`:"0 open",color:q>0?"#e0b24e":"#7E8A55",muted:q===0},{label:"Resolved This Month",value:`${d} this month`,muted:d===0},{label:"Equipment Logged",value:c.length>0?`${c.length} assets tracked`:"0 assets tracked",muted:c.length===0},{label:"Next PM Due",value:F?`${F.equipmentName||F.equipmentType}`:"No PM scheduled",muted:!F}];return e.jsx("div",{className:"flex gap-3 overflow-x-auto pb-2 mb-6 scrollbar-thin","data-testid":"asset-health-strip",children:j.map((y,f)=>e.jsxs("div",{className:"flex-shrink-0 min-w-[180px] rounded-[2px] p-3 border-l-[3px]",style:{background:"#241812",borderLeftColor:"#a9702f"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider mb-1",style:{color:"#a99a82"},children:y.label}),e.jsx("p",{className:"text-sm font-semibold truncate",style:{color:y.color||(y.muted?"#8a7d66":"#efe7d8")},"data-testid":`asset-strip-${f}`,children:y.value})]},f))})}function _t(c){if(!c)return null;try{const r=c.match(/A\)\s*SITUATION SUMMARY[:\s]*\n?([\s\S]*?)(?=\n\s*B\))/i),C=c.match(/B\)\s*PRIORITY LEVEL[:\s]*\n?([\s\S]*?)(?=\n\s*C\))/i),x=c.match(/C\)\s*IMMEDIATE ACTIONS[:\s]*\n?([\s\S]*?)(?=\n\s*D\))/i),q=c.match(/D\)\s*VENDOR\s*\/?\s*REPAIR SCRIPT[:\s]*\n?([\s\S]*?)(?=\n\s*E\))/i),u=c.match(/E\)\s*(?:LOG ENTRY|DOCUMENTATION)[:\s]*\n?([\s\S]*?)$/i),b=r?.[1]?.trim()||"",d=C?.[1]?.trim()||"",F=d.match(/Tier\s*(\d)/i),j=d.match(/Service Impact:\s*(.*)/i),y=F?`Tier ${F[1]}`:"",f=j?.[1]?.trim()||d.split(`
127`)[0]||"",ee=x?.[1]?.trim()||"",P=ee.split(`
128`).filter(p=>p.trim().match(/^\d+[\.\)]/)).map(p=>p.trim().replace(/^\d+[\.\)]\s*/,"")),se=q?.[1]?.trim()||"",D=se.match(/Who to call[:\s]*(.*)/i),ve=se.match(/What to say[:\s]*([\s\S]*?)(?=\n\s*[-•]?\s*Authorization|$)/i),T=se.match(/Authorization[^:]*[:\s]*(.*)/i),Ne=se.split(`
129`).filter(p=>p.trim().match(/^\d+[\.\)]|^[-•]\s*(?:What|How|When|Ask|Do|Is|Can|Will)/i)).map(p=>p.trim().replace(/^[-•\d\.\)]\s*/,"")),te=(u?.[1]?.trim()||"").split(`
130`).filter(p=>p.trim()&&!p.trim().startsWith("#")).map(p=>p.trim().replace(/^[-•☐□]\s*/,"")).slice(0,5);return te.length===0&&te.push("Time and date of issue logged","Vendor contacted — name and ETA","ETA confirmed for repair","Repair completed and verified","Invoice filed"),{situation:b,priority:d,priorityTier:y,serviceImpact:f,actions:P.length>0?P:ee.split(`
131`).filter(p=>p.trim()).map(p=>p.trim()),vendorScript:{whoToCall:D?.[1]?.trim()||"",whatToSay:ve?.[1]?.trim()||"",authLimit:T?.[1]?.trim()||"",questions:Ne.length>0?Ne:["What is your estimated arrival time?","Will you need to order parts?","What is the estimated repair cost?"]},docChecklist:te}}catch{return null}}function Va(){const{toast:c}=qs(),[r,C]=i.useState("breakdown"),[x,q]=i.useState("no"),[u,b]=i.useState("no"),[d,F]=i.useState(""),[j,y]=i.useState(""),[f,ee]=i.useState(""),[P,se]=i.useState(""),[D,ve]=i.useState(""),[T,Ne]=i.useState([]),[N,te]=i.useState(""),[p,Ve]=i.useState(!1),[_,Ce]=i.useState(""),[h,Te]=i.useState(""),[w,Ue]=i.useState(""),[m,Be]=i.useState(""),[ae,Ee]=i.useState(""),[k,Ie]=i.useState(""),[B,Oe]=i.useState("revenue-critical"),[oe,We]=i.useState(""),[ne,$e]=i.useState(""),[le,we]=i.useState(""),[G,ke]=i.useState([]),[Ae,Se]=i.useState(""),[X,Pe]=i.useState("unsure"),[re,_e]=i.useState(new Set),[ie,Le]=i.useState(new Set),[qe,He]=i.useState("pipeline"),[ze,Ye]=i.useState(null),[a,l]=i.useState(!1),[g,ce]=i.useState(!1),[R,M]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem(pe.equipment)||"[]")}catch{}return[]}),[de,xe]=i.useState(()=>{try{if(typeof window<"u")return JSON.parse(localStorage.getItem(pe.pmSchedules)||"[]")}catch{}return[]}),[Q,W]=i.useState(!1),[V,me]=i.useState(null),[Ke,Vs]=i.useState("all"),[Qe,Us]=i.useState(""),[Bs,rs]=i.useState(!1),{data:De=[]}=as({queryKey:["/api/vendors"]}),{data:he=[],isError:Ws,refetch:Hs}=as({queryKey:["/api/facility-issues"]}),{data:Je}=as({queryKey:["/api/facility-issues/stats"]}),bs=ye({mutationFn:async s=>fe("POST","/api/vendors",s),onSuccess:()=>
131{Y.invalidateQueries({queryKey:["/api/vendors"]}),W(!1),me(null),c({title:"Vendor added"})},onError:()=>{c({title:"Failed to add vendor",variant:"destructive"})}}),js=ye({mutationFn:async({id:s,data:t})=>fe("PUT",`/api/vendors/${s}`,t),onSuccess:()=>{Y.invalidateQueries({queryKey:["/api/vendors"]}),W(!1),me(null),c({title:"Vendor updated"})},onError:()=>{c({title:"Failed to update vendor",variant:"destructive"})}}),zs=ye({mutationFn:async s=>fe("DELETE",`/api/vendors/${s}`),onSuccess:()=>{Y.invalidateQueries({queryKey:["/api/vendors"]}),c({title:"Vendor deleted"})},onError:()=>{c({title:"Failed to delete vendor",variant:"destructive"})}}),Ys=ye({mutationFn:async s=>fe("PATCH",`/api/vendors/${s}/favorite`),onSuccess:()=>{Y.invalidateQueries({queryKey:["/api/vendors"]})}}),is=ye({mutationFn:async s=>fe("POST","/api/facility-issues",s),onSuccess:()=>{Y.invalidateQueries({queryKey:["/api/facility-issues"]}),Y.invalidateQueries({queryKey:["/api/facility-issues/stats"]}),rs(!1),c({title:"Issue saved to Dashboard"})},onError:()=>{c({title:"Failed to log issue",variant:"destructive"})}}),vs=ye({mutationFn:async({id:s,data:t})=>fe("PUT",`/api/facility-issues/${s}`,t),onSuccess:()=>
131{Y.invalidateQueries({queryKey:["/api/facility-issues"]}),Y.invalidateQueries({queryKey:["/api/facility-issues/stats"]}),c({title:"Issue updated"})}}),Ns=ye({mutationFn:async({id:s,repairNotes:t,repairCost:o})=>fe("PATCH",`/api/facility-issues/${s}/resolve`,{repairNotes:t,repairCost:o}),onSuccess:()=>{Y.invalidateQueries({queryKey:["/api/facility-issues"]}),Y.invalidateQueries({queryKey:["/api/facility-issues/stats"]}),c({title:"Issue resolved"})}}),ws=De.filter(s=>{const t=Ke==="all"||s.specialty===Ke||Ke==="favorite"&&s.isFavorite,o=!Qe||s.name.toLowerCase().includes(Qe.toLowerCase())||s.notes?.toLowerCase().includes(Qe.toLowerCase());return t&&o}),Ge=()=>d?De.filter(s=>s.specialty===d||s.specialty==="general").slice(0,3):[],E=[{value:"refrigeration",label:"Refrigeration / Ice"},{value:"cooking",label:"Cooking Equipment"},{value:"dish",label:"Dish Machine"},{value:"hvac",label:"HVAC"},{value:"plumbing",label:"Plumbing"},{value:"electrical",label:"Electrical"},{value:"pos",label:"POS & Network"},{value:"other",label:"Other"}],ge={refrigeration:"#c8934e",cooking:"#c8934e",dish:"#c8934e",hvac:"#7E8A55",plumbing:"#3fa892",electrical:"#e0b24e",pos:"#b58a5c",other:"#8a7d66"},ks=[{value:"temps",label:"Temps (walk-in, reach-in)",tip:"Walk-in and reach-in units can rise above safe temps without alarm"},{value:"ice-sanitation",label:"Ice machine sanitation",tip:"Ice machines need regular sanitation to prevent biofilm buildup"},{value:"hood-ansul",label:"Hood/ANSUL checks",tip:"Fire suppression systems require periodic visual and functional checks"},{value:"hvac-filters",label:"HVAC filter cadence",tip:"Dirty filters reduce efficiency and can cause equipment failure"},{value:"dish-sanitizer",label:"Dish sanitizer ppm/temp",tip:"Sanitizer concentration and water temperature must be verified per shift"}],Ks=s=>{Ne(t=>t.includes(s)?t.filter(o=>o!==s):[...t,s])},Xe={refrigeration:["Check door seal for gaps","Clean condenser coils","Verify evaporator fan is running","Check defrost timer","Ensure proper airflow (not overpacked)"],cooking:["Check pilot light / igniter","Verify gas supply valve is open","Calibrate thermostat with oven thermometer","Check thermocouple connection","Clean burner tubes"],dish:["Check water supply valves","Clean spray arms and filters","Verify chemical levels","Inspect fill valve and drain"],hvac:["Check thermostat batteries and settings","Replace air filter","Verify breaker hasn't tripped","Check if vents are blocked"],plumbing:["Check shut-off valves","Inspect for visible leaks","Verify hot water heater is functioning","Check grease trap levels"],electrical:["Check breaker panel for tripped breakers","Verify outlets with a tester","Look for burn marks or unusual smells","Check GFCI reset buttons"],pos:["Power cycle the terminal","Check network/ethernet cables","Verify payment processor connection","Restart the router"],other:["Document the issue clearly with photos","Check if issue is isolated or affects multiple areas","Note when problem first appeared"]}[d]||[],Ze=()=>{const s=x==="yes",t=u==="yes";return s&&t?{level:"CRITICAL",text:"Safety hazard during active service. Stop use immediately if risk to staff or guests.",color:"#e07a66",bgColor:"rgba(239,68,68,0.1)",borderColor:"rgba(239,68,68,0.3)"}:s&&!t?{level:"HIGH",text:"Workaround needed — service is active",color:"#e0b24e",bgColor:"rgba(245,158,11,0.1)",borderColor:"rgba(245,158,11,0.3)"}:!s&&t?{level:"ELEVATED",text:"Safety issue. Resolve before next service.",color:"#e0b24e",bgColor:"rgba(245,158,11,0.1)",borderColor:"rgba(245,158,11,0.3)"}:{level:"LOW",text:"Log for scheduled repair.",color:"#4a4030",bgColor:"rgba(74, 64, 48,0.15)",borderColor:"rgba(74, 64, 48,0.3)"}},Qs=async()=>{if(r==="breakdown"&&!j){c({title:"Please describe the issue",variant:"destructive"});return}if(r==="pm"&&!d){c({title:"Please select equipment type",variant:"destructive"});return}Ve(!0),te(""),_e(new Set),Le(new Set);try{const s=E.find(U=>U.value===d)?.label||d,t=T.map(U=>ks.find(ns=>ns.value===U)?.label||U).join(", "),o=Ge(),J=o.length>0?o.map(U=>`${U.name}: ${U.phone||"no phone"}${U.callOutFee?`, call-out fee: ${U.callOutFee}`:""}${U.isEmergency?" (24/7)":""}`).join("; "):"";let Z="";const Is=Ze();r==="breakdown"?Z=`You are a maintenance operations expert for a live restaurant. Your job is to prevent downtime, control repair costs, and keep the restaurant service-ready.
132
133SITUATION:
134- Equipment/Problem: ${j}
135- Equipment Type: ${s||"Not specified"}
136- Priority: ${Is.level} (${Is.text})
137- Service Status: ${x==="yes"?"Active — restaurant is currently serving":"Not in service"}
138- Safety Risk: ${u==="yes"?"YES - PRIORITIZE SAFETY":"No"}
139${f?`- Equipment name/model: ${f}`:""}
140${P?`- Last service date: ${P}`:""}
141${D?`- Symptoms: ${D}`:""}
142${_?`- Estimated downtime: ${_}`:""}
143${h?`- Discovered by: ${h}`:""}
144${J?`- Available vendors: ${J}`:""}
145${Xe.length>0?`- Quick troubleshooting tips were shown: ${Xe.join("; ")}`:""}
146
147Follow this order: Recognize, Contain, Triage, Decide, Document.
148
149Provide response in this EXACT format:
150
151A) SITUATION SUMMARY
152(2-3 sentence summary of the situation and initial assessment)
153
154B) PRIORITY LEVEL
155Tier 1 (service-critical) / Tier 2 (service-impacting) / Tier 3 (non-critical)
156Service Impact: [describe the impact on service]
157
158C) IMMEDIATE ACTIONS
1591. [Action verb] [specific action]
1602. [Action verb] [specific action]
161(max 7 numbered items)
162
163D) VENDOR / REPAIR SCRIPT
164- Who to call: [specific vendor type or name]
165- What to say: [exact script to use on the phone]
166- Authorization limit: [dollar amount and language to use]
167- Questions to ask: [numbered list of questions]
168
169E) DOCUMENTATION CHECKLIST
170- Time and date logged
171- Vendor contacted with ETA
172- Repair completed and verified
173- Invoice filed
174- Follow-up scheduled
175
176IMPORTANT: Never recommend unsafe workarounds for gas, electrical, refrigeration, or fire suppression.`:r==="pm"?Z=`You are a maintenance operations expert for a live restaurant. Build a comprehensive preventative maintenance plan.
177
178EQUIPMENT FOCUS: ${s}
179${f?`Equipment name/model: ${f}`:""}
180${m?`Last PM completed: ${m}`:""}
181${w?`Service volume: ${w}`:""}
182${T.length>0?`Fail-Silent Monitors requested: ${t}`:""}
183
184Provide response as a structured PM schedule. For each task, use this format:
185TASK: [task name] | FREQUENCY: [Daily/Weekly/Monthly/Quarterly/Annual] | WHO: [role responsible]
186
187Then if fail-silent monitors were requested, add:
188ESCALATION: [monitor name] | THRESHOLD: [value] | ACTION: [what to do]
189
190Keep it practical and specific to restaurant operations.`:Z=`You are a maintenance operations expert for a live restaurant. Create an equipment profile and maintenance guide.
191
192EQUIPMENT: ${f||s||"General Equipment"}
193Type: ${s}
194${P?`Last service date: ${P}`:""}
195${D?`Current issues/symptoms: ${D}`:""}
196${j?`Notes: ${j}`:""}
197${ae?`Purchase/Install date: ${ae}`:""}
198${k?`Warranty expires: ${k}`:""}
199${oe?`Serial number: ${oe}`:""}
200Criticality: ${B==="revenue-critical"?"Revenue-Critical (direct impact on service if down)":"Support Equipment (operation continues without it)"}
201
202Provide response in this format:
203
204A) EQUIPMENT PROFILE
205Summary of this equipment's role, typical lifespan, and maintenance needs.
206
207B) MAINTENANCE INTERVALS
208- [Task] every [interval]
209(list 3-5 key maintenance tasks with intervals)
210
211C) COMMON FAILURE POINTS
212- [Failure mode]: [warning signs]
213(list 2-3 common failures)
214
215D) RISK FLAGS
216- [Warning or risk to watch for]
217(list 2-3 operator warnings)`;const Os=await fetch("/api/consultant/ask",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({question:Z}),credentials:"include"});if(!Os.ok)throw new Error("Failed to generate response");const $s=Os.body?.getReader(),nt=new TextDecoder;if($s){let U="";for(;;){const{done:ns,value:ct}=await $s.read();if(ns)break;const dt=nt.decode(ct).split(`
218`).filter(cs=>cs.startsWith("data: "));for(const cs of dt)try{const As=JSON.parse(cs.slice(6));As.content&&(U+=As.content,te(U))}catch{}}}}catch{c({title:"Failed to generate response",variant:"destructive"})}finally{Ve(!1)}},Ss=async()=>{try{const s=globalThis.Capacitor?.Plugins?.Haptics;s&&await s.impact({style:"LIGHT"})}catch{}},Js=s=>{Ss(),_e(t=>{const o=new Set(t);return o.has(s)?o.delete(s):o.add(s),o})},Gs=s=>{Ss(),Le(t=>{const o=new Set(t);return o.has(s)?o.delete(s):o.add(s),o})},es=()=>{navigator.clipboard.writeText(N.replace(/\*\*/g,"").replace(/#{1,3}\s/g,"")),l(!0),setTimeout(()=>l(!1),2e3),c({title:"Copied to clipboard"})},Cs=()=>{const s=Ze();is.mutate({equipmentType:d||"other",equipmentName:f||E.find(t=>t.value===d)?.label||"Equipment",description:j,urgencyLevel:s.level.toLowerCase(),triageResponse:N})},Xs=()=>{const t=[{id:Date.now().toString(),name:f||E.find(o=>o.value===d)?.label||"Equipment",type:d,criticality:B,serialNumber:oe,purchaseDate:ae,warrantyExpiration:k,lastServiceDate:P,notes:j,aiProfile:N,savedAt:new Date().toISOString()},...R];M(t),typeof window<"u"&&localStorage.setItem(pe.equipment,JSON.stringify(t)),c({title:"Equipment profile saved"})},Zs=s=>{const t=R.filter(o=>o.id!==s);M(t),typeof window<"u"&&localStorage.setItem(pe.equipment,JSON.stringify(t)),c({title:"Equipment removed"})},et=()=>{const t=[{id:Date.now().toString(),equipmentType:d,equipmentName:f||E.find(o=>o.value===d)?.label||"",frequency:w,content:N,savedAt:new Date().toISOString()},...de];xe(t),typeof window<"u"&&localStorage.setItem(pe.pmSchedules,JSON.stringify(t)),c({title:"PM schedule saved"})},st=()=>{const s=window.open("","_blank");
218s&&(s.document.write(`<html><head><title>PM Schedule</title><style>body{font-family:system-ui,sans-serif;color:#000;padding:40px;max-width:800px;margin:0 auto}h1{font-size:20px;border-bottom:2px solid #a9702f;padding-bottom:8px}pre{white-space:pre-wrap;font-size:13px;line-height:1.6}</style></head><body><h1>Preventative Maintenance Schedule — ${f||E.find(t=>t.value===d)?.label||"Equipment"}</h1><pre>${N.replace(/\*\*/g,"").replace(/#{1,3}\s/g,"")}</pre><p style="font-size:11px;color:#999;margin-top:40px">Generated ${new Date().toLocaleDateString()}</p></body></html>`),s.document.close(),s.print())},Ts=()=>{y(""),ee(""),se(""),ve(""),te(""),Ce(""),Te(""),Ee(""),Ie(""),We(""),_e(new Set),Le(new Set)},Fe=(s,t)=>{Ts(),t&&F(t),C(s)},S=r==="breakdown"&&N?_t(N):null,tt=[...R].sort((s,t)=>s.criticality==="revenue-critical"&&t.criticality!=="revenue-critical"?-1:t.criticality==="revenue-critical"&&s.criticality!=="revenue-critical"?1:s.name.localeCompare(t.name)),at=he.filter(s=>s.status==="open"),lt=he.filter(s=>s.status==="in_progress"||s.status==="waiting_parts"),rt=he.filter(s=>s.status==="resolved"||s.status==="closed"),Es=he.filter(s=>{const t=new Date(s.reportedAt),o=new Date;return t.getMonth()===o.getMonth()&&t.getFullYear()===o.getFullYear()&&s.repairCost}).reduce((s,t)=>s+(parseFloat(t.repairCost)||0),0),os=he.reduce((s,t)=>(s[t.equipmentType]=(s[t.equipmentType]||0)+1,s),{}),it=Math.max(...Object.values(os),1),ot={animation:"shimmer 3s ease-in-out infinite",background:"#241812",borderColor:"#b8860b22",borderWidth:"1px",borderStyle:"solid",borderRadius:"12px"};return e.jsxs(us,{className:"mb-8",style:ot,"data-testid":"facility-command-center",children:[e.jsxs(xs,{style:{background:"linear-gradient(135deg, #241812 0%, #2e2619 100%)",borderRadius:"12px 12px 0 0"},children:[e.jsxs(hs,{className:"flex items-center gap-2",children:[e.jsx(ut,{className:"h-5 w-5",style:{color:"#c8934e"}}),e.jsx("span",{className:"text-white",children:"Facility Command Center"})]}),e.jsx(Ds,{style:{color:"#a99a82"},children:"Prevent downtime. Track repairs. Enforce PM schedules."})]}),e.jsxs(gs,{className:"space-y-4 pt-4",style:{background:"#241812"},children:[e.jsx("div",{className:"flex gap-1 overflow-x-auto pb-1",children:[{value:"breakdown",icon:be,label:"Breakdown",shortLabel:"Issue"},{value:"pm",icon:ss,label:"PM Schedule",shortLabel:"PM"},{value:"log",icon:kt,label:"Equipment",shortLabel:"Log"},{value:"vendors",icon:ds,label:"Vendors",shortLabel:"Vendors"},{value:"dashboard",icon:Ct,label:"Dashboard",shortLabel:"Dash"}].map(s=>e.jsxs("button",{onClick:()=>{C(s.value),s.value!==r&&Ts()},className:"flex items-center gap-1.5 px-3 py-2 text-xs sm:text-sm font-medium rounded-t-lg transition-colors whitespace-nowrap min-h-[44px]",style:{background:r===s.value?"#2e2619":"transparent",color:r===s.value?"#efe7d8":"#a99a82",borderBottom:r===s.value?"2px solid #c8934e":"2px solid transparent"},"data-testid":`tab-${s.value}`,children:[e.jsx(s.icon,{className:"h-4 w-4",style:{color:r===s.value?"#c8934e":"#8a7d66"}}),e.jsx("span",{className:"hidden sm:inline",children:s.label}),e.jsx("span",{className:"sm:hidden",children:s.shortLabel})]},s.value))}),e.jsx("div",{className:"h-px",style:{background:"#382019"}}),r==="breakdown"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"During Active Service?"}),e.jsx("button",{onClick:()=>q(x==="yes"?"no":"yes"),className:"w-full mt-1 py-2.5 px-3 rounded-lg text-sm font-medium min-h-[44px]",style:{background:x==="yes"?"rgba(239,68,68,0.2)":"#1f1310",border:`1px solid ${x==="yes"?"rgba(239,68,68,0.4)":"#4a4030"}`,color:x==="yes"?"#e07a66":"#a99a82"},"data-testid":"btn-during-service",children:x==="yes"?"Yes — In Service":"No — Closed/Prep"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Safety Risk?"}),e.jsx("button",{onClick:()=>b(u==="yes"?"no":"yes"),className:"w-full mt-1 py-2.5 px-3 rounded-lg text-sm font-medium min-h-[44px]",style:{background:u==="yes"?"rgba(239,68,68,0.2)":"#1f1310",border:`1px solid ${u==="yes"?"rgba(239,68,68,0.4)":"#4a4030"}`,color:u==="yes"?"#e07a66":"#a99a82"},"data-testid":"btn-safety-risk",children:u==="yes"?"Yes — Safety Risk":"No Safety Risk"})]})]}),(()=>{const s=Ze();return e.jsxs("div",{className:"p-3 rounded-lg flex items-center gap-3",style:{background:s.bgColor,border:`1px solid ${s.borderColor}`,borderLeft:`4px solid ${s.color}`},"data-testid":"breakdown-priority",children:[e.jsx(be,{className:"h-5 w-5 shrink-0",style:{color:s.color}}),e.jsxs("div",{children:[e.jsx("span",{className:"font-bold text-sm",style:{color:s.color},children:s.level}),e.jsx("span",{className:"text-sm ml-2",style:{color:"#a99a82"}
218,children:s.text})]})]})})(),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Type"}),e.jsxs(I,{value:d,onValueChange:F,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-equipment-type",children:e.jsx($,{placeholder:"Select equipment type..."})}),e.jsx(A,{children:E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value))})]})]}),Xe.length>0&&e.jsxs("div",{className:"p-3 rounded-lg",style:{background:"rgba(200, 147, 78,0.05)",border:"1px solid rgba(200, 147, 78,0.2)"},children:[e.jsx("p",{className:"text-xs font-medium mb-2",style:{color:"#c8934e"},children:"Quick checks before calling for repair:"}),e.jsx("ul",{className:"space-y-1",children:Xe.map((s,t)=>e.jsxs("li",{className:"text-xs flex items-start gap-1.5",style:{color:"#a99a82"},children:[e.jsx(K,{className:"h-3 w-3 shrink-0 mt-0.5",style:{color:"#c8934e"}}),s]},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Issue / Problem Description"}),e.jsx(Me,{placeholder:"e.g., Walk-in cooler reading 45F, ice machine not producing, fryer won't heat...",className:"mt-1 min-h-[80px]",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},value:j,onChange:s=>y(s.target.value),"data-testid":"textarea-issue"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Name/Model (optional)"}),e.jsx(v,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"e.g., True T-49 Reach-in",value:f,onChange:s=>ee(s.target.value),"data-testid":"input-equipment-name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Symptoms (optional)"}),e.jsx(v,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"e.g., temp high, leaking, error code E5",value:D,onChange:s=>ve(s.target.value),"data-testid":"input-symptoms"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Estimated Downtime"}),e.jsxs(I,{value:_,onValueChange:Ce,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-downtime",children:e.jsx($,{placeholder:"Select..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"operational",children:"Still operational (workaround in place)"}),e.jsx(n,{value:"under-2h",children:"Less than 2 hours"}),e.jsx(n,{value:"half-day",children:"Half day"}),e.jsx(n,{value:"full-day",children:"Full day or more"}),e.jsx(n,{value:"unknown",children:"Unknown"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Who Discovered It?"}),e.jsxs(I,{value:h,onValueChange:Te,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-discovered-by",children:e.jsx($,{placeholder:"Select..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"manager",children:"Manager on Duty"}),e.jsx(n,{value:"kitchen",children:"Kitchen Staff"}),e.jsx(n,{value:"foh",children:"Front of House"}),e.jsx(n,{value:"vendor",children:"Vendor"}),e.jsx(n,{value:"owner",children:"Owner"})]})]})]})]}),d&&e.jsxs("div",{className:"p-3 rounded-lg",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ds,{className:"h-4 w-4",style:{color:"#c8934e"}}),e.jsxs("span",{className:"text-sm font-medium text-white",children:["Suggested Vendors for ",E.find(s=>s.value===d)?.label]})]}),Ge().length>0?e.jsx("div",{className:"flex flex-wrap gap-2",children:Ge().map(s=>e.jsxs("div",{className:"flex items-center gap-2 p-2 rounded-lg text-sm",style:{background:"#241812",border:"1px solid #382019"},"data-testid":`suggested-vendor-${s.id}`,children:[e.jsx("span",{className:"font-medium text-white",children:s.name}),s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-1 px-2 py-0.5 rounded text-xs font-medium",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.3)"},children:[e.jsx(Re,{className:"h-3 w-3"}),s.phone]}),s.isEmergency&&e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:"rgba(34,197,94,0.15)",color:"#7E8A55"},children:"24/7"})]},s.id))}):e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-sm",style:{color:"#8a7d66"}
218,children:"No vendors for this equipment type yet."}),e.jsx("button",{onClick:()=>Fe("vendors"),className:"text-xs font-medium px-3 py-1.5 rounded-lg",style:{color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.3)",background:"rgba(200, 147, 78,0.1)"},"data-testid":"btn-add-vendor-shortcut",children:"Add Vendor"})]})]})]}),r==="pm"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Type"}),e.jsxs(I,{value:d,onValueChange:F,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-pm-equipment-type",children:e.jsx($,{placeholder:"Select equipment type..."})}),e.jsx(A,{children:E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Specific Equipment (optional)"}),e.jsx(v,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"e.g., Walk-in cooler, All fryers, Ice machine",value:f,onChange:s=>ee(s.target.value),"data-testid":"input-pm-equipment-name"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Service Frequency"}),e.jsxs(I,{value:w,onValueChange:Ue,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-service-frequency",children:e.jsx($,{placeholder:"Select volume..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"high",children:"High Volume (open 7 days, heavy use)"}),e.jsx(n,{value:"standard",children:"Standard (5-6 days/week)"}),e.jsx(n,{value:"low",children:"Low Volume (less than 5 days or seasonal)"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Last PM Completed (optional)"}),e.jsx(v,{type:"date",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},value:m,onChange:s=>Be(s.target.value),"data-testid":"input-last-pm"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Fail-Silent Monitors (optional)"}),e.jsx("p",{className:"text-xs",style:{color:"#8a7d66"},children:"Select items to include monitoring logs and escalation thresholds"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:ks.map(s=>e.jsx("button",{onClick:()=>Ks(s.value),className:"px-3 py-1.5 rounded-full text-xs font-medium transition-colors min-h-[36px]",style:{background:T.includes(s.value)?"rgba(169, 112, 47,0.15)":"transparent",border:`1px solid ${T.includes(s.value)?"#a9702f":"#4a4030"}`,color:T.includes(s.value)?"#c8934e":"#a99a82"},title:s.tip,"data-testid":`badge-fail-silent-${s.value}`,children:s.label},s.value))})]})]}),r==="log"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Type"}),e.jsxs(I,{value:d,onValueChange:F,children:[e.jsx(O,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-log-equipment-type",children:e.jsx($,{placeholder:"Select equipment type..."})}),e.jsx(A,{children:E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Name/Model"}),e.jsx(v,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"e.g., Hoshizaki KM-320MAJ Ice Machine",value:f,onChange:s=>ee(s.target.value),"data-testid":"input-log-equipment-name"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Purchase / Install Date (optional)"}),e.jsx(v,{type:"date",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},value:ae,onChange:s=>Ee(s.target.value),"data-testid":"input-purchase-date"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"}
218,children:"Warranty Expiration (optional)"}),e.jsx(v,{type:"date",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},value:k,onChange:s=>Ie(s.target.value),"data-testid":"input-warranty"}),k&&(()=>{const s=Math.ceil((new Date(k).getTime()-Date.now())/864e5);return s<=0?e.jsx("span",{className:"text-[13px] font-medium mt-1 inline-block px-2 py-0.5 rounded",style:{background:"rgba(239,68,68,0.15)",color:"#e07a66"},children:"Expired"}):s<=60?e.jsxs("span",{className:"text-[13px] font-medium mt-1 inline-block px-2 py-0.5 rounded",style:{background:"rgba(245,158,11,0.15)",color:"#e0b24e"},children:["Expiring Soon (",s,"d)"]}):null})()]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Serial Number / Asset Tag (optional)"}),e.jsx(v,{className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"e.g., SN-2024-001",value:oe,onChange:s=>We(s.target.value),"data-testid":"input-serial"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Last Service Date (optional)"}),e.jsx(v,{type:"date",className:"mt-1",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},value:P,onChange:s=>se(s.target.value),"data-testid":"input-last-service"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Criticality"}),e.jsx("div",{className:"flex gap-2 mt-1",children:[{value:"revenue-critical",label:"Revenue-Critical",desc:"Direct impact on service if down",color:"#e07a66"},{value:"support",label:"Support Equipment",desc:"Operation continues without it",color:"#8a7d66"}].map(s=>e.jsxs("button",{onClick:()=>Oe(s.value),className:"flex-1 p-3 rounded-lg text-left min-h-[44px]",style:{background:B===s.value?"rgba(200, 147, 78,0.1)":"#1f1310",border:`1px solid ${B===s.value?"#c8934e":"#4a4030"}`},"data-testid":`btn-criticality-${s.value}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2.5 h-2.5 rounded-full",style:{background:s.color}}),e.jsx("span",{className:"text-sm font-medium text-white",children:s.label})]}),e.jsx("p",{className:"text-[14px] mt-1",style:{color:"#8a7d66"},children:s.desc})]},s.value))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Notes / Current Issues (optional)"}),e.jsx(Me,{className:"mt-1 min-h-[80px]",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},placeholder:"Any notes about this equipment...",value:j,onChange:s=>y(s.target.value),"data-testid":"textarea-log-notes"})]}),R.length>0&&e.jsxs("div",{className:"mt-6",children:[e.jsxs("h4",{className:"text-sm font-semibold text-white mb-3 flex items-center gap-2",children:[e.jsx(Ls,{className:"h-4 w-4",style:{color:"#c8934e"}}),"Saved Equipment (",R.length,")"]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:tt.map(s=>{const t=E.find(J=>J.value===s.type)?.label||s.type,o=s.warrantyExpiration?Math.ceil((new Date(s.warrantyExpiration).getTime()-Date.now())/(1e3*60*60*24)):null;return e.jsxs("div",{className:"p-3 rounded-lg",style:{background:"#1f1310",border:"1px solid #382019"},"data-testid":`equipment-card-${s.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-white",children:s.name}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e"},children:t}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:s.criticality==="revenue-critical"?"rgba(239,68,68,0.15)":"rgba(138, 125, 102,0.15)",color:s.criticality==="revenue-critical"?"#e07a66":"#8a7d66"},children:s.criticality==="revenue-critical"?"Revenue-Critical":"Support"}),o!==null&&o<=60&&e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:o<=0?"rgba(239,68,68,0.15)":"rgba(245,158,11,0.15)",color:o<=0?"#e07a66":"#e0b24e"},children:o<=0?"Warranty Expired":`Warranty: ${o}d left`})]})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>Fe("pm",s.type),className:"p-1 rounded",style:{color:"#c8934e"},title:"Create PM Schedule","data-testid":`btn-create-pm-${s.id}`,children:e.jsx(ss,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>Zs(s.id),className:"p-1 rounded",style:{color:"#e07a66"},"data-testid":`btn-delete-equip-${s.id}`,children:e.jsx(ls,{className:"h-3.5 w-3.5"})})]})]}),e.jsxs("p",{className:"text-[14px]",style:{color:"#8a7d66"},children:["Saved ",new Date(s.savedAt).toLocaleDateString()]})]},s.id)})})]}),R.length===0&&!N&&e.jsxs("div",{className:"text-center py-6",style:{color:"#8a7d66"},children:[e.jsx(Ls,{className:"h-8 w-8 mx-auto mb-2 opacity-40"}),e.jsx("p",{className:"text-sm",children:"No equipment logged yet. Add your first asset above."})]})]}),r==="vendors"&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2 justify-between",children:[e.jsxs("div",{className:"flex gap-2 flex-1",children:[e.jsx(v,{placeholder:"Search vendors...",value:Qe,onCh
218ange:s=>Us(s.target.value),className:"max-w-xs",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-search"}),e.jsxs(I,{value:Ke,onValueChange:Vs,children:[e.jsx(O,{className:"w-40",style:{background:"#1f1310",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-vendor-filter",children:e.jsx($,{placeholder:"Filter by..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"all",children:"All Vendors"}),e.jsx(n,{value:"favorite",children:"Favorites"}),E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value)),e.jsx(n,{value:"general",children:"General"})]})]})]}),e.jsxs("button",{onClick:()=>{me(null),W(!0),ke([]),$e(""),we(""),Se(""),Pe("unsure")},className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium min-h-[44px]",style:{background:"#a9702f",color:"#efe7d8"},"data-testid":"btn-add-vendor",children:[e.jsx(Ps,{className:"h-4 w-4"}),"Add Vendor"]})]}),Q&&e.jsxs("div",{className:"p-4 rounded-xl space-y-4",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsx("h4",{className:"font-semibold text-white",children:V?"Edit Vendor":"Add New Vendor"}),e.jsxs("form",{onSubmit:s=>{s.preventDefault();const t=new FormData(s.currentTarget),o={name:t.get("name"),specialty:t.get("specialty"),phone:t.get("phone"),email:t.get("email"),website:t.get("website"),notes:t.get("notes"),responseTime:Ae||t.get("responseTime"),callOutFee:le||t.get("callOutFee"),accountNumber:t.get("accountNumber"),rating:parseInt(t.get("rating"))||0,isEmergency:X==="yes",afterHoursPhone:ne,equipmentTypesCovered:G.join(","),authorizationLimit:le,avgResponseTime:Ae};V?js.mutate({id:V.id,data:o}):bs.mutate(o)},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Vendor Name *"}),e.jsx(v,{name:"name",required:!0,defaultValue:V?.name||"",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Primary Specialty *"}),e.jsxs(I,{name:"specialty",defaultValue:V?.specialty||"general",children:[e.jsx(O,{style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-vendor-specialty",children:e.jsx($,{})}),e.jsxs(A,{children:[E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value)),e.jsx(n,{value:"general",children:"General"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Phone"}),e.jsx(v,{name:"phone",type:"tel",defaultValue:V?.phone||"",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-phone"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Email"}),e.jsx(v,{name:"email",type:"email",defaultValue:V?.email||"",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-email"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Types Covered"}),e.jsx("div",{className:"flex flex-wrap gap-2 mt-1",children:E.map(s=>e.jsx("button",{type:"button",onClick:()=>ke(t=>t.includes(s.value)?t.filter(o=>o!==s.value):[...t,s.value]),className:"px-2.5 py-1 rounded-full text-[14px] font-medium",style:{background:G.
218includes(s.value)?"rgba(169, 112, 47,0.15)":"transparent",border:`1px solid ${G.includes(s.value)?"#a9702f":"#4a4030"}`,color:G.includes(s.value)?"#c8934e":"#8a7d66"},"data-testid":`chip-vendor-type-${s.value}`,children:s.label},s.value))})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Emergency / After-Hours?"}),e.jsx("div",{className:"flex gap-1 mt-1",children:["yes","no","unsure"].map(s=>e.jsx("button",{type:"button",onClick:()=>Pe(s),className:"flex-1 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:X===s?"rgba(200, 147, 78,0.1)":"#1c1210",border:`1px solid ${X===s?"#c8934e":"#4a4030"}`,color:X===s?"#c8934e":"#8a7d66"},children:s==="yes"?"Yes":s==="no"?"No":"Unsure"},s))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Avg. Response Time"}),e.jsxs(I,{value:Ae,onValueChange:Se,children:[e.jsx(O,{className:"mt-1",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-vendor-avg-response",children:e.jsx($,{placeholder:"Select..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"under-2h",children:"Under 2 hours"}),e.jsx(n,{value:"2-4h",children:"2-4 hours"}),e.jsx(n,{value:"same-day",children:"Same day"}),e.jsx(n,{value:"next-day",children:"Next day"}),e.jsx(n,{value:"unknown",children:"Unknown"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Authorized Up To $"}),e.jsx(v,{type:"text",placeholder:"e.g., 500",value:le,onChange:s=>we(s.target.value),style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-auth-limit"})]})]}),X==="yes"&&e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"After-Hours Phone"}),e.jsx(v,{type:"tel",value:ne,onChange:s=>$e(s.target.value),placeholder:"After-hours contact number",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-vendor-after-hours"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Notes / History"}),e.jsx(Me,{name:"notes",placeholder:"Repair history, preferred contact name...",defaultValue:V?.notes||"",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"textarea-vendor-notes"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"submit",className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium min-h-[44px]",style:{background:"#a9702f",color:"#efe7d8"},"data-testid":"btn-save-vendor",children:[(bs.isPending||js.isPending)&&e.jsx(ts,{className:"h-4 w-4 animate-spin"}),V?"Update Vendor":"Add Vendor"]}),e.jsx("button",{type:"button",onClick:()=>{W(!1),me(null)},className:"px-4 py-2 rounded-lg text-sm min-h-[44px]",style:{border:"1px solid #4a4030",color:"#a99a82"},"data-testid":"btn-cancel-vendor",children:"Cancel"})]}),e.jsx("input",{type:"hidden",name:"responseTime",value:""}),e.jsx("input",{type:"hidden",name:"callOutFee",value:""}),e.jsx("input",{type:"hidden",name:"accountNumber",value:""}),e.jsx("input",{type:"hidden",name:"website",value:""}),e.jsx("input",{type:"hidden",name:"rating",value:"0"})]})]}),e.jsx("div",{className:"space-y-3",children:ws.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(ds,{className:"h-8 w-8 mx-auto mb-2 opacity-40",style:{color:"#8a7d66"}}),e.jsx("p",{className:"text-sm",style:{color:"#8a7d66"},children:De.length===0?"Your vendor bench determines how fast you recover. Build it before you need it.":"No vendors match your search."})]}):ws.map(s=>{const t=ge[s.specialty]||"#8a7d66";return e.jsxs("div",{className:"p-4 rounded-xl",style:{background:"#1f1310",borderLeft:`4px solid ${t}`,border:"1px solid #382019",borderLeftWidth:"4px",borderLeftColor:t},"data-testid":`vendor-card-${s.id}`,children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-semibold text-white",children:s.name}),s.isEmergency&&e.jsx("span",{className:"text-[13px] px-2 py-0.5 rounded-full font-medium",style:{background:"rgba(34,197,94,0.15)",color:"#7E8A55",border:"1px solid rgba(34,197,94,0.3)"},children:"24/7"}),!s.isEmergency&&e.jsx("span",{className:"text-[13px] px-2 py-0.5 rounded-full",style:{background:"rgba(138, 125, 102,0.15)",color:"#8a7d66"},children:"Business Hours"})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{onClick:()=>Ys.mutate(s.id),className:"p-1.5 rounded","data-testid":`btn-favorite-${s.id}`,children:e.jsx(xt,{className:`h-4 w-4 ${s.isFavorite?"fill-yellow-500":""}`,style:{color:s.isFavorite?"#cf9a45":"#8a7d66"}})}),e.jsx("button",{onClick:()=>
218{me(s),W(!0),ke(s.equipmentTypesCovered?.split(",").filter(Boolean)||[]),$e(s.afterHoursPhone||""),we(s.authorizationLimit||s.callOutFee||""),Se(s.avgResponseTime||""),Pe(s.isEmergency?"yes":"no")},className:"p-1.5 rounded",style:{color:"#a99a82"},"data-testid":`btn-edit-vendor-${s.id}`,children:e.jsx(St,{className:"h-4 w-4"})}),e.jsx("button",{onClick:()=>zs.mutate(s.id),className:"p-1.5 rounded",style:{color:"#e07a66"},"data-testid":`btn-delete-vendor-${s.id}`,children:e.jsx(ls,{className:"h-4 w-4"})})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-1.5 mb-2",children:[e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{background:`${t}20`,color:t},children:s.specialty}),s.equipmentTypesCovered?.split(",").filter(Boolean).map(o=>e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{background:"rgba(138, 125, 102,0.1)",color:"#a99a82"},children:E.find(J=>J.value===o)?.label||o},o))]}),e.jsxs("div",{className:"flex flex-wrap gap-2 mb-2",children:[s.phone&&e.jsxs("a",{href:`tel:${s.phone}`,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(200, 147, 78,0.12)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.25)"},"data-testid":`btn-call-${s.id}`,children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),s.phone]}),s.afterHoursPhone&&e.jsxs("a",{href:`tel:${s.afterHoursPhone}`,className:"flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(239,68,68,0.1)",color:"#e07a66",border:"1px solid rgba(239,68,68,0.2)"},children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"After Hours"]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 text-xs",style:{color:"#8a7d66"},children:[(s.avgResponseTime||s.responseTime)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Ms,{className:"h-3 w-3"}),s.avgResponseTime||s.responseTime]}),(s.authorizationLimit||s.callOutFee)&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ht,{className:"h-3 w-3"}),"Auth: $",s.authorizationLimit||s.callOutFee]}),s.email&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(gt,{className:"h-3 w-3"}),s.email]})]}),s.notes&&e.jsx("p",{className:"text-xs mt-2",style:{color:"#8a7d66",fontStyle:"italic"},children:s.notes})]},s.id)})})]}),r==="dashboard"&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[{label:"Open Issues",value:Je?.open||0,color:"#e07a66",topBorder:"#e07a66"},{label:"In Progress",value:Je?.inProgress||0,color:"#e0b24e",topBorder:"#e0b24e"},{label:"Resolved",value:Je?.resolved||0,color:"#7E8A55",topBorder:"#7E8A55"},{label:"Avg. Days to Fix",value:Je?.avgResolutionDays||0,color:"#c8934e",topBorder:"#c8934e"}].map((s,t)=>e.jsxs("div",{className:"p-3 rounded-xl text-center",style:{background:"#1f1310",borderTop:`3px solid ${s.topBorder}`},"data-testid":`dashboard-stat-${t}`,children:[e.jsx("div",{className:"text-3xl font-bold",style:{color:s.color},children:s.value}),e.jsx("div",{className:"text-[14px] mt-1",style:{color:"#a99a82"},children:s.label})]},t))}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("h4",{className:"text-sm font-semibold text-white flex items-center gap-2",children:[e.jsx(Fs,{className:"h-4 w-4",style:{color:"#c8934e"}}),"Issue Tracker"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex rounded-lg overflow-hidden",style:{border:"1px solid #4a4030"},children:["list","pipeline"].map(s=>e.jsx("button",{onClick:()=>He(s),className:"px-3 py-1.5 text-xs font-medium min-h-[32px]",style:{background:qe===s?"#2e2619":"transparent",color:qe===s?"#c8934e":"#8a7d66"},"data-testid":`btn-view-${s}`,children:s==="list"?"List":"Pipeline"},s))}),e.jsxs("button",{onClick:()=>rs(!0),className:"flex items-center gap-1 px-3 py-1.5 rounded-lg text-xs font-medium min-h-[32px]",style:{background:"#a9702f",color:"#efe7d8"},"data-testid":"btn-log-issue",children:[e.jsx(Ps,{className:"h-3.5 w-3.5"}),"Log Issue"]})]})]}),Bs&&e.jsxs("div",{className:"p-4 rounded-xl space-y-3",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsx("h4",{className:"font-semibold text-white",children:"Log New Issue"}),e.jsxs("form",{onSubmit:s=>{s.preventDefault();const t=new FormData(s.currentTarget),o=t.get("vendorId"),J=De.find(Z=>Z.id===parseInt(o));is.mutate({equipmentType:t.get("equipmentType"),equipmentName:t.get("equipmentName"),description:t.get("description"),urgencyLevel:t.get("urgencyLevel"),vendorId:o?parseInt(o):null,vendorName:J?.name||null})},className:"space-y-3",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"}
218,children:"Equipment Type *"}),e.jsxs(I,{name:"equipmentType",required:!0,children:[e.jsx(O,{style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-issue-equipment",children:e.jsx($,{placeholder:"Select..."})}),e.jsx(A,{children:E.map(s=>e.jsx(n,{value:s.value,children:s.label},s.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Urgency Level"}),e.jsxs(I,{name:"urgencyLevel",defaultValue:"medium",children:[e.jsx(O,{style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-issue-urgency",children:e.jsx($,{})}),e.jsxs(A,{children:[e.jsx(n,{value:"critical",children:"Critical"}),e.jsx(n,{value:"high",children:"High"}),e.jsx(n,{value:"medium",children:"Medium"}),e.jsx(n,{value:"low",children:"Low"})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Equipment Name"}),e.jsx(v,{name:"equipmentName",placeholder:"e.g., Walk-in cooler #1",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"input-issue-name"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Assigned Vendor"}),e.jsxs(I,{name:"vendorId",children:[e.jsx(O,{style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"select-issue-vendor",children:e.jsx($,{placeholder:"Select vendor..."})}),e.jsxs(A,{children:[e.jsx(n,{value:"",children:"No vendor assigned"}),De.map(s=>e.jsx(n,{value:String(s.id),children:s.name},s.id))]})]})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium",style:{color:"#a99a82"},children:"Description *"}),e.jsx(Me,{name:"description",required:!0,placeholder:"Describe the issue...",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":"textarea-issue-description"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"submit",className:"flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium min-h-[44px]",style:{background:"#a9702f",color:"#efe7d8"},"data-testid":"btn-submit-issue",children:[is.isPending&&e.jsx(ts,{className:"h-4 w-4 animate-spin"}),"Log Issue"]}),e.jsx("button",{type:"button",onClick:()=>rs(!1),className:"px-4 py-2 rounded-lg text-sm min-h-[44px]",style:{border:"1px solid #4a4030",color:"#a99a82"},children:"Cancel"})]})]})]}),qe==="pipeline"?e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-3",children:[{title:"Open",items:at,headerColor:"#e07a66"},{title:"In Progress",items:lt,headerColor:"#e0b24e"},{title:"Resolved",items:rt.slice(0,10),headerColor:"#7E8A55"}].map(s=>e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsxs("div",{className:"px-3 py-2 flex items-center justify-between",style:{background:`${s.headerColor}15`,borderBottom:`2px solid ${s.headerColor}`},children:[e.jsx("span",{className:"text-xs font-bold",style:{color:s.headerColor},children:s.title}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded-full font-medium",style:{background:`${s.headerColor}20`,color:s.headerColor},children:s.items.length})]}),e.jsx("div",{className:"p-2 space-y-2 min-h-[80px]",children:s.items.length===0?e.jsx("p",{className:"text-center text-[14px] py-4",style:{color:"#8a7d66"},children:"No issues"}):s.items.map(t=>{const o=Math.floor((Date.now()-new Date(t.reportedAt).getTime())/864e5),J=ze===t.id;return e.jsxs("div",{className:"rounded-lg cursor-pointer",style:{background:"#241812",border:"1px solid #382019"},onClick:()=>Ye(J?null:t.id),"data-testid":`pipeline-issue-${t.id}`,children:[e.jsxs("div",{className:"p-2.5",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-1 flex-wrap",children:[e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:`${ge[t.equipmentType]||"#8a7d66"}20`,color:ge[t.equipmentType]||"#8a7d66"},children:t.equipmentType}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:t.urgencyLevel==="critical"?"rgba(239,68,68,0.15)":t.urgencyLevel==="high"?"rgba(245,158,11,0.15)":"rgba(138, 125, 102,0.1)",color:t.urgencyLevel==="critical"?"#e07a66":t.urgencyLevel==="high"?"#e0b24e":"#a99a82"}
218,children:t.urgencyLevel?.toUpperCase()})]}),e.jsx("p",{className:"text-xs font-medium text-white truncate",children:t.equipmentName||t.equipmentType}),e.jsx("p",{className:"text-[14px] truncate",style:{color:"#8a7d66"},children:t.description}),e.jsxs("div",{className:"flex justify-between mt-1.5",children:[e.jsx("span",{className:"text-[13px]",style:{color:"#8a7d66"},children:new Date(t.reportedAt).toLocaleDateString()}),e.jsxs("span",{className:"text-[13px] font-medium",style:{color:o>3?"#e0b24e":"#8a7d66"},children:[o,"d open"]})]})]}),J&&e.jsxs("div",{className:"px-2.5 pb-2.5 space-y-2",style:{borderTop:"1px solid #382019"},children:[e.jsxs("div",{className:"pt-2",children:[e.jsx("label",{className:"text-[13px] font-medium",style:{color:"#a99a82"},children:"Status"}),e.jsxs(I,{value:t.status,onValueChange:Z=>{vs.mutate({id:t.id,data:{status:Z}})},children:[e.jsx(O,{className:"h-8 text-xs mt-0.5",style:{background:"#1c1210",borderColor:"#4a4030",color:"#efe7d8"},"data-testid":`select-status-${t.id}`,children:e.jsx($,{})}),e.jsxs(A,{children:[e.jsx(n,{value:"open",children:"Open"}),e.jsx(n,{value:"in_progress",children:"In Progress"}),e.jsx(n,{value:"waiting_parts",children:"Waiting Parts"}),e.jsx(n,{value:"resolved",children:"Resolved"})]})]})]}),t.vendorName&&e.jsxs("p",{className:"text-[14px]",style:{color:"#8a7d66"},children:["Vendor: ",t.vendorName]}),t.status!=="resolved"&&t.status!=="closed"&&e.jsxs("button",{onClick:Z=>{Z.stopPropagation(),Ns.mutate({id:t.id})},className:"w-full py-1.5 rounded-lg text-xs font-medium flex items-center justify-center gap-1 min-h-[32px]",style:{background:"rgba(34,197,94,0.1)",color:"#7E8A55",border:"1px solid rgba(34,197,94,0.2)"},"data-testid":`btn-resolve-${t.id}`,children:[e.jsx(K,{className:"h-3 w-3"}),"Resolve"]})]})]},t.id)})})]},s.title))}):e.jsx("div",{className:"space-y-2",children:Ws?e.jsx(yt,{onRetry:()=>Hs(),title:"Couldn't load issues",testId:"facility-issues-error"}):he.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(be,{className:"h-8 w-8 mx-auto mb-2 opacity-40",style:{color:"#8a7d66"}}),e.jsx("p",{className:"text-sm",style:{color:"#8a7d66"},children:"No issues logged yet. Track equipment problems and repairs here."})]}):he.slice(0,15).map(s=>{const t=Math.floor((Date.now()-new Date(s.reportedAt).getTime())/864e5);return e.jsx("div",{className:"p-3 rounded-lg",style:{background:"#1f1310",border:"1px solid #382019"},"data-testid":`issue-card-${s.id}`,children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap mb-1",children:[e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:s.urgencyLevel==="critical"?"rgba(239,68,68,0.15)":s.urgencyLevel==="high"?"rgba(245,158,11,0.15)":"rgba(138, 125, 102,0.1)",color:s.urgencyLevel==="critical"?"#e07a66":s.urgencyLevel==="high"?"#e0b24e":"#a99a82"},children:s.urgencyLevel}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded",style:{background:`${ge[s.equipmentType]||"#8a7d66"}15`,color:ge[s.equipmentType]||"#8a7d66"},children:s.equipmentType}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:s.status==="open"?"rgba(239,68,68,0.1)":s.status==="resolved"?"rgba(34,197,94,0.1)":"rgba(245,158,11,0.1)",color:s.status==="open"?"#e07a66":s.status==="resolved"?"#7E8A55":"#e0b24e"},children:s.status.replace("_"," ")}),t>3&&s.status!=="resolved"&&e.jsxs("span",{className:"text-[13px]",style:{color:"#e0b24e"},children:[t,"d"]})]}),e.jsx("p",{className:"text-sm font-medium text-white",children:s.equipmentName||s.equipmentType}),e.jsx("p",{className:"text-xs",style:{color:"#8a7d66"},children:s.description})]}),s.status!=="resolved"&&s.status!=="closed"&&e.jsxs("div",{className:"flex gap-1 shrink-0 ml-2",children:[e.jsxs(I,{value:s.status,onValueChange:o=>vs.mutate({id:s.id,data:{status:o}}),children:[e.jsx(O,{className:"w-24 h-7 text-[13px]",style:{background:"#1c1210",borderColor:"#4a4030",color:"#a99a82"},"data-testid":`select-status-${s.id}`,children:e.jsx($,{})}),e.jsxs(A,{children:[e.jsx(n,{value:"open",children:"Open"}),e.jsx(n,{value:"in_progress",children:"In Progress"}),e.jsx(n,{value:"waiting_parts",children:"Waiting"})]})]}),e.jsx("button",{onClick:()=>Ns.mutate({id:s.id}),className:"px-2 py-1 rounded text-[13px] font-medium min-h-[28px]",style:{background:"rgba(34,197,94,0.1)",color:"#7E8A55",border:"1px solid rgba(34,197,94,0.2)"},"data-testid":`btn-resolve-${s.id}`,children:e.jsx(K,{className:"h-3 w-3"})})]})]})},s.id)})}),Object.keys(os).length>0&&e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsx("h4",{className:"text-xs font-semibold mb-3",style:{color:"#a99a82"}
218,children:"Equipment Failure Breakdown"}),e.jsx("div",{className:"space-y-2",children:Object.entries(os).sort(([,s],[,t])=>t-s).map(([s,t])=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[14px] w-24 truncate",style:{color:"#a99a82"},children:E.find(o=>o.value===s)?.label||s}),e.jsx("div",{className:"flex-1 h-4 rounded-full overflow-hidden",style:{background:"#241812"},children:e.jsx("div",{className:"h-full rounded-full transition-all",style:{width:`${t/it*100}%`,background:ge[s]||"#c8934e"}})}),e.jsx("span",{className:"text-[14px] font-medium w-6 text-right",style:{color:ge[s]||"#c8934e"},children:t})]},s))})]}),Es>0&&e.jsxs("div",{className:"rounded-xl p-4",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsx("span",{className:"text-[12px] uppercase tracking-wider",style:{color:"#a99a82"},children:"Cost This Month"}),e.jsxs("p",{className:"text-2xl font-bold mt-1",style:{color:"#e0b24e"},children:["$",Es.toFixed(2)]})]}),e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{background:"#1f1310",border:"1px solid #382019"},children:[e.jsxs("button",{onClick:()=>ce(!g),className:"w-full px-4 py-3 flex items-center justify-between","data-testid":"btn-toggle-pm-schedules",children:[e.jsxs("span",{className:"text-sm font-medium text-white flex items-center gap-2",children:[e.jsx(ss,{className:"h-4 w-4",style:{color:"#c8934e"}}),"Saved PM Schedules (",de.length,")"]}),e.jsx(Rs,{className:"h-4 w-4 transition-transform",style:{color:"#c8934e",transform:g?"rotate(180deg)":"rotate(0deg)"}})]}),g&&e.jsx("div",{className:"px-4 pb-3",children:de.length===0?e.jsx("p",{className:"text-xs py-3 text-center",style:{color:"#8a7d66"},children:"No PM schedules saved yet. Build one in the PM Schedule tab."}):e.jsx("div",{className:"space-y-2",children:de.map(s=>e.jsxs("div",{className:"flex items-center justify-between p-2 rounded-lg",style:{background:"#241812"},children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-white",children:s.equipmentName||s.equipmentType}),e.jsxs("p",{className:"text-[13px]",style:{color:"#8a7d66"},children:["Saved ",new Date(s.savedAt).toLocaleDateString()]})]}),e.jsx("button",{onClick:()=>{const t=window.open("","_blank");t&&(t.document.write(`<html><head><title>PM Schedule</title><style>body{font-family:system-ui;padding:40px;max-width:800px;margin:0 auto}pre{white-space:pre-wrap;font-size:13px;line-height:1.6}</style></head><body><h1>PM Schedule — ${s.equipmentName||s.equipmentType}</h1><pre>${s.content.replace(/\*\*/g,"")}</pre></body></html>`),t.document.close(),t.print())},className:"text-[13px] px-2 py-1 rounded",style:{color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.2)"},children:"Print"})]},s.id))})})]}),e.jsxs("button",{onClick:()=>Fe("breakdown"),className:"w-full py-2.5 rounded-lg text-sm font-medium flex items-center justify-center gap-2 min-h-[44px]",style:{border:"1px solid #4a4030",color:"#c8934e"},"data-testid":"btn-dashboard-log-issue",children:[e.jsx(be,{className:"h-4 w-4"}),"Log a Breakdown Issue"]})]}),(r==="breakdown"||r==="pm"||r==="log")&&e.jsx("button",{onClick:Qs,disabled:p||r==="breakdown"&&!j||r==="pm"&&!d,className:"w-full py-3 rounded-lg text-sm font-medium flex items-center justify-center gap-2 min-h-[48px] disabled:opacity-40",style:{background:p?"#2e2619":"#a9702f",color:"#efe7d8"},"data-testid":"btn-generate-facility",children:p?e.jsxs(e.Fragment,{children:[e.jsx(ts,{className:"h-4 w-4 animate-spin"}),r==="breakdown"?"Generating triage response...":r==="pm"?"Building PM schedule...":"Creating equipment profile..."]}):e.jsxs(e.Fragment,{children:[e.jsx(ys,{className:"h-4 w-4"}),r==="breakdown"?"Run Triage":r==="pm"?"Build PM Schedule":"Generate Equipment Profile"]})}),p&&e.jsx("div",{className:"space-y-3 p-4 rounded-xl",style:{background:"#1f1310"},children:[...Array(5)].map((s,t)=>e.jsx("div",{className:"h-4 rounded",style:{background:"#241812",width:`${85-t*12}%`,animation:`shimmer 1.5s ease-in-out ${t*.15}s infinite`}},t))}),N&&!p&&r==="breakdown"&&S&&e.jsxs("div",{className:"space-y-4 mt
218-4",children:[e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #382019"},children:[S.situation&&e.jsxs("div",{className:"p-4",style:{background:"#1f1310"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider font-bold mb-1",style:{color:"#c8934e"},children:"Situation Summary"}),e.jsx("p",{className:"text-sm",style:{color:"#a99a82"},children:S.situation})]}),e.jsxs("div",{className:"p-4",style:{background:"#241812",borderTop:"1px solid #382019"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider font-bold mb-2",style:{color:"#c8934e"},children:"Priority Level"}),e.jsxs("div",{className:"flex items-center gap-2",children:[(()=>{const s=Ze();return e.jsx("span",{className:"text-xs px-2 py-1 rounded font-bold",style:{background:`${s.color}20`,color:s.color,border:`1px solid ${s.color}40`},children:s.level})})(),S.priorityTier&&e.jsx("span",{className:"text-xs",style:{color:"#a99a82"},children:S.priorityTier})]}),S.serviceImpact&&e.jsx("p",{className:"text-xs mt-1",style:{color:"#8a7d66"},children:S.serviceImpact})]}),S.actions.length>0&&e.jsxs("div",{className:"p-4",style:{background:"#1f1310",borderTop:"1px solid #382019"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider font-bold mb-3",style:{color:"#c8934e"},children:"Immediate Actions"}),e.jsx("div",{className:"space-y-2",children:S.actions.map((s,t)=>e.jsxs("button",{onClick:()=>Js(t),className:"flex items-start gap-3 w-full text-left py-1.5 group",style:{opacity:re.has(t)?.5:1},"data-testid":`triage-action-${t}`,children:[e.jsx("div",{className:"w-5 h-5 rounded flex items-center justify-center shrink-0 mt-0.5",style:{background:re.has(t)?"#c8934e":"transparent",border:`2px solid ${re.has(t)?"#c8934e":"#4a4030"}`},children:re.has(t)&&e.jsx(K,{className:"h-3 w-3 text-white"})}),e.jsxs("span",{className:`text-sm ${re.has(t)?"line-through":""}`,style:{color:re.has(t)?"#8a7d66":"#efe7d8"},children:[e.jsxs("span",{className:"font-semibold",style:{color:re.has(t)?"#8a7d66":"#c8934e"},children:[t+1,"."]})," ",s]})]},t))})]}),e.jsxs("div",{className:"p-4",style:{background:"#241812",borderTop:"1px solid #382019"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider font-bold mb-3",style:{color:"#c8934e"},children:"Vendor / Repair Script"}),S.vendorScript.whoToCall&&e.jsxs("p",{className:"text-sm mb-2",children:[e.jsx("span",{className:"font-semibold text-white",children:"Who to call:"})," ",e.jsx("span",{style:{color:"#a99a82"},children:S.vendorScript.whoToCall})]}),S.vendorScript.whatToSay&&e.jsx("div",{className:"p-3 rounded-lg mb-2",style:{background:"#1f1310",borderLeft:"3px solid #4a4030"},children:e.jsxs("p",{className:"text-xs italic",style:{color:"#a99a82"},children:['"',S.vendorScript.whatToSay,'"']})}),S.vendorScript.authLimit&&e.jsx("div",{className:"p-2.5 rounded-lg mb-2",style:{background:"rgba(200, 147, 78,0.05)",border:"1px solid rgba(200, 147, 78,0.2)"},children:e.jsxs("p",{className:"text-xs",children:[e.jsx("span",{className:"font-medium",style:{color:"#c8934e"},children:"Authorization:"})," ",e.jsx("span",{style:{color:"#a99a82"},children:S.vendorScript.authLimit})]})}),S.vendorScript.questions.length>0&&e.jsxs("div",{className:"mt-2",children:[e.jsx("p",{className:"text-xs font-medium text-white mb-1",children:"Questions to ask:"}),e.jsx("ul",{className:"space-y-1",children:S.vendorScript.questions.map((s,t)=>e.jsxs("li",{className:"text-xs flex items-start gap-1.5",style:{color:"#a99a82"},children:[e.jsxs("span",{style:{color:"#c8934e"},children:[t+1,"."]})," ",s]},t))})]})]}),e.jsxs("div",{className:"p-4",style:{background:"#1f1310",borderTop:"1px solid #382019"},children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider font-bold mb-3",style:{color:"#c8934e"},children:"Documentation Checklist"}),e.jsx("div",{className:"space-y-2",children:S.docChecklist.map((s,t)=>e.jsxs("button",{onClick:()=>Gs(t),className:"flex items-center gap-3 w-full text-left py-1",style:{opacity:ie.has(t)?.5:1},"data-testid":`doc-check-${t}`,children:[e.jsx("div",{className:"w-4 h-4 rounded flex items-center justify-center shrink-0",style:{background:ie.has(t)?"#c8934e":"transparent",border:`2px solid ${ie.has(t)?"#c8934e":"#4a4030"}`},children:ie.has(t)&&e.jsx(K,{className:"h-2.5 w-2.5 text-white"})}),e.jsx("span",{className:`text-xs ${ie.has(t)?"line-through":""}`,style:{color:ie.has(t)?"#8a7d66":"#a99a82"}
218,children:s})]},t))})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:es,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:a?"#7E8A55":"#a99a82"},"data-testid":"btn-copy-facility",children:a?e.jsxs(e.Fragment,{children:[e.jsx(K,{className:"h-3.5 w-3.5"}),"Copied"]}):e.jsxs(e.Fragment,{children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Copy Triage Report"]})}),e.jsxs("button",{onClick:Cs,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(200, 147, 78,0.1)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.2)"},"data-testid":"btn-save-to-dashboard",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Save to Issue Log"]}),(()=>{const s=Ge();return s.length>0&&s[0].phone?e.jsxs("a",{href:`tel:${s[0].phone}`,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(34,197,94,0.1)",color:"#7E8A55",border:"1px solid rgba(34,197,94,0.2)"},"data-testid":"btn-start-vendor-call",children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"Call ",s[0].name]}):e.jsxs("button",{onClick:()=>Fe("vendors"),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#8a7d66"},children:[e.jsx(Re,{className:"h-3.5 w-3.5"}),"Add vendor first"]})})()]})]}),N&&!p&&r==="breakdown"&&!S&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx("div",{className:"p-4 rounded-xl",style:{background:"#1f1310",border:"1px solid #382019"},children:e.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap text-sm",style:{color:"#a99a82"},children:N})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:es,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#a99a82"},"data-testid":"btn-copy-facility",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Copy"]}),e.jsxs("button",{onClick:Cs,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(200, 147, 78,0.1)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.2)"},"data-testid":"btn-save-to-dashboard",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Save to Issue Log"]})]})]}),N&&!p&&r==="pm"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsx("div",{className:"p-4 rounded-xl",style:{background:"#1f1310",border:"1px solid #382019"},children:e.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap text-sm",style:{color:"#a99a82"},children:N})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:st,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#a99a82"},children:[e.jsx(fs,{className:"h-3.5 w-3.5"}),"Export PM Schedule"]}),e.jsxs("button",{onClick:et,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(200, 147, 78,0.1)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.2)"},"data-testid":"btn-save-pm",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Save PM Schedule"]}),e.jsxs("button",{onClick:es,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#a99a82"},"data-testid":"btn-copy-facility",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Copy"]})]})]}),N&&!p&&r==="log"&&e.jsxs("div",{className:"mt-4 space-y-4",children:[e.jsxs("div",{className:"rounded-xl overflow-hidden",style:{border:"1px solid #382019"},children:[e.jsx("div",{className:"p-4 flex items-center justify-between",style:{background:"#241812"},children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-white",children:f||E.find(s=>s.value===d)?.label||"Equipment"}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:"rgba(200, 147, 78,0.15)",color:"#c8934e"},children:E.find(s=>s.value===d)?.label}),e.jsx("span",{className:"text-[13px] px-1.5 py-0.5 rounded font-medium",style:{background:B==="revenue-critical"?"rgba(239,68,68,0.15)":"rgba(138, 125, 102,0.15)",color:B==="revenue-critical"?"#e07a66":"#8a7d66"},children:B==="revenue-critical"?"Revenue-Critical":"Support"})]})}),e.jsx("div",{className:"p-4",style:{background:"#1f1310"},children:e.jsx("div",{className:"prose prose-sm max-w-none whitespace-pre-wrap text-sm",style:{color:"#a99a82"}
218,children:N})})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{onClick:Xs,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{background:"rgba(200, 147, 78,0.1)",color:"#c8934e",border:"1px solid rgba(200, 147, 78,0.2)"},"data-testid":"btn-save-equipment",children:[e.jsx(je,{className:"h-3.5 w-3.5"}),"Save Equipment Profile"]}),e.jsxs("button",{onClick:()=>Fe("pm",d),className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#a99a82"},"data-testid":"btn-create-pm-from-equip",children:[e.jsx(ss,{className:"h-3.5 w-3.5"}),"Create PM Schedule"]}),e.jsxs("button",{onClick:es,className:"flex items-center gap-1.5 px-3 py-2 rounded-lg text-xs font-medium min-h-[36px]",style:{border:"1px solid #4a4030",color:"#a99a82"},"data-testid":"btn-copy-facility",children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Copy"]})]})]})]})]})}export{Ma as AssetHealthStrip,Va as FacilityCommandCenter,Ra as SOPCaptureEngine,Fa as SOPHealthStrip};

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.