From 811813165b2e3d9945069ad1dcc7f170fb19eacb Mon Sep 17 00:00:00 2001 From: maziggy Date: Mon, 23 Mar 2026 13:55:12 +0100 Subject: [PATCH] Fix stale SpoolBuddy update status after daemon restart After an SSH update completed, the UI kept showing "Update complete, daemon restarting..." and the old "update available" banner because nothing cleared the stale state. Registration now resets update_status when the daemon comes back, and WebSocket handlers for spoolbuddy_update and spoolbuddy_online invalidate the frontend queries immediately. --- CHANGELOG.md | 1 + backend/app/api/routes/spoolbuddy.py | 4 ++++ frontend/src/hooks/useWebSocket.ts | 8 ++++++++ static/assets/{index-ABN02nc3.js => index-BSgCAUZw.js} | 2 +- static/index.html | 2 +- 5 files changed, 15 insertions(+), 2 deletions(-) rename static/assets/{index-ABN02nc3.js => index-BSgCAUZw.js} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index a27e5c691..6fc33dfff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to Bambuddy will be documented in this file. ### Fixed - **SpoolBuddy Update Check Always Shows "Up to Date"** — The SpoolBuddy daemon update check compared the device's firmware version against GitHub releases instead of the running Bambuddy backend version. This meant the check could incorrectly report "up to date" even when the daemon was behind. Fixed by comparing directly against `APP_VERSION` from the backend config. - **SpoolBuddy Updates Now Use SSH** — Replaced the fragile self-update mechanism (daemon pulls its own code via git, permission errors on `.git/`, hardcoded `main` branch) with SSH-based updates driven by the Bambuddy backend. Bambuddy now SSHes into the SpoolBuddy Pi and runs git fetch/checkout, pip install, systemctl restart, and kiosk browser restart remotely. Updates automatically use the same branch as Bambuddy. SSH key pairing is fully automatic — Bambuddy generates an ED25519 keypair and includes the public key in the device registration response; the daemon deploys it to `authorized_keys` on first connect. The install script creates the `spoolbuddy` user with a bash shell and sudoers entries for daemon and kiosk restart. A "Force Update" button allows re-deploying even when versions match. The SSH public key is also shown in SpoolBuddy Settings → Updates → SSH Setup for manual pairing if needed. +- **SpoolBuddy Update Status Stale After Restart** — After a SpoolBuddy update completed, the UI continued showing "Update complete, daemon restarting..." and the old "update available" banner because stale status was never cleared. Fixed by clearing `update_status` on device re-registration (daemon restart), and adding WebSocket handlers for `spoolbuddy_update` and `spoolbuddy_online` events so the frontend immediately refreshes device state and update check results. - **Virtual Printer Proxy A1 Printing Fails** ([#757](https://github.com/maziggy/bambuddy/issues/757)) — BambuStudio could not send prints to A1 (and potentially P1S) virtual printers in proxy mode. The slicer connects to undocumented proprietary ports 2024-2026 on these models, which the proxy was not forwarding, causing BambuStudio to show an access code dialog instead of printing. Added transparent TCP pass-through proxying for ports 2024-2026. These ports are silently ignored on models that don't use them (X1C, H2C, P2S). Reported by @Utility9298. - **Spool Assignment on Empty AMS Slots** ([#784](https://github.com/maziggy/bambuddy/issues/784)) — Empty AMS slots (no physical spool detected) showed "Assign Spool" and "Configure" buttons in the hover popup. Assigning a spool to an empty slot created a stuck state because no "Unassign" button is available for empty slots. Removed both buttons from empty AMS and HT AMS slot popups. External spool holders are unaffected. Reported by @RosdasHH. diff --git a/backend/app/api/routes/spoolbuddy.py b/backend/app/api/routes/spoolbuddy.py index 54a61de8f..5e4f72959 100644 --- a/backend/app/api/routes/spoolbuddy.py +++ b/backend/app/api/routes/spoolbuddy.py @@ -101,6 +101,10 @@ async def register_device( device.nfc_connection = req.nfc_connection device.has_backlight = req.has_backlight device.last_seen = now + # Clear stale update status on re-registration (daemon restarted after update) + if device.update_status in ("complete", "error"): + device.update_status = None + device.update_message = None logger.info("SpoolBuddy device re-registered: %s (%s)", req.device_id, req.hostname) else: device = SpoolBuddyDevice( diff --git a/frontend/src/hooks/useWebSocket.ts b/frontend/src/hooks/useWebSocket.ts index 723cd5240..324edb506 100644 --- a/frontend/src/hooks/useWebSocket.ts +++ b/frontend/src/hooks/useWebSocket.ts @@ -287,10 +287,18 @@ export function useWebSocket() { case 'spoolbuddy_online': window.dispatchEvent(new CustomEvent('spoolbuddy-online', { detail: message })); + debouncedInvalidate('spoolbuddy-devices'); + debouncedInvalidate('spoolbuddy-update-check'); break; case 'spoolbuddy_offline': window.dispatchEvent(new CustomEvent('spoolbuddy-offline', { detail: message })); + debouncedInvalidate('spoolbuddy-devices'); + break; + + case 'spoolbuddy_update': + debouncedInvalidate('spoolbuddy-devices'); + debouncedInvalidate('spoolbuddy-update-check'); break; } }, [queryClient, debouncedInvalidate, throttledPrinterStatusUpdate]); diff --git a/static/assets/index-ABN02nc3.js b/static/assets/index-BSgCAUZw.js similarity index 99% rename from static/assets/index-ABN02nc3.js rename to static/assets/index-BSgCAUZw.js index 78f14eb38..db4381dae 100644 --- a/static/assets/index-ABN02nc3.js +++ b/static/assets/index-BSgCAUZw.js @@ -8718,7 +8718,7 @@ Difference: ${l}g (within tolerance)`:`Scale: ${Math.round(n)}g Calculated: ${Math.round(a)}g Difference: ${l}g (mismatch!)`;return i.jsxs("div",{className:`flex items-center gap-1 text-sm font-medium ${o?"text-green-400":"text-yellow-400"}`,title:c,children:[i.jsxs("span",{children:[Math.round(n),"g"]}),o?i.jsx(Zr,{className:"w-3 h-3"}):i.jsxs(i.Fragment,{children:[i.jsx(jn,{className:"w-3 h-3"}),e&&i.jsx("button",{type:"button",onClick:u=>{u.stopPropagation(),u.preventDefault(),e(t)},className:"p-1 hover:bg-bambu-green/20 rounded transition-colors text-bambu-green",title:"Sync: trust scale weight and reset tracking",children:i.jsx(Sr,{className:"w-3.5 h-3.5"})})]})]})}},t3={id:t=>t.id,added_time:t=>t.created_at||"",encode_time:t=>t.encode_time||"",last_used_time:t=>t.last_used||"",material:t=>(t.material||"").toLowerCase(),subtype:t=>(t.subtype||"").toLowerCase(),color_name:t=>(t.color_name||"").toLowerCase(),brand:t=>(t.brand||"").toLowerCase(),slicer_filament:t=>(t.slicer_filament_name||t.slicer_filament||"").toLowerCase(),location:(t,e)=>{const n=e[t.id];if(!n)return"";const r=n.ams_id===254||n.ams_id===255,a=!r&&n.ams_id>=128,s=n.ams_label?` (${n.ams_label})`:"";return`${n.printer_name||""} ${FI(n.ams_id,n.tray_id,a,r)}${s}`},label_weight:t=>t.label_weight,net:t=>Math.max(0,t.label_weight-t.weight_used),gross:t=>Math.max(0,t.label_weight-t.weight_used)+t.core_weight,used:t=>t.weight_used,remaining:t=>t.label_weight>0?Math.max(0,t.label_weight-t.weight_used)/t.label_weight:0,note:t=>(t.note||"").toLowerCase(),data_origin:t=>(t.data_origin||"").toLowerCase(),tag_type:t=>(t.tag_type||"").toLowerCase(),stock:t=>t.slicer_filament?1:0,spool_name:t=>t.core_weight_catalog_id??0,cost_per_kg:t=>t.cost_per_kg??0,weight_check:t=>{if(t.last_scale_weight==null)return-1;const e=Math.max(0,t.label_weight-t.weight_used)+t.core_weight;return Math.abs(t.last_scale_weight-e)}},TL="bambuddy-inventory-sort";function tnt(){try{const t=localStorage.getItem(TL);if(t)return JSON.parse(t)}catch{}return null}function nnt(t){try{t?localStorage.setItem(TL,JSON.stringify(t)):localStorage.removeItem(TL)}catch{}}function rnt(){const{data:t}=et({queryKey:["spoolman-settings"],queryFn:ge.getSpoolmanSettings,staleTime:3e5});return t?.spoolman_enabled==="true"&&t?.spoolman_url?i.jsx("iframe",{src:t.spoolman_url,className:"h-full w-full border-0",title:"Spoolman",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups allow-popups-to-escape-sandbox"}):i.jsx(int,{})}function int(){const{t}=Dt(),e=sn(),{showToast:n}=bn(),[r,a]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[u,d]=w.useState("all"),[m,p]=w.useState(""),[f,y]=w.useState(""),[v,b]=w.useState(""),[g,_]=w.useState("all"),[N,C]=w.useState(""),[k,P]=w.useState("table"),[T,D]=w.useState(tnt),[A,R]=w.useState(Qtt),[G,z]=w.useState(!1),[Z,I]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[J,ae]=w.useState(new Set),[Y,ue]=w.useState(0),[de,he]=w.useState(()=>{try{const ke=localStorage.getItem("bambuddy-inventory-pageSize");if(ke){const Ce=Number(ke);if([15,30,50,100,-1].includes(Ce))return Ce}}catch{}return 15}),{data:V}=et({queryKey:["settings"],queryFn:ge.getSettings}),ne=V?.date_format||"system",{data:se,isLoading:pe}=et({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!0),refetchInterval:3e4}),{data:Te}=et({queryKey:["spool-assignments"],queryFn:()=>ge.getAssignments(),refetchInterval:3e4}),{data:q}=et({queryKey:["spool-catalog"],queryFn:()=>ge.getSpoolCatalog()}),X=gt({mutationFn:ke=>ge.deleteSpool(ke),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),j=gt({mutationFn:ke=>ge.archiveSpool(ke),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),E=gt({mutationFn:ke=>ge.restoreSpool(ke),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),U=async ke=>{if(ke.last_scale_weight!=null)try{await pa.updateSpoolWeight(ke.id,ke.last_scale_weight),e.invalidateQueries({queryKey:["inventory-spools"]});const Ce=[ke.brand,ke.material,ke.color_name].filter(Boolean).join(" ");n(`Synced "${Ce}" to scale weight`,"success")}catch{n("Failed to sync weight","error")}},K=V?.low_stock_threshold??20,[H,re]=w.useState(!1),[O,$]=w.useState(K.toString());w.useEffect(()=>{H||$(K.toString())},[K,H]);const ee=gt({mutationFn:ke=>ge.updateSettings({low_stock_threshold:ke}),onSuccess:()=>{e.invalidateQueries({queryKey:["settings"]}),n(t("common.saved"),"success"),re(!1)},onError:()=>{n(t("inventory.lowStockThresholdError"),"error")}}),W=w.useMemo(()=>{if(!se)return null;let ke=0,Ce=0,$e=0,nt=0;const xt={};for(const vt of se){if(vt.archived_at)continue;nt++;const mt=Math.max(0,vt.label_weight-vt.weight_used);ke+=mt,Ce+=vt.weight_used,(vt.label_weight>0?mt/vt.label_weight*100:0){const ke={};for(const Ce of Te||[])ke[Ce.spool_id]=Ce;return ke},[Te]),xe=w.useMemo(()=>{const ke={};for(const Ce of q||[])ke[Ce.id]=Ce;return ke},[q]),oe=w.useMemo(()=>W?Object.entries(W.byMaterial).sort((ke,Ce)=>Ce[1].weight-ke[1].weight).slice(0,4):[],[W]),L=w.useMemo(()=>{let ke=se||[];if(l==="active"?ke=ke.filter(Ce=>!Ce.archived_at):ke=ke.filter(Ce=>!!Ce.archived_at),u==="used"?ke=ke.filter(Ce=>Ce.weight_used>0):u==="new"?ke=ke.filter(Ce=>Ce.weight_used===0):u==="lowstock"&&(ke=ke.filter(Ce=>{const $e=Math.max(0,Ce.label_weight-Ce.weight_used);return(Ce.label_weight>0?$e/Ce.label_weight*100:0)Ce.material===m)),f&&(ke=ke.filter(Ce=>Ce.brand===f)),v){const Ce=Number(v);ke=ke.filter($e=>$e.core_weight_catalog_id===Ce)}if(g==="stock"?ke=ke.filter(Ce=>!Ce.slicer_filament):g==="configured"&&(ke=ke.filter(Ce=>!!Ce.slicer_filament)),N){const Ce=N.toLowerCase();ke=ke.filter($e=>$e.brand?.toLowerCase().includes(Ce)||$e.material.toLowerCase().includes(Ce)||$e.color_name?.toLowerCase().includes(Ce)||$e.subtype?.toLowerCase().includes(Ce)||$e.note?.toLowerCase().includes(Ce)||$e.slicer_filament_name?.toLowerCase().includes(Ce))}return ke},[se,l,u,m,f,v,g,N,K]),F=()=>ue(0),te=[...new Set(se?.map(ke=>ke.material)||[])].sort(),ve=[...new Set(se?.map(ke=>ke.brand).filter(Boolean)||[])].sort(),fe=[...new Set(se?.map(ke=>ke.core_weight_catalog_id).filter(ke=>ke!=null)||[])].sort((ke,Ce)=>{const $e=(xe[ke]?.name||"").toLowerCase(),nt=(xe[Ce]?.name||"").toLowerCase();return $e.localeCompare(nt)}),me=l!=="active"||u!=="all"||!!m||!!f||!!v||g!=="all"||!!N,je=ke=>{R(ke),Ztt(ke)},we=w.useMemo(()=>A.filter(ke=>ke.visible).map(ke=>ke.id),[A]),Fe=ke=>{t3[ke]&&(D(Ce=>{let $e;return Ce?.column===ke?$e=Ce.direction==="asc"?{column:ke,direction:"desc"}:null:$e={column:ke,direction:"asc"},nnt($e),$e}),F())},He=w.useMemo(()=>{if(!T)return L;const ke=t3[T.column];return ke?[...L].sort(($e,nt)=>{const xt=ke($e,be),vt=ke(nt,be);return xtvt?T.direction==="asc"?1:-1:0}):L},[L,T,be]),Oe=w.useMemo(()=>{if(!Z)return He.map(nt=>({type:"single",spool:nt}));const ke=new Map;for(const nt of He)if(!(nt.weight_used>0||be[nt.id])){const xt=zY(nt),vt=ke.get(xt);vt?vt.push(nt):ke.set(xt,[nt])}const Ce=[],$e=new Set;for(const nt of He){if(nt.weight_used>0||be[nt.id]){Ce.push({type:"single",spool:nt});continue}const xt=zY(nt);if($e.has(xt))continue;$e.add(xt);const vt=ke.get(xt);vt.length===1?Ce.push({type:"single",spool:vt[0]}):Ce.push({type:"group",key:xt,spools:vt,representative:vt[0]})}return Ce},[He,Z,be]),_e=de===-1,Ae=Oe.length,Be=_e?Ae||1:de,Me=Math.max(1,Math.ceil(Ae/Be)),Xe=_e?0:Math.min(Y,Me-1),ye=_e?Oe:Oe.slice(Xe*Be,(Xe+1)*Be),We=()=>{const ke=!Z;I(ke),ae(new Set),F();try{localStorage.setItem("bambuddy-inventory-group",String(ke))}catch{}},Pe=ke=>{ae(Ce=>{const $e=new Set(Ce);return $e.has(ke)?$e.delete(ke):$e.add(ke),$e})},Ke=ke=>{he(ke),ue(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(ke))}catch{}},Ve=()=>{c("active"),d("all"),p(""),y(""),b(""),_("all"),C(""),F()};return i.jsxs("div",{className:"p-4 md:p-6 space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(Wi,{className:"w-6 h-6 text-bambu-green"}),i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("inventory.title")})]}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1 ml-9",children:(t("inventory.noSpools").split(".")[0],"")})]}),i.jsxs(ze,{onClick:()=>a({spool:null}),children:[i.jsx(ir,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),W&&!pe&&i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-3",children:[i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Wi,{className:"w-4 h-4 text-bambu-green"}),i.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalInventory")})]}),i.jsx("div",{className:"text-xl font-bold text-white",children:mu(W.totalWeight,!0)}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[W.totalSpools," ",W.totalSpools!==1?t("inventory.spools"):t("inventory.spool")]})]}),i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(XL,{className:"w-4 h-4 text-blue-400"}),i.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.totalConsumed")})]}),i.jsx("div",{className:"text-xl font-bold text-white",children:mu(W.totalConsumed,!0)}),i.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.sinceTracking")})]}),i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(Gi,{className:"w-4 h-4 text-green-400"}),i.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.byMaterial")})]}),i.jsx("div",{className:"flex flex-wrap gap-1.5 mt-1",children:oe.map(([ke,Ce])=>i.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${Jtt[ke]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[ke," ",i.jsx("span",{className:"opacity-70",children:mu(Ce.weight,!0)})]},ke))})]}),i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(_r,{className:"w-4 h-4 text-purple-400"}),i.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.inPrinter")})]}),i.jsx("div",{className:"text-xl font-bold text-white",children:ie}),i.jsx("div",{className:"text-xs text-bambu-gray mt-1",children:t("inventory.loadedInAms")})]}),i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg p-4",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[i.jsx(jn,{className:"w-4 h-4 text-yellow-400"}),i.jsx("span",{className:"text-xs text-bambu-gray font-medium uppercase tracking-wide",children:t("inventory.lowStock")})]}),i.jsx("div",{className:`text-xl font-bold ${W.lowStock>0?"text-yellow-400":"text-white"}`,children:W.lowStock}),i.jsx("div",{className:"text-xs text-bambu-gray mt-1 flex items-center gap-2",children:H?i.jsxs("form",{onSubmit:ke=>{ke.preventDefault();const Ce=parseFloat(O);!isNaN(Ce)&&Ce>=.1&&Ce<=99.9?ee.mutate(Ce):n(t("inventory.lowStockThresholdError"),"error")},className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-xs text-bambu-gray",children:"<"}),i.jsx("input",{type:"text",inputMode:"decimal",pattern:"^\\d{0,2}(\\.\\d?)?$",maxLength:4,value:O,onChange:ke=>{const Ce=ke.target.value.replace(/[^\d.]/g,"");/^\d{0,2}(\.\d?)?$/.test(Ce)&&$(Ce)},className:"px-1.5 py-1 rounded border border-bambu-dark-tertiary text-xs text-white bg-bambu-dark-secondary focus:outline-none focus:border-bambu-green w-14 text-center",onWheel:ke=>ke.currentTarget.blur(),disabled:ee.isPending}),i.jsx("span",{className:"text-xs text-bambu-gray",children:"%"}),i.jsx(ze,{type:"submit",size:"sm",disabled:ee.isPending,children:t("common.save")}),i.jsx(ze,{type:"button",size:"sm",variant:"ghost",onClick:()=>re(!1),disabled:ee.isPending,children:t("common.cancel")})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"text-bambu-gray",children:["< ",K,"%"]}),i.jsx("button",{className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:t("common.edit"),onClick:()=>{$(K.toString()),re(!0)},children:i.jsx(mh,{className:"w-4 h-4"})})]})})]})]}),i.jsxs("div",{className:"flex flex-col sm:flex-row gap-3 items-start sm:items-center justify-between",children:[i.jsxs("div",{className:"relative flex-1 max-w-md",children:[i.jsx(Rr,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50"}),i.jsx("input",{type:"text",value:N,onChange:ke=>{C(ke.target.value),F()},placeholder:t("inventory.search"),className:"w-full pl-10 pr-8 py-2 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green"}),N&&i.jsx("button",{onClick:()=>{C(""),F()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[k==="table"&&i.jsxs("button",{onClick:()=>z(!0),className:"flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium text-bambu-gray border border-bambu-dark-tertiary rounded-lg hover:bg-bambu-dark-tertiary transition-colors",title:t("inventory.configureColumns"),children:[i.jsx(wpe,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("inventory.columns")})]}),i.jsxs("button",{onClick:We,className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium border rounded-lg transition-colors ${Z?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,title:t("inventory.groupSimilar"),children:[i.jsx(ffe,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("inventory.groupSimilar")})]}),i.jsxs("div",{className:"flex bg-bambu-dark-primary border border-bambu-dark-tertiary rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>P("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${k==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(sbe,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),i.jsxs("button",{onClick:()=>P("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${k==="cards"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(ww,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("inventory.cards")})]})]})]})]}),i.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[i.jsxs("button",{onClick:()=>{c("active"),F()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="active"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(Wi,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),i.jsxs("button",{onClick:()=>{c("archived"),F()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${l==="archived"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(Vs,{className:"w-3.5 h-3.5"}),t("inventory.archived")]})]}),i.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),i.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[i.jsx("button",{onClick:()=>{d("all"),F()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),i.jsxs("button",{onClick:()=>{d("used"),F()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${u==="used"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(Zn,{className:"w-3.5 h-3.5"}),t("inventory.used")]}),i.jsx("button",{onClick:()=>{d("new"),F()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${u==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")}),i.jsxs("button",{onClick:()=>{d("lowstock"),F()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${u==="lowstock"?"bg-yellow-500/20 text-yellow-400":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(jn,{className:"w-3.5 h-3.5"}),t("inventory.lowStock")]})]}),i.jsxs("div",{className:"flex items-center rounded-lg border border-bambu-dark-tertiary overflow-hidden",children:[i.jsx("button",{onClick:()=>{_("all"),F()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${g==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),i.jsx("button",{onClick:()=>{_("stock"),F()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${g==="stock"?"bg-amber-500/20 text-amber-400":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.stock")}),i.jsx("button",{onClick:()=>{_("configured"),F()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${g==="configured"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.configured")})]}),i.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),i.jsxs("select",{value:m,onChange:ke=>{p(ke.target.value),F()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${m?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[i.jsx("option",{value:"",children:t("inventory.material")}),te.map(ke=>i.jsx("option",{value:ke,children:ke},ke))]}),i.jsxs("select",{value:f,onChange:ke=>{y(ke.target.value),F()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${f?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[i.jsx("option",{value:"",children:t("inventory.brand")}),ve.map(ke=>i.jsx("option",{value:ke,children:ke},ke))]}),fe.length>0&&i.jsxs("select",{value:v,onChange:ke=>{b(ke.target.value),F()},className:`px-3 py-1.5 rounded-lg border text-xs font-medium transition-colors cursor-pointer focus:outline-none ${v?"bg-bambu-green/20 text-bambu-green border-bambu-green/30":"bg-transparent text-bambu-gray border-bambu-dark-tertiary hover:bg-bambu-dark-tertiary"}`,children:[i.jsx("option",{value:"",children:t("inventory.spoolName")}),fe.map(ke=>i.jsx("option",{value:ke,children:xe[ke]?.name||`#${ke}`},ke))]}),me&&i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"w-px h-5 bg-bambu-dark-tertiary"}),i.jsxs("button",{onClick:Ve,className:"flex items-center gap-1 text-xs text-bambu-gray hover:text-bambu-green transition-colors",children:[i.jsx(Ht,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),i.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[He.length," ",He.length!==1?t("inventory.spools"):t("inventory.spool"),Z&&Ae0?i.jsxs(i.Fragment,{children:[i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4",children:ye.map(ke=>{if(ke.type==="group"){const{key:vt,spools:mt,representative:qe}=ke,Nt=qe.rgba?`#${qe.rgba.substring(0,6)}`:"#808080",_t=J.has(vt);return i.jsxs("div",{className:"col-span-full",children:[i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-green/30 hover:border-bambu-green transition-colors cursor-pointer",onClick:()=>Pe(vt),children:[i.jsx("div",{className:"h-10 flex items-center px-4 gap-3",style:{backgroundColor:Nt},children:i.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:DI(qe.color_name,qe.rgba)||"-"})}),i.jsxs("div",{className:"px-4 py-3 flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx(In,{className:`w-4 h-4 text-bambu-gray transition-transform ${_t?"":"-rotate-90"}`}),i.jsxs("div",{children:[i.jsxs("h3",{className:"font-semibold text-white",children:[qe.material,qe.subtype?` ${qe.subtype}`:""]}),i.jsx("p",{className:"text-sm text-bambu-gray",children:qe.brand||"-"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:mu(qe.label_weight)}),i.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:t("inventory.groupedSpools",{count:mt.length})})]})]})]}),_t&&i.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-4 mt-2 ml-4",children:mt.map(rt=>{const Rt=Math.max(0,rt.label_weight-rt.weight_used),qt=rt.label_weight>0?Rt/rt.label_weight*100:0,Kt=rt.rgba?`#${rt.rgba.substring(0,6)}`:"#808080";return i.jsx(UY,{spool:rt,remaining:Rt,pct:qt,colorStyle:Kt,onClick:()=>a({spool:rt}),t},rt.id)})})]},`group-${vt}`)}const Ce=ke.spool,$e=Math.max(0,Ce.label_weight-Ce.weight_used),nt=Ce.label_weight>0?$e/Ce.label_weight*100:0,xt=Ce.rgba?`#${Ce.rgba.substring(0,6)}`:"#808080";return i.jsx(UY,{spool:Ce,remaining:$e,pct:nt,colorStyle:xt,onClick:()=>a({spool:Ce}),t},Ce.id)})}),i.jsx(ant,{pageIndex:Xe,pageSize:de,totalRows:Ae,totalPages:Me,onPageChange:ue,onPageSizeChange:Ke,t})]}):i.jsx(BY,{hasFilters:me,onAddSpool:()=>a({spool:null}),t}):ye.length>0?i.jsxs("div",{className:"bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary",children:[i.jsx("div",{className:"overflow-x-auto",children:i.jsxs("table",{className:"w-full",children:[i.jsx("thead",{children:i.jsxs("tr",{className:"border-b border-bambu-dark-tertiary bg-bambu-dark-tertiary/30",children:[we.map(ke=>{const Ce=!!t3[ke],$e=T?.column===ke;return i.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${ke==="remaining"?"min-w-[150px]":""} ${Ce?"cursor-pointer hover:text-bambu-green transition-colors":""} ${$e?"text-bambu-green":"text-bambu-gray"}`,onClick:Ce?()=>Fe(ke):void 0,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[ent[ke]?.(t)??ke,Ce&&($e?T.direction==="asc"?i.jsx(Af,{className:"w-3 h-3"}):i.jsx(cx,{className:"w-3 h-3"}):i.jsx(qL,{className:"w-3 h-3 opacity-30"}))]})},ke)}),i.jsx("th",{className:"text-right py-3 px-4 text-xs font-medium text-bambu-gray uppercase tracking-wide",children:t("common.actions")})]})}),i.jsx("tbody",{children:ye.map(ke=>{if(ke.type==="group"){const{key:xt,spools:vt,representative:mt}=ke,qe=J.has(xt),Nt=Math.max(0,mt.label_weight-mt.weight_used),_t=mt.label_weight>0?Nt/mt.label_weight*100:0;return i.jsx(snt,{spools:vt,representative:mt,remaining:Nt,pct:_t,isExpanded:qe,onToggle:()=>Pe(xt),onEdit:rt=>a({spool:rt}),onArchive:rt=>o({type:"archive",spoolId:rt}),onDelete:rt=>o({type:"delete",spoolId:rt}),visibleColumns:we,assignmentMap:be,catalogMap:xe,currencySymbol:ce,dateFormat:ne,t,onSyncWeight:U},`group-${xt}`)}const Ce=ke.spool,$e=Math.max(0,Ce.label_weight-Ce.weight_used),nt=Ce.label_weight>0?$e/Ce.label_weight*100:0;return i.jsx(Zoe,{spool:Ce,remaining:$e,pct:nt,onEdit:()=>a({spool:Ce}),onRestore:()=>E.mutate(Ce.id),onArchive:()=>o({type:"archive",spoolId:Ce.id}),onDelete:()=>o({type:"delete",spoolId:Ce.id}),visibleColumns:we,assignmentMap:be,catalogMap:xe,currencySymbol:ce,dateFormat:ne,t,onSyncWeight:U},Ce.id)})})]})}),i.jsxs("div",{className:"flex items-center justify-between px-4 py-3 bg-bambu-dark-tertiary/50 border-t border-bambu-dark-tertiary text-sm",children:[i.jsx("span",{className:"text-bambu-gray",children:_e?`${Ae} ${t(Ae!==1?"inventory.spools":"inventory.spool")}`:i.jsxs(i.Fragment,{children:[t("inventory.showing")," ",Xe*Be+1," ",t("inventory.to")," ",Math.min((Xe+1)*Be,Ae)," ",t("inventory.of")," ",Ae," ",t("inventory.spools")]})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-bambu-gray",children:t("inventory.show")}),i.jsxs("select",{value:de,onChange:ke=>Ke(Number(ke.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(ke=>i.jsx("option",{value:ke,children:ke},ke)),i.jsx("option",{value:-1,children:t("inventory.all")})]}),!_e&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>ue(0),disabled:Xe===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"First page",children:i.jsx(VX,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>ue(ke=>Math.max(0,ke-1)),disabled:Xe===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(Cc,{className:"w-4 h-4"})}),i.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[t("inventory.page")," ",Xe+1," ",t("inventory.of")," ",Me]}),i.jsx("button",{onClick:()=>ue(ke=>Math.min(Me-1,ke+1)),disabled:Xe>=Me-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(fa,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>ue(Me-1),disabled:Xe>=Me-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",title:"Last page",children:i.jsx(GX,{className:"w-4 h-4"})})]})]})]})]}):i.jsx(BY,{hasFilters:me,onAddSpool:()=>a({spool:null}),t}),r!==null&&i.jsx(Ytt,{isOpen:!0,onClose:()=>a(null),spool:r.spool,currencySymbol:ce}),s&&i.jsx(Nn,{title:s.type==="delete"?t("common.delete"):t("inventory.archive"),message:s.type==="delete"?t("inventory.deleteConfirm"):t("inventory.archiveConfirm"),confirmText:s.type==="delete"?t("common.delete"):t("inventory.archive"),variant:s.type==="delete"?"danger":"warning",onConfirm:()=>{s.type==="delete"?X.mutate(s.spoolId):j.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),i.jsx(Xtt,{isOpen:G,onClose:()=>z(!1),columns:A,defaultColumns:AN,onSave:je})]})}function ant({pageIndex:t,pageSize:e,totalRows:n,totalPages:r,onPageChange:a,onPageSizeChange:s,t:o}){const l=e===-1;if(r<=1&&!l)return null;const c=l?n||1:e;return i.jsxs("div",{className:"flex items-center justify-between pt-2 text-sm",children:[i.jsx("span",{className:"text-bambu-gray",children:l?`${n} ${o(n!==1?"inventory.spools":"inventory.spool")}`:i.jsxs(i.Fragment,{children:[o("inventory.showing")," ",t*c+1," ",o("inventory.to")," ",Math.min((t+1)*c,n)," ",o("inventory.of")," ",n," ",o("inventory.spools")]})}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-bambu-gray",children:o("inventory.show")}),i.jsxs("select",{value:e,onChange:u=>s(Number(u.target.value)),className:"px-2 py-1 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white text-sm focus:outline-none focus:border-bambu-green",children:[[15,30,50,100].map(u=>i.jsx("option",{value:u,children:u},u)),i.jsx("option",{value:-1,children:o("inventory.all")})]}),!l&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>a(0),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(VX,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>a(Math.max(0,t-1)),disabled:t===0,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(Cc,{className:"w-4 h-4"})}),i.jsxs("span",{className:"text-bambu-gray px-2 whitespace-nowrap",children:[o("inventory.page")," ",t+1," ",o("inventory.of")," ",r]}),i.jsx("button",{onClick:()=>a(Math.min(r-1,t+1)),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(fa,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>a(r-1),disabled:t>=r-1,className:"p-1.5 rounded text-bambu-gray hover:text-white disabled:opacity-30 disabled:cursor-not-allowed transition-colors",children:i.jsx(GX,{className:"w-4 h-4"})})]})]})]})}function UY({spool:t,remaining:e,pct:n,colorStyle:r,onClick:a,t:s}){return i.jsxs("div",{className:`bg-bambu-dark-secondary rounded-lg overflow-hidden border border-bambu-dark-tertiary hover:border-bambu-green transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:a,children:[i.jsx("div",{className:"h-14 flex items-center justify-center",style:{backgroundColor:r},children:i.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:DI(t.color_name,t.rgba)||"-"})}),i.jsxs("div",{className:"p-4 space-y-3",children:[i.jsxs("div",{className:"flex items-start justify-between gap-2",children:[i.jsxs("div",{children:[i.jsxs("h3",{className:"font-semibold text-white",children:[t.material,t.subtype?` ${t.subtype}`:""]}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t.brand||"-"})]}),i.jsxs("span",{className:"text-xs font-mono text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded",children:["#",t.id]})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between text-xs text-bambu-gray mb-1",children:[i.jsx("span",{children:s("inventory.remaining")}),i.jsxs("span",{children:[Math.round(n),"%"]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("div",{className:"flex-1 h-2 bg-bambu-dark-tertiary rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full rounded-full ${n>50?"bg-bambu-green":n>20?"bg-yellow-500":"bg-red-500"}`,style:{width:`${Math.min(n,100)}%`}})}),i.jsxs("span",{className:"text-xs text-bambu-gray min-w-[40px] text-right",children:[Math.round(e),"g"]})]})]}),i.jsxs("div",{className:"grid grid-cols-2 gap-2 text-xs",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.labelWeight"),": "]}),i.jsx("span",{className:"text-bambu-gray",children:mu(t.label_weight)})]}),i.jsxs("div",{children:[i.jsxs("span",{className:"text-bambu-gray/60",children:[s("inventory.weightUsed"),": "]}),i.jsx("span",{className:"text-bambu-gray",children:t.weight_used>0?mu(t.weight_used):"-"})]})]}),t.note&&i.jsx("div",{className:"text-xs text-bambu-gray/60 pt-2 border-t border-bambu-dark-tertiary truncate",title:t.note,children:t.note})]})]})}function Zoe({spool:t,remaining:e,pct:n,onEdit:r,onRestore:a,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,catalogMap:u,currencySymbol:d,dateFormat:m,t:p,onSyncWeight:f}){return i.jsxs("tr",{className:`border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer ${t.archived_at?"opacity-50":""}`,onClick:r,children:[l.map(y=>i.jsx("td",{className:"py-3 px-4",children:CL[y]?.({spool:t,remaining:e,pct:n,assignmentMap:c,catalogMap:u,currencySymbol:d,dateFormat:m,t:p,onSyncWeight:f})},y)),i.jsx("td",{className:"py-3 px-4",children:i.jsxs("div",{className:"flex items-center justify-end gap-1",onClick:y=>y.stopPropagation(),children:[i.jsx("button",{onClick:r,className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:p("common.edit"),children:i.jsx(mh,{className:"w-4 h-4"})}),t.archived_at?i.jsx("button",{onClick:a,className:"p-1.5 text-bambu-gray hover:text-bambu-green rounded transition-colors",title:p("inventory.restore"),children:i.jsx(To,{className:"w-4 h-4"})}):i.jsx("button",{onClick:s,className:"p-1.5 text-bambu-gray hover:text-yellow-400 rounded transition-colors",title:p("inventory.archive"),children:i.jsx(Vs,{className:"w-4 h-4"})}),i.jsx("button",{onClick:o,className:"p-1.5 text-bambu-gray hover:text-red-400 rounded transition-colors",title:p("common.delete"),children:i.jsx(nn,{className:"w-4 h-4"})})]})})]})}function snt({spools:t,representative:e,remaining:n,pct:r,isExpanded:a,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:u,assignmentMap:d,catalogMap:m,currencySymbol:p,dateFormat:f,t:y,onSyncWeight:v}){return i.jsxs(i.Fragment,{children:[i.jsxs("tr",{className:"border-b border-bambu-dark-tertiary/50 hover:bg-bambu-dark-tertiary/30 transition-colors cursor-pointer bg-bambu-green/5",onClick:s,children:[u.map((b,g)=>i.jsx("td",{className:"py-3 px-4",children:g===0?i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(In,{className:`w-4 h-4 text-bambu-gray transition-transform ${a?"":"-rotate-90"}`}),CL[b]?.({spool:e,remaining:n,pct:r,assignmentMap:d,catalogMap:m,currencySymbol:p,dateFormat:f,t:y,onSyncWeight:v})]}):b==="id"?i.jsx("span",{className:"text-xs font-medium bg-bambu-green/20 text-bambu-green px-2 py-0.5 rounded-full",children:y("inventory.groupedSpools",{count:t.length})}):CL[b]?.({spool:e,remaining:n,pct:r,assignmentMap:d,catalogMap:m,currencySymbol:p,dateFormat:f,t:y,onSyncWeight:v})},b)),i.jsx("td",{className:"py-3 px-4",children:i.jsx("span",{className:"text-xs text-bambu-gray",children:t.map(b=>`#${b.id}`).join(", ")})})]}),a&&t.map(b=>{const g=Math.max(0,b.label_weight-b.weight_used),_=b.label_weight>0?g/b.label_weight*100:0;return i.jsx(Zoe,{spool:b,remaining:g,pct:_,onEdit:()=>o(b),onRestore:()=>{},onArchive:()=>l(b.id),onDelete:()=>c(b.id),visibleColumns:u,assignmentMap:d,catalogMap:m,currencySymbol:p,dateFormat:f,t:y,onSyncWeight:v},b.id)})]})}function BY({hasFilters:t,onAddSpool:e,t:n}){return i.jsxs("div",{className:"flex flex-col items-center justify-center py-16 px-4",children:[i.jsxs("div",{className:"relative mb-6",children:[i.jsx("div",{className:"absolute inset-0 -m-4 bg-bambu-green/5 rounded-full blur-2xl"}),i.jsxs("div",{className:"relative flex items-center justify-center w-24 h-24 rounded-2xl bg-gradient-to-br from-bambu-dark-secondary to-bambu-dark-tertiary border border-bambu-dark-tertiary shadow-lg",children:[i.jsx("div",{className:"absolute -top-1 -right-1 w-3 h-3 rounded-full bg-bambu-green/30"}),i.jsx("div",{className:"absolute -bottom-2 -left-2 w-2 h-2 rounded-full bg-bambu-green/20"}),t?i.jsx(Rr,{className:"w-10 h-10 text-bambu-gray/40",strokeWidth:1.5}):i.jsxs("div",{className:"relative",children:[i.jsx("div",{className:"w-14 h-14 rounded-full border-4 border-bambu-gray/20 flex items-center justify-center",children:i.jsx("div",{className:"w-6 h-6 rounded-full bg-bambu-gray/10 border-2 border-bambu-gray/20"})}),i.jsx("div",{className:"absolute -bottom-1 -right-1 w-6 h-6 rounded-full bg-bambu-green flex items-center justify-center shadow-md",children:i.jsx("span",{className:"text-white text-lg font-bold leading-none",children:"+"})})]})]})]}),i.jsx("h3",{className:"text-lg font-semibold text-white mb-2 text-center",children:t?n("inventory.noSpoolsMatch"):n("inventory.noSpools").split(".")[0]}),i.jsx("p",{className:"text-sm text-bambu-gray text-center max-w-sm mb-6",children:n(t?"inventory.noSpoolsMatchDesc":"inventory.noSpools")}),!t&&i.jsxs(ze,{onClick:e,children:[i.jsx(Wi,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const HY=["DEBUG","INFO","WARNING","ERROR"],n3={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},ont={DEBUG:ux,INFO:Hs,WARNING:jn,ERROR:Li};function lnt(){const t=sn(),[e,n]=w.useState(!0),[r,a]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[u,d]=w.useState(!1),[m,p]=w.useState(!1),f=w.useRef(null),{data:y,isLoading:v,refetch:b}=et({queryKey:["application-logs",l,s],queryFn:()=>Kb.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:m?2e3:!1,enabled:u});w.useEffect(()=>{u||p(!1)},[u]);const g=gt({mutationFn:()=>Kb.clearLogs(),onSuccess:()=>{t.invalidateQueries({queryKey:["application-logs"]})}});w.useEffect(()=>{e&&f.current&&y?.entries&&(f.current.scrollTop=f.current.scrollHeight)},[y?.entries,e]);const _=T=>{a(D=>{const A=new Set(D);return A.has(T)?A.delete(T):A.add(T),A})},N=T=>{const D=T.split(" ");return D.length>=2?D[1]:T},C=w.useMemo(()=>y?.entries??[],[y?.entries]),k=w.useMemo(()=>[...C].reverse(),[C]),P=({level:T})=>{const D=ont[T]||Hs;return i.jsx(D,{className:`w-3.5 h-3.5 ${n3[T]||"text-gray-400"}`})};return i.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>d(!u),className:"w-full flex items-center justify-between p-4 hover:bg-bambu-dark-tertiary/50 transition-colors",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${m?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:i.jsx(ux,{className:"w-5 h-5"})}),i.jsxs("div",{className:"text-left",children:[i.jsx("p",{className:"font-medium text-white",children:"Application Logs"}),i.jsx("p",{className:"text-sm text-bambu-gray",children:m?`Live streaming - ${y?.filtered_count??0} entries`:"View and filter application logs"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[m&&i.jsxs("span",{className:"flex items-center gap-1.5 px-2 py-1 bg-bambu-green/20 rounded text-bambu-green text-xs",children:[i.jsx("span",{className:"w-1.5 h-1.5 bg-bambu-green rounded-full animate-pulse"}),"Live"]}),u?i.jsx(Vl,{className:"w-5 h-5 text-bambu-gray"}):i.jsx(In,{className:"w-5 h-5 text-bambu-gray"})]})]}),u&&i.jsxs("div",{className:"border-t border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary",children:[i.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[m?i.jsxs("button",{onClick:T=>{T.stopPropagation(),p(!1)},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded transition-colors",children:[i.jsx(rl,{className:"w-4 h-4"}),"Stop"]}):i.jsxs("button",{onClick:T=>{T.stopPropagation(),p(!0),b()},className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 rounded transition-colors",children:[i.jsx(Co,{className:"w-4 h-4"}),"Start"]}),i.jsxs("button",{onClick:()=>g.mutate(),disabled:g.isPending||C.length===0,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:[i.jsx(nn,{className:"w-4 h-4"}),"Clear"]}),i.jsx("button",{onClick:()=>b(),disabled:v,className:"flex items-center gap-1.5 px-3 py-1.5 text-sm bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-secondary rounded transition-colors disabled:opacity-50",children:i.jsx(Sr,{className:`w-4 h-4 ${v?"animate-spin":""}`})}),i.jsx("div",{className:"flex-1"}),i.jsxs("label",{className:"flex items-center gap-2 text-sm text-bambu-gray cursor-pointer",children:[i.jsx("input",{type:"checkbox",checked:e,onChange:T=>n(T.target.checked),className:"rounded border-bambu-dark-tertiary bg-bambu-dark-tertiary"}),"Auto-scroll"]}),i.jsxs("span",{className:"text-sm text-bambu-gray",children:[y?.filtered_count??0,"/",y?.total_in_file??0]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsxs("div",{className:"relative flex-1",children:[i.jsx(Rr,{className:"absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray"}),i.jsx("input",{type:"text",placeholder:"Search message or logger name...",value:s,onChange:T=>o(T.target.value),className:"w-full pl-8 pr-8 py-1.5 text-sm bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none"}),s&&i.jsx("button",{onClick:()=>o(""),className:"absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:i.jsx(Ht,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"flex items-center gap-1 bg-bambu-dark-secondary rounded border border-bambu-dark-tertiary",children:[i.jsx("button",{onClick:()=>c("ALL"),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${l==="ALL"?"bg-bambu-green text-white":"text-bambu-gray hover:text-white"}`,children:"All"}),HY.map((T,D)=>i.jsx("button",{onClick:()=>c(T),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${D===HY.length-1?"rounded-r":""} ${l===T?`${n3[T]} bg-bambu-dark-tertiary`:"text-bambu-gray hover:text-white"}`,children:T},T))]})]})]}),i.jsx("div",{ref:f,className:"overflow-auto font-mono text-xs bg-black min-h-[300px] max-h-[500px]",children:C.length===0?i.jsxs("div",{className:"flex flex-col items-center justify-center h-[300px] text-bambu-gray",children:[i.jsx("p",{className:"mb-2",children:"No log entries found"}),i.jsx("p",{className:"text-sm",children:"Log file may be empty or cleared"})]}):i.jsx("div",{className:"divide-y divide-bambu-dark-tertiary/30",children:k.map((T,D)=>{const A=r.has(D),R=T.message.includes(` `);return i.jsx("div",{className:`p-2 cursor-pointer hover:bg-bambu-dark-secondary/50 transition-colors ${A?"bg-bambu-dark-secondary/30":""}`,onClick:()=>R&&_(D),children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:N(T.timestamp)}),i.jsx("span",{className:"shrink-0",children:i.jsx(P,{level:T.level})}),i.jsxs("span",{className:"text-purple-400/80 shrink-0 max-w-[200px] truncate",title:T.logger_name,children:["[",T.logger_name,"]"]}),i.jsx("span",{className:`flex-1 ${n3[T.level]||"text-white/80"} ${!A&&R?"truncate":""}`,children:A?i.jsx("pre",{className:"whitespace-pre-wrap break-all",children:T.message}):T.message.split(` -`)[0]}),R&&i.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?i.jsx(Vl,{className:"w-3.5 h-3.5"}):i.jsx(In,{className:"w-3.5 h-3.5"})})]})},D)})})}),i.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:m?i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):i.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function cnt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Ai({icon:t,label:e,value:n,subValue:r,color:a="text-bambu-green"}){return i.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${a}`,children:i.jsx(t,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:e}),i.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function $Y({percent:t,color:e="bg-bambu-green"}){return i.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Wm({title:t,icon:e,children:n}){return i.jsxs(Pt,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(e,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function unt(){const{t}=Dt(),e=sn(),[n,r]=w.useState(null),[a,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:m}=et({queryKey:["systemInfo"],queryFn:ge.getSystemInfo,refetchInterval:3e4}),{data:p}=et({queryKey:["debugLogging"],queryFn:Kb.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:f}=et({queryKey:["settings"],queryFn:ge.getSettings}),{data:y}=et({queryKey:["library-stats"],queryFn:ge.getLibraryStats}),v=f?.time_format||"system",b=async()=>{l(!0);try{const C=await Kb.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],C)}catch(C){console.error("Failed to toggle debug logging:",C)}finally{l(!1)}},g=async()=>{r(null),s(!0);try{await Kb.downloadSupportBundle()}catch(C){r(C instanceof Error?C.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return i.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const _=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),i.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),i.jsxs("button",{onClick:()=>d(),disabled:m,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[i.jsx(Sr,{className:`w-4 h-4 ${m?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),i.jsx(Wm,{title:t("system.application","Application"),icon:Op,children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Ai,{icon:Op,label:t("system.version","Version"),value:`v${c.app.version}`}),i.jsx(Ai,{icon:Zn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),i.jsx(Ai,{icon:Op,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),i.jsx(Wm,{title:t("support.title","Support & Troubleshooting"),icon:wfe,children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:i.jsx(ux,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&i.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),i.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&i.jsx(ft,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:i.jsx(fi,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),i.jsxs("button",{onClick:g,disabled:a||!p?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[a&&i.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&i.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:i.jsxs("p",{className:"text-sm text-bambu-gray",children:[i.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),i.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),i.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),i.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),i.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),i.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[i.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),i.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),i.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),i.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),i.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),i.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),i.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),i.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),i.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),i.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),i.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),i.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),i.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[i.jsxs("li",{children:["• ",t("support.notItem1","Printer names and serial numbers")]}),i.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),i.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),i.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),i.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),i.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]}),i.jsxs("li",{children:["• ",t("support.notItem7","IP addresses")]})]})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","Email addresses in logs are replaced with [EMAIL], printer names with [PRINTER], serial numbers with [SERIAL], and IP addresses with [IP].")})]}),i.jsx(lnt,{})]})}),i.jsxs(Wm,{title:t("system.database","Database"),icon:hu,children:[i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(Ai,{icon:Vs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),i.jsx(Ai,{icon:vc,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),i.jsx(Ai,{icon:Vi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),i.jsx(Ai,{icon:ft,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Ai,{icon:_r,label:t("system.printers","Printers"),value:c.database.printers}),i.jsx(Ai,{icon:Sw,label:t("system.filaments","Filaments"),value:c.database.filaments}),i.jsx(Ai,{icon:vs,label:t("system.projects","Projects"),value:c.database.projects}),i.jsx(Ai,{icon:Ul,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[i.jsx(Ai,{icon:Zn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),i.jsx(Ai,{icon:Vs,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),i.jsxs(Wm,{title:t("system.connectedPrinters","Connected Printers"),icon:_r,children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[i.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),i.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?i.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(C=>i.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),i.jsx("span",{className:"font-medium text-white",children:C.name})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[i.jsx("span",{children:C.model}),i.jsx("span",{className:`px-2 py-0.5 rounded ${C.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":C.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:C.state})]})]},C.id))}):i.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),i.jsx(Wm,{title:t("system.storage","Storage"),icon:Vx,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),i.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),i.jsx($Y,{percent:c.storage.disk_percent_used,color:_}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Ai,{icon:Vs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),i.jsx(Ai,{icon:hu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),y&&i.jsx(Ai,{icon:Ac,label:t("system.fileManagerStorage","File Manager"),value:cnt(y.total_size_bytes),subValue:`${y.total_files} files, ${y.total_folders} folders`})]})]})}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[i.jsx(Wm,{title:t("system.memory","Memory"),icon:Jfe,children:i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),i.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),i.jsx($Y,{percent:c.memory.percent_used,color:N}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),i.jsx(Wm,{title:t("system.cpu","CPU"),icon:m_,children:i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Ai,{icon:m_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),i.jsx(Ai,{icon:m_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),i.jsx(Wm,{title:t("system.systemDetails","System Details"),icon:Op,children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Ai,{icon:Op,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),i.jsx(Ai,{icon:m_,label:t("system.architecture","Architecture"),value:c.system.architecture}),i.jsx(Ai,{icon:Op,label:t("system.python","Python"),value:c.system.python_version}),i.jsx(Ai,{icon:Zn,label:t("system.bootTime","Boot Time"),value:Df(c.system.boot_time,v)})]})})]})}function dnt(){const t=ol(),{t:e}=Dt(),{login:n}=Ar(),{showToast:r}=bn(),{mode:a}=ng(),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!1),[m,p]=w.useState(""),{data:f}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),y=gt({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=gt({mutationFn:_=>ge.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),d(!1),p("")},onError:_=>{r(_.message,"error")}}),b=_=>{if(_.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}y.mutate()},g=_=>{if(_.preventDefault(),!m){r("Please enter your email address","error");return}v.mutate(m)};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[i.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-6",children:i.jsx("img",{src:a==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),i.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),i.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),i.jsxs("form",{className:"mt-8 space-y-6",onSubmit:b,children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:f?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),i.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:_=>o(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:f?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),i.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:_=>c(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),i.jsx("div",{children:i.jsx("button",{type:"submit",disabled:y.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:y.isPending?e("login.signingIn"):e("login.signIn")})}),f?.advanced_auth_enabled&&i.jsx("div",{className:"text-center",children:i.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[i.jsx(Bn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mx,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),i.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>{d(!1),p("")},children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsx(Et,{children:f?.advanced_auth_enabled?i.jsxs("form",{onSubmit:g,className:"space-y-4",children:[i.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),i.jsx("input",{id:"forgot-email",type:"email",required:!0,value:m,onChange:_=>p(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.emailPlaceholder")||"your.email@example.com"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ze,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),p("")},children:e("login.cancel")||"Cancel"}),i.jsx(ze,{type:"submit",className:"flex-1",disabled:v.isPending,children:v.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[i.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),i.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[i.jsx("li",{children:e("login.resetStep1")}),i.jsx("li",{children:e("login.resetStep2")}),i.jsx("li",{children:e("login.resetStep3")}),i.jsx("li",{children:e("login.resetStep4")})]})]}),i.jsx(ze,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function mnt(){const t=ol(),{t:e}=Dt(),{showToast:n}=bn(),{mode:r}=ng(),{refreshAuth:a}=Ar(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[u,d]=w.useState(""),[m,p]=w.useState(""),f=gt({mutationFn:()=>ge.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async v=>{await a(),v.auth_enabled?v.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:v=>{n(v.message,"error")}}),y=v=>{if(v.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==m){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}f.mutate()};return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:i.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-6",children:i.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),i.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),i.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),i.jsxs("form",{className:"mt-8 space-y-6",onSubmit:y,children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:v=>o(v.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),i.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&i.jsxs("div",{className:"space-y-4 mt-4",children:[i.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(Hs,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"text-sm text-bambu-gray",children:[i.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),i.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",i.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),i.jsx("input",{id:"admin-username",type:"text",value:l,onChange:v=>c(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",i.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),i.jsx("input",{id:"admin-password",type:"password",value:u,onChange:v=>d(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&i.jsxs("div",{children:[i.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),i.jsx("input",{id:"confirm-password",type:"password",value:m,onChange:v=>p(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),i.jsx("div",{children:i.jsx("button",{type:"submit",disabled:f.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:f.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function hnt(){const{t}=Dt(),{user:e}=Ar(),{showToast:n}=bn(),r=sn(),a=ol(),[s,o]=w.useState(!0),[l,c]=w.useState(!0),[u,d]=w.useState(!0),[m,p]=w.useState(!0),[f,y]=w.useState(!1),{data:v,isLoading:b}=et({queryKey:["advancedAuthStatus"],queryFn:ge.getAdvancedAuthStatus,staleTime:300*1e3}),{data:g,isLoading:_}=et({queryKey:["settings"],queryFn:ge.getSettings,staleTime:300*1e3}),{data:N,isLoading:C}=et({queryKey:["user-email-preferences"],queryFn:()=>ge.getUserEmailPreferences()});w.useEffect(()=>{(v&&!v.advanced_auth_enabled||g&&!g.user_notifications_enabled)&&a("/settings",{replace:!0})},[v,g,a]),w.useEffect(()=>{N&&(o(N.notify_print_start),c(N.notify_print_complete),d(N.notify_print_failed),p(N.notify_print_stopped),y(!1))},[N]);const k=gt({mutationFn:()=>ge.updateUserEmailPreferences({notify_print_start:s,notify_print_complete:l,notify_print_failed:u,notify_print_stopped:m}),onSuccess:()=>{r.invalidateQueries({queryKey:["user-email-preferences"]}),y(!1),n(t("notifications.userEmail.saveSuccess"),"success")},onError:T=>{n(T.message||t("notifications.userEmail.saveError"),"error")}}),P=(T,D)=>{T(!D),y(!0)};return C||b||_?i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):i.jsxs("div",{className:"p-4 md:p-6 max-w-2xl mx-auto",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[i.jsx(_h,{className:"w-7 h-7 text-bambu-green"}),i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("notifications.userEmail.title")})]}),i.jsx(Pt,{className:"mb-6 border-blue-500/30 bg-blue-500/5",children:i.jsx(Et,{className:"py-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:i.jsx(mx,{className:"w-5 h-5 text-blue-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-white font-medium",children:t("notifications.userEmail.emailNotifications")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t("notifications.userEmail.emailNotificationsDesc")}),e?.email?i.jsxs("p",{className:"text-sm text-blue-400 mt-2",children:[t("notifications.userEmail.sendingTo"),": ",i.jsx("strong",{children:e.email})]}):i.jsx("p",{className:"text-sm text-yellow-400 mt-2",children:t("notifications.userEmail.noEmailWarning")})]})]})})}),i.jsxs(Pt,{className:"mb-6",children:[i.jsxs(Bn,{children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("notifications.userEmail.printJobNotifications")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t("notifications.userEmail.printJobNotificationsDesc")})]}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${s?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${s?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobStarts")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobStartsDesc")})]})]}),i.jsx("button",{onClick:()=>P(o,s),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${s?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":s,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${l?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobFinishes")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobFinishesDesc")})]})]}),i.jsx("button",{onClick:()=>P(c,l),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${l?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":l,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${u?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${u?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printErrors")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printErrorsDesc")})]})]}),i.jsx("button",{onClick:()=>P(d,u),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${u?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":u,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${m?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${m?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobStops")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobStopsDesc")})]})]}),i.jsx("button",{onClick:()=>P(p,m),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${m?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":m,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m?"translate-x-6":"translate-x-1"}`})})]})]})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(ze,{onClick:()=>k.mutate(),disabled:!f||k.isPending||!e?.email,children:k.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(as,{className:"w-4 h-4"}),t("common.save")]})})})]})}function pnt(){const t=w.useRef(null),e=w.useRef(null),n=sn(),[r,a]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),m=w.useRef(()=>{}),p=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const _=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{m.current(N),u.current.length>0?setTimeout(_,16):d.current=!1}):d.current=!1};_()},[]),f=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,C=new WebSocket(N);let k=null;C.onopen=()=>{console.log("[WebSocket] Connected"),a(!0),k=window.setInterval(()=>{C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:"ping"}))},3e4)},C.onmessage=P=>{try{const T=JSON.parse(P.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?m.current(T):(u.current.push(T),p())}catch{}},C.onclose=P=>{console.log("[WebSocket] Closed",P.code,P.reason),k&&(clearInterval(k),k=null),a(!1),t.current=null,e.current=window.setTimeout(()=>{f()},3e3)},C.onerror=P=>{console.error("[WebSocket] Error",P),C.close()},t.current=C},[p]),y=w.useCallback((_,N)=>{const C=l.current.get(_)||{};l.current.set(_,{...C,...N}),c.current||(c.current=window.setTimeout(()=>{const k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((P,T)=>{n.setQueryData(["printerStatus",T],D=>{const A={...D,...P};return A.wifi_signal==null&&D?.wifi_signal!=null&&(A.wifi_signal=D.wifi_signal),A})})})},100))},[n]),v=w.useCallback(_=>{s.current.add(_),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let C=0;N.forEach(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},C),C+=500})},3e3)},[n]),b=w.useCallback(_=>{switch(_.type){case"printer_status":_.printer_id!==void 0&&_.data&&y(_.printer_id,_.data);break;case"print_start":_.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",_.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:_.printer_id,printer_name:_.printer_name,message:_.message}}));break;case"spool_auto_assigned":v("inventory-spools"),v("spool-assignments");break;case"spool_usage_logged":v("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:_.printer_id,ams_id:_.ams_id,tray_id:_.tray_id,tag_uid:_.tag_uid,tray_uuid:_.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:_.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:_}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:_})),v("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:_}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:_}));break;case"spoolbuddy_tag_written":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-written",{detail:_})),v("inventory-spools");break;case"spoolbuddy_tag_write_failed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-write-failed",{detail:_}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:_}));break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:_}));break}},[n,v,y]);w.useEffect(()=>{m.current=b},[b]),w.useEffect(()=>(f(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[f]);const g=w.useCallback(_=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(_))},[]);return{isConnected:r,sendMessage:g}}function fnt({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=Dt(),[a,s]=w.useState(new Date),{data:o=[]}=et({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),l=tg({queries:o.map(d=>({queryKey:["printerStatus",d.id],queryFn:()=>ge.getPrinterStatus(d.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((d,m)=>l[m]?.data?.connected),[o,l]);w.useEffect(()=>{const d=c.some(m=>m.id===t);(!t||!d)&&c.length>0&&e(c[0].id)},[c,t,e]);const{data:u}=et({queryKey:["settings"],queryFn:ge.getSettings});return w.useEffect(()=>{const d=setInterval(()=>s(new Date),1e3);return()=>clearInterval(d)},[]),i.jsxs("div",{className:"h-12 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0",children:[i.jsx("div",{className:"flex items-center shrink-0",children:i.jsx("img",{src:"/img/spoolbuddy_logo_dark_small.png",alt:"SpoolBuddy",width:113,height:28,className:"h-7 w-auto"})}),i.jsx("div",{className:"flex-1 flex justify-center",children:i.jsx("select",{value:t??"",onChange:d=>e(Number(d.target.value)),className:"bg-bambu-dark text-white text-base px-4 py-2 rounded border border-bambu-dark-tertiary focus:outline-none focus:border-bambu-green min-w-[180px]",children:c.length===0?i.jsx("option",{value:"",children:r("spoolbuddy.status.noPrinters","No printers online")}):c.map(d=>i.jsx("option",{value:d.id,children:d.name},d.id))})}),i.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[i.jsx("div",{className:"flex items-center",title:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline"),children:n?i.jsx("div",{className:"flex items-end gap-0.5 h-4",children:[1,2,3,4].map(d=>i.jsx("div",{className:`w-1 rounded-sm ${d<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${d*4}px`}},d))}):i.jsx(zh,{className:"w-5 h-5 text-red-400"})}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:`w-3 h-3 rounded-full ${n?"bg-bambu-green shadow-[0_0_6px_rgba(34,197,94,0.5)]":"bg-bambu-gray"}`}),i.jsx("span",{className:"text-sm text-white/50",children:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline")})]}),i.jsx("span",{className:"text-white/50 text-base font-mono min-w-[50px] text-right",children:hQ(a,u?.time_format||"system")})]})]})}const gnt=[{to:"/spoolbuddy",labelKey:"spoolbuddy.nav.dashboard",fallback:"Dashboard",icon:i.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{to:"/spoolbuddy/ams",labelKey:"spoolbuddy.nav.ams",fallback:"AMS",icon:i.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})},{to:"/spoolbuddy/write-tag",labelKey:"spoolbuddy.nav.writeTag",fallback:"Write",icon:i.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z"})]})},{to:"/spoolbuddy/settings",labelKey:"spoolbuddy.nav.settings",fallback:"Settings",icon:i.jsxs("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}];function bnt(){const{t}=Dt();return i.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:gnt.map(e=>i.jsxs(Ib,{to:e.to,end:e.to==="/spoolbuddy",className:({isActive:n})=>`flex-1 flex flex-col items-center justify-center gap-1 transition-colors ${n?"text-bambu-green bg-bambu-dark":"text-white/50 hover:text-white/70 hover:bg-bambu-dark-tertiary"}`,children:[e.icon,i.jsx("span",{className:"text-xs font-medium",children:t(e.labelKey,e.fallback)})]},e.to))})}function xnt({alert:t}){const{t:e}=Dt(),n=t?t.type==="error"?"bg-red-500":t.type==="warning"?"bg-amber-500":"bg-bambu-green":"bg-bambu-green",r=t?t.type==="error"?"border-red-500":t.type==="warning"?"border-amber-500":"border-bambu-dark-tertiary":"border-bambu-dark-tertiary";return i.jsxs("div",{className:`h-9 bg-bambu-dark-secondary border-t-2 ${r} flex items-center px-3 gap-3 shrink-0`,children:[i.jsx("div",{className:`w-3.5 h-3.5 rounded-full ${n} animate-pulse`}),i.jsx("div",{className:"flex-1 text-sm text-white/50 truncate",children:t?i.jsx("span",{children:t.message}):i.jsx("span",{className:"text-bambu-green",children:e("spoolbuddy.status.systemReady","System Ready")})})]})}const ynt={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function vnt(t,e){switch(e.type){case"WEIGHT_UPDATE":return{...t,weight:e.weight,weightStable:e.stable,rawAdc:e.rawAdc,deviceId:e.deviceId,deviceOnline:!0};case"TAG_MATCHED":return{...t,matchedSpool:e.spool,unknownTagUid:null,deviceId:e.deviceId};case"UNKNOWN_TAG":return{...t,matchedSpool:null,unknownTagUid:e.tagUid,deviceId:e.deviceId};case"TAG_REMOVED":return{...t,matchedSpool:null,unknownTagUid:null};case"DEVICE_ONLINE":return{...t,deviceOnline:!0,deviceId:e.deviceId};case"DEVICE_OFFLINE":return{...t,deviceOnline:!1,weight:null,weightStable:!1,rawAdc:null};default:return t}}function wnt(){const[t,e]=w.useReducer(vnt,ynt),n=w.useCallback(d=>{const m=d.detail;e({type:"WEIGHT_UPDATE",weight:m.weight_grams??m.data?.weight_grams,stable:m.stable??m.data?.stable??!1,rawAdc:m.raw_adc??m.data?.raw_adc??null,deviceId:m.device_id??m.data?.device_id??""})},[]),r=w.useCallback(d=>{const m=d.detail,p=m.spool??m.data?.spool;p&&e({type:"TAG_MATCHED",spool:{id:p.id,tag_uid:m.tag_uid??m.data?.tag_uid??"",material:p.material??"",subtype:p.subtype??null,color_name:p.color_name??null,rgba:p.rgba??null,brand:p.brand??null,label_weight:p.label_weight??0,core_weight:p.core_weight??0,weight_used:p.weight_used??0},deviceId:m.device_id??m.data?.device_id??""})},[]),a=w.useCallback(d=>{const m=d.detail;e({type:"UNKNOWN_TAG",tagUid:m.tag_uid??m.data?.tag_uid??"",deviceId:m.device_id??m.data?.device_id??""})},[]),s=w.useCallback(d=>{const m=d.detail;e({type:"TAG_REMOVED",deviceId:m.device_id??m.data?.device_id??""})},[]),o=w.useCallback(d=>{const m=d.detail;e({type:"DEVICE_ONLINE",deviceId:m.device_id??m.data?.device_id??""})},[]),l=w.useCallback(d=>{const m=d.detail;e({type:"DEVICE_OFFLINE",deviceId:m.device_id??m.data?.device_id??""})},[]);w.useEffect(()=>(window.addEventListener("spoolbuddy-weight",n),window.addEventListener("spoolbuddy-tag-matched",r),window.addEventListener("spoolbuddy-unknown-tag",a),window.addEventListener("spoolbuddy-tag-removed",s),window.addEventListener("spoolbuddy-online",o),window.addEventListener("spoolbuddy-offline",l),()=>{window.removeEventListener("spoolbuddy-weight",n),window.removeEventListener("spoolbuddy-tag-matched",r),window.removeEventListener("spoolbuddy-unknown-tag",a),window.removeEventListener("spoolbuddy-tag-removed",s),window.removeEventListener("spoolbuddy-online",o),window.removeEventListener("spoolbuddy-offline",l)}),[n,r,a,s,o,l]);const c=t.matchedSpool?Math.max(0,t.matchedSpool.label_weight-t.matchedSpool.weight_used):null,u=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:u}}var PN={exports:{}};var Snt=PN.exports,qY;function _nt(){return qY||(qY=1,(function(t,e){(function(n,r){t.exports=r(Jf())})(Snt,(function(n){return(function(){var r={981:function(){typeof Element>"u"||"remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<"u"&&"document"in self&&((!("classList"in document.createElement("_"))||document.createElementNS&&!("classList"in document.createElementNS("http://www.w3.org/2000/svg","g")))&&(function(l){if("Element"in l){var c="classList",u="prototype",d=l.Element[u],m=Object,p=String[u].trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=Array[u].indexOf||function(C){for(var k=0,P=this.length;k1?arguments[1]:void 0)}},7916:function(q,X,j){var E=j(6080),U=j(9565),K=j(8981),H=j(6319),re=j(4209),O=j(3517),$=j(6198),ee=j(4659),W=j(4527),ie=j(81),ce=j(851),be=Array;q.exports=function(xe){var oe=K(xe),L=O(this),F=arguments.length,te=F>1?arguments[1]:void 0,ve=te!==void 0;ve&&(te=E(te,F>2?arguments[2]:void 0));var fe,me,je,we,Fe,He,Oe=ce(oe),_e=0;if(!Oe||this===be&&re(Oe))for(fe=$(oe),me=L?new this(fe):be(fe);fe>_e;_e++)He=ve?te(oe[_e],_e):oe[_e],ee(me,_e,He);else for(me=L?new this:[],Fe=(we=ie(oe,Oe)).next;!(je=U(Fe,we)).done;_e++)He=ve?H(we,te,[je.value,_e],!0):je.value,ee(me,_e,He);return W(me,_e),me}},9617:function(q,X,j){var E=j(5397),U=j(5610),K=j(6198),H=function(re){return function(O,$,ee){var W=E(O),ie=K(W);if(ie===0)return!re&&-1;var ce,be=U(ee,ie);if(re&&$!=$){for(;ie>be;)if((ce=W[be++])!=ce)return!0}else for(;ie>be;be++)if((re||be in W)&&W[be]===$)return re||be||0;return!re&&-1}};q.exports={includes:H(!0),indexOf:H(!1)}},9213:function(q,X,j){var E=j(6080),U=j(7055),K=j(8981),H=j(6198),re=j(1469),O=j(4659),$=function(ee){var W=ee===1,ie=ee===2,ce=ee===3,be=ee===4,xe=ee===6,oe=ee===7,L=ee===5||xe;return function(F,te,ve){for(var fe,me,je=K(F),we=U(je),Fe=H(we),He=E(te,ve),Oe=0,_e=0,Ae=W?re(F,Fe):ie||oe?re(F,0):void 0;Fe>Oe;Oe++)if((L||Oe in we)&&(me=He(fe=we[Oe],Oe,je),ee))if(W)O(Ae,Oe,me);else if(me)switch(ee){case 3:return!0;case 5:return fe;case 6:return Oe;case 2:O(Ae,_e++,fe)}else switch(ee){case 4:return!1;case 7:O(Ae,_e++,fe)}return xe?-1:ce||be?be:Ae}};q.exports={forEach:$(0),map:$(1),filter:$(2),some:$(3),every:$(4),find:$(5),findIndex:$(6),filterReject:$(7)}},597:function(q,X,j){var E=j(9039),U=j(8227),K=j(9519),H=U("species");q.exports=function(re){return K>=51||!E((function(){var O=[];return(O.constructor={})[H]=function(){return{foo:1}},O[re](Boolean).foo!==1}))}},4598:function(q,X,j){var E=j(9039);q.exports=function(U,K){var H=[][U];return!!H&&E((function(){H.call(null,K||function(){return 1},1)}))}},926:function(q,X,j){var E=j(9306),U=j(8981),K=j(7055),H=j(6198),re=TypeError,O="Reduce of empty array with no initial value",$=function(ee){return function(W,ie,ce,be){var xe=U(W),oe=K(xe),L=H(xe);if(E(ie),L===0&&ce<2)throw new re(O);var F=ee?L-1:0,te=ee?-1:1;if(ce<2)for(;;){if(F in oe){be=oe[F],F+=te;break}if(F+=te,ee?F<0:L<=F)throw new re(O)}for(;ee?F>=0:L>F;F+=te)F in oe&&(be=ie(be,oe[F],F,xe));return be}};q.exports={left:$(!1),right:$(!0)}},4527:function(q,X,j){var E=j(3724),U=j(4376),K=TypeError,H=Object.getOwnPropertyDescriptor,re=E&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(O){return O instanceof TypeError}})();q.exports=re?function(O,$){if(U(O)&&!H(O,"length").writable)throw new K("Cannot set read only .length");return O.length=$}:function(O,$){return O.length=$}},7680:function(q,X,j){var E=j(9504);q.exports=E([].slice)},4488:function(q,X,j){var E=j(7680),U=Math.floor,K=function(H,re){var O=H.length;if(O<8)for(var $,ee,W=1;W0;)H[ee]=H[--ee];ee!==W++&&(H[ee]=$)}else for(var ie=U(O/2),ce=K(E(H,0,ie),re),be=K(E(H,ie),re),xe=ce.length,oe=be.length,L=0,F=0;L9007199254740991)throw X("Maximum allowed index exceeded");return j}},7400:function(q){q.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},9296:function(q,X,j){var E=j(4055)("span").classList,U=E&&E.constructor&&E.constructor.prototype;q.exports=U===Object.prototype?void 0:U},8727:function(q){q.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709:function(q,X,j){var E=j(2839).match(/firefox\/(\d+)/i);q.exports=!!E&&+E[1]},3763:function(q,X,j){var E=j(2839);q.exports=/MSIE|Trident/.test(E)},6193:function(q,X,j){var E=j(4215);q.exports=E==="NODE"},2839:function(q,X,j){var E=j(4576).navigator,U=E&&E.userAgent;q.exports=U?String(U):""},9519:function(q,X,j){var E,U,K=j(4576),H=j(2839),re=K.process,O=K.Deno,$=re&&re.versions||O&&O.version,ee=$&&$.v8;ee&&(U=(E=ee.split("."))[0]>0&&E[0]<4?1:+(E[0]+E[1])),!U&&H&&(!(E=H.match(/Edge\/(\d+)/))||E[1]>=74)&&(E=H.match(/Chrome\/(\d+)/))&&(U=+E[1]),q.exports=U},3607:function(q,X,j){var E=j(2839).match(/AppleWebKit\/(\d+)\./);q.exports=!!E&&+E[1]},4215:function(q,X,j){var E=j(4576),U=j(2839),K=j(2195),H=function(re){return U.slice(0,re.length)===re};q.exports=H("Bun/")?"BUN":H("Cloudflare-Workers")?"CLOUDFLARE":H("Deno/")?"DENO":H("Node.js/")?"NODE":E.Bun&&typeof Bun.version=="string"?"BUN":E.Deno&&typeof Deno.version=="object"?"DENO":K(E.process)==="process"?"NODE":E.window&&E.document?"BROWSER":"REST"},6518:function(q,X,j){var E=j(4576),U=j(7347).f,K=j(6699),H=j(6840),re=j(9433),O=j(7740),$=j(2796);q.exports=function(ee,W){var ie,ce,be,xe,oe,L=ee.target,F=ee.global,te=ee.stat;if(ie=F?E:te?E[L]||re(L,{}):E[L]&&E[L].prototype)for(ce in W){if(xe=W[ce],be=ee.dontCallGetSet?(oe=U(ie,ce))&&oe.value:ie[ce],!$(F?ce:L+(te?".":"#")+ce,ee.forced)&&be!==void 0){if(typeof xe==typeof be)continue;O(xe,be)}(ee.sham||be&&be.sham)&&K(xe,"sham",!0),H(ie,ce,xe,ee)}}},9039:function(q){q.exports=function(X){try{return!!X()}catch{return!0}}},9228:function(q,X,j){j(7495);var E=j(9565),U=j(6840),K=j(7323),H=j(9039),re=j(8227),O=j(6699),$=re("species"),ee=RegExp.prototype;q.exports=function(W,ie,ce,be){var xe=re(W),oe=!H((function(){var ve={};return ve[xe]=function(){return 7},""[W](ve)!==7})),L=oe&&!H((function(){var ve=!1,fe=/a/;if(W==="split"){var me={};me[$]=function(){return fe},(fe={constructor:me,flags:""})[xe]=/./[xe]}return fe.exec=function(){return ve=!0,null},fe[xe](""),!ve}));if(!oe||!L||ce){var F=/./[xe],te=ie(xe,""[W],(function(ve,fe,me,je,we){var Fe=fe.exec;return Fe===K||Fe===ee.exec?oe&&!we?{done:!0,value:E(F,fe,me,je)}:{done:!0,value:E(ve,me,fe,je)}:{done:!1}}));U(String.prototype,W,te[0]),U(ee,xe,te[1])}be&&O(ee[xe],"sham",!0)}},8745:function(q,X,j){var E=j(616),U=Function.prototype,K=U.apply,H=U.call;q.exports=typeof Reflect=="object"&&Reflect.apply||(E?H.bind(K):function(){return H.apply(K,arguments)})},6080:function(q,X,j){var E=j(7476),U=j(9306),K=j(616),H=E(E.bind);q.exports=function(re,O){return U(re),O===void 0?re:K?H(re,O):function(){return re.apply(O,arguments)}}},616:function(q,X,j){var E=j(9039);q.exports=!E((function(){var U=(function(){}).bind();return typeof U!="function"||U.hasOwnProperty("prototype")}))},566:function(q,X,j){var E=j(9504),U=j(9306),K=j(34),H=j(9297),re=j(7680),O=j(616),$=Function,ee=E([].concat),W=E([].join),ie={};q.exports=O?$.bind:function(ce){var be=U(this),xe=be.prototype,oe=re(arguments,1),L=function(){var F=ee(oe,re(arguments));return this instanceof L?(function(te,ve,fe){if(!H(ie,ve)){for(var me=[],je=0;je]*>)/g,ee=/\$([$&'`]|\d{1,2})/g;q.exports=function(W,ie,ce,be,xe,oe){var L=ce+W.length,F=be.length,te=ee;return xe!==void 0&&(xe=U(xe),te=$),re(oe,te,(function(ve,fe){var me;switch(H(fe,0)){case"$":return"$";case"&":return W;case"`":return O(ie,0,ce);case"'":return O(ie,L);case"<":me=xe[O(fe,1,-1)];break;default:var je=+fe;if(je===0)return ve;if(je>F){var we=K(je/10);return we===0?ve:we<=F?be[we-1]===void 0?H(fe,1):be[we-1]+H(fe,1):ve}me=be[je-1]}return me===void 0?"":me}))}},4576:function(q,X,j){var E=function(U){return U&&U.Math===Math&&U};q.exports=E(typeof globalThis=="object"&&globalThis)||E(typeof window=="object"&&window)||E(typeof self=="object"&&self)||E(typeof j.g=="object"&&j.g)||E(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297:function(q,X,j){var E=j(9504),U=j(8981),K=E({}.hasOwnProperty);q.exports=Object.hasOwn||function(H,re){return K(U(H),re)}},421:function(q){q.exports={}},397:function(q,X,j){var E=j(7751);q.exports=E("document","documentElement")},5917:function(q,X,j){var E=j(3724),U=j(9039),K=j(4055);q.exports=!E&&!U((function(){return Object.defineProperty(K("div"),"a",{get:function(){return 7}}).a!==7}))},7055:function(q,X,j){var E=j(9504),U=j(9039),K=j(2195),H=Object,re=E("".split);q.exports=U((function(){return!H("z").propertyIsEnumerable(0)}))?function(O){return K(O)==="String"?re(O,""):H(O)}:H},3167:function(q,X,j){var E=j(4901),U=j(34),K=j(2967);q.exports=function(H,re,O){var $,ee;return K&&E($=re.constructor)&&$!==O&&U(ee=$.prototype)&&ee!==O.prototype&&K(H,ee),H}},3706:function(q,X,j){var E=j(9504),U=j(4901),K=j(7629),H=E(Function.toString);U(K.inspectSource)||(K.inspectSource=function(re){return H(re)}),q.exports=K.inspectSource},1181:function(q,X,j){var E,U,K,H=j(8622),re=j(4576),O=j(34),$=j(6699),ee=j(9297),W=j(7629),ie=j(6119),ce=j(421),be="Object already initialized",xe=re.TypeError,oe=re.WeakMap;if(H||W.state){var L=W.state||(W.state=new oe);L.get=L.get,L.has=L.has,L.set=L.set,E=function(te,ve){if(L.has(te))throw new xe(be);return ve.facade=te,L.set(te,ve),ve},U=function(te){return L.get(te)||{}},K=function(te){return L.has(te)}}else{var F=ie("state");ce[F]=!0,E=function(te,ve){if(ee(te,F))throw new xe(be);return ve.facade=te,$(te,F,ve),ve},U=function(te){return ee(te,F)?te[F]:{}},K=function(te){return ee(te,F)}}q.exports={set:E,get:U,has:K,enforce:function(te){return K(te)?U(te):E(te,{})},getterFor:function(te){return function(ve){var fe;if(!O(ve)||(fe=U(ve)).type!==te)throw new xe("Incompatible receiver, "+te+" required");return fe}}}},4209:function(q,X,j){var E=j(8227),U=j(6269),K=E("iterator"),H=Array.prototype;q.exports=function(re){return re!==void 0&&(U.Array===re||H[K]===re)}},4376:function(q,X,j){var E=j(2195);q.exports=Array.isArray||function(U){return E(U)==="Array"}},4901:function(q){var X=typeof document=="object"&&document.all;q.exports=X===void 0&&X!==void 0?function(j){return typeof j=="function"||j===X}:function(j){return typeof j=="function"}},3517:function(q,X,j){var E=j(9504),U=j(9039),K=j(4901),H=j(6955),re=j(7751),O=j(3706),$=function(){},ee=re("Reflect","construct"),W=/^\s*(?:class|function)\b/,ie=E(W.exec),ce=!W.test($),be=function(oe){if(!K(oe))return!1;try{return ee($,[],oe),!0}catch{return!1}},xe=function(oe){if(!K(oe))return!1;switch(H(oe)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ce||!!ie(W,O(oe))}catch{return!0}};xe.sham=!0,q.exports=!ee||U((function(){var oe;return be(be.call)||!be(Object)||!be((function(){oe=!0}))||oe}))?xe:be},2796:function(q,X,j){var E=j(9039),U=j(4901),K=/#|\.prototype\./,H=function(W,ie){var ce=O[re(W)];return ce===ee||ce!==$&&(U(ie)?E(ie):!!ie)},re=H.normalize=function(W){return String(W).replace(K,".").toLowerCase()},O=H.data={},$=H.NATIVE="N",ee=H.POLYFILL="P";q.exports=H},2087:function(q,X,j){var E=j(34),U=Math.floor;q.exports=Number.isInteger||function(K){return!E(K)&&isFinite(K)&&U(K)===K}},4117:function(q){q.exports=function(X){return X==null}},34:function(q,X,j){var E=j(4901);q.exports=function(U){return typeof U=="object"?U!==null:E(U)}},3925:function(q,X,j){var E=j(34);q.exports=function(U){return E(U)||U===null}},6395:function(q){q.exports=!1},5810:function(q,X,j){var E=j(34),U=j(1181).get;q.exports=function(K){if(!E(K))return!1;var H=U(K);return!!H&&H.type==="RawJSON"}},788:function(q,X,j){var E=j(34),U=j(2195),K=j(8227)("match");q.exports=function(H){var re;return E(H)&&((re=H[K])!==void 0?!!re:U(H)==="RegExp")}},757:function(q,X,j){var E=j(7751),U=j(4901),K=j(1625),H=j(7040),re=Object;q.exports=H?function(O){return typeof O=="symbol"}:function(O){var $=E("Symbol");return U($)&&K($.prototype,re(O))}},9539:function(q,X,j){var E=j(9565),U=j(8551),K=j(5966);q.exports=function(H,re,O){var $,ee;U(H);try{if(!($=K(H,"return"))){if(re==="throw")throw O;return O}$=E($,H)}catch(W){ee=!0,$=W}if(re==="throw")throw O;if(ee)throw $;return U($),O}},3994:function(q,X,j){var E=j(7657).IteratorPrototype,U=j(2360),K=j(6980),H=j(687),re=j(6269),O=function(){return this};q.exports=function($,ee,W,ie){var ce=ee+" Iterator";return $.prototype=U(E,{next:K(+!ie,W)}),H($,ce,!1,!0),re[ce]=O,$}},1088:function(q,X,j){var E=j(6518),U=j(9565),K=j(6395),H=j(350),re=j(4901),O=j(3994),$=j(2787),ee=j(2967),W=j(687),ie=j(6699),ce=j(6840),be=j(8227),xe=j(6269),oe=j(7657),L=H.PROPER,F=H.CONFIGURABLE,te=oe.IteratorPrototype,ve=oe.BUGGY_SAFARI_ITERATORS,fe=be("iterator"),me="keys",je="values",we="entries",Fe=function(){return this};q.exports=function(He,Oe,_e,Ae,Be,Me,Xe){O(_e,Oe,Ae);var ye,We,Pe,Ke=function(vt){if(vt===Be&&nt)return nt;if(!ve&&vt&&vt in Ce)return Ce[vt];switch(vt){case me:case je:case we:return function(){return new _e(this,vt)}}return function(){return new _e(this)}},Ve=Oe+" Iterator",ke=!1,Ce=He.prototype,$e=Ce[fe]||Ce["@@iterator"]||Be&&Ce[Be],nt=!ve&&$e||Ke(Be),xt=Oe==="Array"&&Ce.entries||$e;if(xt&&(ye=$(xt.call(new He)))!==Object.prototype&&ye.next&&(K||$(ye)===te||(ee?ee(ye,te):re(ye[fe])||ce(ye,fe,Fe)),W(ye,Ve,!0,!0),K&&(xe[Ve]=Fe)),L&&Be===je&&$e&&$e.name!==je&&(!K&&F?ie(Ce,"name",je):(ke=!0,nt=function(){return U($e,this)})),Be)if(We={values:Ke(je),keys:Me?nt:Ke(me),entries:Ke(we)},Xe)for(Pe in We)(ve||ke||!(Pe in Ce))&&ce(Ce,Pe,We[Pe]);else E({target:Oe,proto:!0,forced:ve||ke},We);return K&&!Xe||Ce[fe]===nt||ce(Ce,fe,nt,{name:Be}),xe[Oe]=nt,We}},7657:function(q,X,j){var E,U,K,H=j(9039),re=j(4901),O=j(34),$=j(2360),ee=j(2787),W=j(6840),ie=j(8227),ce=j(6395),be=ie("iterator"),xe=!1;[].keys&&("next"in(K=[].keys())?(U=ee(ee(K)))!==Object.prototype&&(E=U):xe=!0),!O(E)||H((function(){var oe={};return E[be].call(oe)!==oe}))?E={}:ce&&(E=$(E)),re(E[be])||W(E,be,(function(){return this})),q.exports={IteratorPrototype:E,BUGGY_SAFARI_ITERATORS:xe}},6269:function(q){q.exports={}},6198:function(q,X,j){var E=j(8014);q.exports=function(U){return E(U.length)}},283:function(q,X,j){var E=j(9504),U=j(9039),K=j(4901),H=j(9297),re=j(3724),O=j(350).CONFIGURABLE,$=j(3706),ee=j(1181),W=ee.enforce,ie=ee.get,ce=String,be=Object.defineProperty,xe=E("".slice),oe=E("".replace),L=E([].join),F=re&&!U((function(){return be((function(){}),"length",{value:8}).length!==8})),te=String(String).split("String"),ve=q.exports=function(fe,me,je){xe(ce(me),0,7)==="Symbol("&&(me="["+oe(ce(me),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),je&&je.getter&&(me="get "+me),je&&je.setter&&(me="set "+me),(!H(fe,"name")||O&&fe.name!==me)&&(re?be(fe,"name",{value:me,configurable:!0}):fe.name=me),F&&je&&H(je,"arity")&&fe.length!==je.arity&&be(fe,"length",{value:je.arity});try{je&&H(je,"constructor")&&je.constructor?re&&be(fe,"prototype",{writable:!1}):fe.prototype&&(fe.prototype=void 0)}catch{}var we=W(fe);return H(we,"source")||(we.source=L(te,typeof me=="string"?me:"")),fe};Function.prototype.toString=ve((function(){return K(this)&&ie(this).source||$(this)}),"toString")},741:function(q){var X=Math.ceil,j=Math.floor;q.exports=Math.trunc||function(E){var U=+E;return(U>0?j:X)(U)}},7819:function(q,X,j){var E=j(9039);q.exports=!E((function(){var U="9007199254740993",K=JSON.rawJSON(U);return!JSON.isRawJSON(K)||JSON.stringify(K)!==U}))},5749:function(q,X,j){var E=j(788),U=TypeError;q.exports=function(K){if(E(K))throw new U("The method doesn't accept regular expressions");return K}},4213:function(q,X,j){var E=j(3724),U=j(9504),K=j(9565),H=j(9039),re=j(1072),O=j(3717),$=j(8773),ee=j(8981),W=j(7055),ie=Object.assign,ce=Object.defineProperty,be=U([].concat);q.exports=!ie||H((function(){if(E&&ie({b:1},ie(ce({},"a",{enumerable:!0,get:function(){ce(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var xe={},oe={},L=Symbol("assign detection"),F="abcdefghijklmnopqrst";return xe[L]=7,F.split("").forEach((function(te){oe[te]=te})),ie({},xe)[L]!==7||re(ie({},oe)).join("")!==F}))?function(xe,oe){for(var L=ee(xe),F=arguments.length,te=1,ve=O.f,fe=$.f;F>te;)for(var me,je=W(arguments[te++]),we=ve?be(re(je),ve(je)):re(je),Fe=we.length,He=0;Fe>He;)me=we[He++],E&&!K(fe,je,me)||(L[me]=je[me]);return L}:ie},2360:function(q,X,j){var E,U=j(8551),K=j(6801),H=j(8727),re=j(421),O=j(397),$=j(4055),ee=j(6119),W="prototype",ie="script",ce=ee("IE_PROTO"),be=function(){},xe=function(F){return"<"+ie+">"+F+""},oe=function(F){F.write(xe("")),F.close();var te=F.parentWindow.Object;return F=null,te},L=function(){try{E=new ActiveXObject("htmlfile")}catch{}var F,te,ve;L=typeof document<"u"?document.domain&&E?oe(E):(te=$("iframe"),ve="java"+ie+":",te.style.display="none",O.appendChild(te),te.src=String(ve),(F=te.contentWindow.document).open(),F.write(xe("document.F=Object")),F.close(),F.F):oe(E);for(var fe=H.length;fe--;)delete L[W][H[fe]];return L()};re[ce]=!0,q.exports=Object.create||function(F,te){var ve;return F!==null?(be[W]=U(F),ve=new be,be[W]=null,ve[ce]=F):ve=L(),te===void 0?ve:K.f(ve,te)}},6801:function(q,X,j){var E=j(3724),U=j(8686),K=j(4913),H=j(8551),re=j(5397),O=j(1072);X.f=E&&!U?Object.defineProperties:function($,ee){H($);for(var W,ie=re(ee),ce=O(ee),be=ce.length,xe=0;be>xe;)K.f($,W=ce[xe++],ie[W]);return $}},4913:function(q,X,j){var E=j(3724),U=j(5917),K=j(8686),H=j(8551),re=j(6969),O=TypeError,$=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,W="enumerable",ie="configurable",ce="writable";X.f=E?K?function(be,xe,oe){if(H(be),xe=re(xe),H(oe),typeof be=="function"&&xe==="prototype"&&"value"in oe&&ce in oe&&!oe[ce]){var L=ee(be,xe);L&&L[ce]&&(be[xe]=oe.value,oe={configurable:ie in oe?oe[ie]:L[ie],enumerable:W in oe?oe[W]:L[W],writable:!1})}return $(be,xe,oe)}:$:function(be,xe,oe){if(H(be),xe=re(xe),H(oe),U)try{return $(be,xe,oe)}catch{}if("get"in oe||"set"in oe)throw new O("Accessors not supported");return"value"in oe&&(be[xe]=oe.value),be}},7347:function(q,X,j){var E=j(3724),U=j(9565),K=j(8773),H=j(6980),re=j(5397),O=j(6969),$=j(9297),ee=j(5917),W=Object.getOwnPropertyDescriptor;X.f=E?W:function(ie,ce){if(ie=re(ie),ce=O(ce),ee)try{return W(ie,ce)}catch{}if($(ie,ce))return H(!U(K.f,ie,ce),ie[ce])}},298:function(q,X,j){var E=j(2195),U=j(5397),K=j(8480).f,H=j(7680),re=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];q.exports.f=function(O){return re&&E(O)==="Window"?(function($){try{return K($)}catch{return H(re)}})(O):K(U(O))}},8480:function(q,X,j){var E=j(1828),U=j(8727).concat("length","prototype");X.f=Object.getOwnPropertyNames||function(K){return E(K,U)}},3717:function(q,X){X.f=Object.getOwnPropertySymbols},2787:function(q,X,j){var E=j(9297),U=j(4901),K=j(8981),H=j(6119),re=j(2211),O=H("IE_PROTO"),$=Object,ee=$.prototype;q.exports=re?$.getPrototypeOf:function(W){var ie=K(W);if(E(ie,O))return ie[O];var ce=ie.constructor;return U(ce)&&ie instanceof ce?ce.prototype:ie instanceof $?ee:null}},1625:function(q,X,j){var E=j(9504);q.exports=E({}.isPrototypeOf)},1828:function(q,X,j){var E=j(9504),U=j(9297),K=j(5397),H=j(9617).indexOf,re=j(421),O=E([].push);q.exports=function($,ee){var W,ie=K($),ce=0,be=[];for(W in ie)!U(re,W)&&U(ie,W)&&O(be,W);for(;ee.length>ce;)U(ie,W=ee[ce++])&&(~H(be,W)||O(be,W));return be}},1072:function(q,X,j){var E=j(1828),U=j(8727);q.exports=Object.keys||function(K){return E(K,U)}},8773:function(q,X){var j={}.propertyIsEnumerable,E=Object.getOwnPropertyDescriptor,U=E&&!j.call({1:2},1);X.f=U?function(K){var H=E(this,K);return!!H&&H.enumerable}:j},2551:function(q,X,j){var E=j(6395),U=j(4576),K=j(9039),H=j(3607);q.exports=E||!K((function(){if(!(H&&H<535)){var re=Math.random();__defineSetter__.call(null,re,(function(){})),delete U[re]}}))},2967:function(q,X,j){var E=j(6706),U=j(34),K=j(7750),H=j(3506);q.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var re,O=!1,$={};try{(re=E(Object.prototype,"__proto__","set"))($,[]),O=$ instanceof Array}catch{}return function(ee,W){return K(ee),H(W),U(ee)&&(O?re(ee,W):ee.__proto__=W),ee}})():void 0)},3179:function(q,X,j){var E=j(2140),U=j(6955);q.exports=E?{}.toString:function(){return"[object "+U(this)+"]"}},4270:function(q,X,j){var E=j(9565),U=j(4901),K=j(34),H=TypeError;q.exports=function(re,O){var $,ee;if(O==="string"&&U($=re.toString)&&!K(ee=E($,re))||U($=re.valueOf)&&!K(ee=E($,re))||O!=="string"&&U($=re.toString)&&!K(ee=E($,re)))return ee;throw new H("Can't convert object to primitive value")}},5031:function(q,X,j){var E=j(7751),U=j(9504),K=j(8480),H=j(3717),re=j(8551),O=U([].concat);q.exports=E("Reflect","ownKeys")||function($){var ee=K.f(re($)),W=H.f;return W?O(ee,W($)):ee}},8235:function(q,X,j){var E=j(9504),U=j(9297),K=SyntaxError,H=parseInt,re=String.fromCharCode,O=E("".charAt),$=E("".slice),ee=E(/./.exec),W={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":` +`)[0]}),R&&i.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?i.jsx(Vl,{className:"w-3.5 h-3.5"}):i.jsx(In,{className:"w-3.5 h-3.5"})})]})},D)})})}),i.jsx("div",{className:"flex items-center justify-between p-3 border-t border-bambu-dark-tertiary text-sm text-bambu-gray",children:m?i.jsxs("span",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"w-2 h-2 bg-green-500 rounded-full animate-pulse"}),"Auto-refreshing every 2 seconds"]}):i.jsx("span",{children:"Click Start to enable live log streaming"})})]})]})}function cnt(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function Ai({icon:t,label:e,value:n,subValue:r,color:a="text-bambu-green"}){return i.jsxs("div",{className:"flex items-start gap-3 p-4 bg-bambu-dark rounded-lg",children:[i.jsx("div",{className:`p-2 rounded-lg bg-bambu-dark-tertiary ${a}`,children:i.jsx(t,{className:"w-5 h-5"})}),i.jsxs("div",{className:"flex-1 min-w-0",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:e}),i.jsx("p",{className:"text-lg font-semibold text-white truncate",children:n}),r&&i.jsx("p",{className:"text-xs text-bambu-gray mt-0.5",children:r})]})]})}function $Y({percent:t,color:e="bg-bambu-green"}){return i.jsx("div",{className:"w-full h-2 bg-bambu-dark rounded-full overflow-hidden",children:i.jsx("div",{className:`h-full ${e} transition-all duration-300`,style:{width:`${Math.min(100,t)}%`}})})}function Wm({title:t,icon:e,children:n}){return i.jsxs(Pt,{className:"p-6",children:[i.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[i.jsx(e,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:t})]}),n]})}function unt(){const{t}=Dt(),e=sn(),[n,r]=w.useState(null),[a,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:u,refetch:d,isFetching:m}=et({queryKey:["systemInfo"],queryFn:ge.getSystemInfo,refetchInterval:3e4}),{data:p}=et({queryKey:["debugLogging"],queryFn:Kb.getDebugLoggingState,staleTime:10*1e3,refetchInterval:10*1e3}),{data:f}=et({queryKey:["settings"],queryFn:ge.getSettings}),{data:y}=et({queryKey:["library-stats"],queryFn:ge.getLibraryStats}),v=f?.time_format||"system",b=async()=>{l(!0);try{const C=await Kb.setDebugLogging(!p?.enabled);e.setQueryData(["debugLogging"],C)}catch(C){console.error("Failed to toggle debug logging:",C)}finally{l(!1)}},g=async()=>{r(null),s(!0);try{await Kb.downloadSupportBundle()}catch(C){r(C instanceof Error?C.message:"Failed to download support bundle")}finally{s(!1)}};if(u)return i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx(ft,{className:"w-8 h-8 text-bambu-green animate-spin"})});if(!c)return i.jsx("div",{className:"p-6 text-center text-bambu-gray",children:t("system.failedToLoad","Failed to load system information")});const _=c.storage.disk_percent_used>90?"bg-red-500":c.storage.disk_percent_used>75?"bg-yellow-500":"bg-bambu-green",N=c.memory.percent_used>90?"bg-red-500":c.memory.percent_used>75?"bg-yellow-500":"bg-bambu-green";return i.jsxs("div",{className:"p-6 space-y-6",children:[i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{children:[i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("system.title","System Information")}),i.jsx("p",{className:"text-bambu-gray mt-1",children:t("system.subtitle","Monitor system resources and database statistics")})]}),i.jsxs("button",{onClick:()=>d(),disabled:m,className:"flex items-center gap-2 px-4 py-2 bg-bambu-dark-secondary hover:bg-bambu-dark-tertiary rounded-lg transition-colors disabled:opacity-50",children:[i.jsx(Sr,{className:`w-4 h-4 ${m?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),i.jsx(Wm,{title:t("system.application","Application"),icon:Op,children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Ai,{icon:Op,label:t("system.version","Version"),value:`v${c.app.version}`}),i.jsx(Ai,{icon:Zn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),i.jsx(Ai,{icon:Op,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),i.jsx(Wm,{title:t("support.title","Support & Troubleshooting"),icon:wfe,children:i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.description","Enable debug logging to capture detailed information, then download a support bundle to share when reporting issues.")}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`p-2 rounded-lg ${p?.enabled?"bg-amber-500/20 text-amber-500":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:i.jsx(ux,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-white",children:t("support.debugLogging","Debug Logging")}),i.jsxs("p",{className:"text-sm text-bambu-gray",children:[p?.enabled?t("support.debugLoggingEnabled","Capturing detailed logs"):t("support.debugLoggingDisabled","Normal logging level"),p?.enabled&&p.duration_seconds!==null&&i.jsxs("span",{className:"text-amber-400 ml-2",children:["(",Math.floor(p.duration_seconds/60),"m ",p.duration_seconds%60,"s)"]})]})]})]}),i.jsxs("button",{onClick:b,disabled:o,className:`px-4 py-2 rounded-lg font-medium transition-colors flex items-center gap-2 ${p?.enabled?"bg-amber-500/20 text-amber-400 hover:bg-amber-500/30":"bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30"} disabled:opacity-50`,children:[o&&i.jsx(ft,{className:"w-4 h-4 animate-spin"}),p?.enabled?t("support.disableDebug","Disable"):t("support.enableDebug","Enable")]})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"p-2 rounded-lg bg-bambu-dark-tertiary text-bambu-green",children:i.jsx(fi,{className:"w-5 h-5"})}),i.jsxs("div",{children:[i.jsx("p",{className:"font-medium text-white",children:t("support.supportBundle","Support Bundle")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("support.supportBundleDescription","Download system info and logs as a ZIP file")})]})]}),i.jsxs("button",{onClick:g,disabled:a||!p?.enabled,className:"px-4 py-2 rounded-lg font-medium bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30 transition-colors flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed",title:p?.enabled?void 0:t("support.enableDebugFirst","Enable debug logging first"),children:[a&&i.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.download","Download")]})]}),n&&i.jsx("div",{className:"p-3 bg-red-500/20 border border-red-500/30 rounded-lg text-red-400 text-sm",children:n}),!p?.enabled&&i.jsx("div",{className:"p-4 bg-bambu-dark-tertiary/50 rounded-lg",children:i.jsxs("p",{className:"text-sm text-bambu-gray",children:[i.jsx("span",{className:"text-amber-400 font-medium",children:t("support.instructions","To report an issue:")}),i.jsx("br",{}),"1. ",t("support.step1","Enable debug logging"),i.jsx("br",{}),"2. ",t("support.step2","Reproduce the issue"),i.jsx("br",{}),"3. ",t("support.step3","Download the support bundle"),i.jsx("br",{}),"4. ",t("support.step4","Attach the ZIP file to your issue report")]})}),i.jsxs("div",{className:"p-4 bg-bambu-dark rounded-lg space-y-3",children:[i.jsx("p",{className:"text-sm font-medium text-white",children:t("support.privacyTitle","What's in the support bundle?")}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 text-sm",children:[i.jsxs("div",{children:[i.jsx("p",{className:"text-bambu-green font-medium mb-1",children:t("support.collected","Collected:")}),i.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[i.jsxs("li",{children:["• ",t("support.collectItem1","App version and debug mode")]}),i.jsxs("li",{children:["• ",t("support.collectItem2","OS, architecture, Python version")]}),i.jsxs("li",{children:["• ",t("support.collectItem3","Database statistics (counts only)")]}),i.jsxs("li",{children:["• ",t("support.collectItem4","Printer models and nozzle counts")]}),i.jsxs("li",{children:["• ",t("support.collectItem5","Non-sensitive settings (themes, formats)")]}),i.jsxs("li",{children:["• ",t("support.collectItem6","Debug logs (sanitized)")]}),i.jsxs("li",{children:["• ",t("support.collectItem7","Printer connectivity and firmware versions")]}),i.jsxs("li",{children:["• ",t("support.collectItem8","Integration status (Spoolman, MQTT, HA)")]}),i.jsxs("li",{children:["• ",t("support.collectItem9","Network interfaces (subnets only)")]}),i.jsxs("li",{children:["• ",t("support.collectItem10","Python package versions")]}),i.jsxs("li",{children:["• ",t("support.collectItem11","Database health checks")]}),i.jsxs("li",{children:["• ",t("support.collectItem12","Docker environment details")]})]})]}),i.jsxs("div",{children:[i.jsx("p",{className:"text-red-400 font-medium mb-1",children:t("support.notCollected","NOT collected:")}),i.jsxs("ul",{className:"text-bambu-gray space-y-0.5",children:[i.jsxs("li",{children:["• ",t("support.notItem1","Printer names and serial numbers")]}),i.jsxs("li",{children:["• ",t("support.notItem2","Access codes and passwords")]}),i.jsxs("li",{children:["• ",t("support.notItem3","Email addresses")]}),i.jsxs("li",{children:["• ",t("support.notItem4","API keys and tokens")]}),i.jsxs("li",{children:["• ",t("support.notItem5","Webhook URLs")]}),i.jsxs("li",{children:["• ",t("support.notItem6","Your hostname or username")]}),i.jsxs("li",{children:["• ",t("support.notItem7","IP addresses")]})]})]})]}),i.jsx("p",{className:"text-xs text-bambu-gray/70",children:t("support.privacyNote","Email addresses in logs are replaced with [EMAIL], printer names with [PRINTER], serial numbers with [SERIAL], and IP addresses with [IP].")})]}),i.jsx(lnt,{})]})}),i.jsxs(Wm,{title:t("system.database","Database"),icon:hu,children:[i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(Ai,{icon:Vs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),i.jsx(Ai,{icon:vc,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),i.jsx(Ai,{icon:Vi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),i.jsx(Ai,{icon:ft,label:t("system.printing","Printing"),value:c.database.archives_printing,color:"text-yellow-500"})]}),i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Ai,{icon:_r,label:t("system.printers","Printers"),value:c.database.printers}),i.jsx(Ai,{icon:Sw,label:t("system.filaments","Filaments"),value:c.database.filaments}),i.jsx(Ai,{icon:vs,label:t("system.projects","Projects"),value:c.database.projects}),i.jsx(Ai,{icon:Ul,label:t("system.smartPlugs","Smart Plugs"),value:c.database.smart_plugs})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4",children:[i.jsx(Ai,{icon:Zn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),i.jsx(Ai,{icon:Vs,label:t("system.totalFilament","Total Filament Used"),value:`${c.database.total_filament_kg} kg`,subValue:`${c.database.total_filament_grams.toLocaleString()} g`})]})]}),i.jsxs(Wm,{title:t("system.connectedPrinters","Connected Printers"),icon:_r,children:[i.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[i.jsx("div",{className:"text-3xl font-bold text-bambu-green",children:c.printers.connected}),i.jsx("div",{className:"text-bambu-gray",children:t("system.ofTotal","of {{total}} printers connected",{total:c.printers.total})})]}),c.printers.connected_list.length>0?i.jsx("div",{className:"space-y-2",children:c.printers.connected_list.map(C=>i.jsxs("div",{className:"flex items-center justify-between p-3 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:"w-2 h-2 rounded-full bg-bambu-green"}),i.jsx("span",{className:"font-medium text-white",children:C.name})]}),i.jsxs("div",{className:"flex items-center gap-4 text-sm text-bambu-gray",children:[i.jsx("span",{children:C.model}),i.jsx("span",{className:`px-2 py-0.5 rounded ${C.state==="RUNNING"?"bg-bambu-green/20 text-bambu-green":C.state==="IDLE"?"bg-blue-500/20 text-blue-400":"bg-bambu-dark-tertiary"}`,children:C.state})]})]},C.id))}):i.jsx("p",{className:"text-bambu-gray",children:t("system.noPrintersConnected","No printers connected")})]}),i.jsx(Wm,{title:t("system.storage","Storage"),icon:Vx,children:i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:t("system.diskUsage","Disk Usage")}),i.jsxs("span",{className:"text-white",children:[c.storage.disk_used_formatted," / ",c.storage.disk_total_formatted]})]}),i.jsx($Y,{percent:c.storage.disk_percent_used,color:_}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.storage.disk_free_formatted," ",t("system.free","free")," (",(100-c.storage.disk_percent_used).toFixed(1),"%)"]})]}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Ai,{icon:Vs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),i.jsx(Ai,{icon:hu,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),y&&i.jsx(Ai,{icon:Ac,label:t("system.fileManagerStorage","File Manager"),value:cnt(y.total_size_bytes),subValue:`${y.total_files} files, ${y.total_folders} folders`})]})]})}),i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[i.jsx(Wm,{title:t("system.memory","Memory"),icon:Jfe,children:i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{children:[i.jsxs("div",{className:"flex justify-between text-sm mb-1",children:[i.jsx("span",{className:"text-bambu-gray",children:t("system.memoryUsage","Memory Usage")}),i.jsxs("span",{className:"text-white",children:[c.memory.used_formatted," / ",c.memory.total_formatted]})]}),i.jsx($Y,{percent:c.memory.percent_used,color:N}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),i.jsx(Wm,{title:t("system.cpu","CPU"),icon:m_,children:i.jsx("div",{className:"space-y-4",children:i.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[i.jsx(Ai,{icon:m_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),i.jsx(Ai,{icon:m_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),i.jsx(Wm,{title:t("system.systemDetails","System Details"),icon:Op,children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Ai,{icon:Op,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),i.jsx(Ai,{icon:m_,label:t("system.architecture","Architecture"),value:c.system.architecture}),i.jsx(Ai,{icon:Op,label:t("system.python","Python"),value:c.system.python_version}),i.jsx(Ai,{icon:Zn,label:t("system.bootTime","Boot Time"),value:Df(c.system.boot_time,v)})]})})]})}function dnt(){const t=ol(),{t:e}=Dt(),{login:n}=Ar(),{showToast:r}=bn(),{mode:a}=ng(),[s,o]=w.useState(""),[l,c]=w.useState(""),[u,d]=w.useState(!1),[m,p]=w.useState(""),{data:f}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),y=gt({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=gt({mutationFn:_=>ge.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),d(!1),p("")},onError:_=>{r(_.message,"error")}}),b=_=>{if(_.preventDefault(),!s||!l){r(e("login.enterCredentials"),"error");return}y.mutate()},g=_=>{if(_.preventDefault(),!m){r("Please enter your email address","error");return}v.mutate(m)};return i.jsxs("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:[i.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-6",children:i.jsx("img",{src:a==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),i.jsx("h2",{className:"text-3xl font-bold text-white",children:e("login.title")}),i.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("login.subtitle")})]}),i.jsxs("form",{className:"mt-8 space-y-6",onSubmit:b,children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{children:[i.jsx("label",{htmlFor:"username",className:"block text-sm font-medium text-white mb-2",children:f?.advanced_auth_enabled?e("login.usernameOrEmail")||"Username or Email":e("login.username")}),i.jsx("input",{id:"username",type:"text",required:!0,value:s,onChange:_=>o(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:f?.advanced_auth_enabled?e("login.usernameOrEmailPlaceholder")||"Enter your username or email":e("login.usernamePlaceholder"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"password",className:"block text-sm font-medium text-white mb-2",children:e("login.password")}),i.jsx("input",{id:"password",type:"password",required:!0,value:l,onChange:_=>c(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.passwordPlaceholder"),autoComplete:"current-password"})]})]}),i.jsx("div",{children:i.jsx("button",{type:"submit",disabled:y.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:y.isPending?e("login.signingIn"):e("login.signIn")})}),f?.advanced_auth_enabled&&i.jsx("div",{className:"text-center",children:i.jsx("button",{type:"button",onClick:()=>d(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),u&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>d(!1),children:i.jsxs(Pt,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[i.jsx(Bn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(mx,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),i.jsx(ze,{variant:"ghost",size:"sm",onClick:()=>{d(!1),p("")},children:i.jsx(Ht,{className:"w-5 h-5"})})]})}),i.jsx(Et,{children:f?.advanced_auth_enabled?i.jsxs("form",{onSubmit:g,className:"space-y-4",children:[i.jsx("p",{className:"text-bambu-gray text-sm",children:e("login.forgotPasswordEmailMessage")||"Enter your email address and we'll send you a new password."}),i.jsxs("div",{children:[i.jsx("label",{htmlFor:"forgot-email",className:"block text-sm font-medium text-white mb-2",children:e("login.emailAddress")||"Email Address"}),i.jsx("input",{id:"forgot-email",type:"email",required:!0,value:m,onChange:_=>p(_.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("login.emailPlaceholder")||"your.email@example.com"})]}),i.jsxs("div",{className:"flex gap-2",children:[i.jsx(ze,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{d(!1),p("")},children:e("login.cancel")||"Cancel"}),i.jsx(ze,{type:"submit",className:"flex-1",disabled:v.isPending,children:v.isPending?e("login.sending")||"Sending...":e("login.sendResetEmail")||"Send Reset Email"})]})]}):i.jsxs("div",{className:"space-y-4",children:[i.jsx("p",{className:"text-bambu-gray",children:e("login.forgotPasswordMessage")}),i.jsxs("div",{className:"bg-bambu-dark rounded-lg p-4 space-y-2",children:[i.jsx("p",{className:"text-sm text-white font-medium",children:e("login.howToReset")}),i.jsxs("ol",{className:"text-sm text-bambu-gray space-y-1 list-decimal list-inside",children:[i.jsx("li",{children:e("login.resetStep1")}),i.jsx("li",{children:e("login.resetStep2")}),i.jsx("li",{children:e("login.resetStep3")}),i.jsx("li",{children:e("login.resetStep4")})]})]}),i.jsx(ze,{variant:"secondary",className:"w-full",onClick:()=>d(!1),children:e("login.gotIt")})]})})]})})]})}function mnt(){const t=ol(),{t:e}=Dt(),{showToast:n}=bn(),{mode:r}=ng(),{refreshAuth:a}=Ar(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[u,d]=w.useState(""),[m,p]=w.useState(""),f=gt({mutationFn:()=>ge.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?u:void 0}),onSuccess:async v=>{await a(),v.auth_enabled?v.admin_created?(n(e("setup.toast.authEnabledAdminCreated")),t("/login")):(n(e("setup.toast.authEnabledExistingAdmins")),t("/login")):(n(e("setup.toast.setupCompleted")),t("/"))},onError:v=>{n(v.message,"error")}}),y=v=>{if(v.preventDefault(),s&&(l||u)){if(!l||!u){n(e("setup.toast.enterBothCredentials"),"error");return}if(u!==m){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(u.length<6){n(e("setup.toast.passwordTooShort"),"error");return}}f.mutate()};return i.jsx("div",{className:"min-h-screen flex items-center justify-center bg-bambu-dark p-4",children:i.jsxs("div",{className:"max-w-md w-full space-y-8 p-8 bg-gradient-to-br from-bambu-card to-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary shadow-lg",children:[i.jsxs("div",{className:"text-center",children:[i.jsx("div",{className:"flex items-center justify-center mb-6",children:i.jsx("img",{src:r==="dark"?"/img/bambuddy_logo_dark_transparent.png":"/img/bambuddy_logo_light.png",alt:"Bambuddy",className:"h-16"})}),i.jsx("h2",{className:"text-3xl font-bold text-white",children:e("setup.title")}),i.jsx("p",{className:"mt-2 text-sm text-bambu-gray",children:e("setup.subtitle")})]}),i.jsxs("form",{className:"mt-8 space-y-6",onSubmit:y,children:[i.jsxs("div",{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center p-4 bg-bambu-dark-secondary/50 rounded-lg border border-bambu-dark-tertiary",children:[i.jsx("input",{id:"auth-enabled",type:"checkbox",checked:s,onChange:v=>o(v.target.checked),className:"h-4 w-4 text-bambu-green focus:ring-bambu-green border-bambu-dark-tertiary rounded bg-bambu-dark-secondary"}),i.jsx("label",{htmlFor:"auth-enabled",className:"ml-3 block text-sm font-medium text-white",children:e("setup.enableAuth")})]}),s&&i.jsxs("div",{className:"space-y-4 mt-4",children:[i.jsx("div",{className:"p-3 bg-bambu-dark-secondary/50 border border-bambu-dark-tertiary rounded-lg",children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx(Hs,{className:"w-4 h-4 text-bambu-green mt-0.5 flex-shrink-0"}),i.jsxs("div",{className:"text-sm text-bambu-gray",children:[i.jsx("p",{className:"text-white font-medium mb-1",children:e("setup.adminAccount")}),i.jsx("p",{children:e("setup.adminAccountDesc")})]})]})}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"admin-username",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminUsername")," ",i.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),i.jsx("input",{id:"admin-username",type:"text",value:l,onChange:v=>c(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminUsernamePlaceholder"),autoComplete:"username"})]}),i.jsxs("div",{children:[i.jsxs("label",{htmlFor:"admin-password",className:"block text-sm font-medium text-white mb-2",children:[e("setup.adminPassword")," ",i.jsx("span",{className:"text-bambu-gray text-xs",children:e("setup.optionalIfAdminExists")})]}),i.jsx("input",{id:"admin-password",type:"password",value:u,onChange:v=>d(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.adminPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]}),u&&i.jsxs("div",{children:[i.jsx("label",{htmlFor:"confirm-password",className:"block text-sm font-medium text-white mb-2",children:e("setup.confirmPassword")}),i.jsx("input",{id:"confirm-password",type:"password",value:m,onChange:v=>p(v.target.value),className:"block w-full px-4 py-3 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg text-white placeholder-bambu-gray focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:border-bambu-green transition-colors",placeholder:e("setup.confirmPasswordPlaceholder"),minLength:6,autoComplete:"new-password"})]})]})]}),i.jsx("div",{children:i.jsx("button",{type:"submit",disabled:f.isPending,className:"w-full flex justify-center py-3 px-4 bg-bambu-green hover:bg-bambu-green-light text-white font-medium rounded-lg shadow-lg shadow-bambu-green/20 hover:shadow-bambu-green/30 focus:outline-none focus:ring-2 focus:ring-bambu-green/50 focus:ring-offset-2 focus:ring-offset-bambu-dark-secondary transition-all disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:bg-bambu-green",children:f.isPending?e("setup.settingUp"):e("setup.completeSetup")})})]})]})})}function hnt(){const{t}=Dt(),{user:e}=Ar(),{showToast:n}=bn(),r=sn(),a=ol(),[s,o]=w.useState(!0),[l,c]=w.useState(!0),[u,d]=w.useState(!0),[m,p]=w.useState(!0),[f,y]=w.useState(!1),{data:v,isLoading:b}=et({queryKey:["advancedAuthStatus"],queryFn:ge.getAdvancedAuthStatus,staleTime:300*1e3}),{data:g,isLoading:_}=et({queryKey:["settings"],queryFn:ge.getSettings,staleTime:300*1e3}),{data:N,isLoading:C}=et({queryKey:["user-email-preferences"],queryFn:()=>ge.getUserEmailPreferences()});w.useEffect(()=>{(v&&!v.advanced_auth_enabled||g&&!g.user_notifications_enabled)&&a("/settings",{replace:!0})},[v,g,a]),w.useEffect(()=>{N&&(o(N.notify_print_start),c(N.notify_print_complete),d(N.notify_print_failed),p(N.notify_print_stopped),y(!1))},[N]);const k=gt({mutationFn:()=>ge.updateUserEmailPreferences({notify_print_start:s,notify_print_complete:l,notify_print_failed:u,notify_print_stopped:m}),onSuccess:()=>{r.invalidateQueries({queryKey:["user-email-preferences"]}),y(!1),n(t("notifications.userEmail.saveSuccess"),"success")},onError:T=>{n(T.message||t("notifications.userEmail.saveError"),"error")}}),P=(T,D)=>{T(!D),y(!0)};return C||b||_?i.jsx("div",{className:"flex items-center justify-center h-64",children:i.jsx(ft,{className:"w-8 h-8 animate-spin text-bambu-green"})}):i.jsxs("div",{className:"p-4 md:p-6 max-w-2xl mx-auto",children:[i.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[i.jsx(_h,{className:"w-7 h-7 text-bambu-green"}),i.jsx("h1",{className:"text-2xl font-bold text-white",children:t("notifications.userEmail.title")})]}),i.jsx(Pt,{className:"mb-6 border-blue-500/30 bg-blue-500/5",children:i.jsx(Et,{className:"py-4",children:i.jsxs("div",{className:"flex items-start gap-3",children:[i.jsx("div",{className:"w-10 h-10 rounded-full flex items-center justify-center bg-blue-500/20 flex-shrink-0",children:i.jsx(mx,{className:"w-5 h-5 text-blue-400"})}),i.jsxs("div",{children:[i.jsx("h3",{className:"text-white font-medium",children:t("notifications.userEmail.emailNotifications")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t("notifications.userEmail.emailNotificationsDesc")}),e?.email?i.jsxs("p",{className:"text-sm text-blue-400 mt-2",children:[t("notifications.userEmail.sendingTo"),": ",i.jsx("strong",{children:e.email})]}):i.jsx("p",{className:"text-sm text-yellow-400 mt-2",children:t("notifications.userEmail.noEmailWarning")})]})]})})}),i.jsxs(Pt,{className:"mb-6",children:[i.jsxs(Bn,{children:[i.jsx("h2",{className:"text-lg font-semibold text-white",children:t("notifications.userEmail.printJobNotifications")}),i.jsx("p",{className:"text-sm text-bambu-gray mt-1",children:t("notifications.userEmail.printJobNotificationsDesc")})]}),i.jsxs(Et,{className:"space-y-4",children:[i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${s?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${s?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobStarts")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobStartsDesc")})]})]}),i.jsx("button",{onClick:()=>P(o,s),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${s?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":s,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${s?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${l?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${l?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobFinishes")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobFinishesDesc")})]})]}),i.jsx("button",{onClick:()=>P(c,l),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${l?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":l,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${l?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${u?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${u?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printErrors")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printErrorsDesc")})]})]}),i.jsx("button",{onClick:()=>P(d,u),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${u?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":u,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${u?"translate-x-6":"translate-x-1"}`})})]}),i.jsxs("div",{className:"flex items-center justify-between p-4 bg-bambu-dark rounded-lg",children:[i.jsxs("div",{className:"flex items-center gap-3",children:[i.jsx("div",{className:`w-10 h-10 rounded-full flex items-center justify-center ${m?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(vc,{className:`w-5 h-5 ${m?"text-bambu-green":"text-bambu-gray"}`})}),i.jsxs("div",{children:[i.jsx("p",{className:"text-white font-medium",children:t("notifications.userEmail.printJobStops")}),i.jsx("p",{className:"text-sm text-bambu-gray",children:t("notifications.userEmail.printJobStopsDesc")})]})]}),i.jsx("button",{onClick:()=>P(p,m),className:`relative inline-flex h-6 w-11 items-center rounded-full transition-colors focus:outline-none focus:ring-2 focus:ring-bambu-green focus:ring-offset-2 focus:ring-offset-bambu-dark ${m?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":m,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${m?"translate-x-6":"translate-x-1"}`})})]})]})]}),i.jsx("div",{className:"flex justify-end",children:i.jsx(ze,{onClick:()=>k.mutate(),disabled:!f||k.isPending||!e?.email,children:k.isPending?i.jsxs(i.Fragment,{children:[i.jsx(ft,{className:"w-4 h-4 animate-spin"}),t("common.saving")]}):i.jsxs(i.Fragment,{children:[i.jsx(as,{className:"w-4 h-4"}),t("common.save")]})})})]})}function pnt(){const t=w.useRef(null),e=w.useRef(null),n=sn(),[r,a]=w.useState(!1),s=w.useRef(new Set),o=w.useRef(null),l=w.useRef(new Map),c=w.useRef(null),u=w.useRef([]),d=w.useRef(!1),m=w.useRef(()=>{}),p=w.useCallback(()=>{if(d.current||u.current.length===0)return;d.current=!0;const _=()=>{const N=u.current.shift();N?requestAnimationFrame(()=>{m.current(N),u.current.length>0?setTimeout(_,16):d.current=!1}):d.current=!1};_()},[]),f=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const N=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,C=new WebSocket(N);let k=null;C.onopen=()=>{console.log("[WebSocket] Connected"),a(!0),k=window.setInterval(()=>{C.readyState===WebSocket.OPEN&&C.send(JSON.stringify({type:"ping"}))},3e4)},C.onmessage=P=>{try{const T=JSON.parse(P.data);T.type==="printer_status"&&T.printer_id!==void 0&&T.data?m.current(T):(u.current.push(T),p())}catch{}},C.onclose=P=>{console.log("[WebSocket] Closed",P.code,P.reason),k&&(clearInterval(k),k=null),a(!1),t.current=null,e.current=window.setTimeout(()=>{f()},3e3)},C.onerror=P=>{console.error("[WebSocket] Error",P),C.close()},t.current=C},[p]),y=w.useCallback((_,N)=>{const C=l.current.get(_)||{};l.current.set(_,{...C,...N}),c.current||(c.current=window.setTimeout(()=>{const k=new Map(l.current);l.current.clear(),c.current=null,requestAnimationFrame(()=>{k.forEach((P,T)=>{n.setQueryData(["printerStatus",T],D=>{const A={...D,...P};return A.wifi_signal==null&&D?.wifi_signal!=null&&(A.wifi_signal=D.wifi_signal),A})})})},100))},[n]),v=w.useCallback(_=>{s.current.add(_),o.current&&clearTimeout(o.current),o.current=window.setTimeout(()=>{const N=Array.from(s.current);s.current.clear(),o.current=null;let C=0;N.forEach(k=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[k]})})},C),C+=500})},3e3)},[n]),b=w.useCallback(_=>{switch(_.type){case"printer_status":_.printer_id!==void 0&&_.data&&y(_.printer_id,_.data);break;case"print_start":_.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",_.printer_id]});break;case"print_complete":v("archives"),v("archiveStats");break;case"archive_created":v("archives"),v("archiveStats");break;case"archive_updated":v("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:_.printer_id,printer_name:_.printer_name,message:_.message}}));break;case"spool_auto_assigned":v("inventory-spools"),v("spool-assignments");break;case"spool_usage_logged":v("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:_.printer_id,ams_id:_.ams_id,tray_id:_.tray_id,tag_uid:_.tag_uid,tray_uuid:_.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:_.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:_}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:_})),v("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:_}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:_}));break;case"spoolbuddy_tag_written":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-written",{detail:_})),v("inventory-spools");break;case"spoolbuddy_tag_write_failed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-write-failed",{detail:_}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:_})),v("spoolbuddy-devices"),v("spoolbuddy-update-check");break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:_})),v("spoolbuddy-devices");break;case"spoolbuddy_update":v("spoolbuddy-devices"),v("spoolbuddy-update-check");break}},[n,v,y]);w.useEffect(()=>{m.current=b},[b]),w.useEffect(()=>(f(),()=>{e.current&&clearTimeout(e.current),o.current&&clearTimeout(o.current),c.current&&clearTimeout(c.current),t.current&&t.current.close()}),[f]);const g=w.useCallback(_=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(_))},[]);return{isConnected:r,sendMessage:g}}function fnt({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=Dt(),[a,s]=w.useState(new Date),{data:o=[]}=et({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),l=tg({queries:o.map(d=>({queryKey:["printerStatus",d.id],queryFn:()=>ge.getPrinterStatus(d.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((d,m)=>l[m]?.data?.connected),[o,l]);w.useEffect(()=>{const d=c.some(m=>m.id===t);(!t||!d)&&c.length>0&&e(c[0].id)},[c,t,e]);const{data:u}=et({queryKey:["settings"],queryFn:ge.getSettings});return w.useEffect(()=>{const d=setInterval(()=>s(new Date),1e3);return()=>clearInterval(d)},[]),i.jsxs("div",{className:"h-12 bg-bambu-dark-secondary border-b border-bambu-dark-tertiary flex items-center px-3 gap-4 shrink-0",children:[i.jsx("div",{className:"flex items-center shrink-0",children:i.jsx("img",{src:"/img/spoolbuddy_logo_dark_small.png",alt:"SpoolBuddy",width:113,height:28,className:"h-7 w-auto"})}),i.jsx("div",{className:"flex-1 flex justify-center",children:i.jsx("select",{value:t??"",onChange:d=>e(Number(d.target.value)),className:"bg-bambu-dark text-white text-base px-4 py-2 rounded border border-bambu-dark-tertiary focus:outline-none focus:border-bambu-green min-w-[180px]",children:c.length===0?i.jsx("option",{value:"",children:r("spoolbuddy.status.noPrinters","No printers online")}):c.map(d=>i.jsx("option",{value:d.id,children:d.name},d.id))})}),i.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[i.jsx("div",{className:"flex items-center",title:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline"),children:n?i.jsx("div",{className:"flex items-end gap-0.5 h-4",children:[1,2,3,4].map(d=>i.jsx("div",{className:`w-1 rounded-sm ${d<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${d*4}px`}},d))}):i.jsx(zh,{className:"w-5 h-5 text-red-400"})}),i.jsxs("div",{className:"flex items-center gap-1.5",children:[i.jsx("div",{className:`w-3 h-3 rounded-full ${n?"bg-bambu-green shadow-[0_0_6px_rgba(34,197,94,0.5)]":"bg-bambu-gray"}`}),i.jsx("span",{className:"text-sm text-white/50",children:n?r("spoolbuddy.status.backend","Backend"):r("spoolbuddy.status.offline","Offline")})]}),i.jsx("span",{className:"text-white/50 text-base font-mono min-w-[50px] text-right",children:hQ(a,u?.time_format||"system")})]})]})}const gnt=[{to:"/spoolbuddy",labelKey:"spoolbuddy.nav.dashboard",fallback:"Dashboard",icon:i.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 12l2-2m0 0l7-7 7 7M5 10v10a1 1 0 001 1h3m10-11l2 2m-2-2v10a1 1 0 01-1 1h-3m-6 0a1 1 0 001-1v-4a1 1 0 011-1h2a1 1 0 011 1v4a1 1 0 001 1m-6 0h6"})})},{to:"/spoolbuddy/ams",labelKey:"spoolbuddy.nav.ams",fallback:"AMS",icon:i.jsx("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"})})},{to:"/spoolbuddy/write-tag",labelKey:"spoolbuddy.nav.writeTag",fallback:"Write",icon:i.jsxs("svg",{className:"w-6 h-6",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M8.288 15.038a5.25 5.25 0 017.424 0M5.106 11.856c3.807-3.808 9.98-3.808 13.788 0M1.924 8.674c5.565-5.565 14.587-5.565 20.152 0"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12.53 18.22l-.53.53-.53-.53a.75.75 0 011.06 0z"})]})},{to:"/spoolbuddy/settings",labelKey:"spoolbuddy.nav.settings",fallback:"Settings",icon:i.jsxs("svg",{className:"w-6 h-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:[i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.066 2.573c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.573 1.066c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.066-2.573c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z"}),i.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 12a3 3 0 11-6 0 3 3 0 016 0z"})]})}];function bnt(){const{t}=Dt();return i.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:gnt.map(e=>i.jsxs(Ib,{to:e.to,end:e.to==="/spoolbuddy",className:({isActive:n})=>`flex-1 flex flex-col items-center justify-center gap-1 transition-colors ${n?"text-bambu-green bg-bambu-dark":"text-white/50 hover:text-white/70 hover:bg-bambu-dark-tertiary"}`,children:[e.icon,i.jsx("span",{className:"text-xs font-medium",children:t(e.labelKey,e.fallback)})]},e.to))})}function xnt({alert:t}){const{t:e}=Dt(),n=t?t.type==="error"?"bg-red-500":t.type==="warning"?"bg-amber-500":"bg-bambu-green":"bg-bambu-green",r=t?t.type==="error"?"border-red-500":t.type==="warning"?"border-amber-500":"border-bambu-dark-tertiary":"border-bambu-dark-tertiary";return i.jsxs("div",{className:`h-9 bg-bambu-dark-secondary border-t-2 ${r} flex items-center px-3 gap-3 shrink-0`,children:[i.jsx("div",{className:`w-3.5 h-3.5 rounded-full ${n} animate-pulse`}),i.jsx("div",{className:"flex-1 text-sm text-white/50 truncate",children:t?i.jsx("span",{children:t.message}):i.jsx("span",{className:"text-bambu-green",children:e("spoolbuddy.status.systemReady","System Ready")})})]})}const ynt={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function vnt(t,e){switch(e.type){case"WEIGHT_UPDATE":return{...t,weight:e.weight,weightStable:e.stable,rawAdc:e.rawAdc,deviceId:e.deviceId,deviceOnline:!0};case"TAG_MATCHED":return{...t,matchedSpool:e.spool,unknownTagUid:null,deviceId:e.deviceId};case"UNKNOWN_TAG":return{...t,matchedSpool:null,unknownTagUid:e.tagUid,deviceId:e.deviceId};case"TAG_REMOVED":return{...t,matchedSpool:null,unknownTagUid:null};case"DEVICE_ONLINE":return{...t,deviceOnline:!0,deviceId:e.deviceId};case"DEVICE_OFFLINE":return{...t,deviceOnline:!1,weight:null,weightStable:!1,rawAdc:null};default:return t}}function wnt(){const[t,e]=w.useReducer(vnt,ynt),n=w.useCallback(d=>{const m=d.detail;e({type:"WEIGHT_UPDATE",weight:m.weight_grams??m.data?.weight_grams,stable:m.stable??m.data?.stable??!1,rawAdc:m.raw_adc??m.data?.raw_adc??null,deviceId:m.device_id??m.data?.device_id??""})},[]),r=w.useCallback(d=>{const m=d.detail,p=m.spool??m.data?.spool;p&&e({type:"TAG_MATCHED",spool:{id:p.id,tag_uid:m.tag_uid??m.data?.tag_uid??"",material:p.material??"",subtype:p.subtype??null,color_name:p.color_name??null,rgba:p.rgba??null,brand:p.brand??null,label_weight:p.label_weight??0,core_weight:p.core_weight??0,weight_used:p.weight_used??0},deviceId:m.device_id??m.data?.device_id??""})},[]),a=w.useCallback(d=>{const m=d.detail;e({type:"UNKNOWN_TAG",tagUid:m.tag_uid??m.data?.tag_uid??"",deviceId:m.device_id??m.data?.device_id??""})},[]),s=w.useCallback(d=>{const m=d.detail;e({type:"TAG_REMOVED",deviceId:m.device_id??m.data?.device_id??""})},[]),o=w.useCallback(d=>{const m=d.detail;e({type:"DEVICE_ONLINE",deviceId:m.device_id??m.data?.device_id??""})},[]),l=w.useCallback(d=>{const m=d.detail;e({type:"DEVICE_OFFLINE",deviceId:m.device_id??m.data?.device_id??""})},[]);w.useEffect(()=>(window.addEventListener("spoolbuddy-weight",n),window.addEventListener("spoolbuddy-tag-matched",r),window.addEventListener("spoolbuddy-unknown-tag",a),window.addEventListener("spoolbuddy-tag-removed",s),window.addEventListener("spoolbuddy-online",o),window.addEventListener("spoolbuddy-offline",l),()=>{window.removeEventListener("spoolbuddy-weight",n),window.removeEventListener("spoolbuddy-tag-matched",r),window.removeEventListener("spoolbuddy-unknown-tag",a),window.removeEventListener("spoolbuddy-tag-removed",s),window.removeEventListener("spoolbuddy-online",o),window.removeEventListener("spoolbuddy-offline",l)}),[n,r,a,s,o,l]);const c=t.matchedSpool?Math.max(0,t.matchedSpool.label_weight-t.matchedSpool.weight_used):null,u=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:u}}var PN={exports:{}};var Snt=PN.exports,qY;function _nt(){return qY||(qY=1,(function(t,e){(function(n,r){t.exports=r(Jf())})(Snt,(function(n){return(function(){var r={981:function(){typeof Element>"u"||"remove"in Element.prototype||(Element.prototype.remove=function(){this.parentNode&&this.parentNode.removeChild(this)}),typeof self<"u"&&"document"in self&&((!("classList"in document.createElement("_"))||document.createElementNS&&!("classList"in document.createElementNS("http://www.w3.org/2000/svg","g")))&&(function(l){if("Element"in l){var c="classList",u="prototype",d=l.Element[u],m=Object,p=String[u].trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=Array[u].indexOf||function(C){for(var k=0,P=this.length;k1?arguments[1]:void 0)}},7916:function(q,X,j){var E=j(6080),U=j(9565),K=j(8981),H=j(6319),re=j(4209),O=j(3517),$=j(6198),ee=j(4659),W=j(4527),ie=j(81),ce=j(851),be=Array;q.exports=function(xe){var oe=K(xe),L=O(this),F=arguments.length,te=F>1?arguments[1]:void 0,ve=te!==void 0;ve&&(te=E(te,F>2?arguments[2]:void 0));var fe,me,je,we,Fe,He,Oe=ce(oe),_e=0;if(!Oe||this===be&&re(Oe))for(fe=$(oe),me=L?new this(fe):be(fe);fe>_e;_e++)He=ve?te(oe[_e],_e):oe[_e],ee(me,_e,He);else for(me=L?new this:[],Fe=(we=ie(oe,Oe)).next;!(je=U(Fe,we)).done;_e++)He=ve?H(we,te,[je.value,_e],!0):je.value,ee(me,_e,He);return W(me,_e),me}},9617:function(q,X,j){var E=j(5397),U=j(5610),K=j(6198),H=function(re){return function(O,$,ee){var W=E(O),ie=K(W);if(ie===0)return!re&&-1;var ce,be=U(ee,ie);if(re&&$!=$){for(;ie>be;)if((ce=W[be++])!=ce)return!0}else for(;ie>be;be++)if((re||be in W)&&W[be]===$)return re||be||0;return!re&&-1}};q.exports={includes:H(!0),indexOf:H(!1)}},9213:function(q,X,j){var E=j(6080),U=j(7055),K=j(8981),H=j(6198),re=j(1469),O=j(4659),$=function(ee){var W=ee===1,ie=ee===2,ce=ee===3,be=ee===4,xe=ee===6,oe=ee===7,L=ee===5||xe;return function(F,te,ve){for(var fe,me,je=K(F),we=U(je),Fe=H(we),He=E(te,ve),Oe=0,_e=0,Ae=W?re(F,Fe):ie||oe?re(F,0):void 0;Fe>Oe;Oe++)if((L||Oe in we)&&(me=He(fe=we[Oe],Oe,je),ee))if(W)O(Ae,Oe,me);else if(me)switch(ee){case 3:return!0;case 5:return fe;case 6:return Oe;case 2:O(Ae,_e++,fe)}else switch(ee){case 4:return!1;case 7:O(Ae,_e++,fe)}return xe?-1:ce||be?be:Ae}};q.exports={forEach:$(0),map:$(1),filter:$(2),some:$(3),every:$(4),find:$(5),findIndex:$(6),filterReject:$(7)}},597:function(q,X,j){var E=j(9039),U=j(8227),K=j(9519),H=U("species");q.exports=function(re){return K>=51||!E((function(){var O=[];return(O.constructor={})[H]=function(){return{foo:1}},O[re](Boolean).foo!==1}))}},4598:function(q,X,j){var E=j(9039);q.exports=function(U,K){var H=[][U];return!!H&&E((function(){H.call(null,K||function(){return 1},1)}))}},926:function(q,X,j){var E=j(9306),U=j(8981),K=j(7055),H=j(6198),re=TypeError,O="Reduce of empty array with no initial value",$=function(ee){return function(W,ie,ce,be){var xe=U(W),oe=K(xe),L=H(xe);if(E(ie),L===0&&ce<2)throw new re(O);var F=ee?L-1:0,te=ee?-1:1;if(ce<2)for(;;){if(F in oe){be=oe[F],F+=te;break}if(F+=te,ee?F<0:L<=F)throw new re(O)}for(;ee?F>=0:L>F;F+=te)F in oe&&(be=ie(be,oe[F],F,xe));return be}};q.exports={left:$(!1),right:$(!0)}},4527:function(q,X,j){var E=j(3724),U=j(4376),K=TypeError,H=Object.getOwnPropertyDescriptor,re=E&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(O){return O instanceof TypeError}})();q.exports=re?function(O,$){if(U(O)&&!H(O,"length").writable)throw new K("Cannot set read only .length");return O.length=$}:function(O,$){return O.length=$}},7680:function(q,X,j){var E=j(9504);q.exports=E([].slice)},4488:function(q,X,j){var E=j(7680),U=Math.floor,K=function(H,re){var O=H.length;if(O<8)for(var $,ee,W=1;W0;)H[ee]=H[--ee];ee!==W++&&(H[ee]=$)}else for(var ie=U(O/2),ce=K(E(H,0,ie),re),be=K(E(H,ie),re),xe=ce.length,oe=be.length,L=0,F=0;L9007199254740991)throw X("Maximum allowed index exceeded");return j}},7400:function(q){q.exports={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0}},9296:function(q,X,j){var E=j(4055)("span").classList,U=E&&E.constructor&&E.constructor.prototype;q.exports=U===Object.prototype?void 0:U},8727:function(q){q.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709:function(q,X,j){var E=j(2839).match(/firefox\/(\d+)/i);q.exports=!!E&&+E[1]},3763:function(q,X,j){var E=j(2839);q.exports=/MSIE|Trident/.test(E)},6193:function(q,X,j){var E=j(4215);q.exports=E==="NODE"},2839:function(q,X,j){var E=j(4576).navigator,U=E&&E.userAgent;q.exports=U?String(U):""},9519:function(q,X,j){var E,U,K=j(4576),H=j(2839),re=K.process,O=K.Deno,$=re&&re.versions||O&&O.version,ee=$&&$.v8;ee&&(U=(E=ee.split("."))[0]>0&&E[0]<4?1:+(E[0]+E[1])),!U&&H&&(!(E=H.match(/Edge\/(\d+)/))||E[1]>=74)&&(E=H.match(/Chrome\/(\d+)/))&&(U=+E[1]),q.exports=U},3607:function(q,X,j){var E=j(2839).match(/AppleWebKit\/(\d+)\./);q.exports=!!E&&+E[1]},4215:function(q,X,j){var E=j(4576),U=j(2839),K=j(2195),H=function(re){return U.slice(0,re.length)===re};q.exports=H("Bun/")?"BUN":H("Cloudflare-Workers")?"CLOUDFLARE":H("Deno/")?"DENO":H("Node.js/")?"NODE":E.Bun&&typeof Bun.version=="string"?"BUN":E.Deno&&typeof Deno.version=="object"?"DENO":K(E.process)==="process"?"NODE":E.window&&E.document?"BROWSER":"REST"},6518:function(q,X,j){var E=j(4576),U=j(7347).f,K=j(6699),H=j(6840),re=j(9433),O=j(7740),$=j(2796);q.exports=function(ee,W){var ie,ce,be,xe,oe,L=ee.target,F=ee.global,te=ee.stat;if(ie=F?E:te?E[L]||re(L,{}):E[L]&&E[L].prototype)for(ce in W){if(xe=W[ce],be=ee.dontCallGetSet?(oe=U(ie,ce))&&oe.value:ie[ce],!$(F?ce:L+(te?".":"#")+ce,ee.forced)&&be!==void 0){if(typeof xe==typeof be)continue;O(xe,be)}(ee.sham||be&&be.sham)&&K(xe,"sham",!0),H(ie,ce,xe,ee)}}},9039:function(q){q.exports=function(X){try{return!!X()}catch{return!0}}},9228:function(q,X,j){j(7495);var E=j(9565),U=j(6840),K=j(7323),H=j(9039),re=j(8227),O=j(6699),$=re("species"),ee=RegExp.prototype;q.exports=function(W,ie,ce,be){var xe=re(W),oe=!H((function(){var ve={};return ve[xe]=function(){return 7},""[W](ve)!==7})),L=oe&&!H((function(){var ve=!1,fe=/a/;if(W==="split"){var me={};me[$]=function(){return fe},(fe={constructor:me,flags:""})[xe]=/./[xe]}return fe.exec=function(){return ve=!0,null},fe[xe](""),!ve}));if(!oe||!L||ce){var F=/./[xe],te=ie(xe,""[W],(function(ve,fe,me,je,we){var Fe=fe.exec;return Fe===K||Fe===ee.exec?oe&&!we?{done:!0,value:E(F,fe,me,je)}:{done:!0,value:E(ve,me,fe,je)}:{done:!1}}));U(String.prototype,W,te[0]),U(ee,xe,te[1])}be&&O(ee[xe],"sham",!0)}},8745:function(q,X,j){var E=j(616),U=Function.prototype,K=U.apply,H=U.call;q.exports=typeof Reflect=="object"&&Reflect.apply||(E?H.bind(K):function(){return H.apply(K,arguments)})},6080:function(q,X,j){var E=j(7476),U=j(9306),K=j(616),H=E(E.bind);q.exports=function(re,O){return U(re),O===void 0?re:K?H(re,O):function(){return re.apply(O,arguments)}}},616:function(q,X,j){var E=j(9039);q.exports=!E((function(){var U=(function(){}).bind();return typeof U!="function"||U.hasOwnProperty("prototype")}))},566:function(q,X,j){var E=j(9504),U=j(9306),K=j(34),H=j(9297),re=j(7680),O=j(616),$=Function,ee=E([].concat),W=E([].join),ie={};q.exports=O?$.bind:function(ce){var be=U(this),xe=be.prototype,oe=re(arguments,1),L=function(){var F=ee(oe,re(arguments));return this instanceof L?(function(te,ve,fe){if(!H(ie,ve)){for(var me=[],je=0;je]*>)/g,ee=/\$([$&'`]|\d{1,2})/g;q.exports=function(W,ie,ce,be,xe,oe){var L=ce+W.length,F=be.length,te=ee;return xe!==void 0&&(xe=U(xe),te=$),re(oe,te,(function(ve,fe){var me;switch(H(fe,0)){case"$":return"$";case"&":return W;case"`":return O(ie,0,ce);case"'":return O(ie,L);case"<":me=xe[O(fe,1,-1)];break;default:var je=+fe;if(je===0)return ve;if(je>F){var we=K(je/10);return we===0?ve:we<=F?be[we-1]===void 0?H(fe,1):be[we-1]+H(fe,1):ve}me=be[je-1]}return me===void 0?"":me}))}},4576:function(q,X,j){var E=function(U){return U&&U.Math===Math&&U};q.exports=E(typeof globalThis=="object"&&globalThis)||E(typeof window=="object"&&window)||E(typeof self=="object"&&self)||E(typeof j.g=="object"&&j.g)||E(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297:function(q,X,j){var E=j(9504),U=j(8981),K=E({}.hasOwnProperty);q.exports=Object.hasOwn||function(H,re){return K(U(H),re)}},421:function(q){q.exports={}},397:function(q,X,j){var E=j(7751);q.exports=E("document","documentElement")},5917:function(q,X,j){var E=j(3724),U=j(9039),K=j(4055);q.exports=!E&&!U((function(){return Object.defineProperty(K("div"),"a",{get:function(){return 7}}).a!==7}))},7055:function(q,X,j){var E=j(9504),U=j(9039),K=j(2195),H=Object,re=E("".split);q.exports=U((function(){return!H("z").propertyIsEnumerable(0)}))?function(O){return K(O)==="String"?re(O,""):H(O)}:H},3167:function(q,X,j){var E=j(4901),U=j(34),K=j(2967);q.exports=function(H,re,O){var $,ee;return K&&E($=re.constructor)&&$!==O&&U(ee=$.prototype)&&ee!==O.prototype&&K(H,ee),H}},3706:function(q,X,j){var E=j(9504),U=j(4901),K=j(7629),H=E(Function.toString);U(K.inspectSource)||(K.inspectSource=function(re){return H(re)}),q.exports=K.inspectSource},1181:function(q,X,j){var E,U,K,H=j(8622),re=j(4576),O=j(34),$=j(6699),ee=j(9297),W=j(7629),ie=j(6119),ce=j(421),be="Object already initialized",xe=re.TypeError,oe=re.WeakMap;if(H||W.state){var L=W.state||(W.state=new oe);L.get=L.get,L.has=L.has,L.set=L.set,E=function(te,ve){if(L.has(te))throw new xe(be);return ve.facade=te,L.set(te,ve),ve},U=function(te){return L.get(te)||{}},K=function(te){return L.has(te)}}else{var F=ie("state");ce[F]=!0,E=function(te,ve){if(ee(te,F))throw new xe(be);return ve.facade=te,$(te,F,ve),ve},U=function(te){return ee(te,F)?te[F]:{}},K=function(te){return ee(te,F)}}q.exports={set:E,get:U,has:K,enforce:function(te){return K(te)?U(te):E(te,{})},getterFor:function(te){return function(ve){var fe;if(!O(ve)||(fe=U(ve)).type!==te)throw new xe("Incompatible receiver, "+te+" required");return fe}}}},4209:function(q,X,j){var E=j(8227),U=j(6269),K=E("iterator"),H=Array.prototype;q.exports=function(re){return re!==void 0&&(U.Array===re||H[K]===re)}},4376:function(q,X,j){var E=j(2195);q.exports=Array.isArray||function(U){return E(U)==="Array"}},4901:function(q){var X=typeof document=="object"&&document.all;q.exports=X===void 0&&X!==void 0?function(j){return typeof j=="function"||j===X}:function(j){return typeof j=="function"}},3517:function(q,X,j){var E=j(9504),U=j(9039),K=j(4901),H=j(6955),re=j(7751),O=j(3706),$=function(){},ee=re("Reflect","construct"),W=/^\s*(?:class|function)\b/,ie=E(W.exec),ce=!W.test($),be=function(oe){if(!K(oe))return!1;try{return ee($,[],oe),!0}catch{return!1}},xe=function(oe){if(!K(oe))return!1;switch(H(oe)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return ce||!!ie(W,O(oe))}catch{return!0}};xe.sham=!0,q.exports=!ee||U((function(){var oe;return be(be.call)||!be(Object)||!be((function(){oe=!0}))||oe}))?xe:be},2796:function(q,X,j){var E=j(9039),U=j(4901),K=/#|\.prototype\./,H=function(W,ie){var ce=O[re(W)];return ce===ee||ce!==$&&(U(ie)?E(ie):!!ie)},re=H.normalize=function(W){return String(W).replace(K,".").toLowerCase()},O=H.data={},$=H.NATIVE="N",ee=H.POLYFILL="P";q.exports=H},2087:function(q,X,j){var E=j(34),U=Math.floor;q.exports=Number.isInteger||function(K){return!E(K)&&isFinite(K)&&U(K)===K}},4117:function(q){q.exports=function(X){return X==null}},34:function(q,X,j){var E=j(4901);q.exports=function(U){return typeof U=="object"?U!==null:E(U)}},3925:function(q,X,j){var E=j(34);q.exports=function(U){return E(U)||U===null}},6395:function(q){q.exports=!1},5810:function(q,X,j){var E=j(34),U=j(1181).get;q.exports=function(K){if(!E(K))return!1;var H=U(K);return!!H&&H.type==="RawJSON"}},788:function(q,X,j){var E=j(34),U=j(2195),K=j(8227)("match");q.exports=function(H){var re;return E(H)&&((re=H[K])!==void 0?!!re:U(H)==="RegExp")}},757:function(q,X,j){var E=j(7751),U=j(4901),K=j(1625),H=j(7040),re=Object;q.exports=H?function(O){return typeof O=="symbol"}:function(O){var $=E("Symbol");return U($)&&K($.prototype,re(O))}},9539:function(q,X,j){var E=j(9565),U=j(8551),K=j(5966);q.exports=function(H,re,O){var $,ee;U(H);try{if(!($=K(H,"return"))){if(re==="throw")throw O;return O}$=E($,H)}catch(W){ee=!0,$=W}if(re==="throw")throw O;if(ee)throw $;return U($),O}},3994:function(q,X,j){var E=j(7657).IteratorPrototype,U=j(2360),K=j(6980),H=j(687),re=j(6269),O=function(){return this};q.exports=function($,ee,W,ie){var ce=ee+" Iterator";return $.prototype=U(E,{next:K(+!ie,W)}),H($,ce,!1,!0),re[ce]=O,$}},1088:function(q,X,j){var E=j(6518),U=j(9565),K=j(6395),H=j(350),re=j(4901),O=j(3994),$=j(2787),ee=j(2967),W=j(687),ie=j(6699),ce=j(6840),be=j(8227),xe=j(6269),oe=j(7657),L=H.PROPER,F=H.CONFIGURABLE,te=oe.IteratorPrototype,ve=oe.BUGGY_SAFARI_ITERATORS,fe=be("iterator"),me="keys",je="values",we="entries",Fe=function(){return this};q.exports=function(He,Oe,_e,Ae,Be,Me,Xe){O(_e,Oe,Ae);var ye,We,Pe,Ke=function(vt){if(vt===Be&&nt)return nt;if(!ve&&vt&&vt in Ce)return Ce[vt];switch(vt){case me:case je:case we:return function(){return new _e(this,vt)}}return function(){return new _e(this)}},Ve=Oe+" Iterator",ke=!1,Ce=He.prototype,$e=Ce[fe]||Ce["@@iterator"]||Be&&Ce[Be],nt=!ve&&$e||Ke(Be),xt=Oe==="Array"&&Ce.entries||$e;if(xt&&(ye=$(xt.call(new He)))!==Object.prototype&&ye.next&&(K||$(ye)===te||(ee?ee(ye,te):re(ye[fe])||ce(ye,fe,Fe)),W(ye,Ve,!0,!0),K&&(xe[Ve]=Fe)),L&&Be===je&&$e&&$e.name!==je&&(!K&&F?ie(Ce,"name",je):(ke=!0,nt=function(){return U($e,this)})),Be)if(We={values:Ke(je),keys:Me?nt:Ke(me),entries:Ke(we)},Xe)for(Pe in We)(ve||ke||!(Pe in Ce))&&ce(Ce,Pe,We[Pe]);else E({target:Oe,proto:!0,forced:ve||ke},We);return K&&!Xe||Ce[fe]===nt||ce(Ce,fe,nt,{name:Be}),xe[Oe]=nt,We}},7657:function(q,X,j){var E,U,K,H=j(9039),re=j(4901),O=j(34),$=j(2360),ee=j(2787),W=j(6840),ie=j(8227),ce=j(6395),be=ie("iterator"),xe=!1;[].keys&&("next"in(K=[].keys())?(U=ee(ee(K)))!==Object.prototype&&(E=U):xe=!0),!O(E)||H((function(){var oe={};return E[be].call(oe)!==oe}))?E={}:ce&&(E=$(E)),re(E[be])||W(E,be,(function(){return this})),q.exports={IteratorPrototype:E,BUGGY_SAFARI_ITERATORS:xe}},6269:function(q){q.exports={}},6198:function(q,X,j){var E=j(8014);q.exports=function(U){return E(U.length)}},283:function(q,X,j){var E=j(9504),U=j(9039),K=j(4901),H=j(9297),re=j(3724),O=j(350).CONFIGURABLE,$=j(3706),ee=j(1181),W=ee.enforce,ie=ee.get,ce=String,be=Object.defineProperty,xe=E("".slice),oe=E("".replace),L=E([].join),F=re&&!U((function(){return be((function(){}),"length",{value:8}).length!==8})),te=String(String).split("String"),ve=q.exports=function(fe,me,je){xe(ce(me),0,7)==="Symbol("&&(me="["+oe(ce(me),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),je&&je.getter&&(me="get "+me),je&&je.setter&&(me="set "+me),(!H(fe,"name")||O&&fe.name!==me)&&(re?be(fe,"name",{value:me,configurable:!0}):fe.name=me),F&&je&&H(je,"arity")&&fe.length!==je.arity&&be(fe,"length",{value:je.arity});try{je&&H(je,"constructor")&&je.constructor?re&&be(fe,"prototype",{writable:!1}):fe.prototype&&(fe.prototype=void 0)}catch{}var we=W(fe);return H(we,"source")||(we.source=L(te,typeof me=="string"?me:"")),fe};Function.prototype.toString=ve((function(){return K(this)&&ie(this).source||$(this)}),"toString")},741:function(q){var X=Math.ceil,j=Math.floor;q.exports=Math.trunc||function(E){var U=+E;return(U>0?j:X)(U)}},7819:function(q,X,j){var E=j(9039);q.exports=!E((function(){var U="9007199254740993",K=JSON.rawJSON(U);return!JSON.isRawJSON(K)||JSON.stringify(K)!==U}))},5749:function(q,X,j){var E=j(788),U=TypeError;q.exports=function(K){if(E(K))throw new U("The method doesn't accept regular expressions");return K}},4213:function(q,X,j){var E=j(3724),U=j(9504),K=j(9565),H=j(9039),re=j(1072),O=j(3717),$=j(8773),ee=j(8981),W=j(7055),ie=Object.assign,ce=Object.defineProperty,be=U([].concat);q.exports=!ie||H((function(){if(E&&ie({b:1},ie(ce({},"a",{enumerable:!0,get:function(){ce(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var xe={},oe={},L=Symbol("assign detection"),F="abcdefghijklmnopqrst";return xe[L]=7,F.split("").forEach((function(te){oe[te]=te})),ie({},xe)[L]!==7||re(ie({},oe)).join("")!==F}))?function(xe,oe){for(var L=ee(xe),F=arguments.length,te=1,ve=O.f,fe=$.f;F>te;)for(var me,je=W(arguments[te++]),we=ve?be(re(je),ve(je)):re(je),Fe=we.length,He=0;Fe>He;)me=we[He++],E&&!K(fe,je,me)||(L[me]=je[me]);return L}:ie},2360:function(q,X,j){var E,U=j(8551),K=j(6801),H=j(8727),re=j(421),O=j(397),$=j(4055),ee=j(6119),W="prototype",ie="script",ce=ee("IE_PROTO"),be=function(){},xe=function(F){return"<"+ie+">"+F+""},oe=function(F){F.write(xe("")),F.close();var te=F.parentWindow.Object;return F=null,te},L=function(){try{E=new ActiveXObject("htmlfile")}catch{}var F,te,ve;L=typeof document<"u"?document.domain&&E?oe(E):(te=$("iframe"),ve="java"+ie+":",te.style.display="none",O.appendChild(te),te.src=String(ve),(F=te.contentWindow.document).open(),F.write(xe("document.F=Object")),F.close(),F.F):oe(E);for(var fe=H.length;fe--;)delete L[W][H[fe]];return L()};re[ce]=!0,q.exports=Object.create||function(F,te){var ve;return F!==null?(be[W]=U(F),ve=new be,be[W]=null,ve[ce]=F):ve=L(),te===void 0?ve:K.f(ve,te)}},6801:function(q,X,j){var E=j(3724),U=j(8686),K=j(4913),H=j(8551),re=j(5397),O=j(1072);X.f=E&&!U?Object.defineProperties:function($,ee){H($);for(var W,ie=re(ee),ce=O(ee),be=ce.length,xe=0;be>xe;)K.f($,W=ce[xe++],ie[W]);return $}},4913:function(q,X,j){var E=j(3724),U=j(5917),K=j(8686),H=j(8551),re=j(6969),O=TypeError,$=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,W="enumerable",ie="configurable",ce="writable";X.f=E?K?function(be,xe,oe){if(H(be),xe=re(xe),H(oe),typeof be=="function"&&xe==="prototype"&&"value"in oe&&ce in oe&&!oe[ce]){var L=ee(be,xe);L&&L[ce]&&(be[xe]=oe.value,oe={configurable:ie in oe?oe[ie]:L[ie],enumerable:W in oe?oe[W]:L[W],writable:!1})}return $(be,xe,oe)}:$:function(be,xe,oe){if(H(be),xe=re(xe),H(oe),U)try{return $(be,xe,oe)}catch{}if("get"in oe||"set"in oe)throw new O("Accessors not supported");return"value"in oe&&(be[xe]=oe.value),be}},7347:function(q,X,j){var E=j(3724),U=j(9565),K=j(8773),H=j(6980),re=j(5397),O=j(6969),$=j(9297),ee=j(5917),W=Object.getOwnPropertyDescriptor;X.f=E?W:function(ie,ce){if(ie=re(ie),ce=O(ce),ee)try{return W(ie,ce)}catch{}if($(ie,ce))return H(!U(K.f,ie,ce),ie[ce])}},298:function(q,X,j){var E=j(2195),U=j(5397),K=j(8480).f,H=j(7680),re=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];q.exports.f=function(O){return re&&E(O)==="Window"?(function($){try{return K($)}catch{return H(re)}})(O):K(U(O))}},8480:function(q,X,j){var E=j(1828),U=j(8727).concat("length","prototype");X.f=Object.getOwnPropertyNames||function(K){return E(K,U)}},3717:function(q,X){X.f=Object.getOwnPropertySymbols},2787:function(q,X,j){var E=j(9297),U=j(4901),K=j(8981),H=j(6119),re=j(2211),O=H("IE_PROTO"),$=Object,ee=$.prototype;q.exports=re?$.getPrototypeOf:function(W){var ie=K(W);if(E(ie,O))return ie[O];var ce=ie.constructor;return U(ce)&&ie instanceof ce?ce.prototype:ie instanceof $?ee:null}},1625:function(q,X,j){var E=j(9504);q.exports=E({}.isPrototypeOf)},1828:function(q,X,j){var E=j(9504),U=j(9297),K=j(5397),H=j(9617).indexOf,re=j(421),O=E([].push);q.exports=function($,ee){var W,ie=K($),ce=0,be=[];for(W in ie)!U(re,W)&&U(ie,W)&&O(be,W);for(;ee.length>ce;)U(ie,W=ee[ce++])&&(~H(be,W)||O(be,W));return be}},1072:function(q,X,j){var E=j(1828),U=j(8727);q.exports=Object.keys||function(K){return E(K,U)}},8773:function(q,X){var j={}.propertyIsEnumerable,E=Object.getOwnPropertyDescriptor,U=E&&!j.call({1:2},1);X.f=U?function(K){var H=E(this,K);return!!H&&H.enumerable}:j},2551:function(q,X,j){var E=j(6395),U=j(4576),K=j(9039),H=j(3607);q.exports=E||!K((function(){if(!(H&&H<535)){var re=Math.random();__defineSetter__.call(null,re,(function(){})),delete U[re]}}))},2967:function(q,X,j){var E=j(6706),U=j(34),K=j(7750),H=j(3506);q.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var re,O=!1,$={};try{(re=E(Object.prototype,"__proto__","set"))($,[]),O=$ instanceof Array}catch{}return function(ee,W){return K(ee),H(W),U(ee)&&(O?re(ee,W):ee.__proto__=W),ee}})():void 0)},3179:function(q,X,j){var E=j(2140),U=j(6955);q.exports=E?{}.toString:function(){return"[object "+U(this)+"]"}},4270:function(q,X,j){var E=j(9565),U=j(4901),K=j(34),H=TypeError;q.exports=function(re,O){var $,ee;if(O==="string"&&U($=re.toString)&&!K(ee=E($,re))||U($=re.valueOf)&&!K(ee=E($,re))||O!=="string"&&U($=re.toString)&&!K(ee=E($,re)))return ee;throw new H("Can't convert object to primitive value")}},5031:function(q,X,j){var E=j(7751),U=j(9504),K=j(8480),H=j(3717),re=j(8551),O=U([].concat);q.exports=E("Reflect","ownKeys")||function($){var ee=K.f(re($)),W=H.f;return W?O(ee,W($)):ee}},8235:function(q,X,j){var E=j(9504),U=j(9297),K=SyntaxError,H=parseInt,re=String.fromCharCode,O=E("".charAt),$=E("".slice),ee=E(/./.exec),W={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":` `,"\\r":"\r","\\t":" "},ie=/^[\da-f]{4}$/i,ce=/^[\u0000-\u001F]$/;q.exports=function(be,xe){for(var oe=!0,L="";xe0&&(!ye.multiline||ye.multiline&&F(Pe,ye.lastIndex-1)!==` `)&&($e="(?: "+$e+")",xt=" "+xt,nt++),Oe=new RegExp("^(?:"+$e+")",Ce)),we&&(Oe=new RegExp("^"+$e+"$(?!\\s)",Ce)),me&&(_e=ye.lastIndex),Ae=K(oe,ke?Oe:ye,xt),ke?Ae?(Ae.input=fe(Ae.input,nt),Ae[0]=fe(Ae[0],nt),Ae.index=ye.lastIndex,ye.lastIndex+=Ae[0].length):ye.lastIndex=0:me&&Ae&&(ye.lastIndex=ye.global?Ae.index+Ae[0].length:_e),we&&Ae&&Ae.length>1&&K(xe,Ae[0],Oe,(function(){for(Be=1;Beb)","g");return K.exec("b").groups.a!=="b"||"b".replace(K,"$c")!=="bc"}))},7750:function(q,X,j){var E=j(4117),U=TypeError;q.exports=function(K){if(E(K))throw new U("Can't call method on "+K);return K}},7633:function(q,X,j){var E=j(7751),U=j(2106),K=j(8227),H=j(3724),re=K("species");q.exports=function(O){var $=E(O);H&&$&&!$[re]&&U($,re,{configurable:!0,get:function(){return this}})}},687:function(q,X,j){var E=j(4913).f,U=j(9297),K=j(8227)("toStringTag");q.exports=function(H,re,O){H&&!O&&(H=H.prototype),H&&!U(H,K)&&E(H,K,{configurable:!0,value:re})}},6119:function(q,X,j){var E=j(5745),U=j(3392),K=E("keys");q.exports=function(H){return K[H]||(K[H]=U(H))}},7629:function(q,X,j){var E=j(6395),U=j(4576),K=j(9433),H="__core-js_shared__",re=q.exports=U[H]||K(H,{});(re.versions||(re.versions=[])).push({version:"3.48.0",mode:E?"pure":"global",copyright:"© 2013–2025 Denis Pushkarev (zloirock.ru), 2025–2026 CoreJS Company (core-js.io). All rights reserved.",license:"https://github.com/zloirock/core-js/blob/v3.48.0/LICENSE",source:"https://github.com/zloirock/core-js"})},5745:function(q,X,j){var E=j(7629);q.exports=function(U,K){return E[U]||(E[U]=K||{})}},2293:function(q,X,j){var E=j(8551),U=j(5548),K=j(4117),H=j(8227)("species");q.exports=function(re,O){var $,ee=E(re).constructor;return ee===void 0||K($=E(ee)[H])?O:U($)}},8183:function(q,X,j){var E=j(9504),U=j(1291),K=j(655),H=j(7750),re=E("".charAt),O=E("".charCodeAt),$=E("".slice),ee=function(W){return function(ie,ce){var be,xe,oe=K(H(ie)),L=U(ce),F=oe.length;return L<0||L>=F?W?"":void 0:(be=O(oe,L))<55296||be>56319||L+1===F||(xe=O(oe,L+1))<56320||xe>57343?W?re(oe,L):be:W?$(oe,L,L+2):xe-56320+(be-55296<<10)+65536}};q.exports={codeAt:ee(!1),charAt:ee(!0)}},706:function(q,X,j){var E=j(350).PROPER,U=j(9039),K=j(7452);q.exports=function(H){return U((function(){return!!K[H]()||"​…᠎"[H]()!=="​…᠎"||E&&K[H].name!==H}))}},3802:function(q,X,j){var E=j(9504),U=j(7750),K=j(655),H=j(7452),re=E("".replace),O=RegExp("^["+H+"]+"),$=RegExp("(^|[^"+H+"])["+H+"]+$"),ee=function(W){return function(ie){var ce=K(U(ie));return 1&W&&(ce=re(ce,O,"")),2&W&&(ce=re(ce,$,"$1")),ce}};q.exports={start:ee(1),end:ee(2),trim:ee(3)}},4495:function(q,X,j){var E=j(9519),U=j(9039),K=j(4576).String;q.exports=!!Object.getOwnPropertySymbols&&!U((function(){var H=Symbol("symbol detection");return!K(H)||!(Object(H)instanceof Symbol)||!Symbol.sham&&E&&E<41}))},8242:function(q,X,j){var E=j(9565),U=j(7751),K=j(8227),H=j(6840);q.exports=function(){var re=U("Symbol"),O=re&&re.prototype,$=O&&O.valueOf,ee=K("toPrimitive");O&&!O[ee]&&H(O,ee,(function(W){return E($,this)}),{arity:1})}},1296:function(q,X,j){var E=j(4495);q.exports=E&&!!Symbol.for&&!!Symbol.keyFor},1240:function(q,X,j){var E=j(9504);q.exports=E(1.1.valueOf)},5610:function(q,X,j){var E=j(1291),U=Math.max,K=Math.min;q.exports=function(H,re){var O=E(H);return O<0?U(O+re,0):K(O,re)}},5397:function(q,X,j){var E=j(7055),U=j(7750);q.exports=function(K){return E(U(K))}},1291:function(q,X,j){var E=j(741);q.exports=function(U){var K=+U;return K!=K||K===0?0:E(K)}},8014:function(q,X,j){var E=j(1291),U=Math.min;q.exports=function(K){var H=E(K);return H>0?U(H,9007199254740991):0}},8981:function(q,X,j){var E=j(7750),U=Object;q.exports=function(K){return U(E(K))}},2777:function(q,X,j){var E=j(9565),U=j(34),K=j(757),H=j(5966),re=j(4270),O=j(8227),$=TypeError,ee=O("toPrimitive");q.exports=function(W,ie){if(!U(W)||K(W))return W;var ce,be=H(W,ee);if(be){if(ie===void 0&&(ie="default"),ce=E(be,W,ie),!U(ce)||K(ce))return ce;throw new $("Can't convert object to primitive value")}return ie===void 0&&(ie="number"),re(W,ie)}},6969:function(q,X,j){var E=j(2777),U=j(757);q.exports=function(K){var H=E(K,"string");return U(H)?H:H+""}},2140:function(q,X,j){var E={};E[j(8227)("toStringTag")]="z",q.exports=String(E)==="[object z]"},655:function(q,X,j){var E=j(6955),U=String;q.exports=function(K){if(E(K)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return U(K)}},6823:function(q){var X=String;q.exports=function(j){try{return X(j)}catch{return"Object"}}},3392:function(q,X,j){var E=j(9504),U=0,K=Math.random(),H=E(1.1.toString);q.exports=function(re){return"Symbol("+(re===void 0?"":re)+")_"+H(++U+K,36)}},7040:function(q,X,j){var E=j(4495);q.exports=E&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686:function(q,X,j){var E=j(3724),U=j(9039);q.exports=E&&U((function(){return Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype!==42}))},8622:function(q,X,j){var E=j(4576),U=j(4901),K=E.WeakMap;q.exports=U(K)&&/native code/.test(String(K))},511:function(q,X,j){var E=j(9167),U=j(9297),K=j(1951),H=j(4913).f;q.exports=function(re){var O=E.Symbol||(E.Symbol={});U(O,re)||H(O,re,{value:K.f(re)})}},1951:function(q,X,j){var E=j(8227);X.f=E},8227:function(q,X,j){var E=j(4576),U=j(5745),K=j(9297),H=j(3392),re=j(4495),O=j(7040),$=E.Symbol,ee=U("wks"),W=O?$.for||$:$&&$.withoutSetter||H;q.exports=function(ie){return K(ee,ie)||(ee[ie]=re&&K($,ie)?$[ie]:W("Symbol."+ie)),ee[ie]}},7452:function(q){q.exports=` diff --git a/static/index.html b/static/index.html index 76f8af18f..3091e4e00 100644 --- a/static/index.html +++ b/static/index.html @@ -23,7 +23,7 @@ - +