diff --git a/CHANGELOG.md b/CHANGELOG.md index a23a46551..0a6d716fe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ All notable changes to Bambuddy will be documented in this file. - **WiFi Safeguard for SpoolBuddy Pi** — The install script now drops an APT hook (`/etc/apt/apt.conf.d/80-preserve-wifi`) that backs up NetworkManager WiFi connections before every `apt upgrade` and restores them if they get wiped. Prevents headless SpoolBuddy Pis from losing WiFi connectivity after Raspberry Pi OS package upgrades (observed with Bookworm kernel/raspi-config updates that clear `/etc/NetworkManager/system-connections/`). - **SpoolBuddy Install Script Now Upgrades System Packages** — The install script now runs `apt-get upgrade -y` after installing required packages and the WiFi safeguard. This ensures the Pi is fully up to date before SpoolBuddy is deployed, and the WiFi safeguard protects connectivity during the upgrade. - **SpoolBuddy Assign-to-AMS Material Mismatch Warnings** — The SpoolBuddy "Assign to AMS" modal now warns when the spool's material or slicer profile doesn't match the target slot's current filament. Shows a confirmation dialog with five warning levels: exact material mismatch, partial material match, profile-only mismatch, and combined material+profile mismatches. Respects the global `disable_filament_warnings` setting. Previously, assigning a spool to an occupied slot proceeded without any validation, matching the behavior already present in the main Assign Spool modal. +- **Spool Assignment Changes Sync Across Tabs** — Assigning or unassigning a spool now broadcasts a WebSocket event to all connected clients. Other open browser tabs and the SpoolBuddy frontend update automatically without requiring a page reload. ### Fixed - **Delete Tag Leaves Stale Tag Type** — The "Delete Tag" button in the spool edit modal only cleared `tag_uid` but left `tray_uuid`, `tag_type`, and `data_origin` intact. All tag-related fields are now cleared together. diff --git a/backend/app/api/routes/inventory.py b/backend/app/api/routes/inventory.py index 5e70b5601..cffef7fdf 100644 --- a/backend/app/api/routes/inventory.py +++ b/backend/app/api/routes/inventory.py @@ -13,6 +13,7 @@ from backend.app.core.auth import RequirePermissionIfAuthEnabled from backend.app.core.catalog_defaults import DEFAULT_COLOR_CATALOG, DEFAULT_SPOOL_CATALOG from backend.app.core.database import get_db from backend.app.core.permissions import Permission +from backend.app.core.websocket import ws_manager from backend.app.models.ams_label import AmsLabel from backend.app.models.color_catalog import ColorCatalogEntry from backend.app.models.spool import Spool @@ -1100,6 +1101,16 @@ async def assign_spool( resp = result.scalar_one() response = SpoolAssignmentResponse.model_validate(resp) response.configured = configured + + await ws_manager.broadcast( + { + "type": "spool_assignment_changed", + "printer_id": data.printer_id, + "ams_id": data.ams_id, + "tray_id": data.tray_id, + } + ) + return response @@ -1125,6 +1136,16 @@ async def unassign_spool( await db.delete(assignment) await db.commit() + + await ws_manager.broadcast( + { + "type": "spool_assignment_changed", + "printer_id": printer_id, + "ams_id": ams_id, + "tray_id": tray_id, + } + ) + return {"status": "deleted"} diff --git a/backend/tests/unit/services/test_printer_manager.py b/backend/tests/unit/services/test_printer_manager.py index cfff3ace8..d7ef1cc86 100644 --- a/backend/tests/unit/services/test_printer_manager.py +++ b/backend/tests/unit/services/test_printer_manager.py @@ -1163,17 +1163,23 @@ class TestHasStgCurIdleBug: assert has_stg_cur_idle_bug("a1") is True # case insensitive assert has_stg_cur_idle_bug("a1 mini") is True - def test_a1_internal_codes_return_true(self): - """Verify A1 internal model codes return True.""" + def test_p1_models_return_true(self): + """Verify P1P/P1S model variants return True.""" + assert has_stg_cur_idle_bug("P1P") is True + assert has_stg_cur_idle_bug("P1S") is True + assert has_stg_cur_idle_bug("p1p") is True # case insensitive + + def test_internal_codes_return_true(self): + """Verify internal model codes return True.""" assert has_stg_cur_idle_bug("N1") is True # A1 Mini assert has_stg_cur_idle_bug("N2S") is True # A1 + assert has_stg_cur_idle_bug("C11") is True # P1P + assert has_stg_cur_idle_bug("C12") is True # P1S - def test_non_a1_models_return_false(self): - """Verify non-A1 models return False.""" + def test_non_affected_models_return_false(self): + """Verify non-affected models return False.""" assert has_stg_cur_idle_bug("X1C") is False assert has_stg_cur_idle_bug("X1") is False - assert has_stg_cur_idle_bug("P1P") is False - assert has_stg_cur_idle_bug("P1S") is False assert has_stg_cur_idle_bug("H2D") is False def test_none_model_returns_false(self): diff --git a/frontend/src/hooks/useWebSocket.ts b/frontend/src/hooks/useWebSocket.ts index b266c613f..d430f9583 100644 --- a/frontend/src/hooks/useWebSocket.ts +++ b/frontend/src/hooks/useWebSocket.ts @@ -263,6 +263,12 @@ export function useWebSocket() { })); break; + case 'spool_assignment_changed': + // Spool assigned/unassigned - refresh assignment data across all tabs + debouncedInvalidate('spool-assignments'); + debouncedInvalidate('slotPresets'); + break; + case 'spool_auto_assigned': // RFID tag matched - refresh inventory and assignment data debouncedInvalidate('inventory-spools'); diff --git a/static/assets/index-CS1ycNG7.js b/static/assets/index-BKqUb3-A.js similarity index 99% rename from static/assets/index-CS1ycNG7.js rename to static/assets/index-BKqUb3-A.js index c83c2f6ba..02d7842ef 100644 --- a/static/assets/index-CS1ycNG7.js +++ b/static/assets/index-BKqUb3-A.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:d=>{d.stopPropagation(),d.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(vr,{className:"w-3.5 h-3.5"})})]})]})}},r3={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||""} ${BI(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)}},DL="bambuddy-inventory-sort";function unt(){try{const t=localStorage.getItem(DL);if(t)return JSON.parse(t)}catch{}return null}function mnt(t){try{t?localStorage.setItem(DL,JSON.stringify(t)):localStorage.removeItem(DL)}catch{}}function hnt(){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.replace(/\/+$/,"")}/spool`,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(pnt,{})}function pnt(){const{t}=jt(),e=cn(),{showToast:n}=pn(),[r,a]=w.useState(null),[s,o]=w.useState(null),[l,c]=w.useState("active"),[d,u]=w.useState("all"),[m,p]=w.useState(""),[f,y]=w.useState(""),[v,b]=w.useState(""),[g,_]=w.useState("all"),[k,C]=w.useState(""),[N,M]=w.useState("table"),[T,j]=w.useState(unt),[A,F]=w.useState(ont),[G,U]=w.useState(!1),[J,I]=w.useState(()=>{try{return localStorage.getItem("bambuddy-inventory-group")==="true"}catch{return!1}}),[te,ae]=w.useState(new Set),[Z,de]=w.useState(0),[ue,he]=w.useState(()=>{try{const Ce=localStorage.getItem("bambuddy-inventory-pageSize");if(Ce){const Te=Number(Ce);if([15,30,50,100,-1].includes(Te))return Te}}catch{}return 15}),{data:K}=et({queryKey:["settings"],queryFn:ge.getSettings}),se=K?.date_format||"system",{data:ce,isLoading:fe}=et({queryKey:["inventory-spools"],queryFn:()=>ge.getSpools(!0),refetchInterval:3e4}),{data:Se}=et({queryKey:["spool-assignments"],queryFn:()=>ge.getAssignments(),refetchInterval:3e4}),{data:B}=et({queryKey:["spool-catalog"],queryFn:()=>ge.getSpoolCatalog()}),X=ht({mutationFn:Ce=>ge.deleteSpool(Ce),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolDeleted"),"success")}}),D=ht({mutationFn:Ce=>ge.archiveSpool(Ce),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolArchived"),"success")}}),P=ht({mutationFn:Ce=>ge.restoreSpool(Ce),onSuccess:()=>{e.invalidateQueries({queryKey:["inventory-spools"]}),n(t("inventory.spoolRestored"),"success")}}),z=async Ce=>{if(Ce.last_scale_weight!=null)try{await zi.updateSpoolWeight(Ce.id,Ce.last_scale_weight),e.invalidateQueries({queryKey:["inventory-spools"]});const Te=[Ce.brand,Ce.material,Ce.color_name].filter(Boolean).join(" ");n(`Synced "${Te}" to scale weight`,"success")}catch{n("Failed to sync weight","error")}},W=K?.low_stock_threshold??20,[H,re]=w.useState(!1),[O,q]=w.useState(W.toString());w.useEffect(()=>{H||q(W.toString())},[W,H]);const Y=ht({mutationFn:Ce=>ge.updateSettings({low_stock_threshold:Ce}),onSuccess:()=>{e.invalidateQueries({queryKey:["settings"]}),n(t("common.saved"),"success"),re(!1)},onError:()=>{n(t("inventory.lowStockThresholdError"),"error")}}),V=w.useMemo(()=>{if(!ce)return null;let Ce=0,Te=0,$e=0,nt=0;const bt={};for(const vt of ce){if(vt.archived_at)continue;nt++;const mt=Math.max(0,vt.label_weight-vt.weight_used);Ce+=mt,Te+=vt.weight_used,(vt.label_weight>0?mt/vt.label_weight*100:0){const Ce={};for(const Te of Se||[])Ce[Te.spool_id]=Te;return Ce},[Se]),pe=w.useMemo(()=>{const Ce={};for(const Te of B||[])Ce[Te.id]=Te;return Ce},[B]),ie=w.useMemo(()=>V?Object.entries(V.byMaterial).sort((Ce,Te)=>Te[1].weight-Ce[1].weight).slice(0,4):[],[V]),L=w.useMemo(()=>{let Ce=ce||[];if(l==="active"?Ce=Ce.filter(Te=>!Te.archived_at):Ce=Ce.filter(Te=>!!Te.archived_at),d==="used"?Ce=Ce.filter(Te=>Te.weight_used>0):d==="new"?Ce=Ce.filter(Te=>Te.weight_used===0):d==="lowstock"&&(Ce=Ce.filter(Te=>{const $e=Math.max(0,Te.label_weight-Te.weight_used);return(Te.label_weight>0?$e/Te.label_weight*100:0)Te.material===m)),f&&(Ce=Ce.filter(Te=>Te.brand===f)),v){const Te=Number(v);Ce=Ce.filter($e=>$e.core_weight_catalog_id===Te)}if(g==="stock"?Ce=Ce.filter(Te=>!Te.slicer_filament):g==="configured"&&(Ce=Ce.filter(Te=>!!Te.slicer_filament)),k){const Te=k.toLowerCase();Ce=Ce.filter($e=>$e.brand?.toLowerCase().includes(Te)||$e.material.toLowerCase().includes(Te)||$e.color_name?.toLowerCase().includes(Te)||$e.subtype?.toLowerCase().includes(Te)||$e.note?.toLowerCase().includes(Te)||$e.slicer_filament_name?.toLowerCase().includes(Te))}return Ce},[ce,l,d,m,f,v,g,k,W]),R=()=>de(0),ne=[...new Set(ce?.map(Ce=>Ce.material)||[])].sort(),ye=[...new Set(ce?.map(Ce=>Ce.brand).filter(Boolean)||[])].sort(),ve=[...new Set(ce?.map(Ce=>Ce.core_weight_catalog_id).filter(Ce=>Ce!=null)||[])].sort((Ce,Te)=>{const $e=(pe[Ce]?.name||"").toLowerCase(),nt=(pe[Te]?.name||"").toLowerCase();return $e.localeCompare(nt)}),be=l!=="active"||d!=="all"||!!m||!!f||!!v||g!=="all"||!!k,Be=Ce=>{F(Ce),lnt(Ce)},we=w.useMemo(()=>A.filter(Ce=>Ce.visible).map(Ce=>Ce.id),[A]),Ae=Ce=>{r3[Ce]&&(j(Te=>{let $e;return Te?.column===Ce?$e=Te.direction==="asc"?{column:Ce,direction:"desc"}:null:$e={column:Ce,direction:"asc"},mnt($e),$e}),R())},Le=w.useMemo(()=>{if(!T)return L;const Ce=r3[T.column];return Ce?[...L].sort(($e,nt)=>{const bt=Ce($e,me),vt=Ce(nt,me);return btvt?T.direction==="asc"?1:-1:0}):L},[L,T,me]),Ee=w.useMemo(()=>{if(!J)return Le.map(nt=>({type:"single",spool:nt}));const Ce=new Map;for(const nt of Le)if(!(nt.weight_used>0||me[nt.id])){const bt=qY(nt),vt=Ce.get(bt);vt?vt.push(nt):Ce.set(bt,[nt])}const Te=[],$e=new Set;for(const nt of Le){if(nt.weight_used>0||me[nt.id]){Te.push({type:"single",spool:nt});continue}const bt=qY(nt);if($e.has(bt))continue;$e.add(bt);const vt=Ce.get(bt);vt.length===1?Te.push({type:"single",spool:vt[0]}):Te.push({type:"group",key:bt,spools:vt,representative:vt[0]})}return Te},[Le,J,me]),ke=ue===-1,Me=Ee.length,He=ke?Me||1:ue,De=Math.max(1,Math.ceil(Me/He)),Xe=ke?0:Math.min(Z,De-1),xe=ke?Ee:Ee.slice(Xe*He,(Xe+1)*He),We=()=>{const Ce=!J;I(Ce),ae(new Set),R();try{localStorage.setItem("bambuddy-inventory-group",String(Ce))}catch{}},Pe=Ce=>{ae(Te=>{const $e=new Set(Te);return $e.has(Ce)?$e.delete(Ce):$e.add(Ce),$e})},Ke=Ce=>{he(Ce),de(0);try{localStorage.setItem("bambuddy-inventory-pageSize",String(Ce))}catch{}},Ve=()=>{c("active"),u("all"),p(""),y(""),b(""),_("all"),C(""),R()};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(Ii,{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(Ie,{onClick:()=>a({spool:null}),children:[i.jsx(ir,{className:"w-4 h-4"}),t("inventory.addSpool")]})]}),V&&!fe&&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(Ii,{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:md(V.totalWeight,!0)}),i.jsxs("div",{className:"text-xs text-bambu-gray mt-1",children:[V.totalSpools," ",V.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(nO,{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:md(V.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(Ki,{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:ie.map(([Ce,Te])=>i.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${cnt[Ce]||"bg-bambu-dark-tertiary text-bambu-gray"}`,children:[Ce," ",i.jsx("span",{className:"opacity-70",children:md(Te.weight,!0)})]},Ce))})]}),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:ee}),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 ${V.lowStock>0?"text-yellow-400":"text-white"}`,children:V.lowStock}),i.jsx("div",{className:"text-xs text-bambu-gray mt-1 flex items-center gap-2",children:H?i.jsxs("form",{onSubmit:Ce=>{Ce.preventDefault();const Te=parseFloat(O);!isNaN(Te)&&Te>=.1&&Te<=99.9?Y.mutate(Te):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:Ce=>{const Te=Ce.target.value.replace(/[^\d.]/g,"");/^\d{0,2}(\.\d?)?$/.test(Te)&&q(Te)},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:Ce=>Ce.currentTarget.blur(),disabled:Y.isPending}),i.jsx("span",{className:"text-xs text-bambu-gray",children:"%"}),i.jsx(Ie,{type:"submit",size:"sm",disabled:Y.isPending,children:t("common.save")}),i.jsx(Ie,{type:"button",size:"sm",variant:"ghost",onClick:()=>re(!1),disabled:Y.isPending,children:t("common.cancel")})]}):i.jsxs(i.Fragment,{children:[i.jsxs("span",{className:"text-bambu-gray",children:["< ",W,"%"]}),i.jsx("button",{className:"p-1.5 text-bambu-gray hover:text-white rounded transition-colors",title:t("common.edit"),onClick:()=>{q(W.toString()),re(!0)},children:i.jsx(fh,{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(Fr,{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:k,onChange:Ce=>{C(Ce.target.value),R()},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"}),k&&i.jsx("button",{onClick:()=>{C(""),R()},className:"absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white",children:i.jsx(qt,{className:"w-4 h-4"})})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[N==="table"&&i.jsxs("button",{onClick:()=>U(!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(Bpe,{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 ${J?"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(Lfe,{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:()=>M("table"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="table"?"bg-bambu-green text-white":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:[i.jsx(Pbe,{className:"w-4 h-4"}),i.jsx("span",{className:"hidden sm:inline",children:t("inventory.table")})]}),i.jsxs("button",{onClick:()=>M("cards"),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium transition-colors ${N==="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"),R()},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(Ii,{className:"w-3.5 h-3.5"}),t("inventory.active")]}),i.jsxs("button",{onClick:()=>{c("archived"),R()},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:()=>{u("all"),R()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="all"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.all")}),i.jsxs("button",{onClick:()=>{u("used"),R()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${d==="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:()=>{u("new"),R()},className:`px-3 py-1.5 text-xs font-medium transition-colors ${d==="new"?"bg-bambu-green/20 text-bambu-green":"text-bambu-gray hover:bg-bambu-dark-tertiary"}`,children:t("inventory.new")}),i.jsxs("button",{onClick:()=>{u("lowstock"),R()},className:`flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium transition-colors ${d==="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"),R()},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"),R()},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"),R()},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:Ce=>{p(Ce.target.value),R()},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")}),ne.map(Ce=>i.jsx("option",{value:Ce,children:Ce},Ce))]}),i.jsxs("select",{value:f,onChange:Ce=>{y(Ce.target.value),R()},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")}),ye.map(Ce=>i.jsx("option",{value:Ce,children:Ce},Ce))]}),ve.length>0&&i.jsxs("select",{value:v,onChange:Ce=>{b(Ce.target.value),R()},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")}),ve.map(Ce=>i.jsx("option",{value:Ce,children:pe[Ce]?.name||`#${Ce}`},Ce))]}),be&&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(qt,{className:"w-3.5 h-3.5"}),t("inventory.clearFilters")]})]}),i.jsxs("span",{className:"ml-auto text-xs text-bambu-gray",children:[Le.length," ",Le.length!==1?t("inventory.spools"):t("inventory.spool"),J&&Me0?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:xe.map(Ce=>{if(Ce.type==="group"){const{key:vt,spools:mt,representative:Ht}=Ce,Yt=Ht.rgba?`#${Ht.rgba.substring(0,6)}`:"#808080",Pt=te.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:Yt},children:i.jsx("span",{className:"bg-white/90 text-gray-800 px-3 py-0.5 rounded-full text-sm font-medium",children:zI(Ht.color_name,Ht.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(zn,{className:`w-4 h-4 text-bambu-gray transition-transform ${Pt?"":"-rotate-90"}`}),i.jsxs("div",{children:[i.jsxs("h3",{className:"font-semibold text-white",children:[Ht.material,Ht.subtype?` ${Ht.subtype}`:""]}),i.jsx("p",{className:"text-sm text-bambu-gray",children:Ht.brand||"-"})]})]}),i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx("span",{className:"text-sm text-bambu-gray",children:md(Ht.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})})]})]})]}),Pt&&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(ut=>{const Lt=Math.max(0,ut.label_weight-ut.weight_used),qe=ut.label_weight>0?Lt/ut.label_weight*100:0,St=ut.rgba?`#${ut.rgba.substring(0,6)}`:"#808080";return i.jsx(VY,{spool:ut,remaining:Lt,pct:qe,colorStyle:St,onClick:()=>a({spool:ut}),t},ut.id)})})]},`group-${vt}`)}const Te=Ce.spool,$e=Math.max(0,Te.label_weight-Te.weight_used),nt=Te.label_weight>0?$e/Te.label_weight*100:0,bt=Te.rgba?`#${Te.rgba.substring(0,6)}`:"#808080";return i.jsx(VY,{spool:Te,remaining:$e,pct:nt,colorStyle:bt,onClick:()=>a({spool:Te}),t},Te.id)})}),i.jsx(fnt,{pageIndex:Xe,pageSize:ue,totalRows:Me,totalPages:De,onPageChange:de,onPageSizeChange:Ke,t})]}):i.jsx(GY,{hasFilters:be,onAddSpool:()=>a({spool:null}),t}):xe.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(Ce=>{const Te=!!r3[Ce],$e=T?.column===Ce;return i.jsx("th",{className:`text-left py-3 px-4 text-xs font-medium uppercase tracking-wide select-none ${Ce==="remaining"?"min-w-[150px]":""} ${Te?"cursor-pointer hover:text-bambu-green transition-colors":""} ${$e?"text-bambu-green":"text-bambu-gray"}`,onClick:Te?()=>Ae(Ce):void 0,children:i.jsxs("span",{className:"inline-flex items-center gap-1",children:[dnt[Ce]?.(t)??Ce,Te&&($e?T.direction==="asc"?i.jsx(Ef,{className:"w-3 h-3"}):i.jsx(ux,{className:"w-3 h-3"}):i.jsx(XL,{className:"w-3 h-3 opacity-30"}))]})},Ce)}),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:xe.map(Ce=>{if(Ce.type==="group"){const{key:bt,spools:vt,representative:mt}=Ce,Ht=te.has(bt),Yt=Math.max(0,mt.label_weight-mt.weight_used),Pt=mt.label_weight>0?Yt/mt.label_weight*100:0;return i.jsx(gnt,{spools:vt,representative:mt,remaining:Yt,pct:Pt,isExpanded:Ht,onToggle:()=>Pe(bt),onEdit:ut=>a({spool:ut}),onArchive:ut=>o({type:"archive",spoolId:ut}),onDelete:ut=>o({type:"delete",spoolId:ut}),visibleColumns:we,assignmentMap:me,catalogMap:pe,currencySymbol:oe,dateFormat:se,t,onSyncWeight:z},`group-${bt}`)}const Te=Ce.spool,$e=Math.max(0,Te.label_weight-Te.weight_used),nt=Te.label_weight>0?$e/Te.label_weight*100:0;return i.jsx(ble,{spool:Te,remaining:$e,pct:nt,onEdit:()=>a({spool:Te}),onRestore:()=>P.mutate(Te.id),onArchive:()=>o({type:"archive",spoolId:Te.id}),onDelete:()=>o({type:"delete",spoolId:Te.id}),visibleColumns:we,assignmentMap:me,catalogMap:pe,currencySymbol:oe,dateFormat:se,t,onSyncWeight:z},Te.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:ke?`${Me} ${t(Me!==1?"inventory.spools":"inventory.spool")}`:i.jsxs(i.Fragment,{children:[t("inventory.showing")," ",Xe*He+1," ",t("inventory.to")," ",Math.min((Xe+1)*He,Me)," ",t("inventory.of")," ",Me," ",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:ue,onChange:Ce=>Ke(Number(Ce.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(Ce=>i.jsx("option",{value:Ce,children:Ce},Ce)),i.jsx("option",{value:-1,children:t("inventory.all")})]}),!ke&&i.jsxs(i.Fragment,{children:[i.jsx("button",{onClick:()=>de(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(XX,{className:"w-4 h-4"})}),i.jsx("button",{onClick:()=>de(Ce=>Math.max(0,Ce-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(Ac,{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")," ",De]}),i.jsx("button",{onClick:()=>de(Ce=>Math.min(De-1,Ce+1)),disabled:Xe>=De-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:()=>de(De-1),disabled:Xe>=De-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(QX,{className:"w-4 h-4"})})]})]})]})]}):i.jsx(GY,{hasFilters:be,onAddSpool:()=>a({spool:null}),t}),r!==null&&i.jsx(ant,{isOpen:!0,onClose:()=>a(null),spool:r.spool,currencySymbol:oe}),s&&i.jsx(_n,{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):D.mutate(s.spoolId),o(null)},onCancel:()=>o(null)}),i.jsx(snt,{isOpen:G,onClose:()=>U(!1),columns:A,defaultColumns:Ak,onSave:Be})]})}function fnt({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:d=>s(Number(d.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(d=>i.jsx("option",{value:d,children:d},d)),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(XX,{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(Ac,{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(QX,{className:"w-4 h-4"})})]})]})]})}function VY({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:zI(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:md(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?md(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 ble({spool:t,remaining:e,pct:n,onEdit:r,onRestore:a,onArchive:s,onDelete:o,visibleColumns:l,assignmentMap:c,catalogMap:d,currencySymbol:u,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:jL[y]?.({spool:t,remaining:e,pct:n,assignmentMap:c,catalogMap:d,currencySymbol:u,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(fh,{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(Ao,{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(an,{className:"w-4 h-4"})})]})})]})}function gnt({spools:t,representative:e,remaining:n,pct:r,isExpanded:a,onToggle:s,onEdit:o,onArchive:l,onDelete:c,visibleColumns:d,assignmentMap:u,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:[d.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(zn,{className:`w-4 h-4 text-bambu-gray transition-transform ${a?"":"-rotate-90"}`}),jL[b]?.({spool:e,remaining:n,pct:r,assignmentMap:u,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})}):jL[b]?.({spool:e,remaining:n,pct:r,assignmentMap:u,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(ble,{spool:b,remaining:g,pct:_,onEdit:()=>o(b),onRestore:()=>{},onArchive:()=>l(b.id),onDelete:()=>c(b.id),visibleColumns:d,assignmentMap:u,catalogMap:m,currencySymbol:p,dateFormat:f,t:y,onSyncWeight:v},b.id)})]})}function GY({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(Fr,{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(Ie,{onClick:e,children:[i.jsx(Ii,{className:"w-4 h-4"}),n("inventory.addSpool")]})]})}const WY=["DEBUG","INFO","WARNING","ERROR"],i3={DEBUG:"text-gray-400",INFO:"text-blue-400",WARNING:"text-yellow-400",ERROR:"text-red-400"},bnt={DEBUG:mx,INFO:Hs,WARNING:jn,ERROR:Oi};function xnt(){const t=cn(),[e,n]=w.useState(!0),[r,a]=w.useState(new Set),[s,o]=w.useState(""),[l,c]=w.useState("ALL"),[d,u]=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:()=>Xb.getLogs({limit:200,level:l==="ALL"?void 0:l,search:s||void 0}),refetchInterval:m?2e3:!1,enabled:d});w.useEffect(()=>{d||p(!1)},[d]);const g=ht({mutationFn:()=>Xb.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(j=>{const A=new Set(j);return A.has(T)?A.delete(T):A.add(T),A})},k=T=>{const j=T.split(" ");return j.length>=2?j[1]:T},C=w.useMemo(()=>y?.entries??[],[y?.entries]),N=w.useMemo(()=>[...C].reverse(),[C]),M=({level:T})=>{const j=bnt[T]||Hs;return i.jsx(j,{className:`w-3.5 h-3.5 ${i3[T]||"text-gray-400"}`})};return i.jsxs("div",{className:"bg-bambu-dark rounded-lg overflow-hidden",children:[i.jsxs("button",{onClick:()=>u(!d),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(mx,{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"]}),d?i.jsx(Gl,{className:"w-5 h-5 text-bambu-gray"}):i.jsx(zn,{className:"w-5 h-5 text-bambu-gray"})]})]}),d&&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(Ks,{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(an,{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(vr,{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(Fr,{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(qt,{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"}),WY.map((T,j)=>i.jsx("button",{onClick:()=>c(T),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${j===WY.length-1?"rounded-r":""} ${l===T?`${i3[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:N.map((T,j)=>{const A=r.has(j),F=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:()=>F&&_(j),children:i.jsxs("div",{className:"flex items-start gap-2",children:[i.jsx("span",{className:"text-bambu-gray/70 shrink-0 w-20",children:k(T.timestamp)}),i.jsx("span",{className:"shrink-0",children:i.jsx(M,{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 ${i3[T.level]||"text-white/80"} ${!A&&F?"truncate":""}`,children:A?i.jsx("pre",{className:"whitespace-pre-wrap break-all",children:T.message}):T.message.split(` -`)[0]}),F&&i.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?i.jsx(Gl,{className:"w-3.5 h-3.5"}):i.jsx(zn,{className:"w-3.5 h-3.5"})})]})},j)})})}),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 ynt(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 Pi({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 KY({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 Xm({title:t,icon:e,children:n}){return i.jsxs(At,{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 vnt(){const{t}=jt(),e=cn(),[n,r]=w.useState(null),[a,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:d,refetch:u,isFetching:m}=et({queryKey:["systemInfo"],queryFn:ge.getSystemInfo,refetchInterval:3e4}),{data:p}=et({queryKey:["debugLogging"],queryFn:Xb.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 Xb.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 Xb.downloadSupportBundle()}catch(C){r(C instanceof Error?C.message:"Failed to download support bundle")}finally{s(!1)}};if(d)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",k=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:()=>u(),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(vr,{className:`w-4 h-4 ${m?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),i.jsx(Xm,{title:t("system.application","Application"),icon:Bp,children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Pi,{icon:Bp,label:t("system.version","Version"),value:`v${c.app.version}`}),i.jsx(Pi,{icon:Zn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),i.jsx(Pi,{icon:Bp,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),i.jsx(Xm,{title:t("support.title","Support & Troubleshooting"),icon:Hfe,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(mx,{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(xnt,{})]})}),i.jsxs(Xm,{title:t("system.database","Database"),icon:hd,children:[i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(Pi,{icon:Vs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),i.jsx(Pi,{icon:Sc,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),i.jsx(Pi,{icon:Wi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),i.jsx(Pi,{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(Pi,{icon:_r,label:t("system.printers","Printers"),value:c.database.printers}),i.jsx(Pi,{icon:Sw,label:t("system.filaments","Filaments"),value:c.database.filaments}),i.jsx(Pi,{icon:_s,label:t("system.projects","Projects"),value:c.database.projects}),i.jsx(Pi,{icon:Bl,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(Pi,{icon:Zn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),i.jsx(Pi,{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(Xm,{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(Xm,{title:t("system.storage","Storage"),icon:Gx,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(KY,{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(Pi,{icon:Vs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),i.jsx(Pi,{icon:hd,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),y&&i.jsx(Pi,{icon:Mc,label:t("system.fileManagerStorage","File Manager"),value:ynt(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(Xm,{title:t("system.memory","Memory"),icon:vge,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(KY,{percent:c.memory.percent_used,color:k}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),i.jsx(Xm,{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(Pi,{icon:m_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),i.jsx(Pi,{icon:m_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),i.jsx(Xm,{title:t("system.systemDetails","System Details"),icon:Bp,children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Pi,{icon:Bp,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),i.jsx(Pi,{icon:m_,label:t("system.architecture","Architecture"),value:c.system.architecture}),i.jsx(Pi,{icon:Bp,label:t("system.python","Python"),value:c.system.python_version}),i.jsx(Pi,{icon:Zn,label:t("system.bootTime","Boot Time"),value:Lf(c.system.boot_time,v)})]})})]})}function wnt(){const t=ol(),{t:e}=jt(),{login:n}=Ar(),{showToast:r}=pn(),{mode:a}=ag(),[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(!1),[m,p]=w.useState(""),{data:f}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),y=ht({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=ht({mutationFn:_=>ge.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),u(!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:()=>u(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),d&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>u(!1),children:i.jsxs(At,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(px,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{u(!1),p("")},children:i.jsx(qt,{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(Ie,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{u(!1),p("")},children:e("login.cancel")||"Cancel"}),i.jsx(Ie,{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(Ie,{variant:"secondary",className:"w-full",onClick:()=>u(!1),children:e("login.gotIt")})]})})]})})]})}function Snt(){const t=ol(),{t:e}=jt(),{showToast:n}=pn(),{mode:r}=ag(),{refreshAuth:a}=Ar(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[d,u]=w.useState(""),[m,p]=w.useState(""),f=ht({mutationFn:()=>ge.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?d: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||d)){if(!l||!d){n(e("setup.toast.enterBothCredentials"),"error");return}if(d!==m){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(d.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:d,onChange:v=>u(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"})]}),d&&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 _nt(){const{t}=jt(),{user:e}=Ar(),{showToast:n}=pn(),r=cn(),a=ol(),[s,o]=w.useState(!0),[l,c]=w.useState(!0),[d,u]=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:k,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(()=>{k&&(o(k.notify_print_start),c(k.notify_print_complete),u(k.notify_print_failed),p(k.notify_print_stopped),y(!1))},[k]);const N=ht({mutationFn:()=>ge.updateUserEmailPreferences({notify_print_start:s,notify_print_complete:l,notify_print_failed:d,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")}}),M=(T,j)=>{T(!j),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(Ch,{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(At,{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(px,{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(At,{className:"mb-6",children:[i.jsxs(Hn,{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(Sc,{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:()=>M(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(Sc,{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:()=>M(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 ${d?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(Sc,{className:`w-5 h-5 ${d?"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:()=>M(u,d),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 ${d?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":d,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d?"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(Sc,{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:()=>M(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(Ie,{onClick:()=>N.mutate(),disabled:!f||N.isPending||!e?.email,children:N.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 knt(){const t=w.useRef(null),e=w.useRef(null),n=cn(),[r,a]=w.useState(!1),s=w.useRef(new Map),{showToast:o}=pn(),{t:l}=jt(),c=w.useRef(new Set),d=w.useRef(null),u=w.useRef(new Map),m=w.useRef(null),p=w.useRef([]),f=w.useRef(!1),y=w.useRef(()=>{}),v=w.useCallback(()=>{if(f.current||p.current.length===0)return;f.current=!0;const N=()=>{const M=p.current.shift();M?requestAnimationFrame(()=>{y.current(M),p.current.length>0?setTimeout(N,16):f.current=!1}):f.current=!1};N()},[]),b=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const M=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(M);let j=null;T.onopen=()=>{console.log("[WebSocket] Connected"),a(!0),j=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=A=>{try{const F=JSON.parse(A.data);F.type==="printer_status"&&F.printer_id!==void 0&&F.data?y.current(F):(p.current.push(F),v())}catch{}},T.onclose=A=>{console.log("[WebSocket] Closed",A.code,A.reason),j&&(clearInterval(j),j=null),a(!1),t.current=null,e.current=window.setTimeout(()=>{b()},3e3)},T.onerror=A=>{console.error("[WebSocket] Error",A),T.close()},t.current=T},[v]),g=w.useCallback((N,M)=>{const T=u.current.get(N)||{};u.current.set(N,{...T,...M}),m.current||(m.current=window.setTimeout(()=>{const j=new Map(u.current);u.current.clear(),m.current=null,requestAnimationFrame(()=>{j.forEach((A,F)=>{n.setQueryData(["printerStatus",F],G=>{const U={...G,...A};return U.wifi_signal==null&&G?.wifi_signal!=null&&(U.wifi_signal=G.wifi_signal),U})})})},100))},[n]),_=w.useCallback(N=>{c.current.add(N),d.current&&clearTimeout(d.current),d.current=window.setTimeout(()=>{const M=Array.from(c.current);c.current.clear(),d.current=null;let T=0;M.forEach(j=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[j]})})},T),T+=500})},3e3)},[n]),k=w.useCallback(N=>{switch(N.type){case"printer_status":N.printer_id!==void 0&&N.data&&g(N.printer_id,N.data);break;case"print_start":N.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",N.printer_id]});break;case"missing_spool_assignment":{if(N.printer_id===void 0||!Array.isArray(N.missing_slots))break;const M=N.missing_slots.map(F=>F&&typeof F.slot=="string"?F.slot:"Unknown").filter(F=>F.length>0);if(M.length===0){s.current.delete(N.printer_id);break}const T=M.join("|");if(s.current.get(N.printer_id)===T)break;s.current.set(N.printer_id,T);const j=N.printer_name||`Printer ${N.printer_id}`,A=l("printers.toast.missingSpoolAssignment",{printer:j,slots:M.join(", ")});o(A,"warning");break}case"print_complete":_("archives"),_("archiveStats");break;case"archive_created":_("archives"),_("archiveStats");break;case"archive_updated":_("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:N.printer_id,printer_name:N.printer_name,message:N.message}}));break;case"spool_auto_assigned":_("inventory-spools"),_("spool-assignments");break;case"spool_usage_logged":_("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:N.printer_id,ams_id:N.ams_id,tray_id:N.tray_id,tag_uid:N.tag_uid,tray_uuid:N.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:N.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:N}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:N})),_("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:N}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:N}));break;case"spoolbuddy_tag_written":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-written",{detail:N})),_("inventory-spools");break;case"spoolbuddy_tag_write_failed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-write-failed",{detail:N}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:N})),_("spoolbuddy-devices"),_("spoolbuddy-update-check");break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:N})),_("spoolbuddy-devices");break;case"spoolbuddy_update":_("spoolbuddy-devices"),_("spoolbuddy-update-check");break}},[n,_,g,o,l]);w.useEffect(()=>{y.current=k},[k]),w.useEffect(()=>(b(),()=>{e.current&&clearTimeout(e.current),d.current&&clearTimeout(d.current),m.current&&clearTimeout(m.current),t.current&&t.current.close()}),[b]);const C=w.useCallback(N=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(N))},[]);return{isConnected:r,sendMessage:C}}function Nnt({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=jt(),[a,s]=w.useState(new Date),{data:o=[]}=et({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),l=ig({queries:o.map(u=>({queryKey:["printerStatus",u.id],queryFn:()=>ge.getPrinterStatus(u.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((u,m)=>l[m]?.data?.connected),[o,l]);w.useEffect(()=>{const u=c.some(m=>m.id===t);(!t||!u)&&c.length>0&&e(c[0].id)},[c,t,e]);const{data:d}=et({queryKey:["settings"],queryFn:ge.getSettings});return w.useEffect(()=>{const u=setInterval(()=>s(new Date),1e3);return()=>clearInterval(u)},[]),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:u=>e(Number(u.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(u=>i.jsx("option",{value:u.id,children:u.name},u.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(u=>i.jsx("div",{className:`w-1 rounded-sm ${u<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${u*4}px`}},u))}):i.jsx(Hh,{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:yQ(a,d?.time_format||"system")})]})]})}const Cnt=[{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 Tnt(){const{t}=jt();return i.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:Cnt.map(e=>i.jsxs(Ub,{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 Ant({alert:t}){const{t:e}=jt(),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 Pnt={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function Mnt(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 Ent(){const[t,e]=w.useReducer(Mnt,Pnt),n=w.useCallback(u=>{const m=u.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(u=>{const m=u.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(u=>{const m=u.detail;e({type:"UNKNOWN_TAG",tagUid:m.tag_uid??m.data?.tag_uid??"",deviceId:m.device_id??m.data?.device_id??""})},[]),s=w.useCallback(u=>{const m=u.detail;e({type:"TAG_REMOVED",deviceId:m.device_id??m.data?.device_id??""})},[]),o=w.useCallback(u=>{const m=u.detail;e({type:"DEVICE_ONLINE",deviceId:m.device_id??m.data?.device_id??""})},[]),l=w.useCallback(u=>{const m=u.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,d=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:d}}var Pk={exports:{}};var jnt=Pk.exports,YY;function Dnt(){return YY||(YY=1,(function(t,e){(function(n,r){t.exports=r(ng())})(jnt,(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",d="prototype",u=l.Element[d],m=Object,p=String[d].trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=Array[d].indexOf||function(C){for(var N=0,M=this.length;N1?arguments[1]:void 0)}},7916:function(B,X,D){var P=D(6080),z=D(9565),W=D(8981),H=D(6319),re=D(4209),O=D(3517),q=D(6198),Y=D(4659),V=D(4527),ee=D(81),oe=D(851),me=Array;B.exports=function(pe){var ie=W(pe),L=O(this),R=arguments.length,ne=R>1?arguments[1]:void 0,ye=ne!==void 0;ye&&(ne=P(ne,R>2?arguments[2]:void 0));var ve,be,Be,we,Ae,Le,Ee=oe(ie),ke=0;if(!Ee||this===me&&re(Ee))for(ve=q(ie),be=L?new this(ve):me(ve);ve>ke;ke++)Le=ye?ne(ie[ke],ke):ie[ke],Y(be,ke,Le);else for(be=L?new this:[],Ae=(we=ee(ie,Ee)).next;!(Be=z(Ae,we)).done;ke++)Le=ye?H(we,ne,[Be.value,ke],!0):Be.value,Y(be,ke,Le);return V(be,ke),be}},9617:function(B,X,D){var P=D(5397),z=D(5610),W=D(6198),H=function(re){return function(O,q,Y){var V=P(O),ee=W(V);if(ee===0)return!re&&-1;var oe,me=z(Y,ee);if(re&&q!=q){for(;ee>me;)if((oe=V[me++])!=oe)return!0}else for(;ee>me;me++)if((re||me in V)&&V[me]===q)return re||me||0;return!re&&-1}};B.exports={includes:H(!0),indexOf:H(!1)}},9213:function(B,X,D){var P=D(6080),z=D(7055),W=D(8981),H=D(6198),re=D(1469),O=D(4659),q=function(Y){var V=Y===1,ee=Y===2,oe=Y===3,me=Y===4,pe=Y===6,ie=Y===7,L=Y===5||pe;return function(R,ne,ye){for(var ve,be,Be=W(R),we=z(Be),Ae=H(we),Le=P(ne,ye),Ee=0,ke=0,Me=V?re(R,Ae):ee||ie?re(R,0):void 0;Ae>Ee;Ee++)if((L||Ee in we)&&(be=Le(ve=we[Ee],Ee,Be),Y))if(V)O(Me,Ee,be);else if(be)switch(Y){case 3:return!0;case 5:return ve;case 6:return Ee;case 2:O(Me,ke++,ve)}else switch(Y){case 4:return!1;case 7:O(Me,ke++,ve)}return pe?-1:oe||me?me:Me}};B.exports={forEach:q(0),map:q(1),filter:q(2),some:q(3),every:q(4),find:q(5),findIndex:q(6),filterReject:q(7)}},597:function(B,X,D){var P=D(9039),z=D(8227),W=D(9519),H=z("species");B.exports=function(re){return W>=51||!P((function(){var O=[];return(O.constructor={})[H]=function(){return{foo:1}},O[re](Boolean).foo!==1}))}},4598:function(B,X,D){var P=D(9039);B.exports=function(z,W){var H=[][z];return!!H&&P((function(){H.call(null,W||function(){return 1},1)}))}},926:function(B,X,D){var P=D(9306),z=D(8981),W=D(7055),H=D(6198),re=TypeError,O="Reduce of empty array with no initial value",q=function(Y){return function(V,ee,oe,me){var pe=z(V),ie=W(pe),L=H(pe);if(P(ee),L===0&&oe<2)throw new re(O);var R=Y?L-1:0,ne=Y?-1:1;if(oe<2)for(;;){if(R in ie){me=ie[R],R+=ne;break}if(R+=ne,Y?R<0:L<=R)throw new re(O)}for(;Y?R>=0:L>R;R+=ne)R in ie&&(me=ee(me,ie[R],R,pe));return me}};B.exports={left:q(!1),right:q(!0)}},4527:function(B,X,D){var P=D(3724),z=D(4376),W=TypeError,H=Object.getOwnPropertyDescriptor,re=P&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(O){return O instanceof TypeError}})();B.exports=re?function(O,q){if(z(O)&&!H(O,"length").writable)throw new W("Cannot set read only .length");return O.length=q}:function(O,q){return O.length=q}},7680:function(B,X,D){var P=D(9504);B.exports=P([].slice)},4488:function(B,X,D){var P=D(7680),z=Math.floor,W=function(H,re){var O=H.length;if(O<8)for(var q,Y,V=1;V0;)H[Y]=H[--Y];Y!==V++&&(H[Y]=q)}else for(var ee=z(O/2),oe=W(P(H,0,ee),re),me=W(P(H,ee),re),pe=oe.length,ie=me.length,L=0,R=0;L9007199254740991)throw X("Maximum allowed index exceeded");return D}},7400:function(B){B.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(B,X,D){var P=D(4055)("span").classList,z=P&&P.constructor&&P.constructor.prototype;B.exports=z===Object.prototype?void 0:z},8727:function(B){B.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709:function(B,X,D){var P=D(2839).match(/firefox\/(\d+)/i);B.exports=!!P&&+P[1]},3763:function(B,X,D){var P=D(2839);B.exports=/MSIE|Trident/.test(P)},6193:function(B,X,D){var P=D(4215);B.exports=P==="NODE"},2839:function(B,X,D){var P=D(4576).navigator,z=P&&P.userAgent;B.exports=z?String(z):""},9519:function(B,X,D){var P,z,W=D(4576),H=D(2839),re=W.process,O=W.Deno,q=re&&re.versions||O&&O.version,Y=q&&q.v8;Y&&(z=(P=Y.split("."))[0]>0&&P[0]<4?1:+(P[0]+P[1])),!z&&H&&(!(P=H.match(/Edge\/(\d+)/))||P[1]>=74)&&(P=H.match(/Chrome\/(\d+)/))&&(z=+P[1]),B.exports=z},3607:function(B,X,D){var P=D(2839).match(/AppleWebKit\/(\d+)\./);B.exports=!!P&&+P[1]},4215:function(B,X,D){var P=D(4576),z=D(2839),W=D(2195),H=function(re){return z.slice(0,re.length)===re};B.exports=H("Bun/")?"BUN":H("Cloudflare-Workers")?"CLOUDFLARE":H("Deno/")?"DENO":H("Node.js/")?"NODE":P.Bun&&typeof Bun.version=="string"?"BUN":P.Deno&&typeof Deno.version=="object"?"DENO":W(P.process)==="process"?"NODE":P.window&&P.document?"BROWSER":"REST"},6518:function(B,X,D){var P=D(4576),z=D(7347).f,W=D(6699),H=D(6840),re=D(9433),O=D(7740),q=D(2796);B.exports=function(Y,V){var ee,oe,me,pe,ie,L=Y.target,R=Y.global,ne=Y.stat;if(ee=R?P:ne?P[L]||re(L,{}):P[L]&&P[L].prototype)for(oe in V){if(pe=V[oe],me=Y.dontCallGetSet?(ie=z(ee,oe))&&ie.value:ee[oe],!q(R?oe:L+(ne?".":"#")+oe,Y.forced)&&me!==void 0){if(typeof pe==typeof me)continue;O(pe,me)}(Y.sham||me&&me.sham)&&W(pe,"sham",!0),H(ee,oe,pe,Y)}}},9039:function(B){B.exports=function(X){try{return!!X()}catch{return!0}}},9228:function(B,X,D){D(7495);var P=D(9565),z=D(6840),W=D(7323),H=D(9039),re=D(8227),O=D(6699),q=re("species"),Y=RegExp.prototype;B.exports=function(V,ee,oe,me){var pe=re(V),ie=!H((function(){var ye={};return ye[pe]=function(){return 7},""[V](ye)!==7})),L=ie&&!H((function(){var ye=!1,ve=/a/;if(V==="split"){var be={};be[q]=function(){return ve},(ve={constructor:be,flags:""})[pe]=/./[pe]}return ve.exec=function(){return ye=!0,null},ve[pe](""),!ye}));if(!ie||!L||oe){var R=/./[pe],ne=ee(pe,""[V],(function(ye,ve,be,Be,we){var Ae=ve.exec;return Ae===W||Ae===Y.exec?ie&&!we?{done:!0,value:P(R,ve,be,Be)}:{done:!0,value:P(ye,be,ve,Be)}:{done:!1}}));z(String.prototype,V,ne[0]),z(Y,pe,ne[1])}me&&O(Y[pe],"sham",!0)}},8745:function(B,X,D){var P=D(616),z=Function.prototype,W=z.apply,H=z.call;B.exports=typeof Reflect=="object"&&Reflect.apply||(P?H.bind(W):function(){return H.apply(W,arguments)})},6080:function(B,X,D){var P=D(7476),z=D(9306),W=D(616),H=P(P.bind);B.exports=function(re,O){return z(re),O===void 0?re:W?H(re,O):function(){return re.apply(O,arguments)}}},616:function(B,X,D){var P=D(9039);B.exports=!P((function(){var z=(function(){}).bind();return typeof z!="function"||z.hasOwnProperty("prototype")}))},566:function(B,X,D){var P=D(9504),z=D(9306),W=D(34),H=D(9297),re=D(7680),O=D(616),q=Function,Y=P([].concat),V=P([].join),ee={};B.exports=O?q.bind:function(oe){var me=z(this),pe=me.prototype,ie=re(arguments,1),L=function(){var R=Y(ie,re(arguments));return this instanceof L?(function(ne,ye,ve){if(!H(ee,ye)){for(var be=[],Be=0;Be]*>)/g,Y=/\$([$&'`]|\d{1,2})/g;B.exports=function(V,ee,oe,me,pe,ie){var L=oe+V.length,R=me.length,ne=Y;return pe!==void 0&&(pe=z(pe),ne=q),re(ie,ne,(function(ye,ve){var be;switch(H(ve,0)){case"$":return"$";case"&":return V;case"`":return O(ee,0,oe);case"'":return O(ee,L);case"<":be=pe[O(ve,1,-1)];break;default:var Be=+ve;if(Be===0)return ye;if(Be>R){var we=W(Be/10);return we===0?ye:we<=R?me[we-1]===void 0?H(ve,1):me[we-1]+H(ve,1):ye}be=me[Be-1]}return be===void 0?"":be}))}},4576:function(B,X,D){var P=function(z){return z&&z.Math===Math&&z};B.exports=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof D.g=="object"&&D.g)||P(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297:function(B,X,D){var P=D(9504),z=D(8981),W=P({}.hasOwnProperty);B.exports=Object.hasOwn||function(H,re){return W(z(H),re)}},421:function(B){B.exports={}},397:function(B,X,D){var P=D(7751);B.exports=P("document","documentElement")},5917:function(B,X,D){var P=D(3724),z=D(9039),W=D(4055);B.exports=!P&&!z((function(){return Object.defineProperty(W("div"),"a",{get:function(){return 7}}).a!==7}))},7055:function(B,X,D){var P=D(9504),z=D(9039),W=D(2195),H=Object,re=P("".split);B.exports=z((function(){return!H("z").propertyIsEnumerable(0)}))?function(O){return W(O)==="String"?re(O,""):H(O)}:H},3167:function(B,X,D){var P=D(4901),z=D(34),W=D(2967);B.exports=function(H,re,O){var q,Y;return W&&P(q=re.constructor)&&q!==O&&z(Y=q.prototype)&&Y!==O.prototype&&W(H,Y),H}},3706:function(B,X,D){var P=D(9504),z=D(4901),W=D(7629),H=P(Function.toString);z(W.inspectSource)||(W.inspectSource=function(re){return H(re)}),B.exports=W.inspectSource},1181:function(B,X,D){var P,z,W,H=D(8622),re=D(4576),O=D(34),q=D(6699),Y=D(9297),V=D(7629),ee=D(6119),oe=D(421),me="Object already initialized",pe=re.TypeError,ie=re.WeakMap;if(H||V.state){var L=V.state||(V.state=new ie);L.get=L.get,L.has=L.has,L.set=L.set,P=function(ne,ye){if(L.has(ne))throw new pe(me);return ye.facade=ne,L.set(ne,ye),ye},z=function(ne){return L.get(ne)||{}},W=function(ne){return L.has(ne)}}else{var R=ee("state");oe[R]=!0,P=function(ne,ye){if(Y(ne,R))throw new pe(me);return ye.facade=ne,q(ne,R,ye),ye},z=function(ne){return Y(ne,R)?ne[R]:{}},W=function(ne){return Y(ne,R)}}B.exports={set:P,get:z,has:W,enforce:function(ne){return W(ne)?z(ne):P(ne,{})},getterFor:function(ne){return function(ye){var ve;if(!O(ye)||(ve=z(ye)).type!==ne)throw new pe("Incompatible receiver, "+ne+" required");return ve}}}},4209:function(B,X,D){var P=D(8227),z=D(6269),W=P("iterator"),H=Array.prototype;B.exports=function(re){return re!==void 0&&(z.Array===re||H[W]===re)}},4376:function(B,X,D){var P=D(2195);B.exports=Array.isArray||function(z){return P(z)==="Array"}},4901:function(B){var X=typeof document=="object"&&document.all;B.exports=X===void 0&&X!==void 0?function(D){return typeof D=="function"||D===X}:function(D){return typeof D=="function"}},3517:function(B,X,D){var P=D(9504),z=D(9039),W=D(4901),H=D(6955),re=D(7751),O=D(3706),q=function(){},Y=re("Reflect","construct"),V=/^\s*(?:class|function)\b/,ee=P(V.exec),oe=!V.test(q),me=function(ie){if(!W(ie))return!1;try{return Y(q,[],ie),!0}catch{return!1}},pe=function(ie){if(!W(ie))return!1;switch(H(ie)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return oe||!!ee(V,O(ie))}catch{return!0}};pe.sham=!0,B.exports=!Y||z((function(){var ie;return me(me.call)||!me(Object)||!me((function(){ie=!0}))||ie}))?pe:me},2796:function(B,X,D){var P=D(9039),z=D(4901),W=/#|\.prototype\./,H=function(V,ee){var oe=O[re(V)];return oe===Y||oe!==q&&(z(ee)?P(ee):!!ee)},re=H.normalize=function(V){return String(V).replace(W,".").toLowerCase()},O=H.data={},q=H.NATIVE="N",Y=H.POLYFILL="P";B.exports=H},2087:function(B,X,D){var P=D(34),z=Math.floor;B.exports=Number.isInteger||function(W){return!P(W)&&isFinite(W)&&z(W)===W}},4117:function(B){B.exports=function(X){return X==null}},34:function(B,X,D){var P=D(4901);B.exports=function(z){return typeof z=="object"?z!==null:P(z)}},3925:function(B,X,D){var P=D(34);B.exports=function(z){return P(z)||z===null}},6395:function(B){B.exports=!1},5810:function(B,X,D){var P=D(34),z=D(1181).get;B.exports=function(W){if(!P(W))return!1;var H=z(W);return!!H&&H.type==="RawJSON"}},788:function(B,X,D){var P=D(34),z=D(2195),W=D(8227)("match");B.exports=function(H){var re;return P(H)&&((re=H[W])!==void 0?!!re:z(H)==="RegExp")}},757:function(B,X,D){var P=D(7751),z=D(4901),W=D(1625),H=D(7040),re=Object;B.exports=H?function(O){return typeof O=="symbol"}:function(O){var q=P("Symbol");return z(q)&&W(q.prototype,re(O))}},9539:function(B,X,D){var P=D(9565),z=D(8551),W=D(5966);B.exports=function(H,re,O){var q,Y;z(H);try{if(!(q=W(H,"return"))){if(re==="throw")throw O;return O}q=P(q,H)}catch(V){Y=!0,q=V}if(re==="throw")throw O;if(Y)throw q;return z(q),O}},3994:function(B,X,D){var P=D(7657).IteratorPrototype,z=D(2360),W=D(6980),H=D(687),re=D(6269),O=function(){return this};B.exports=function(q,Y,V,ee){var oe=Y+" Iterator";return q.prototype=z(P,{next:W(+!ee,V)}),H(q,oe,!1,!0),re[oe]=O,q}},1088:function(B,X,D){var P=D(6518),z=D(9565),W=D(6395),H=D(350),re=D(4901),O=D(3994),q=D(2787),Y=D(2967),V=D(687),ee=D(6699),oe=D(6840),me=D(8227),pe=D(6269),ie=D(7657),L=H.PROPER,R=H.CONFIGURABLE,ne=ie.IteratorPrototype,ye=ie.BUGGY_SAFARI_ITERATORS,ve=me("iterator"),be="keys",Be="values",we="entries",Ae=function(){return this};B.exports=function(Le,Ee,ke,Me,He,De,Xe){O(ke,Ee,Me);var xe,We,Pe,Ke=function(vt){if(vt===He&&nt)return nt;if(!ye&&vt&&vt in Te)return Te[vt];switch(vt){case be:case Be:case we:return function(){return new ke(this,vt)}}return function(){return new ke(this)}},Ve=Ee+" Iterator",Ce=!1,Te=Le.prototype,$e=Te[ve]||Te["@@iterator"]||He&&Te[He],nt=!ye&&$e||Ke(He),bt=Ee==="Array"&&Te.entries||$e;if(bt&&(xe=q(bt.call(new Le)))!==Object.prototype&&xe.next&&(W||q(xe)===ne||(Y?Y(xe,ne):re(xe[ve])||oe(xe,ve,Ae)),V(xe,Ve,!0,!0),W&&(pe[Ve]=Ae)),L&&He===Be&&$e&&$e.name!==Be&&(!W&&R?ee(Te,"name",Be):(Ce=!0,nt=function(){return z($e,this)})),He)if(We={values:Ke(Be),keys:De?nt:Ke(be),entries:Ke(we)},Xe)for(Pe in We)(ye||Ce||!(Pe in Te))&&oe(Te,Pe,We[Pe]);else P({target:Ee,proto:!0,forced:ye||Ce},We);return W&&!Xe||Te[ve]===nt||oe(Te,ve,nt,{name:He}),pe[Ee]=nt,We}},7657:function(B,X,D){var P,z,W,H=D(9039),re=D(4901),O=D(34),q=D(2360),Y=D(2787),V=D(6840),ee=D(8227),oe=D(6395),me=ee("iterator"),pe=!1;[].keys&&("next"in(W=[].keys())?(z=Y(Y(W)))!==Object.prototype&&(P=z):pe=!0),!O(P)||H((function(){var ie={};return P[me].call(ie)!==ie}))?P={}:oe&&(P=q(P)),re(P[me])||V(P,me,(function(){return this})),B.exports={IteratorPrototype:P,BUGGY_SAFARI_ITERATORS:pe}},6269:function(B){B.exports={}},6198:function(B,X,D){var P=D(8014);B.exports=function(z){return P(z.length)}},283:function(B,X,D){var P=D(9504),z=D(9039),W=D(4901),H=D(9297),re=D(3724),O=D(350).CONFIGURABLE,q=D(3706),Y=D(1181),V=Y.enforce,ee=Y.get,oe=String,me=Object.defineProperty,pe=P("".slice),ie=P("".replace),L=P([].join),R=re&&!z((function(){return me((function(){}),"length",{value:8}).length!==8})),ne=String(String).split("String"),ye=B.exports=function(ve,be,Be){pe(oe(be),0,7)==="Symbol("&&(be="["+ie(oe(be),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),Be&&Be.getter&&(be="get "+be),Be&&Be.setter&&(be="set "+be),(!H(ve,"name")||O&&ve.name!==be)&&(re?me(ve,"name",{value:be,configurable:!0}):ve.name=be),R&&Be&&H(Be,"arity")&&ve.length!==Be.arity&&me(ve,"length",{value:Be.arity});try{Be&&H(Be,"constructor")&&Be.constructor?re&&me(ve,"prototype",{writable:!1}):ve.prototype&&(ve.prototype=void 0)}catch{}var we=V(ve);return H(we,"source")||(we.source=L(ne,typeof be=="string"?be:"")),ve};Function.prototype.toString=ye((function(){return W(this)&&ee(this).source||q(this)}),"toString")},741:function(B){var X=Math.ceil,D=Math.floor;B.exports=Math.trunc||function(P){var z=+P;return(z>0?D:X)(z)}},7819:function(B,X,D){var P=D(9039);B.exports=!P((function(){var z="9007199254740993",W=JSON.rawJSON(z);return!JSON.isRawJSON(W)||JSON.stringify(W)!==z}))},5749:function(B,X,D){var P=D(788),z=TypeError;B.exports=function(W){if(P(W))throw new z("The method doesn't accept regular expressions");return W}},4213:function(B,X,D){var P=D(3724),z=D(9504),W=D(9565),H=D(9039),re=D(1072),O=D(3717),q=D(8773),Y=D(8981),V=D(7055),ee=Object.assign,oe=Object.defineProperty,me=z([].concat);B.exports=!ee||H((function(){if(P&&ee({b:1},ee(oe({},"a",{enumerable:!0,get:function(){oe(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var pe={},ie={},L=Symbol("assign detection"),R="abcdefghijklmnopqrst";return pe[L]=7,R.split("").forEach((function(ne){ie[ne]=ne})),ee({},pe)[L]!==7||re(ee({},ie)).join("")!==R}))?function(pe,ie){for(var L=Y(pe),R=arguments.length,ne=1,ye=O.f,ve=q.f;R>ne;)for(var be,Be=V(arguments[ne++]),we=ye?me(re(Be),ye(Be)):re(Be),Ae=we.length,Le=0;Ae>Le;)be=we[Le++],P&&!W(ve,Be,be)||(L[be]=Be[be]);return L}:ee},2360:function(B,X,D){var P,z=D(8551),W=D(6801),H=D(8727),re=D(421),O=D(397),q=D(4055),Y=D(6119),V="prototype",ee="script",oe=Y("IE_PROTO"),me=function(){},pe=function(R){return"<"+ee+">"+R+""},ie=function(R){R.write(pe("")),R.close();var ne=R.parentWindow.Object;return R=null,ne},L=function(){try{P=new ActiveXObject("htmlfile")}catch{}var R,ne,ye;L=typeof document<"u"?document.domain&&P?ie(P):(ne=q("iframe"),ye="java"+ee+":",ne.style.display="none",O.appendChild(ne),ne.src=String(ye),(R=ne.contentWindow.document).open(),R.write(pe("document.F=Object")),R.close(),R.F):ie(P);for(var ve=H.length;ve--;)delete L[V][H[ve]];return L()};re[oe]=!0,B.exports=Object.create||function(R,ne){var ye;return R!==null?(me[V]=z(R),ye=new me,me[V]=null,ye[oe]=R):ye=L(),ne===void 0?ye:W.f(ye,ne)}},6801:function(B,X,D){var P=D(3724),z=D(8686),W=D(4913),H=D(8551),re=D(5397),O=D(1072);X.f=P&&!z?Object.defineProperties:function(q,Y){H(q);for(var V,ee=re(Y),oe=O(Y),me=oe.length,pe=0;me>pe;)W.f(q,V=oe[pe++],ee[V]);return q}},4913:function(B,X,D){var P=D(3724),z=D(5917),W=D(8686),H=D(8551),re=D(6969),O=TypeError,q=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,V="enumerable",ee="configurable",oe="writable";X.f=P?W?function(me,pe,ie){if(H(me),pe=re(pe),H(ie),typeof me=="function"&&pe==="prototype"&&"value"in ie&&oe in ie&&!ie[oe]){var L=Y(me,pe);L&&L[oe]&&(me[pe]=ie.value,ie={configurable:ee in ie?ie[ee]:L[ee],enumerable:V in ie?ie[V]:L[V],writable:!1})}return q(me,pe,ie)}:q:function(me,pe,ie){if(H(me),pe=re(pe),H(ie),z)try{return q(me,pe,ie)}catch{}if("get"in ie||"set"in ie)throw new O("Accessors not supported");return"value"in ie&&(me[pe]=ie.value),me}},7347:function(B,X,D){var P=D(3724),z=D(9565),W=D(8773),H=D(6980),re=D(5397),O=D(6969),q=D(9297),Y=D(5917),V=Object.getOwnPropertyDescriptor;X.f=P?V:function(ee,oe){if(ee=re(ee),oe=O(oe),Y)try{return V(ee,oe)}catch{}if(q(ee,oe))return H(!z(W.f,ee,oe),ee[oe])}},298:function(B,X,D){var P=D(2195),z=D(5397),W=D(8480).f,H=D(7680),re=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];B.exports.f=function(O){return re&&P(O)==="Window"?(function(q){try{return W(q)}catch{return H(re)}})(O):W(z(O))}},8480:function(B,X,D){var P=D(1828),z=D(8727).concat("length","prototype");X.f=Object.getOwnPropertyNames||function(W){return P(W,z)}},3717:function(B,X){X.f=Object.getOwnPropertySymbols},2787:function(B,X,D){var P=D(9297),z=D(4901),W=D(8981),H=D(6119),re=D(2211),O=H("IE_PROTO"),q=Object,Y=q.prototype;B.exports=re?q.getPrototypeOf:function(V){var ee=W(V);if(P(ee,O))return ee[O];var oe=ee.constructor;return z(oe)&&ee instanceof oe?oe.prototype:ee instanceof q?Y:null}},1625:function(B,X,D){var P=D(9504);B.exports=P({}.isPrototypeOf)},1828:function(B,X,D){var P=D(9504),z=D(9297),W=D(5397),H=D(9617).indexOf,re=D(421),O=P([].push);B.exports=function(q,Y){var V,ee=W(q),oe=0,me=[];for(V in ee)!z(re,V)&&z(ee,V)&&O(me,V);for(;Y.length>oe;)z(ee,V=Y[oe++])&&(~H(me,V)||O(me,V));return me}},1072:function(B,X,D){var P=D(1828),z=D(8727);B.exports=Object.keys||function(W){return P(W,z)}},8773:function(B,X){var D={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,z=P&&!D.call({1:2},1);X.f=z?function(W){var H=P(this,W);return!!H&&H.enumerable}:D},2551:function(B,X,D){var P=D(6395),z=D(4576),W=D(9039),H=D(3607);B.exports=P||!W((function(){if(!(H&&H<535)){var re=Math.random();__defineSetter__.call(null,re,(function(){})),delete z[re]}}))},2967:function(B,X,D){var P=D(6706),z=D(34),W=D(7750),H=D(3506);B.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var re,O=!1,q={};try{(re=P(Object.prototype,"__proto__","set"))(q,[]),O=q instanceof Array}catch{}return function(Y,V){return W(Y),H(V),z(Y)&&(O?re(Y,V):Y.__proto__=V),Y}})():void 0)},3179:function(B,X,D){var P=D(2140),z=D(6955);B.exports=P?{}.toString:function(){return"[object "+z(this)+"]"}},4270:function(B,X,D){var P=D(9565),z=D(4901),W=D(34),H=TypeError;B.exports=function(re,O){var q,Y;if(O==="string"&&z(q=re.toString)&&!W(Y=P(q,re))||z(q=re.valueOf)&&!W(Y=P(q,re))||O!=="string"&&z(q=re.toString)&&!W(Y=P(q,re)))return Y;throw new H("Can't convert object to primitive value")}},5031:function(B,X,D){var P=D(7751),z=D(9504),W=D(8480),H=D(3717),re=D(8551),O=z([].concat);B.exports=P("Reflect","ownKeys")||function(q){var Y=W.f(re(q)),V=H.f;return V?O(Y,V(q)):Y}},8235:function(B,X,D){var P=D(9504),z=D(9297),W=SyntaxError,H=parseInt,re=String.fromCharCode,O=P("".charAt),q=P("".slice),Y=P(/./.exec),V={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":` +`)[0]}),F&&i.jsx("span",{className:"text-bambu-gray/50 shrink-0",children:A?i.jsx(Gl,{className:"w-3.5 h-3.5"}):i.jsx(zn,{className:"w-3.5 h-3.5"})})]})},j)})})}),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 ynt(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 Pi({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 KY({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 Xm({title:t,icon:e,children:n}){return i.jsxs(At,{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 vnt(){const{t}=jt(),e=cn(),[n,r]=w.useState(null),[a,s]=w.useState(!1),[o,l]=w.useState(!1),{data:c,isLoading:d,refetch:u,isFetching:m}=et({queryKey:["systemInfo"],queryFn:ge.getSystemInfo,refetchInterval:3e4}),{data:p}=et({queryKey:["debugLogging"],queryFn:Xb.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 Xb.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 Xb.downloadSupportBundle()}catch(C){r(C instanceof Error?C.message:"Failed to download support bundle")}finally{s(!1)}};if(d)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",k=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:()=>u(),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(vr,{className:`w-4 h-4 ${m?"animate-spin":""}`}),t("common.refresh","Refresh")]})]}),i.jsx(Xm,{title:t("system.application","Application"),icon:Bp,children:i.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[i.jsx(Pi,{icon:Bp,label:t("system.version","Version"),value:`v${c.app.version}`}),i.jsx(Pi,{icon:Zn,label:t("system.uptime","System Uptime"),value:c.system.uptime_formatted}),i.jsx(Pi,{icon:Bp,label:t("system.hostname","Hostname"),value:c.system.hostname})]})}),i.jsx(Xm,{title:t("support.title","Support & Troubleshooting"),icon:Hfe,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(mx,{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(xnt,{})]})}),i.jsxs(Xm,{title:t("system.database","Database"),icon:hd,children:[i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-4",children:[i.jsx(Pi,{icon:Vs,label:t("system.totalArchives","Total Archives"),value:c.database.archives}),i.jsx(Pi,{icon:Sc,label:t("system.completed","Completed"),value:c.database.archives_completed,color:"text-green-500"}),i.jsx(Pi,{icon:Wi,label:t("system.failed","Failed"),value:c.database.archives_failed,color:"text-red-500"}),i.jsx(Pi,{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(Pi,{icon:_r,label:t("system.printers","Printers"),value:c.database.printers}),i.jsx(Pi,{icon:Sw,label:t("system.filaments","Filaments"),value:c.database.filaments}),i.jsx(Pi,{icon:_s,label:t("system.projects","Projects"),value:c.database.projects}),i.jsx(Pi,{icon:Bl,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(Pi,{icon:Zn,label:t("system.totalPrintTime","Total Print Time"),value:c.database.total_print_time_formatted}),i.jsx(Pi,{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(Xm,{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(Xm,{title:t("system.storage","Storage"),icon:Gx,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(KY,{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(Pi,{icon:Vs,label:t("system.archiveStorage","Archive Storage"),value:c.storage.archive_size_formatted}),i.jsx(Pi,{icon:hd,label:t("system.databaseSize","Database Size"),value:c.storage.database_size_formatted}),y&&i.jsx(Pi,{icon:Mc,label:t("system.fileManagerStorage","File Manager"),value:ynt(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(Xm,{title:t("system.memory","Memory"),icon:vge,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(KY,{percent:c.memory.percent_used,color:k}),i.jsxs("p",{className:"text-xs text-bambu-gray mt-1",children:[c.memory.available_formatted," ",t("system.available","available")]})]})})}),i.jsx(Xm,{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(Pi,{icon:m_,label:t("system.cores","Cores"),value:c.cpu.count,subValue:`${c.cpu.count_logical} logical`}),i.jsx(Pi,{icon:m_,label:t("system.usage","Usage"),value:`${c.cpu.percent}%`})]})})})]}),i.jsx(Xm,{title:t("system.systemDetails","System Details"),icon:Bp,children:i.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[i.jsx(Pi,{icon:Bp,label:t("system.os","Operating System"),value:c.system.platform,subValue:c.system.platform_release}),i.jsx(Pi,{icon:m_,label:t("system.architecture","Architecture"),value:c.system.architecture}),i.jsx(Pi,{icon:Bp,label:t("system.python","Python"),value:c.system.python_version}),i.jsx(Pi,{icon:Zn,label:t("system.bootTime","Boot Time"),value:Lf(c.system.boot_time,v)})]})})]})}function wnt(){const t=ol(),{t:e}=jt(),{login:n}=Ar(),{showToast:r}=pn(),{mode:a}=ag(),[s,o]=w.useState(""),[l,c]=w.useState(""),[d,u]=w.useState(!1),[m,p]=w.useState(""),{data:f}=et({queryKey:["advancedAuthStatus"],queryFn:()=>ge.getAdvancedAuthStatus()}),y=ht({mutationFn:()=>n(s,l),onSuccess:()=>{r(e("login.loginSuccess")),t("/")},onError:_=>{r(_.message||e("login.loginFailed"),"error")}}),v=ht({mutationFn:_=>ge.forgotPassword({email:_}),onSuccess:_=>{r(_.message,"success"),u(!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:()=>u(!0),className:"text-sm text-bambu-gray hover:text-bambu-green transition-colors",children:e("login.forgotPassword")})})]})]}),d&&i.jsx("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:()=>u(!1),children:i.jsxs(At,{className:"w-full max-w-md",onClick:_=>_.stopPropagation(),children:[i.jsx(Hn,{children:i.jsxs("div",{className:"flex items-center justify-between",children:[i.jsxs("div",{className:"flex items-center gap-2",children:[i.jsx(px,{className:"w-5 h-5 text-bambu-green"}),i.jsx("h2",{className:"text-lg font-semibold text-white",children:e("login.forgotPasswordTitle")})]}),i.jsx(Ie,{variant:"ghost",size:"sm",onClick:()=>{u(!1),p("")},children:i.jsx(qt,{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(Ie,{type:"button",variant:"secondary",className:"flex-1",onClick:()=>{u(!1),p("")},children:e("login.cancel")||"Cancel"}),i.jsx(Ie,{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(Ie,{variant:"secondary",className:"w-full",onClick:()=>u(!1),children:e("login.gotIt")})]})})]})})]})}function Snt(){const t=ol(),{t:e}=jt(),{showToast:n}=pn(),{mode:r}=ag(),{refreshAuth:a}=Ar(),[s,o]=w.useState(!1),[l,c]=w.useState(""),[d,u]=w.useState(""),[m,p]=w.useState(""),f=ht({mutationFn:()=>ge.setupAuth({auth_enabled:s,admin_username:s?l:void 0,admin_password:s?d: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||d)){if(!l||!d){n(e("setup.toast.enterBothCredentials"),"error");return}if(d!==m){n(e("setup.toast.passwordsDoNotMatch"),"error");return}if(d.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:d,onChange:v=>u(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"})]}),d&&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 _nt(){const{t}=jt(),{user:e}=Ar(),{showToast:n}=pn(),r=cn(),a=ol(),[s,o]=w.useState(!0),[l,c]=w.useState(!0),[d,u]=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:k,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(()=>{k&&(o(k.notify_print_start),c(k.notify_print_complete),u(k.notify_print_failed),p(k.notify_print_stopped),y(!1))},[k]);const N=ht({mutationFn:()=>ge.updateUserEmailPreferences({notify_print_start:s,notify_print_complete:l,notify_print_failed:d,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")}}),M=(T,j)=>{T(!j),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(Ch,{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(At,{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(px,{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(At,{className:"mb-6",children:[i.jsxs(Hn,{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(Sc,{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:()=>M(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(Sc,{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:()=>M(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 ${d?"bg-bambu-green/20":"bg-bambu-dark-tertiary"}`,children:i.jsx(Sc,{className:`w-5 h-5 ${d?"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:()=>M(u,d),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 ${d?"bg-bambu-green":"bg-bambu-dark-tertiary"}`,role:"switch","aria-checked":d,children:i.jsx("span",{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${d?"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(Sc,{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:()=>M(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(Ie,{onClick:()=>N.mutate(),disabled:!f||N.isPending||!e?.email,children:N.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 knt(){const t=w.useRef(null),e=w.useRef(null),n=cn(),[r,a]=w.useState(!1),s=w.useRef(new Map),{showToast:o}=pn(),{t:l}=jt(),c=w.useRef(new Set),d=w.useRef(null),u=w.useRef(new Map),m=w.useRef(null),p=w.useRef([]),f=w.useRef(!1),y=w.useRef(()=>{}),v=w.useCallback(()=>{if(f.current||p.current.length===0)return;f.current=!0;const N=()=>{const M=p.current.shift();M?requestAnimationFrame(()=>{y.current(M),p.current.length>0?setTimeout(N,16):f.current=!1}):f.current=!1};N()},[]),b=w.useCallback(()=>{if(t.current?.readyState===WebSocket.OPEN)return;const M=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/api/v1/ws`,T=new WebSocket(M);let j=null;T.onopen=()=>{console.log("[WebSocket] Connected"),a(!0),j=window.setInterval(()=>{T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"ping"}))},3e4)},T.onmessage=A=>{try{const F=JSON.parse(A.data);F.type==="printer_status"&&F.printer_id!==void 0&&F.data?y.current(F):(p.current.push(F),v())}catch{}},T.onclose=A=>{console.log("[WebSocket] Closed",A.code,A.reason),j&&(clearInterval(j),j=null),a(!1),t.current=null,e.current=window.setTimeout(()=>{b()},3e3)},T.onerror=A=>{console.error("[WebSocket] Error",A),T.close()},t.current=T},[v]),g=w.useCallback((N,M)=>{const T=u.current.get(N)||{};u.current.set(N,{...T,...M}),m.current||(m.current=window.setTimeout(()=>{const j=new Map(u.current);u.current.clear(),m.current=null,requestAnimationFrame(()=>{j.forEach((A,F)=>{n.setQueryData(["printerStatus",F],G=>{const U={...G,...A};return U.wifi_signal==null&&G?.wifi_signal!=null&&(U.wifi_signal=G.wifi_signal),U})})})},100))},[n]),_=w.useCallback(N=>{c.current.add(N),d.current&&clearTimeout(d.current),d.current=window.setTimeout(()=>{const M=Array.from(c.current);c.current.clear(),d.current=null;let T=0;M.forEach(j=>{setTimeout(()=>{requestAnimationFrame(()=>{n.invalidateQueries({queryKey:[j]})})},T),T+=500})},3e3)},[n]),k=w.useCallback(N=>{switch(N.type){case"printer_status":N.printer_id!==void 0&&N.data&&g(N.printer_id,N.data);break;case"print_start":N.printer_id!==void 0&&n.invalidateQueries({queryKey:["printerStatus",N.printer_id]});break;case"missing_spool_assignment":{if(N.printer_id===void 0||!Array.isArray(N.missing_slots))break;const M=N.missing_slots.map(F=>F&&typeof F.slot=="string"?F.slot:"Unknown").filter(F=>F.length>0);if(M.length===0){s.current.delete(N.printer_id);break}const T=M.join("|");if(s.current.get(N.printer_id)===T)break;s.current.set(N.printer_id,T);const j=N.printer_name||`Printer ${N.printer_id}`,A=l("printers.toast.missingSpoolAssignment",{printer:j,slots:M.join(", ")});o(A,"warning");break}case"print_complete":_("archives"),_("archiveStats");break;case"archive_created":_("archives"),_("archiveStats");break;case"archive_updated":_("archives");break;case"pong":break;case"plate_not_empty":window.dispatchEvent(new CustomEvent("plate-not-empty",{detail:{printer_id:N.printer_id,printer_name:N.printer_name,message:N.message}}));break;case"spool_assignment_changed":_("spool-assignments"),_("slotPresets");break;case"spool_auto_assigned":_("inventory-spools"),_("spool-assignments");break;case"spool_usage_logged":_("inventory-spools");break;case"unknown_tag":window.dispatchEvent(new CustomEvent("unknown-tag",{detail:{printer_id:N.printer_id,ams_id:N.ams_id,tray_id:N.tray_id,tag_uid:N.tag_uid,tray_uuid:N.tray_uuid}}));break;case"background_dispatch":window.dispatchEvent(new CustomEvent("background-dispatch",{detail:N.data||{}}));break;case"spoolbuddy_weight":window.dispatchEvent(new CustomEvent("spoolbuddy-weight",{detail:N}));break;case"spoolbuddy_tag_matched":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-matched",{detail:N})),_("inventory-spools");break;case"spoolbuddy_unknown_tag":window.dispatchEvent(new CustomEvent("spoolbuddy-unknown-tag",{detail:N}));break;case"spoolbuddy_tag_removed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-removed",{detail:N}));break;case"spoolbuddy_tag_written":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-written",{detail:N})),_("inventory-spools");break;case"spoolbuddy_tag_write_failed":window.dispatchEvent(new CustomEvent("spoolbuddy-tag-write-failed",{detail:N}));break;case"spoolbuddy_online":window.dispatchEvent(new CustomEvent("spoolbuddy-online",{detail:N})),_("spoolbuddy-devices"),_("spoolbuddy-update-check");break;case"spoolbuddy_offline":window.dispatchEvent(new CustomEvent("spoolbuddy-offline",{detail:N})),_("spoolbuddy-devices");break;case"spoolbuddy_update":_("spoolbuddy-devices"),_("spoolbuddy-update-check");break}},[n,_,g,o,l]);w.useEffect(()=>{y.current=k},[k]),w.useEffect(()=>(b(),()=>{e.current&&clearTimeout(e.current),d.current&&clearTimeout(d.current),m.current&&clearTimeout(m.current),t.current&&t.current.close()}),[b]);const C=w.useCallback(N=>{t.current?.readyState===WebSocket.OPEN&&t.current.send(JSON.stringify(N))},[]);return{isConnected:r,sendMessage:C}}function Nnt({selectedPrinterId:t,onPrinterChange:e,deviceOnline:n}){const{t:r}=jt(),[a,s]=w.useState(new Date),{data:o=[]}=et({queryKey:["printers"],queryFn:()=>ge.getPrinters()}),l=ig({queries:o.map(u=>({queryKey:["printerStatus",u.id],queryFn:()=>ge.getPrinterStatus(u.id),refetchInterval:1e4}))}),c=w.useMemo(()=>o.filter((u,m)=>l[m]?.data?.connected),[o,l]);w.useEffect(()=>{const u=c.some(m=>m.id===t);(!t||!u)&&c.length>0&&e(c[0].id)},[c,t,e]);const{data:d}=et({queryKey:["settings"],queryFn:ge.getSettings});return w.useEffect(()=>{const u=setInterval(()=>s(new Date),1e3);return()=>clearInterval(u)},[]),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:u=>e(Number(u.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(u=>i.jsx("option",{value:u.id,children:u.name},u.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(u=>i.jsx("div",{className:`w-1 rounded-sm ${u<=4?"bg-white":"bg-bambu-dark-tertiary"}`,style:{height:`${u*4}px`}},u))}):i.jsx(Hh,{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:yQ(a,d?.time_format||"system")})]})]})}const Cnt=[{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 Tnt(){const{t}=jt();return i.jsx("nav",{className:"h-14 bg-bambu-dark-secondary border-t border-bambu-dark-tertiary flex items-stretch shrink-0",children:Cnt.map(e=>i.jsxs(Ub,{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 Ant({alert:t}){const{t:e}=jt(),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 Pnt={weight:null,weightStable:!1,rawAdc:null,matchedSpool:null,unknownTagUid:null,deviceOnline:!1,deviceId:null};function Mnt(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 Ent(){const[t,e]=w.useReducer(Mnt,Pnt),n=w.useCallback(u=>{const m=u.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(u=>{const m=u.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(u=>{const m=u.detail;e({type:"UNKNOWN_TAG",tagUid:m.tag_uid??m.data?.tag_uid??"",deviceId:m.device_id??m.data?.device_id??""})},[]),s=w.useCallback(u=>{const m=u.detail;e({type:"TAG_REMOVED",deviceId:m.device_id??m.data?.device_id??""})},[]),o=w.useCallback(u=>{const m=u.detail;e({type:"DEVICE_ONLINE",deviceId:m.device_id??m.data?.device_id??""})},[]),l=w.useCallback(u=>{const m=u.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,d=t.weight!==null&&t.matchedSpool?Math.max(0,t.weight-t.matchedSpool.core_weight):null;return{...t,remainingWeight:c,netWeight:d}}var Pk={exports:{}};var jnt=Pk.exports,YY;function Dnt(){return YY||(YY=1,(function(t,e){(function(n,r){t.exports=r(ng())})(jnt,(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",d="prototype",u=l.Element[d],m=Object,p=String[d].trim||function(){return this.replace(/^\s+|\s+$/g,"")},f=Array[d].indexOf||function(C){for(var N=0,M=this.length;N1?arguments[1]:void 0)}},7916:function(B,X,D){var P=D(6080),z=D(9565),W=D(8981),H=D(6319),re=D(4209),O=D(3517),q=D(6198),Y=D(4659),V=D(4527),ee=D(81),oe=D(851),me=Array;B.exports=function(pe){var ie=W(pe),L=O(this),R=arguments.length,ne=R>1?arguments[1]:void 0,ye=ne!==void 0;ye&&(ne=P(ne,R>2?arguments[2]:void 0));var ve,be,Be,we,Ae,Le,Ee=oe(ie),ke=0;if(!Ee||this===me&&re(Ee))for(ve=q(ie),be=L?new this(ve):me(ve);ve>ke;ke++)Le=ye?ne(ie[ke],ke):ie[ke],Y(be,ke,Le);else for(be=L?new this:[],Ae=(we=ee(ie,Ee)).next;!(Be=z(Ae,we)).done;ke++)Le=ye?H(we,ne,[Be.value,ke],!0):Be.value,Y(be,ke,Le);return V(be,ke),be}},9617:function(B,X,D){var P=D(5397),z=D(5610),W=D(6198),H=function(re){return function(O,q,Y){var V=P(O),ee=W(V);if(ee===0)return!re&&-1;var oe,me=z(Y,ee);if(re&&q!=q){for(;ee>me;)if((oe=V[me++])!=oe)return!0}else for(;ee>me;me++)if((re||me in V)&&V[me]===q)return re||me||0;return!re&&-1}};B.exports={includes:H(!0),indexOf:H(!1)}},9213:function(B,X,D){var P=D(6080),z=D(7055),W=D(8981),H=D(6198),re=D(1469),O=D(4659),q=function(Y){var V=Y===1,ee=Y===2,oe=Y===3,me=Y===4,pe=Y===6,ie=Y===7,L=Y===5||pe;return function(R,ne,ye){for(var ve,be,Be=W(R),we=z(Be),Ae=H(we),Le=P(ne,ye),Ee=0,ke=0,Me=V?re(R,Ae):ee||ie?re(R,0):void 0;Ae>Ee;Ee++)if((L||Ee in we)&&(be=Le(ve=we[Ee],Ee,Be),Y))if(V)O(Me,Ee,be);else if(be)switch(Y){case 3:return!0;case 5:return ve;case 6:return Ee;case 2:O(Me,ke++,ve)}else switch(Y){case 4:return!1;case 7:O(Me,ke++,ve)}return pe?-1:oe||me?me:Me}};B.exports={forEach:q(0),map:q(1),filter:q(2),some:q(3),every:q(4),find:q(5),findIndex:q(6),filterReject:q(7)}},597:function(B,X,D){var P=D(9039),z=D(8227),W=D(9519),H=z("species");B.exports=function(re){return W>=51||!P((function(){var O=[];return(O.constructor={})[H]=function(){return{foo:1}},O[re](Boolean).foo!==1}))}},4598:function(B,X,D){var P=D(9039);B.exports=function(z,W){var H=[][z];return!!H&&P((function(){H.call(null,W||function(){return 1},1)}))}},926:function(B,X,D){var P=D(9306),z=D(8981),W=D(7055),H=D(6198),re=TypeError,O="Reduce of empty array with no initial value",q=function(Y){return function(V,ee,oe,me){var pe=z(V),ie=W(pe),L=H(pe);if(P(ee),L===0&&oe<2)throw new re(O);var R=Y?L-1:0,ne=Y?-1:1;if(oe<2)for(;;){if(R in ie){me=ie[R],R+=ne;break}if(R+=ne,Y?R<0:L<=R)throw new re(O)}for(;Y?R>=0:L>R;R+=ne)R in ie&&(me=ee(me,ie[R],R,pe));return me}};B.exports={left:q(!1),right:q(!0)}},4527:function(B,X,D){var P=D(3724),z=D(4376),W=TypeError,H=Object.getOwnPropertyDescriptor,re=P&&!(function(){if(this!==void 0)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(O){return O instanceof TypeError}})();B.exports=re?function(O,q){if(z(O)&&!H(O,"length").writable)throw new W("Cannot set read only .length");return O.length=q}:function(O,q){return O.length=q}},7680:function(B,X,D){var P=D(9504);B.exports=P([].slice)},4488:function(B,X,D){var P=D(7680),z=Math.floor,W=function(H,re){var O=H.length;if(O<8)for(var q,Y,V=1;V0;)H[Y]=H[--Y];Y!==V++&&(H[Y]=q)}else for(var ee=z(O/2),oe=W(P(H,0,ee),re),me=W(P(H,ee),re),pe=oe.length,ie=me.length,L=0,R=0;L9007199254740991)throw X("Maximum allowed index exceeded");return D}},7400:function(B){B.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(B,X,D){var P=D(4055)("span").classList,z=P&&P.constructor&&P.constructor.prototype;B.exports=z===Object.prototype?void 0:z},8727:function(B){B.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},3709:function(B,X,D){var P=D(2839).match(/firefox\/(\d+)/i);B.exports=!!P&&+P[1]},3763:function(B,X,D){var P=D(2839);B.exports=/MSIE|Trident/.test(P)},6193:function(B,X,D){var P=D(4215);B.exports=P==="NODE"},2839:function(B,X,D){var P=D(4576).navigator,z=P&&P.userAgent;B.exports=z?String(z):""},9519:function(B,X,D){var P,z,W=D(4576),H=D(2839),re=W.process,O=W.Deno,q=re&&re.versions||O&&O.version,Y=q&&q.v8;Y&&(z=(P=Y.split("."))[0]>0&&P[0]<4?1:+(P[0]+P[1])),!z&&H&&(!(P=H.match(/Edge\/(\d+)/))||P[1]>=74)&&(P=H.match(/Chrome\/(\d+)/))&&(z=+P[1]),B.exports=z},3607:function(B,X,D){var P=D(2839).match(/AppleWebKit\/(\d+)\./);B.exports=!!P&&+P[1]},4215:function(B,X,D){var P=D(4576),z=D(2839),W=D(2195),H=function(re){return z.slice(0,re.length)===re};B.exports=H("Bun/")?"BUN":H("Cloudflare-Workers")?"CLOUDFLARE":H("Deno/")?"DENO":H("Node.js/")?"NODE":P.Bun&&typeof Bun.version=="string"?"BUN":P.Deno&&typeof Deno.version=="object"?"DENO":W(P.process)==="process"?"NODE":P.window&&P.document?"BROWSER":"REST"},6518:function(B,X,D){var P=D(4576),z=D(7347).f,W=D(6699),H=D(6840),re=D(9433),O=D(7740),q=D(2796);B.exports=function(Y,V){var ee,oe,me,pe,ie,L=Y.target,R=Y.global,ne=Y.stat;if(ee=R?P:ne?P[L]||re(L,{}):P[L]&&P[L].prototype)for(oe in V){if(pe=V[oe],me=Y.dontCallGetSet?(ie=z(ee,oe))&&ie.value:ee[oe],!q(R?oe:L+(ne?".":"#")+oe,Y.forced)&&me!==void 0){if(typeof pe==typeof me)continue;O(pe,me)}(Y.sham||me&&me.sham)&&W(pe,"sham",!0),H(ee,oe,pe,Y)}}},9039:function(B){B.exports=function(X){try{return!!X()}catch{return!0}}},9228:function(B,X,D){D(7495);var P=D(9565),z=D(6840),W=D(7323),H=D(9039),re=D(8227),O=D(6699),q=re("species"),Y=RegExp.prototype;B.exports=function(V,ee,oe,me){var pe=re(V),ie=!H((function(){var ye={};return ye[pe]=function(){return 7},""[V](ye)!==7})),L=ie&&!H((function(){var ye=!1,ve=/a/;if(V==="split"){var be={};be[q]=function(){return ve},(ve={constructor:be,flags:""})[pe]=/./[pe]}return ve.exec=function(){return ye=!0,null},ve[pe](""),!ye}));if(!ie||!L||oe){var R=/./[pe],ne=ee(pe,""[V],(function(ye,ve,be,Be,we){var Ae=ve.exec;return Ae===W||Ae===Y.exec?ie&&!we?{done:!0,value:P(R,ve,be,Be)}:{done:!0,value:P(ye,be,ve,Be)}:{done:!1}}));z(String.prototype,V,ne[0]),z(Y,pe,ne[1])}me&&O(Y[pe],"sham",!0)}},8745:function(B,X,D){var P=D(616),z=Function.prototype,W=z.apply,H=z.call;B.exports=typeof Reflect=="object"&&Reflect.apply||(P?H.bind(W):function(){return H.apply(W,arguments)})},6080:function(B,X,D){var P=D(7476),z=D(9306),W=D(616),H=P(P.bind);B.exports=function(re,O){return z(re),O===void 0?re:W?H(re,O):function(){return re.apply(O,arguments)}}},616:function(B,X,D){var P=D(9039);B.exports=!P((function(){var z=(function(){}).bind();return typeof z!="function"||z.hasOwnProperty("prototype")}))},566:function(B,X,D){var P=D(9504),z=D(9306),W=D(34),H=D(9297),re=D(7680),O=D(616),q=Function,Y=P([].concat),V=P([].join),ee={};B.exports=O?q.bind:function(oe){var me=z(this),pe=me.prototype,ie=re(arguments,1),L=function(){var R=Y(ie,re(arguments));return this instanceof L?(function(ne,ye,ve){if(!H(ee,ye)){for(var be=[],Be=0;Be]*>)/g,Y=/\$([$&'`]|\d{1,2})/g;B.exports=function(V,ee,oe,me,pe,ie){var L=oe+V.length,R=me.length,ne=Y;return pe!==void 0&&(pe=z(pe),ne=q),re(ie,ne,(function(ye,ve){var be;switch(H(ve,0)){case"$":return"$";case"&":return V;case"`":return O(ee,0,oe);case"'":return O(ee,L);case"<":be=pe[O(ve,1,-1)];break;default:var Be=+ve;if(Be===0)return ye;if(Be>R){var we=W(Be/10);return we===0?ye:we<=R?me[we-1]===void 0?H(ve,1):me[we-1]+H(ve,1):ye}be=me[Be-1]}return be===void 0?"":be}))}},4576:function(B,X,D){var P=function(z){return z&&z.Math===Math&&z};B.exports=P(typeof globalThis=="object"&&globalThis)||P(typeof window=="object"&&window)||P(typeof self=="object"&&self)||P(typeof D.g=="object"&&D.g)||P(typeof this=="object"&&this)||(function(){return this})()||Function("return this")()},9297:function(B,X,D){var P=D(9504),z=D(8981),W=P({}.hasOwnProperty);B.exports=Object.hasOwn||function(H,re){return W(z(H),re)}},421:function(B){B.exports={}},397:function(B,X,D){var P=D(7751);B.exports=P("document","documentElement")},5917:function(B,X,D){var P=D(3724),z=D(9039),W=D(4055);B.exports=!P&&!z((function(){return Object.defineProperty(W("div"),"a",{get:function(){return 7}}).a!==7}))},7055:function(B,X,D){var P=D(9504),z=D(9039),W=D(2195),H=Object,re=P("".split);B.exports=z((function(){return!H("z").propertyIsEnumerable(0)}))?function(O){return W(O)==="String"?re(O,""):H(O)}:H},3167:function(B,X,D){var P=D(4901),z=D(34),W=D(2967);B.exports=function(H,re,O){var q,Y;return W&&P(q=re.constructor)&&q!==O&&z(Y=q.prototype)&&Y!==O.prototype&&W(H,Y),H}},3706:function(B,X,D){var P=D(9504),z=D(4901),W=D(7629),H=P(Function.toString);z(W.inspectSource)||(W.inspectSource=function(re){return H(re)}),B.exports=W.inspectSource},1181:function(B,X,D){var P,z,W,H=D(8622),re=D(4576),O=D(34),q=D(6699),Y=D(9297),V=D(7629),ee=D(6119),oe=D(421),me="Object already initialized",pe=re.TypeError,ie=re.WeakMap;if(H||V.state){var L=V.state||(V.state=new ie);L.get=L.get,L.has=L.has,L.set=L.set,P=function(ne,ye){if(L.has(ne))throw new pe(me);return ye.facade=ne,L.set(ne,ye),ye},z=function(ne){return L.get(ne)||{}},W=function(ne){return L.has(ne)}}else{var R=ee("state");oe[R]=!0,P=function(ne,ye){if(Y(ne,R))throw new pe(me);return ye.facade=ne,q(ne,R,ye),ye},z=function(ne){return Y(ne,R)?ne[R]:{}},W=function(ne){return Y(ne,R)}}B.exports={set:P,get:z,has:W,enforce:function(ne){return W(ne)?z(ne):P(ne,{})},getterFor:function(ne){return function(ye){var ve;if(!O(ye)||(ve=z(ye)).type!==ne)throw new pe("Incompatible receiver, "+ne+" required");return ve}}}},4209:function(B,X,D){var P=D(8227),z=D(6269),W=P("iterator"),H=Array.prototype;B.exports=function(re){return re!==void 0&&(z.Array===re||H[W]===re)}},4376:function(B,X,D){var P=D(2195);B.exports=Array.isArray||function(z){return P(z)==="Array"}},4901:function(B){var X=typeof document=="object"&&document.all;B.exports=X===void 0&&X!==void 0?function(D){return typeof D=="function"||D===X}:function(D){return typeof D=="function"}},3517:function(B,X,D){var P=D(9504),z=D(9039),W=D(4901),H=D(6955),re=D(7751),O=D(3706),q=function(){},Y=re("Reflect","construct"),V=/^\s*(?:class|function)\b/,ee=P(V.exec),oe=!V.test(q),me=function(ie){if(!W(ie))return!1;try{return Y(q,[],ie),!0}catch{return!1}},pe=function(ie){if(!W(ie))return!1;switch(H(ie)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return oe||!!ee(V,O(ie))}catch{return!0}};pe.sham=!0,B.exports=!Y||z((function(){var ie;return me(me.call)||!me(Object)||!me((function(){ie=!0}))||ie}))?pe:me},2796:function(B,X,D){var P=D(9039),z=D(4901),W=/#|\.prototype\./,H=function(V,ee){var oe=O[re(V)];return oe===Y||oe!==q&&(z(ee)?P(ee):!!ee)},re=H.normalize=function(V){return String(V).replace(W,".").toLowerCase()},O=H.data={},q=H.NATIVE="N",Y=H.POLYFILL="P";B.exports=H},2087:function(B,X,D){var P=D(34),z=Math.floor;B.exports=Number.isInteger||function(W){return!P(W)&&isFinite(W)&&z(W)===W}},4117:function(B){B.exports=function(X){return X==null}},34:function(B,X,D){var P=D(4901);B.exports=function(z){return typeof z=="object"?z!==null:P(z)}},3925:function(B,X,D){var P=D(34);B.exports=function(z){return P(z)||z===null}},6395:function(B){B.exports=!1},5810:function(B,X,D){var P=D(34),z=D(1181).get;B.exports=function(W){if(!P(W))return!1;var H=z(W);return!!H&&H.type==="RawJSON"}},788:function(B,X,D){var P=D(34),z=D(2195),W=D(8227)("match");B.exports=function(H){var re;return P(H)&&((re=H[W])!==void 0?!!re:z(H)==="RegExp")}},757:function(B,X,D){var P=D(7751),z=D(4901),W=D(1625),H=D(7040),re=Object;B.exports=H?function(O){return typeof O=="symbol"}:function(O){var q=P("Symbol");return z(q)&&W(q.prototype,re(O))}},9539:function(B,X,D){var P=D(9565),z=D(8551),W=D(5966);B.exports=function(H,re,O){var q,Y;z(H);try{if(!(q=W(H,"return"))){if(re==="throw")throw O;return O}q=P(q,H)}catch(V){Y=!0,q=V}if(re==="throw")throw O;if(Y)throw q;return z(q),O}},3994:function(B,X,D){var P=D(7657).IteratorPrototype,z=D(2360),W=D(6980),H=D(687),re=D(6269),O=function(){return this};B.exports=function(q,Y,V,ee){var oe=Y+" Iterator";return q.prototype=z(P,{next:W(+!ee,V)}),H(q,oe,!1,!0),re[oe]=O,q}},1088:function(B,X,D){var P=D(6518),z=D(9565),W=D(6395),H=D(350),re=D(4901),O=D(3994),q=D(2787),Y=D(2967),V=D(687),ee=D(6699),oe=D(6840),me=D(8227),pe=D(6269),ie=D(7657),L=H.PROPER,R=H.CONFIGURABLE,ne=ie.IteratorPrototype,ye=ie.BUGGY_SAFARI_ITERATORS,ve=me("iterator"),be="keys",Be="values",we="entries",Ae=function(){return this};B.exports=function(Le,Ee,ke,Me,He,De,Xe){O(ke,Ee,Me);var xe,We,Pe,Ke=function(vt){if(vt===He&&nt)return nt;if(!ye&&vt&&vt in Te)return Te[vt];switch(vt){case be:case Be:case we:return function(){return new ke(this,vt)}}return function(){return new ke(this)}},Ve=Ee+" Iterator",Ce=!1,Te=Le.prototype,$e=Te[ve]||Te["@@iterator"]||He&&Te[He],nt=!ye&&$e||Ke(He),bt=Ee==="Array"&&Te.entries||$e;if(bt&&(xe=q(bt.call(new Le)))!==Object.prototype&&xe.next&&(W||q(xe)===ne||(Y?Y(xe,ne):re(xe[ve])||oe(xe,ve,Ae)),V(xe,Ve,!0,!0),W&&(pe[Ve]=Ae)),L&&He===Be&&$e&&$e.name!==Be&&(!W&&R?ee(Te,"name",Be):(Ce=!0,nt=function(){return z($e,this)})),He)if(We={values:Ke(Be),keys:De?nt:Ke(be),entries:Ke(we)},Xe)for(Pe in We)(ye||Ce||!(Pe in Te))&&oe(Te,Pe,We[Pe]);else P({target:Ee,proto:!0,forced:ye||Ce},We);return W&&!Xe||Te[ve]===nt||oe(Te,ve,nt,{name:He}),pe[Ee]=nt,We}},7657:function(B,X,D){var P,z,W,H=D(9039),re=D(4901),O=D(34),q=D(2360),Y=D(2787),V=D(6840),ee=D(8227),oe=D(6395),me=ee("iterator"),pe=!1;[].keys&&("next"in(W=[].keys())?(z=Y(Y(W)))!==Object.prototype&&(P=z):pe=!0),!O(P)||H((function(){var ie={};return P[me].call(ie)!==ie}))?P={}:oe&&(P=q(P)),re(P[me])||V(P,me,(function(){return this})),B.exports={IteratorPrototype:P,BUGGY_SAFARI_ITERATORS:pe}},6269:function(B){B.exports={}},6198:function(B,X,D){var P=D(8014);B.exports=function(z){return P(z.length)}},283:function(B,X,D){var P=D(9504),z=D(9039),W=D(4901),H=D(9297),re=D(3724),O=D(350).CONFIGURABLE,q=D(3706),Y=D(1181),V=Y.enforce,ee=Y.get,oe=String,me=Object.defineProperty,pe=P("".slice),ie=P("".replace),L=P([].join),R=re&&!z((function(){return me((function(){}),"length",{value:8}).length!==8})),ne=String(String).split("String"),ye=B.exports=function(ve,be,Be){pe(oe(be),0,7)==="Symbol("&&(be="["+ie(oe(be),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),Be&&Be.getter&&(be="get "+be),Be&&Be.setter&&(be="set "+be),(!H(ve,"name")||O&&ve.name!==be)&&(re?me(ve,"name",{value:be,configurable:!0}):ve.name=be),R&&Be&&H(Be,"arity")&&ve.length!==Be.arity&&me(ve,"length",{value:Be.arity});try{Be&&H(Be,"constructor")&&Be.constructor?re&&me(ve,"prototype",{writable:!1}):ve.prototype&&(ve.prototype=void 0)}catch{}var we=V(ve);return H(we,"source")||(we.source=L(ne,typeof be=="string"?be:"")),ve};Function.prototype.toString=ye((function(){return W(this)&&ee(this).source||q(this)}),"toString")},741:function(B){var X=Math.ceil,D=Math.floor;B.exports=Math.trunc||function(P){var z=+P;return(z>0?D:X)(z)}},7819:function(B,X,D){var P=D(9039);B.exports=!P((function(){var z="9007199254740993",W=JSON.rawJSON(z);return!JSON.isRawJSON(W)||JSON.stringify(W)!==z}))},5749:function(B,X,D){var P=D(788),z=TypeError;B.exports=function(W){if(P(W))throw new z("The method doesn't accept regular expressions");return W}},4213:function(B,X,D){var P=D(3724),z=D(9504),W=D(9565),H=D(9039),re=D(1072),O=D(3717),q=D(8773),Y=D(8981),V=D(7055),ee=Object.assign,oe=Object.defineProperty,me=z([].concat);B.exports=!ee||H((function(){if(P&&ee({b:1},ee(oe({},"a",{enumerable:!0,get:function(){oe(this,"b",{value:3,enumerable:!1})}}),{b:2})).b!==1)return!0;var pe={},ie={},L=Symbol("assign detection"),R="abcdefghijklmnopqrst";return pe[L]=7,R.split("").forEach((function(ne){ie[ne]=ne})),ee({},pe)[L]!==7||re(ee({},ie)).join("")!==R}))?function(pe,ie){for(var L=Y(pe),R=arguments.length,ne=1,ye=O.f,ve=q.f;R>ne;)for(var be,Be=V(arguments[ne++]),we=ye?me(re(Be),ye(Be)):re(Be),Ae=we.length,Le=0;Ae>Le;)be=we[Le++],P&&!W(ve,Be,be)||(L[be]=Be[be]);return L}:ee},2360:function(B,X,D){var P,z=D(8551),W=D(6801),H=D(8727),re=D(421),O=D(397),q=D(4055),Y=D(6119),V="prototype",ee="script",oe=Y("IE_PROTO"),me=function(){},pe=function(R){return"<"+ee+">"+R+""},ie=function(R){R.write(pe("")),R.close();var ne=R.parentWindow.Object;return R=null,ne},L=function(){try{P=new ActiveXObject("htmlfile")}catch{}var R,ne,ye;L=typeof document<"u"?document.domain&&P?ie(P):(ne=q("iframe"),ye="java"+ee+":",ne.style.display="none",O.appendChild(ne),ne.src=String(ye),(R=ne.contentWindow.document).open(),R.write(pe("document.F=Object")),R.close(),R.F):ie(P);for(var ve=H.length;ve--;)delete L[V][H[ve]];return L()};re[oe]=!0,B.exports=Object.create||function(R,ne){var ye;return R!==null?(me[V]=z(R),ye=new me,me[V]=null,ye[oe]=R):ye=L(),ne===void 0?ye:W.f(ye,ne)}},6801:function(B,X,D){var P=D(3724),z=D(8686),W=D(4913),H=D(8551),re=D(5397),O=D(1072);X.f=P&&!z?Object.defineProperties:function(q,Y){H(q);for(var V,ee=re(Y),oe=O(Y),me=oe.length,pe=0;me>pe;)W.f(q,V=oe[pe++],ee[V]);return q}},4913:function(B,X,D){var P=D(3724),z=D(5917),W=D(8686),H=D(8551),re=D(6969),O=TypeError,q=Object.defineProperty,Y=Object.getOwnPropertyDescriptor,V="enumerable",ee="configurable",oe="writable";X.f=P?W?function(me,pe,ie){if(H(me),pe=re(pe),H(ie),typeof me=="function"&&pe==="prototype"&&"value"in ie&&oe in ie&&!ie[oe]){var L=Y(me,pe);L&&L[oe]&&(me[pe]=ie.value,ie={configurable:ee in ie?ie[ee]:L[ee],enumerable:V in ie?ie[V]:L[V],writable:!1})}return q(me,pe,ie)}:q:function(me,pe,ie){if(H(me),pe=re(pe),H(ie),z)try{return q(me,pe,ie)}catch{}if("get"in ie||"set"in ie)throw new O("Accessors not supported");return"value"in ie&&(me[pe]=ie.value),me}},7347:function(B,X,D){var P=D(3724),z=D(9565),W=D(8773),H=D(6980),re=D(5397),O=D(6969),q=D(9297),Y=D(5917),V=Object.getOwnPropertyDescriptor;X.f=P?V:function(ee,oe){if(ee=re(ee),oe=O(oe),Y)try{return V(ee,oe)}catch{}if(q(ee,oe))return H(!z(W.f,ee,oe),ee[oe])}},298:function(B,X,D){var P=D(2195),z=D(5397),W=D(8480).f,H=D(7680),re=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];B.exports.f=function(O){return re&&P(O)==="Window"?(function(q){try{return W(q)}catch{return H(re)}})(O):W(z(O))}},8480:function(B,X,D){var P=D(1828),z=D(8727).concat("length","prototype");X.f=Object.getOwnPropertyNames||function(W){return P(W,z)}},3717:function(B,X){X.f=Object.getOwnPropertySymbols},2787:function(B,X,D){var P=D(9297),z=D(4901),W=D(8981),H=D(6119),re=D(2211),O=H("IE_PROTO"),q=Object,Y=q.prototype;B.exports=re?q.getPrototypeOf:function(V){var ee=W(V);if(P(ee,O))return ee[O];var oe=ee.constructor;return z(oe)&&ee instanceof oe?oe.prototype:ee instanceof q?Y:null}},1625:function(B,X,D){var P=D(9504);B.exports=P({}.isPrototypeOf)},1828:function(B,X,D){var P=D(9504),z=D(9297),W=D(5397),H=D(9617).indexOf,re=D(421),O=P([].push);B.exports=function(q,Y){var V,ee=W(q),oe=0,me=[];for(V in ee)!z(re,V)&&z(ee,V)&&O(me,V);for(;Y.length>oe;)z(ee,V=Y[oe++])&&(~H(me,V)||O(me,V));return me}},1072:function(B,X,D){var P=D(1828),z=D(8727);B.exports=Object.keys||function(W){return P(W,z)}},8773:function(B,X){var D={}.propertyIsEnumerable,P=Object.getOwnPropertyDescriptor,z=P&&!D.call({1:2},1);X.f=z?function(W){var H=P(this,W);return!!H&&H.enumerable}:D},2551:function(B,X,D){var P=D(6395),z=D(4576),W=D(9039),H=D(3607);B.exports=P||!W((function(){if(!(H&&H<535)){var re=Math.random();__defineSetter__.call(null,re,(function(){})),delete z[re]}}))},2967:function(B,X,D){var P=D(6706),z=D(34),W=D(7750),H=D(3506);B.exports=Object.setPrototypeOf||("__proto__"in{}?(function(){var re,O=!1,q={};try{(re=P(Object.prototype,"__proto__","set"))(q,[]),O=q instanceof Array}catch{}return function(Y,V){return W(Y),H(V),z(Y)&&(O?re(Y,V):Y.__proto__=V),Y}})():void 0)},3179:function(B,X,D){var P=D(2140),z=D(6955);B.exports=P?{}.toString:function(){return"[object "+z(this)+"]"}},4270:function(B,X,D){var P=D(9565),z=D(4901),W=D(34),H=TypeError;B.exports=function(re,O){var q,Y;if(O==="string"&&z(q=re.toString)&&!W(Y=P(q,re))||z(q=re.valueOf)&&!W(Y=P(q,re))||O!=="string"&&z(q=re.toString)&&!W(Y=P(q,re)))return Y;throw new H("Can't convert object to primitive value")}},5031:function(B,X,D){var P=D(7751),z=D(9504),W=D(8480),H=D(3717),re=D(8551),O=z([].concat);B.exports=P("Reflect","ownKeys")||function(q){var Y=W.f(re(q)),V=H.f;return V?O(Y,V(q)):Y}},8235:function(B,X,D){var P=D(9504),z=D(9297),W=SyntaxError,H=parseInt,re=String.fromCharCode,O=P("".charAt),q=P("".slice),Y=P(/./.exec),V={'\\"':'"',"\\\\":"\\","\\/":"/","\\b":"\b","\\f":"\f","\\n":` `,"\\r":"\r","\\t":" "},ee=/^[\da-f]{4}$/i,oe=/^[\u0000-\u001F]$/;B.exports=function(me,pe){for(var ie=!0,L="";pe0&&(!xe.multiline||xe.multiline&&R(Pe,xe.lastIndex-1)!==` `)&&($e="(?: "+$e+")",bt=" "+bt,nt++),Ee=new RegExp("^(?:"+$e+")",Te)),we&&(Ee=new RegExp("^"+$e+"$(?!\\s)",Te)),be&&(ke=xe.lastIndex),Me=W(ie,Ce?Ee:xe,bt),Ce?Me?(Me.input=ve(Me.input,nt),Me[0]=ve(Me[0],nt),Me.index=xe.lastIndex,xe.lastIndex+=Me[0].length):xe.lastIndex=0:be&&Me&&(xe.lastIndex=xe.global?Me.index+Me[0].length:ke),we&&Me&&Me.length>1&&W(pe,Me[0],Ee,(function(){for(He=1;Heb)","g");return W.exec("b").groups.a!=="b"||"b".replace(W,"$c")!=="bc"}))},7750:function(B,X,D){var P=D(4117),z=TypeError;B.exports=function(W){if(P(W))throw new z("Can't call method on "+W);return W}},7633:function(B,X,D){var P=D(7751),z=D(2106),W=D(8227),H=D(3724),re=W("species");B.exports=function(O){var q=P(O);H&&q&&!q[re]&&z(q,re,{configurable:!0,get:function(){return this}})}},687:function(B,X,D){var P=D(4913).f,z=D(9297),W=D(8227)("toStringTag");B.exports=function(H,re,O){H&&!O&&(H=H.prototype),H&&!z(H,W)&&P(H,W,{configurable:!0,value:re})}},6119:function(B,X,D){var P=D(5745),z=D(3392),W=P("keys");B.exports=function(H){return W[H]||(W[H]=z(H))}},7629:function(B,X,D){var P=D(6395),z=D(4576),W=D(9433),H="__core-js_shared__",re=B.exports=z[H]||W(H,{});(re.versions||(re.versions=[])).push({version:"3.48.0",mode:P?"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(B,X,D){var P=D(7629);B.exports=function(z,W){return P[z]||(P[z]=W||{})}},2293:function(B,X,D){var P=D(8551),z=D(5548),W=D(4117),H=D(8227)("species");B.exports=function(re,O){var q,Y=P(re).constructor;return Y===void 0||W(q=P(Y)[H])?O:z(q)}},8183:function(B,X,D){var P=D(9504),z=D(1291),W=D(655),H=D(7750),re=P("".charAt),O=P("".charCodeAt),q=P("".slice),Y=function(V){return function(ee,oe){var me,pe,ie=W(H(ee)),L=z(oe),R=ie.length;return L<0||L>=R?V?"":void 0:(me=O(ie,L))<55296||me>56319||L+1===R||(pe=O(ie,L+1))<56320||pe>57343?V?re(ie,L):me:V?q(ie,L,L+2):pe-56320+(me-55296<<10)+65536}};B.exports={codeAt:Y(!1),charAt:Y(!0)}},706:function(B,X,D){var P=D(350).PROPER,z=D(9039),W=D(7452);B.exports=function(H){return z((function(){return!!W[H]()||"​…᠎"[H]()!=="​…᠎"||P&&W[H].name!==H}))}},3802:function(B,X,D){var P=D(9504),z=D(7750),W=D(655),H=D(7452),re=P("".replace),O=RegExp("^["+H+"]+"),q=RegExp("(^|[^"+H+"])["+H+"]+$"),Y=function(V){return function(ee){var oe=W(z(ee));return 1&V&&(oe=re(oe,O,"")),2&V&&(oe=re(oe,q,"$1")),oe}};B.exports={start:Y(1),end:Y(2),trim:Y(3)}},4495:function(B,X,D){var P=D(9519),z=D(9039),W=D(4576).String;B.exports=!!Object.getOwnPropertySymbols&&!z((function(){var H=Symbol("symbol detection");return!W(H)||!(Object(H)instanceof Symbol)||!Symbol.sham&&P&&P<41}))},8242:function(B,X,D){var P=D(9565),z=D(7751),W=D(8227),H=D(6840);B.exports=function(){var re=z("Symbol"),O=re&&re.prototype,q=O&&O.valueOf,Y=W("toPrimitive");O&&!O[Y]&&H(O,Y,(function(V){return P(q,this)}),{arity:1})}},1296:function(B,X,D){var P=D(4495);B.exports=P&&!!Symbol.for&&!!Symbol.keyFor},1240:function(B,X,D){var P=D(9504);B.exports=P(1.1.valueOf)},5610:function(B,X,D){var P=D(1291),z=Math.max,W=Math.min;B.exports=function(H,re){var O=P(H);return O<0?z(O+re,0):W(O,re)}},5397:function(B,X,D){var P=D(7055),z=D(7750);B.exports=function(W){return P(z(W))}},1291:function(B,X,D){var P=D(741);B.exports=function(z){var W=+z;return W!=W||W===0?0:P(W)}},8014:function(B,X,D){var P=D(1291),z=Math.min;B.exports=function(W){var H=P(W);return H>0?z(H,9007199254740991):0}},8981:function(B,X,D){var P=D(7750),z=Object;B.exports=function(W){return z(P(W))}},2777:function(B,X,D){var P=D(9565),z=D(34),W=D(757),H=D(5966),re=D(4270),O=D(8227),q=TypeError,Y=O("toPrimitive");B.exports=function(V,ee){if(!z(V)||W(V))return V;var oe,me=H(V,Y);if(me){if(ee===void 0&&(ee="default"),oe=P(me,V,ee),!z(oe)||W(oe))return oe;throw new q("Can't convert object to primitive value")}return ee===void 0&&(ee="number"),re(V,ee)}},6969:function(B,X,D){var P=D(2777),z=D(757);B.exports=function(W){var H=P(W,"string");return z(H)?H:H+""}},2140:function(B,X,D){var P={};P[D(8227)("toStringTag")]="z",B.exports=String(P)==="[object z]"},655:function(B,X,D){var P=D(6955),z=String;B.exports=function(W){if(P(W)==="Symbol")throw new TypeError("Cannot convert a Symbol value to a string");return z(W)}},6823:function(B){var X=String;B.exports=function(D){try{return X(D)}catch{return"Object"}}},3392:function(B,X,D){var P=D(9504),z=0,W=Math.random(),H=P(1.1.toString);B.exports=function(re){return"Symbol("+(re===void 0?"":re)+")_"+H(++z+W,36)}},7040:function(B,X,D){var P=D(4495);B.exports=P&&!Symbol.sham&&typeof Symbol.iterator=="symbol"},8686:function(B,X,D){var P=D(3724),z=D(9039);B.exports=P&&z((function(){return Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype!==42}))},8622:function(B,X,D){var P=D(4576),z=D(4901),W=P.WeakMap;B.exports=z(W)&&/native code/.test(String(W))},511:function(B,X,D){var P=D(9167),z=D(9297),W=D(1951),H=D(4913).f;B.exports=function(re){var O=P.Symbol||(P.Symbol={});z(O,re)||H(O,re,{value:W.f(re)})}},1951:function(B,X,D){var P=D(8227);X.f=P},8227:function(B,X,D){var P=D(4576),z=D(5745),W=D(9297),H=D(3392),re=D(4495),O=D(7040),q=P.Symbol,Y=z("wks"),V=O?q.for||q:q&&q.withoutSetter||H;B.exports=function(ee){return W(Y,ee)||(Y[ee]=re&&W(q,ee)?q[ee]:V("Symbol."+ee)),Y[ee]}},7452:function(B){B.exports=` diff --git a/static/index.html b/static/index.html index 4bf160d76..4abcc729b 100644 --- a/static/index.html +++ b/static/index.html @@ -23,7 +23,7 @@ - +