1){const qe=he(Mt,xt);qe.quantity=Wt-1,await ht.mutateAsync(qe)}}else if(t==="edit-queue-item"&&Qe===1){const wt=Ye(Mt),qe={printer_id:Mt,target_model:null,target_location:null,require_previous_success:F.requirePreviousSuccess,auto_off_after:F.autoOffAfter,gcode_injection:F.gcodeInjection,manual_start:F.scheduleType==="manual",ams_mapping:wt,plate_id:xt,scheduled_time:F.scheduleType==="scheduled"&&F.scheduledTime?new Date(F.scheduledTime).toISOString():null,...T};await yt.mutateAsync(qe)}else{const wt=he(Mt,xt);if(Wt>1&&(wt.quantity=Wt),De){const qe=Math.floor(et/F.staggerGroupSize);if(qe>0){const Lt=qe*F.staggerIntervalMinutes*6e4;wt.scheduled_time=new Date(Je+Lt).toISOString()}}await ht.mutateAsync(wt)}Ge.success++}catch(wt){Ge.failed++;const qe=ce?.find(Xe=>Xe.id===Mt)?.name||`Printer ${Mt}`,Lt=We?We.name||`Plate ${We.index}`:"",Ot=Lt?`${qe} (${Lt})`:qe;Ge.errors.push(`${Ot}: ${wt.message}`)}}}}K(!1),Ge.failed===0?(t==="reprint"&&ot?p(u("queue.itemsQueued",{count:Ge.success})):t!=="reprint"&&(t==="edit-queue-item"?p("Queue item updated"):Ge.success===1?p(L==="model"?`Queued for any ${re}`:u("queue.printQueued")):p(u("queue.itemsQueued",{count:Ge.success}))),m.invalidateQueries({queryKey:["queue"]}),l?.(),o()):Ge.success===0?p(`Failed: ${Ge.errors[0]}`,"error"):(p(`${Ge.success} succeeded, ${Ge.failed} failed`,"error"),m.invalidateQueries({queryKey:["queue"]}))},Gt=$||yt.isPending,Jt=v.useMemo(()=>!(Gt||L==="printer"&&w.length===0||L==="model"&&!re||L==="model"&&t==="reprint"||Ae&&x.size===0),[w.length,L,re,t,Ae,x.size,Gt]),Wt=L==="printer"&&w.length>1?1:C,ln=(()=>{const _t=w.length;if(t==="reprint"){const Ft=ot&&_t>1;let Re=Ft?u("printModal.staggerToPrinters",{count:_t,defaultValue:"Stagger to {{count}} printers"}):_t>1?u("queue.printToPrinters",{count:_t}):u("queue.print");return Wt>1&&(Re=`${Re} ×${Wt}`),{title:u(b?"queue.print":"queue.reprint"),icon:mr,submitText:Re,submitIcon:Ft?ya:mr,loadingText:D.total>1?u("queue.sendingProgress",{current:D.current,total:D.total}):u("queue.sending")}}if(t==="add-to-queue"){let Ft=u("queue.addToQueue");return x.size>1?Ft=u("queue.queueSelectedPlates",{count:x.size}):_t>1&&(Ft=u("queue.queueToPrinters",{count:_t})),Wt>1&&(Ft=`${Ft} ×${Wt}`),{title:u("queue.schedulePrint"),icon:ya,submitText:Ft,submitIcon:ya,loadingText:D.total>1?u("queue.addingProgress",{current:D.current,total:D.total}):u("queue.adding")}}return{title:u("queue.editQueueItem"),icon:ii,submitText:u("common.save"),submitIcon:ii,loadingText:D.total>1?u("queue.savingProgress",{current:D.current,total:D.total}):u("common.saving")}})(),ut=ln.icon,it=ln.submitIcon,vt=G&&x.size<=1&&(b||(Ae?N!==null:!0));return r.jsxs("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4",onClick:$?void 0:o,children:[r.jsx(Ct,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",onClick:_t=>_t.stopPropagation(),children:r.jsxs(At,{className:t==="reprint"?"":"p-0",children:[r.jsxs("div",{className:`flex items-center justify-between ${t==="reprint"?"mb-4":"p-4 border-b border-bambu-dark-tertiary"}`,children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx(ut,{className:"w-5 h-5 text-bambu-green"}),r.jsx("h2",{className:"text-lg font-semibold text-white",children:ln.title})]}),r.jsx(Me,{variant:"ghost",size:"sm",onClick:o,disabled:$,children:r.jsx(Ht,{className:"w-5 h-5"})})]}),r.jsxs("form",{onSubmit:qt,className:t==="reprint"?"":"p-4 space-y-4",children:[r.jsx("p",{className:`text-sm text-bambu-gray ${t==="reprint"?"mb-4":""}`,children:t==="reprint"?r.jsxs(r.Fragment,{children:["Send ",r.jsx("span",{className:"text-white",children:a})," to"," ",s?.length===1&&ce?r.jsx("span",{className:"text-white",children:ce.find(_t=>_t.id===s[0])?.name??"printer(s)"}):"printer(s)"]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"block text-bambu-gray mb-1",children:"Print Job"}),r.jsx("span",{className:"text-white font-medium truncate block",children:a})]})}),r.jsx(y7e,{plates:$e,isMultiPlate:Ae,selectedPlates:x,onToggle:_t=>{_(Ft=>{const Re=new Set(Ft);return t==="add-to-queue"?Re.has(_t)?Re.delete(_t):Re.add(_t):(Re.clear(),Re.add(_t)),Re})},onSelectAll:t==="add-to-queue"?()=>_(new Set($e.map(_t=>_t.index))):void 0,onDeselectAll:t==="add-to-queue"?()=>_(new Set):void 0,multiSelect:t==="add-to-queue"}),!s?.length&&r.jsx(S7e,{printers:ce||[],selectedPrinterIds:w,onMultiSelect:g,isLoading:le,allowMultiple:!0,showInactive:t==="edit-queue-item",disableBusy:t==="reprint",printerMappingResults:tt.printerResults,filamentReqs:Ie,onAutoConfigurePrinter:tt.autoConfigurePrinter,onUpdatePrinterConfig:tt.updatePrinterConfig,assignmentMode:t==="reprint"?"printer":L,onAssignmentModeChange:t!=="reprint"?Z:void 0,targetModel:re,onTargetModelChange:t!=="reprint"?J:void 0,targetLocation:de,onTargetLocationChange:t!=="reprint"?me:void 0,slicedForModel:be}),L==="model"&&re&&Ie&&rt&&rt.length>0&&r.jsx(x7e,{filamentReqs:Ie,availableFilaments:rt,overrides:ue,onChange:W,forceColorMatch:ae,onForceColorMatchChange:(_t,Ft)=>pe(Re=>({...Re,[_t]:Ft}))}),be&&L==="printer"&&w.length===1&&(()=>{const _t=ce?.find(Ft=>Ft.id===w[0]);return _t&&_t.model&&be!==_t.model?r.jsxs("div",{className:"p-3 mb-2 bg-yellow-500/10 border border-yellow-500/30 rounded-lg flex items-center gap-2",children:[r.jsx(Sn,{className:"w-4 h-4 text-yellow-400 flex-shrink-0"}),r.jsxs("span",{className:"text-sm text-yellow-400",children:["File was sliced for ",be,", but printing on ",_t.model]})]}):null})(),Oe&&r.jsxs("div",{className:"flex items-start gap-2 p-3 mb-2 bg-orange-500/10 border border-orange-500/30 rounded-lg text-sm",children:[r.jsx(Ha,{className:"w-4 h-4 text-orange-400 mt-0.5 flex-shrink-0"}),r.jsx("p",{className:"text-orange-400",children:"Archive data unavailable. The source file may have been deleted. Filament mapping is disabled."})]}),vt&&!Oe&&w.length===1&&r.jsx(b7e,{printerId:G,filamentReqs:Ie,manualMappings:M,onManualMappingChange:z,defaultExpanded:!!s?.length||(Y?.per_printer_mapping_expanded??!1),currencySymbol:ee,defaultCostPerKg:ge}),(t==="reprint"||U>0||L==="model"&&re)&&r.jsx(k7e,{options:T,onChange:A,defaultExpanded:!!s?.length}),t!=="edit-queue-item"&&(L==="model"||w.length<=1)&&r.jsxs("div",{className:"flex items-center gap-3",children:[r.jsx("label",{htmlFor:"printQuantity",className:"text-sm text-bambu-gray whitespace-nowrap",children:u("queue.quantity","Quantity")}),r.jsx("input",{id:"printQuantity",type:"number",min:1,max:999,value:C,onChange:_t=>P(Math.max(1,Math.min(999,parseInt(_t.target.value)||1))),className:"w-20 px-2 py-1 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white focus:outline-none focus:ring-1 focus:ring-bambu-green"}),C>1&&r.jsx("span",{className:"text-xs text-bambu-gray",children:u("queue.quantityHint","Creates {{count}} queue items",{count:C})})]}),t==="reprint"&&L==="printer"&&w.length>1&&r.jsxs("div",{className:"space-y-2 pb-2",children:[r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"staggerEnabledReprint",checked:F.staggerEnabled,onChange:_t=>S({...F,staggerEnabled:_t.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),r.jsxs("label",{htmlFor:"staggerEnabledReprint",className:"text-sm flex items-center gap-1 text-bambu-gray",children:[r.jsx(da,{className:"w-3.5 h-3.5"}),u("printModal.staggerPrinterStarts","Stagger printer starts")]})]}),F.staggerEnabled&&(()=>{const _t=F.staggerGroupSize,Ft=F.staggerIntervalMinutes,Re=Math.ceil(w.length/_t),je=(Re-1)*Ft;return r.jsxs("p",{className:"ml-6 text-xs text-bambu-gray",children:[u("printModal.staggerPreview","{{printers}} printers → {{groups}} groups of {{size}}, starting every {{interval}} min",{printers:w.length,groups:Re,size:_t,interval:Ft}),Re>1?` (${u("printModal.staggerTotal","total: {{minutes}} min",{minutes:je})})`:""]})})()]}),t!=="reprint"&&r.jsx(N7e,{options:F,onChange:S,dateFormat:Y?.date_format||"system",timeFormat:Y?.time_format||"system",canControlPrinter:f("printers:control"),showStagger:t==="add-to-queue"&&L==="printer"&&w.length>1,printerCount:w.length,hasGcodeSnippets:!!Y?.gcode_snippets}),t==="reprint"&&!!Y?.gcode_snippets&&Wt>1&&r.jsxs("div",{className:"flex items-center gap-2",children:[r.jsx("input",{type:"checkbox",id:"gcodeInjectionReprint",checked:F.gcodeInjection,onChange:_t=>S({...F,gcodeInjection:_t.target.checked}),className:"rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green"}),r.jsxs("label",{htmlFor:"gcodeInjectionReprint",className:"text-sm flex items-center gap-1 text-bambu-gray",children:[r.jsx(qy,{className:"w-3.5 h-3.5"}),u("printModal.gcodeInjection","Inject auto-print G-code")]})]}),yt.isError&&r.jsx("div",{className:"mb-4 p-3 bg-red-500/20 border border-red-500/50 rounded-lg text-sm text-red-400",children:yt.error?.message||"Failed to complete operation"}),r.jsxs("div",{className:`flex gap-3 ${t==="reprint"?"":"pt-2"}`,children:[r.jsx(Me,{type:"button",variant:"secondary",onClick:o,className:"flex-1",disabled:$,children:"Cancel"}),r.jsx(Me,{type:"submit",disabled:!Jt,className:"flex-1",children:Gt?r.jsxs(r.Fragment,{children:[r.jsx(mt,{className:"w-4 h-4 animate-spin"}),ln.loadingText]}):r.jsxs(r.Fragment,{children:[r.jsx(it,{className:"w-4 h-4"}),ln.submitText]})})]})]})]})}),B&&B.length>0&&r.jsx(vn,{title:u("printModal.insufficientFilamentTitle"),message:nt,confirmText:u("printModal.printAnyway"),cancelText:u("common.cancel"),variant:"warning",onConfirm:()=>{X(null),qt(void 0,{skipFilamentCheck:!0})},onCancel:()=>X(null)})]})}function UK({value:t}){const{t:e}=kt(),[n,a]=v.useState(!1),i=async()=>{try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(t);else{const s=document.createElement("textarea");s.value=t,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s);try{if(s.select(),!document.execCommand("copy"))return}finally{document.body.removeChild(s)}}a(!0),setTimeout(()=>a(!1),2e3)}catch{}};return r.jsx("button",{onClick:i,className:"ml-2 p-1 rounded hover:bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors",title:e(n?"printers.copied":"printers.copyToClipboard"),children:n?r.jsx(_r,{className:"w-3.5 h-3.5 text-bambu-green"}):r.jsx(Ai,{className:"w-3.5 h-3.5"})})}function C7e({printer:t,status:e,totalPrintHours:n,onClose:a}){const{t:i}=kt();v.useEffect(()=>{const o=l=>{l.key==="Escape"&&a()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[a]);const s=[];if(s.push({label:i("printers.model"),value:t.model??"—"}),s.push({label:i("common.status"),value:r.jsxs("span",{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${e?.connected?"bg-bambu-green/20 text-bambu-green":"bg-red-500/20 text-red-400"}`,children:[r.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${e?.connected?"bg-bambu-green":"bg-red-400"}`}),e?.connected?i("printers.status.available"):i("printers.status.offline")]})}),e?.state){const o={IDLE:"printers.status.idle",RUNNING:"printers.status.printing",PAUSE:"printers.status.paused",FINISH:"printers.status.finished",FAILED:"printers.status.error"};s.push({label:i("printers.state"),value:i(o[e.state]??"printers.status.unknown")})}if(s.push({label:i("printers.ipAddress"),value:r.jsxs("span",{className:"flex items-center",children:[r.jsx("span",{className:"font-mono",children:t.ip_address}),r.jsx(UK,{value:t.ip_address})]})}),s.push({label:i("printers.serialNumber"),value:r.jsxs("span",{className:"flex items-center",children:[r.jsx("span",{className:"font-mono truncate",children:t.serial_number}),r.jsx(UK,{value:t.serial_number})]})}),e?.wired_network)s.push({label:i("printers.networkLabel","Network"),value:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(mO,{className:"w-4 h-4 text-bambu-green"}),r.jsx("span",{className:"text-bambu-green",children:i("printers.connection.ethernet","Ethernet")})]})});else if(e?.wifi_signal!=null){const o=See(e.wifi_signal);s.push({label:i("printers.wifiSignalLabel"),value:r.jsxs("span",{className:"flex items-center gap-2",children:[r.jsx(FZ,{className:`w-4 h-4 ${o.color}`}),r.jsx("span",{className:o.color,children:i(o.labelKey)}),r.jsxs("span",{className:"text-bambu-gray text-xs",children:["(",e.wifi_signal," dBm)"]})]})})}return s.push({label:i("printers.firmware"),value:e?.firmware_version??"—"}),e?.developer_mode!=null&&s.push({label:i("printers.developerMode"),value:r.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.developer_mode?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:e.developer_mode?i("printers.enabled"):i("printers.disabled")})}),s.push({label:i("printers.nozzleCount"),value:t.nozzle_count}),s.push({label:i("printers.autoArchive"),value:r.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.auto_archive?"bg-bambu-green/20 text-bambu-green":"bg-bambu-dark-tertiary text-bambu-gray"}`,children:t.auto_archive?i("printers.enabled"):i("printers.disabled")})}),n!=null&&n>0&&s.push({label:i("printers.totalPrintHours"),value:`${Math.round(n)}h`}),t.location&&s.push({label:i("printers.sort.location"),value:t.location}),s.push({label:i("printers.addedOn"),value:Rg(t.created_at)}),r.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",role:"dialog","aria-modal":"true",onClick:a,children:r.jsx(Ct,{className:"w-full max-w-md",onClick:o=>o.stopPropagation(),children:r.jsxs(At,{children:[r.jsxs("div",{className:"flex items-center justify-between mb-4",children:[r.jsx("h2",{className:"text-lg font-semibold text-white",children:t.name}),r.jsx("button",{onClick:a,className:"p-1 hover:bg-bambu-dark rounded flex-shrink-0",children:r.jsx(Ht,{className:"w-5 h-5 text-bambu-gray"})})]}),r.jsx("div",{className:"flex justify-center mb-4",children:r.jsx("img",{src:wee(t.model),alt:t.model??t.name,className:"h-24 object-contain"})}),r.jsx("div",{className:"space-y-0",children:s.map((o,l)=>r.jsxs("div",{className:"flex items-center justify-between gap-4 py-2.5 border-b border-bambu-dark-tertiary last:border-0",children:[r.jsx("span",{className:"text-sm text-bambu-gray whitespace-nowrap",children:o.label}),r.jsx("span",{className:"text-sm text-white text-right",children:o.value})]},l))})]})})})}function P7e(t){if(!t||t.length<6)return!1;const e=parseInt(t.slice(0,2),16),n=parseInt(t.slice(2,4),16),a=parseInt(t.slice(4,6),16);return(.299*e+.587*n+.114*a)/255>.6}function d3({trayColor:t,trayType:e,isEmpty:n,slotNumber:a}){return r.jsx("div",{className:"w-3.5 h-3.5 rounded-full mx-auto mb-0.5 border-2 flex items-center justify-center",style:{backgroundColor:t?`#${t}`:e?"#333":"transparent",borderColor:n?"#666":"rgba(255,255,255,0.1)",borderStyle:n?"dashed":"solid"},children:r.jsx("span",{className:"text-[6px] font-bold leading-none select-none",style:{color:t&&P7e(t)?"#000":"#fff"},children:a})})}function i5({summary:t,children:e,defaultOpen:n=!1,className:a="",summaryClassName:i="",open:s,onToggle:o}){const[l,c]=v.useState(n),d=s!==void 0,u=d?s:l,m=()=>{const p=!u;d||c(p),o?.(p)};return r.jsxs("div",{className:a,children:[r.jsxs("div",{role:"button",tabIndex:0,onClick:m,onKeyDown:p=>{(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),m())},className:`w-full flex items-center justify-between gap-2 text-left cursor-pointer ${i}`,"aria-expanded":u,children:[r.jsx("div",{className:"flex-1 min-w-0",children:t}),r.jsx(Rn,{className:`w-4 h-4 text-bambu-gray flex-shrink-0 transition-transform ${u?"rotate-180":""}`})]}),u&&r.jsx("div",{className:"mt-3",children:e})]})}function u3(t){return(t??.02).toFixed(3)}function BK({side:t}){const{mode:e}=db(),n=e==="dark"?"#1a4d2e":"#e7f5e9";return r.jsx("span",{className:"inline-flex items-center justify-center w-4 h-4 text-[10px] font-bold rounded",style:{backgroundColor:n,color:"#00ae42"},children:t})}function qie(t,e){if(!t)return"";if(t.includes("hardened"))return e("printers.nozzleHardenedSteel");if(t.includes("stainless"))return e("printers.nozzleStainlessSteel");if(t.includes("tungsten"))return e("printers.nozzleTungstenCarbide");if(t.length>=4){const n=t.slice(2,4);if(n==="00")return e("printers.nozzleStainlessSteel");if(n==="01")return e("printers.nozzleHardenedSteel");if(n==="05")return e("printers.nozzleTungstenCarbide")}return t==="00"?e("printers.nozzleStainlessSteel"):t==="01"?e("printers.nozzleHardenedSteel"):t==="05"?e("printers.nozzleTungstenCarbide"):t.startsWith("H")?e("printers.nozzleHardenedSteel"):t}function $ie(t,e){return t?t.startsWith("HH")?e("printers.nozzleHighFlow"):t.startsWith("HS")?e("printers.nozzleStandardFlow"):"":""}function Vie({slot:t,index:e,activeStatus:n,filamentName:a,children:i}){const{t:s}=kt(),[o,l]=v.useState(!1),[c,d]=v.useState("top"),u=v.useRef(null),m=v.useRef(null),p=v.useRef(null),f=!t.nozzle_diameter&&!t.nozzle_type,b=t.stat===1;v.useEffect(()=>{if(o&&u.current&&m.current){const C=u.current.getBoundingClientRect(),P=m.current.offsetHeight,A=C.top-56,F=window.innerHeight-C.bottom;AA?d("bottom"):d("top")}},[o]);const w=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!0),80)},g=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>l(!1),100)};v.useEffect(()=>()=>{p.current&&clearTimeout(p.current)},[]);const x=_O(t.filament_color),_=qie(t.nozzle_type,s),N=$ie(t.nozzle_type,s);return r.jsxs("div",{ref:u,className:"relative",onMouseEnter:w,onMouseLeave:g,children:[i,o&&r.jsxs("div",{ref:m,className:`
absolute left-1/2 -translate-x-1/2 z-50
${c==="top"?"bottom-full mb-2":"top-full mt-2"}
diff --git a/static/index.html b/static/index.html
index aff20538f..81a432afc 100644
--- a/static/index.html
+++ b/static/index.html
@@ -26,7 +26,7 @@
-
+