1import{a as o,j as e,d as z}from"./vendor-query-B-_nDQQY.js";import{L as Y}from"./vendor-react-BUIlT3ms.js";import{y as ee,B as j,a8 as W,e as C,q,I as D,L as R,t as _,b as P,Z as L,C as F,a as M,c as A,p as se,d as O,aa as te}from"./index-D8ww6b7J.js";import{R as U,H as ae}from"./RemnantLabelPrinter-CNCgh0uP.js";import{D as E,a as H,b as G,c as J,e as K,d as Q}from"./dialog-BQWtAG_x.js";import{C as $}from"./circle-check-BXjz6L8_.js";import{S as T}from"./save-d5GEALD8.js";import{C as ne,O as re,H as ie}from"./vendor-three-1K-S22da.js";import{E as V}from"./eye-DQ9YWbv-.js";import{R as le}from"./ruler-Bcj6zKuq.js";import{S as I}from"./scan-h1X5H0-p.js";import{P as Z}from"./package-kgQR05VR.js";import{C as ce}from"./CalendarSummaryBar-BvmS_pZO.js";import{P as de}from"./PageHeader-DOQecRZi.js";import"./vendor-pdf-Bwkk3Ew0.js";import"./vendor-radix-X0WMATEu.js";import"./vendor-charts-i-522T5A.js";import"./barcode-DVFsVwWU.js";import"./qr-code-mbrNJ93D.js";import"./user-CHo1Apvy.js";import"./parseISO-BItZJw-N.js";import"./constants-yGZMfuMC.js";import"./format-C2V2JF1Z.js";/** 2 * @license lucide-react v1.21.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const oe=[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]],me=ee("mouse-pointer-click",oe);function xe({piece:s,onClose:p,onCreated:d}){const[i,h]=o.useState(""),[a,N]=o.useState(""),[b,u]=o.useState(""),[n,m]=o.useState(!1),[c,w]=o.useState(null),[x,v]=o.useState(!1),r=(s==null?void 0:s.material_type)||"Unknown",l=(s==null?void 0:s.material_type)||"quartz",g="3cm",y=i&&a?Number(i)*Number(a)/144:0,k=async()=>{if(!i||!a){_.error("Please enter remnant dimensions");return}m(!0);try{const S=`REM-${Date.now().toString().slice(-6)}`,X=await P.entities.Remnant.create({remnant_number:S,material_name:r,material_type:l,length_inches:Number(i),width_inches:Number(a),thickness:g,calculated_sqft:y,status:"available",location:b||"Warehouse",created_from_job_id:s==null?void 0:s.job_id,notes:`Created from piece: ${(s==null?void 0:s.piece_name)||"unknown"}`});s!=null&&s.id&&await P.entities.ProductionPiece.update(s.id,{is_remnant:!0,remnant_sqft:y}),w(X),_.success("Remnant created â opening label printerâ¦"),v(!0),d==null||d()}catch(S){_.error("Failed to create remnant: "+(S.message||""))}finally{m(!1)}},t=()=>{p(),setTimeout(()=>{w(null),h(""),N(""),u("")},300)},f=c?[{...c,barcode:c.remnant_number,length:c.length_inches,width:c.width_inches,sqft:c.calculated_sqft,selling_price:c.selling_price_per_sqft,name:c.material_name}]:[];return x?e.jsx(U,{remnants:f,onClose:()=>{v(!1),t()}}):e.jsx(E,{open:!0,onOpenChange:t,children:e.jsx(H,{children:c?e.jsxs("div",{className:"text-center py-6 space-y-3",children:[e.jsx($,{className:"w-12 h-12 mx-auto text-green-500"}),e.jsx("h3",{className:"text-lg font-bold",children:"Remnant Created!"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"font-mono font-medium text-foreground",children:c.remnant_number})," ","â ",c.material_name," (",y.toFixed(1)," sq ft) â has been added to your remnant inventory."]}),e.jsxs("div",{className:"flex gap-2 justify-center pt-2",children:[e.jsx(j,{variant:"outline",onClick:t,children:"Close"}),e.jsxs(j,{onClick:()=>v(!0),children:[e.jsx(W,{className:"w-4 h-4 mr-1"})," Print Label"]})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(G,{children:[e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(T,{className:"w-5 h-5"}),"Save Leftover as Remnant"]}),e.jsxs(K,{children:["Capture the leftover material from"," ",e.jsx("span",{className:"font-medium text-foreground",children:s==null?void 0:s.piece_name})," and add it to your remnant inventory."]})]}),e.jsxs("div",{className:"flex flex-wrap gap-2 py-1",children:[e.jsx(C,{variant:"secondary",children:r}),e.jsx(C,{variant:"secondary",children:g}),(s==null?void 0:s.job_label)&&e.jsx(C,{variant:"outline",children:s.job_label})]}),e.jsxs("div",{className:"space-y-3 py-1",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(q,{className:"text-xs",children:"Length (inches
6) *"}),e.jsx(D,{type:"number",value:i,onChange:S=>h(S.target.value),placeholder:"36",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(q,{className:"text-xs",children:"Width (inches) *"}),e.jsx(D,{type:"number",value:a,onChange:S=>N(S.target.value),placeholder:"24",className:"h-9"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(q,{className:"text-xs",children:"Storage Location"}),e.jsx(D,{value:b,onChange:S=>u(S.target.value),placeholder:"Warehouse / Rack A-3",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(q,{className:"text-xs",children:"Calculated Sq Ft"}),e.jsx("div",{className:"h-9 flex items-center px-3 rounded-md border bg-muted text-sm font-medium",children:y>0?y.toFixed(1):"â"})]})]})]}),e.jsxs(Q,{children:[e.jsx(j,{variant:"outline",onClick:t,children:"Cancel"}),e.jsx(j,{onClick:k,disabled:n||!i||!a,children:n?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"})," Creatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{className:"w-4 h-4 mr-1"})," Create Remnant"]})})]})]})})})}const B=["#60a5fa","#34d399","#fbbf24","#f87171","#a78bfa","#fb923c","#22d3ee","#f472b6"];function he({lengthFt:s,widthFt:p}){return e.jsxs("mesh",{position:[0,-.15,0],receiveShadow:!0,children:[e.jsx("boxGeometry",{args:[s,.3,p]}),e.jsx("meshStandardMaterial",{color:"#cbd5e1",transparent:!0,opacity:.35})]})}function ue({piece:s,position:p,color:d,onClick:i,isSelected:h}){const a=(s.length||30)/12,N=(s.width||25)/12;return e.jsxs("group",{position:p,children:[e.jsxs("mesh",{position:[0,.25,0],castShadow:!0,onClick:b=>{b.stopPropagation(),i()},children:[e.jsx("boxGeometry",{args:[a,.5,N]}),e.jsx("meshStandardMaterial",{color:h?"#f59e0b":d,opacity:h?1:.8,transparent:!0})]}),h&&e.jsxs("mesh",{position:[0,.25,0],children:[e.jsx("boxGeometry",{args:[a+.15,.65,N+.15]}),e.jsx("meshBasicMaterial",{color:"#f59e0b",wireframe:!0})]}),e.jsx(ie,{position:[0,.65,0],center:!0,distanceFactor:10,zIndexRange:[10,0],children:e.jsxs("div",{className:"px-1.5 py-0.5 bg-white/90 dark:bg-slate-800/90 rounded text-[10px] font-medium text-slate-800 dark:text-slate-100 whitespace-nowrap pointer-events-none shadow-sm",children:[s.piece_name,e.jsxs("span",{className:"text-slate-400 ml-1",children:[s.length,'"Ã',s.width,'"']})]})})]})}function je({pieces:s=[],slabLength:p=120,slabWidth:d=55,selectedIdx:i,onSelectIdx:h}){const[a,N]=o.useState(null),b=i!==void 0?i:a,u=h||N,n=p/12,m=d/12,c=o.useMemo(()=>{const w=[];let x=-n/2+.3,v=-m/2+.3,r=0;return s.forEach(l=>{const g=(l.length||30)/12,y=(l.width||25)/12;x+g>n/2-.3&&(x=-n/2+.3,v+=r+.25,r=0),w.push([x+g/2,0,v+y/2]),x+=g+.2,r=Math.max(r,y)}),w},[s,n,m]);return s.length===0?e.jsx("div",{className:"w-full h-[500px] flex items-center justify-center bg-slate-100 dark:bg-slate-900 rounded-lg",children:e.jsx("p",{className:"text-muted-foreground",children:"No pieces to display"})}):e.jsx("div",{className:"w-full h-[500px] bg-gradient-to-b from-sky-50 to-slate-100 dark:from-slate-800 dark:to-slate-900 rounded-lg overflow-hidden",children:e.jsxs(ne,{camera:{position:[6,6,6],fov:45},shadows:!0,children:[e.jsx("ambientLight",{intensity:.6}),e.jsx("directionalLight",{position:[10,10,5],intensity:1,castShadow:!0}),e.jsx("directionalLight",{position:[-5,5,-5],intensity:.3}),e.jsxs(o.Suspense,{fallback:null,children:[e.jsx(he,{lengthFt:n,widthFt:m}),s.map((w,x)=>e.jsx(ue,{piece:w,position:c[x],color:B[x%B.length],onClick:()=>u(b===x?null:x),isSelected:b===x},w.id||x))]}),e.jsx(re,{enablePan:!1,minDistance:3,maxDistance:20,maxPolarAngle:Math.PI/2.1})]})})}const ge={pending:"bg-slate-200 text-slate-700",cutting:"bg-yellow-200 text-yellow-800",cutting_complete:"bg-blue-200 text-blue-800",polishing:"bg-cyan-200 text-cyan-800",polishing_complete:"bg-indigo-200 text-indigo-800",qc_pending:"bg-orange-200 text-orange-800",qc_passed:"bg-green-200 text-green-800",qc_failed:"bg-red-200 text-red-800",ready_for_install:"bg-green-300 text-green-900"};function fe({jobId:s,jobLabel:p,onClose:d}
6){const[i,h]=o.useState(null),{data:a=[],isLoading:N}=z({queryKey:["cnc-preview-pieces",s],queryFn:()=>P.entities.ProductionPiece.filter({job_id:s},"piece_number"),enabled:!!s}),b=a.reduce((n,m)=>n+(m.length||0)*(m.width||0)/144,0),u=i!==null?a[i]:null;return e.jsx(E,{open:!0,onOpenChange:d,children:e.jsxs(H,{className:"max-w-5xl max-h-[92vh] overflow-y-auto",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold flex items-center gap-2",children:[e.jsx(V,{className:"w-5 h-5"}),"CNC 3D Preview (Read-Only)"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[p||"Job"," â ",a.length," pieces · ",b.toFixed(1)," sq ft"]})]}),e.jsxs(C,{variant:"secondary",className:"text-xs",children:[e.jsx(me,{className:"w-3 h-3 mr-1"}),"Click pieces to inspect"]})]}),N?e.jsx("div",{className:"h-[500px] flex items-center justify-center",children:e.jsx(R,{className:"w-8 h-8 animate-spin text-primary"})}):e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr_200px] gap-3",children:[e.jsx(je,{pieces:a,selectedIdx:i,onSelectIdx:h}),e.jsx("div",{className:"space-y-1.5 max-h-[500px] overflow-y-auto",children:a.map((n,m)=>{var c;return e.jsxs("button",{onClick:()=>h(i===m?null:m),className:`w-full text-left p-2 rounded-lg border text-sm transition-colors ${i===m?"bg-primary/10 border-primary":"bg-card border-border hover:bg-accent"}`,children:[e.jsx("div",{className:"font-medium text-xs",children:n.piece_name}),e.jsxs("div",{className:"flex items-center justify-between mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:[n.length,'" à ',n.width,'"']}),e.jsx(C,{className:`text-[9px] px-1 py-0 ${ge[n.status]||"bg-slate-200 text-slate-700"}`,children:(c=n.status)==null?void 0:c.replace(/_/g," ")})]})]},n.id||m)})})]}),u&&e.jsxs("div",{className:"mt-2 p-3 rounded-lg border bg-primary/5 grid grid-cols-2 sm:grid-cols-4 gap-3 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Piece"}),e.jsx("p",{className:"font-medium",children:u.piece_name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Dimensions"}),e.jsxs("p",{className:"font-medium",children:[u.length,'" à ',u.width,'"']})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Material"}),e.jsx("p",{className:"font-medium",children:u.material_type})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Edge"}),e.jsx("p",{className:"font-medium",children:u.edge_profile||"â"})]})]}),e.jsx("div",{className:"flex justify-end pt-1",children:e.jsx(j,{variant:"outline",onClick:d,children:"Close"})})]})})}function pe({jobId:s,jobLabel:p,onClose:d}){var k;const[i,h]=o.useState(!1),[a,N]=o.useState(null),[b,u]=o.useState(!1),{data:n=[],isLoading:m}=z({queryKey:["job-slabs-auto",s],queryFn:()=>P.entities.Inventory.filter({reserved_for_job_id:s}),enabled:!!s}),{data:c=[],isLoading:w}=z({queryKey:["job-pieces-auto",s],queryFn:()=>P.entities.ProductionPiece.filter({job_id:s}),enabled:!!s}),x=m||w,v=n.reduce((t,f)=>t+(f.total_sqft||0),0),r=c.reduce((t,f)=>
6t+(f.length||0)*(f.width||0)/144,0),l=Math.max(0,v-r),g=async()=>{var t;h(!0);try{const f=await P.functions.invoke("autoCreateRemnantFromSlab",{job_id:s});N(f.data),((t=f.data.remnants)==null?void 0:t.length)>0?(_.success(`Auto-created ${f.data.remnants.length} remnant(s) â opening label printerâ¦`),u(!0)):_.info("No remnants to create â all slab material was used.")}catch(f){_.error("Failed to create remnant: "+(f.message||""))}finally{h(!1)}},y=((k=a==null?void 0:a.remnants)==null?void 0:k.map(t=>({...t,barcode:t.remnant_number,length:t.length_inches,width:t.width_inches,sqft:t.calculated_sqft,selling_price:t.selling_price_per_sqft,name:t.material_name})))||[];return b&&y.length>0?e.jsx(U,{remnants:y,onClose:()=>{u(!1),d()}}):e.jsx(E,{open:!0,onOpenChange:d,children:e.jsxs(H,{children:[e.jsxs(G,{children:[e.jsxs(J,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"w-5 h-5 text-primary"}),"Auto-Create Remnant from Slab"]}),e.jsxs(K,{children:[p||"Job"," â automatically calculates leftover material and adds it to remnant inventory."]})]}),a?e.jsxs("div",{className:"space-y-4",children:[a.remnants.length>0?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-green-600",children:[e.jsx($,{className:"w-5 h-5"}),e.jsxs("span",{className:"font-medium",children:[a.remnants.length," remnant(s) created!"]})]}),a.remnants.map((t,f)=>e.jsxs("div",{className:"p-3 border rounded-lg space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"font-mono text-sm font-medium",children:t.remnant_number}),e.jsxs(C,{variant:"secondary",children:[t.calculated_sqft," sq ft"]})]}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[t.material_name," ⢠",t.length_inches,'" à ',t.width_inches,'" â¢'," ",t.thickness]})]},f)),e.jsx("div",{className:"text-xs text-muted-foreground p-2 bg-muted rounded",children:"â¡ Dimensions are estimated from slab size minus cut pieces. Verify and adjust if needed."})]}):e.jsx("div",{className:"text-center py-4",children:e.jsx("p",{className:"text-muted-foreground",children:"No leftover material â all slab sqft was used by cut pieces."})}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx(j,{variant:"outline",onClick:d,children:"Close"}),a.remnants.length>0&&e.jsxs(j,{onClick:()=>u(!0),children:[e.jsx(W,{className:"w-4 h-4 mr-1"})," Print Labels"]})]})]}):e.jsxs("div",{className:"space-y-4",children:[x?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(R,{className:"w-6 h-6 animate-spin"})}):n.length===0?e.jsx("div",{className:"text-center py-4 text-muted-foreground",children:"No slabs allocated to this job. Allocate slabs first to auto-calculate remnants."}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center p-3 bg-muted/50 rounded-lg",children:[e.jsx("span",{className:"text-sm",children:"Total Slab Material"}),e.jsxs("span",{className:"font-bold",children:[v.toFixed(1)," sq ft"]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-muted/50 rounded-lg",children:[e.jsxs("span",{className:"text-sm",children:["Cut Pieces (",c.length,")"]}),e.jsxs("span",{className:"font-bold text-orange-600",children:["â",r.toFixed(1)," sq ft"]})]}),e.jsxs("div",{className:"flex justify-between items-center p-3 bg-primary/10 rounded-lg border border-primary/20",children:[e.jsxs("span",{className:"text-sm font-medium flex items-center gap-1",children:[e.jsx(le,{className:"w-4 h-4"})," Remaining (Remnant)"]}),e.jsxs("span",{className:"font-bold text-primary text-lg",children:[l.toFixed(1)," sq ft"]})]})]}),e.jsx("div",{className:"space-y-1",children:n.map((t,f)=>e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsxs("span",{children:[t.material_name," (",t.thickness,")"]}),e.jsxs("span",{children:[(t.total_sqft||0).toFixed(1)," sq ft"]})]},f))}),l<=0?e.jsx("div",{className:"text-center py-2 text-sm text-muted-foreground",children:"All slab material is accounted for â no remnant to create."}):e.jsxs("div",{className:"text-xs text-muted-foreground p-2 bg-muted rounded",children:["â¡ Will create ",n.length," remnant(s) with estimated dimensions. Labels can be printed immediately after."]})]}),e.jsxs(Q,{children:[e.jsx(j,{variant:"outline",onClick:d,children:"Cancel"}),e.jsx(j,{onClick:g,disabled:i||x||n.length===0||l<=0,children:i?e.jsxs(e.Fragment,{children:[e.jsx(R,{className:"w-4 h-4 animate-spin"})," Creatingâ¦"]}):e.jsxs(e.Fragment,{children:[e.jsx(L,{className:"w-4 h-4 mr-1"})," Create Remnant",n.length>
61?"s":""]})})]})]})]})})}function be(){const[s,p]=o.useState(null),[d,i]=o.useState(!1),[h,a]=o.useState([]),[N,b]=o.useState(!1),[u,n]=o.useState(!1),[m,c]=o.useState(!1),w=()=>{i(!0);const r=new ae("reader",{fps:10,qrbox:250});r.render(l=>{x(l),r.clear(),i(!1)},l=>{})},x=async r=>{try{const l=await P.entities.ProductionPiece.filter({barcode:r});if(l.length===0){_.error("Piece not found");return}const g=l[0];p(g);const y={barcode:r,pieceName:g.name,jobId:g.job_id,timestamp:new Date().toISOString(),status:g.status};a(k=>[y,...k.slice(0,9)]),_.success(`Scanned: ${g.name}`),await P.entities.ProductionPiece.update(g.id,{last_scanned:new Date().toISOString(),scan_count:(g.scan_count||0)+1})}catch(l){_.error(`Scan failed: ${l.message}`)}},v=async r=>{if(s)try{await P.entities.ProductionPiece.update(s.id,{status:r,status_changed_at:new Date().toISOString()}),p(l=>l?{...l,status:r}:null),_.success(`Status updated to ${r}`)}catch(l){_.error(`Update failed: ${l.message}`)}};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs(A,{className:"flex items-center gap-2",children:[e.jsx(I,{className:"w-5 h-5 text-blue-600"}),"Production Piece Tracker"]}),e.jsx(se,{children:"Scan barcodes to track pieces through production workflow"})]}),e.jsxs(C,{variant:"default",className:"bg-blue-600",children:[e.jsx(L,{className:"w-3 h-3 mr-1"}),"Real-Time Tracking"]})]})}),e.jsxs(O,{children:[e.jsxs(j,{onClick:w,disabled:d,className:"w-full bg-blue-600 hover:bg-blue-700",size:"lg",children:[e.jsx(I,{className:"w-5 h-5 mr-2"}),d?"Scanner Active...":"Scan Piece Barcode"]}),d&&e.jsx("div",{id:"reader",className:"mt-4"})]})]}),s&&e.jsxs(F,{className:"border-green-200 bg-green-50",children:[e.jsx(M,{children:e.jsxs(A,{className:"flex items-center gap-2 text-green-800",children:[e.jsx($,{className:"w-5 h-5"}),"Piece Scanned"]})}),e.jsx(O,{children:e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Piece Name"}),e.jsx("div",{className:"font-semibold",children:s.name})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Job"}),e.jsx("div",{className:"font-semibold",children:s.job_label||s.job_id})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Material"}),e.jsx("div",{className:"font-semibold",children:s.material_type})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground",children:"Dimensions"}),e.jsxs("div",{className:"font-semibold",children:[s.length,'" Ã ',s.width,'"']})]})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Current Status"}),e.jsx(C,{className:s.status==="cutting"?"bg-yellow-600":s.status==="polishing"?"bg-blue-600":s.status==="completed"?"bg-green-600":"bg-slate-600",children:s.status})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Update Status"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(j,{size:"sm",variant:s.status==="cutting"?"default":"outline",onClick:()=>v("cutting"),children:"Cutting"}),e.jsx(j,{size:"sm",variant:s.status==="polishing"?"default":"outline",onClick:()=>v("polishing"),children:"Polishing"}),e.jsx(j,{size:"sm",variant:s.status==="completed"?"default":"outline",onClick:()=>v("completed"),children:"Complete"})]})]}),e.jsxs("div",{className:"pt-2 border-t",children:[e.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:"Actions"}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>b(!0),children:[e.jsx(T,{className:"w-4 h-4 mr-1"}),"Save Leftover as Remnant"]}),e.jsxs(j,{size:"sm",variant:"outline",onClick:()=>n(!0),children:[e.jsx(V,{className:"w-4 h-4 mr-1"}),"CNC 3D Preview"]}),e.jsxs(j,{size:"sm",variant:"default",onClick:()=>c(!0),children:[e.jsx(L,{className:"w-4 h-4 mr-1"}),"Auto-Create Remnant"]})]})]})]})})]}),h.length>0&&e.jsxs(F,{children:[e.jsx(M,{children:e.jsxs(A,{className:"flex items-center gap-2",children:[e.jsx(Z,{className:"w-5 h-5 text-slate-600"}),"Recent Scans"]})}),e.jsx(O,{children:e.jsx("div",{className:"space-y-2",children:h.map((r,l)=>e.jsxs("div",{className:"flex items-center justify-between p-2 bg-slate-50 rounded",children:[e.jsxs("div",{children:[e.jsx("div",{className:"font-medium text-sm",children:r.pieceName}),e.jsx("div",{className:"text-xs text-muted-foreground",children:new Date(r.timestamp).toLocaleTimeString()})]}),e.jsx(C,{variant:"secondary",className:"text-xs",children:r.status})]},l))})})]}),N&&s&&e.jsx(xe,{piece:s,onClose:()=>b(!1)}),u&&s&&e.jsx(fe,{jobId:s.job_id,jobLabel:s.job_label,onClose:()=>n(!1)}),m&&s&&e.jsx(pe,{jobId:s.job_id,jobLabel:s.job_label,onClose:()=>c(!1)})]})}function Be(){return e.jsxs("div",{className:"container mx-auto p-6 space-y-6",children:[e.jsx(de,{icon:Z,title:"Production Piece Tracker",subtitle:"Scan barcodes to track individual pieces through cutting, polishing, and completion",className:"mb-6",children:e.jsx(Y,{to:"/shop-monitor",target:"_blank",children:e.jsxs(j,{variant:"outline",className:"gap-2",children:[e.jsx(te,{className:"w-4 h-4"}),"Monitor Mode"]})})}),e.jsx(ce,{}),e.jsx(be,{})]})}
6export{Be as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.