PrintersPage-CLG7I78P.js 327 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import{i as e}from"./chunk-aKtaBQYM.js";import{C as t,D as n,S as r,a as i,c as a,l as o,s,t as c,w as l,x as u}from"./client-DnySrlFv.js";import{t as d}from"./react-dom-B8Dg6xzp.js";import{n as f}from"./QueryClientProvider-Ce8_sN3w.js";import{t as p}from"./useQuery-BBCjCezC.js";import{t as m}from"./useMutation-B-Tr2hIP.js";import{t as h}from"./createLucideIcon-DvBYJlWL.js";import{c as g,i as _,n as v,o as y,r as b,s as x}from"./haSensorDisplay-lPbcOxD8.js";import{t as S}from"./arrow-down-Cj0DZhNf.js";import{t as C}from"./arrow-left-0Q6F2rjC.js";import{t as w}from"./arrow-right-DedpIMhP.js";import{t as T}from"./arrow-up-down-BdyOV_2F.js";import{t as E}from"./arrow-up-D-pfJ3WZ.js";import{i as D,n as O,r as k,t as A}from"./ReferenceLine-clJprXoH.js";import{t as j}from"./box-DAdKb9s5.js";import{n as M,t as N}from"./fan-D6AmXZMv.js";import{t as P}from"./calendar-BLKPnWqV.js";import{t as F}from"./check-Ck0cMLU4.js";import{a as I,n as L,r as R,t as ee}from"./info-ROUoQhJR.js";import{n as te,r as ne}from"./ToastContext-BRX0SW3C.js";import{t as z}from"./copy-Cu_0GKCU.js";import{t as re}from"./ellipsis-vertical-t2D7cYyp.js";import{t as B}from"./eye-off-6CkaxYwP.js";import{t as ie}from"./file-box-04V4jZ9_.js";import{t as ae}from"./GcodeToolpathViewer-Cg6UnTDw.js";import{n as V,t as oe}from"./ContextMenu-CwroFwVJ.js";import{n as se,t as ce}from"./scan-search-BDoNAXzz.js";import{t as le}from"./funnel-C3dyAMK9.js";import{t as ue}from"./gauge-D21zgWMb.js";import{t as de}from"./grip-vertical-C_1RDxRw.js";import{t as fe}from"./hard-drive-CgXAHN37.js";import{t as pe}from"./layout-grid-DkD3u6wa.js";import{t as H}from"./loader-circle-BEmFtawu.js";import{t as me}from"./log-in-n0ckHxnD.js";import{t as he}from"./maximize-2-kPQ77q72.js";import{t as U}from"./minimize-2-dqT-k7oI.js";import{a as ge,i as _e,n as ve,r as ye,t as W}from"./CameraDiagnoseModal-BwHHipUP.js";import{t as G}from"./minus-DypeGjGR.js";import{a as be,c as xe,i as Se,l as K,n as Ce,r as we,s as Te,t as q,u as J}from"./CopyButton-C5In5weo.js";import{t as Ee}from"./move-Bc1EIjTD.js";import{t as De}from"./package-BGUevlqS.js";import{t as Oe}from"./pause-DFb6GX_6.js";import{t as ke}from"./play-DIDYtk2S.js";import{t as Ae}from"./search-0n0CBc74.js";import{t as je}from"./settings-2-Cvn837lh.js";import{n as Me,t as Ne}from"./wind-CI8UoBMf.js";import{D as Pe,Fn as Fe,It as Ie,Kt as Le,L as Re,Ln as ze,Lt as Be,M as Ve,Mn as He,On as Ue,Pn as We,R as Ge,Rn as Ke,S as qe,Sn as Je,St as Ye,T as Xe,Ut as Ze,Xt as Qe,Zt as $e,an as et,at as tt,b as nt,c as rt,cn as it,d as at,f as ot,gn as st,j as ct,jt as lt,k as ut,l as dt,ln as ft,mn as pt,mt,nn as ht,p as gt,pt as _t,s as vt,sn as yt,t as bt,u as xt,vn as St,w as Ct,wn as wt,x as Tt,y as Et,z as Dt}from"./CartesianChart-BAcHzPFb.js";import{t as Ot}from"./triangle-alert-Dt_1FcBy.js";import{t as kt}from"./unlink-C098nwOf.js";import{i as At,n as jt,r as Mt,t as Nt}from"./CameraWall-D-W28jK-.js";import{t as Pt}from"./x-DR-Trv6U.js";import{n as Ft,t as It}from"./zoom-out-DNNe6DMN.js";import{n as Lt,t as Rt}from"./Card-Bzc64K35.js";import{t as zt}from"./file-DDkFXH-b.js";import{t as Y}from"./Button-DDr6eAFy.js";import{a as Bt,c as Vt,i as Ht,o as Ut,s as Wt,t as Gt,u as Kt,v as qt}from"./date-G9KUauqz.js";import{n as Jt,r as Yt}from"./filamentSwatchHelpers-D3oXQSGk.js";import{$ as Xt,$t as Zt,At as Qt,Cn as $t,Ct as en,D as tn,E as nn,Et as rn,Ft as an,G as on,H as sn,J as cn,Jt as ln,K as un,Kt as dn,Lt as fn,Mn as pn,Mt as mn,N as hn,Nt as gn,O as _n,On as vn,Ot as yn,Rn as bn,Rt as xn,Sn,U as Cn,V as wn,Vn as Tn,Vt as En,W as Dn,Wt as On,X as kn,Y as An,Yt as jn,Z as Mn,Zt as Nn,_ as Pn,_n as Fn,_t as In,an as Ln,at as Rn,b as zn,bn as Bn,bt as Vn,cn as Hn,ct as Un,dt as Wn,et as Gn,fn as Kn,ft as qn,h as Jn,jn as Yn,jt as Xn,k as Zn,q as Qn,sn as $n,tt as er,un as tr,ut as nr,v as rr,vt as ir,wn as ar,xn as or,xt as sr,y as cr,yt as lr,z as ur}from"./index-Cxa-KVmA.js";import{n as dr,t as fr}from"./FileUploadModal-Dee1GxH_.js";import{n as pr,t as mr}from"./ErrorBarContext-CcijMMkA.js";import{t as hr}from"./Toggle-KiqA_5fU.js";import{t as gr}from"./printerModel-DrNvERGQ.js";import{t as _r}from"./queueItemName-UFY7kpjG.js";import{n as vr,r as yr,t as br}from"./ConfigureAmsSlotModal-BgpDvjjX.js";var xr=h(`air-vent`,[[`path`,{d:`M18 17.5a2.5 2.5 0 1 1-4 2.03V12`,key:`yd12zl`}],[`path`,{d:`M6 12H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2`,key:`larmp2`}],[`path`,{d:`M6 8h12`,key:`6g4wlu`}],[`path`,{d:`M6.6 15.572A2 2 0 1 0 10 17v-5`,key:`1x1kqn`}]]),Sr=h(`chart-line`,[[`path`,{d:`M3 3v16a2 2 0 0 0 2 2h16`,key:`c24i48`}],[`path`,{d:`m19 9-5 5-4-4-3 3`,key:`2osh9i`}]]),Cr=h(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),wr=h(`fullscreen`,[[`path`,{d:`M3 7V5a2 2 0 0 1 2-2h2`,key:`aa7l1z`}],[`path`,{d:`M17 3h2a2 2 0 0 1 2 2v2`,key:`4qcy5o`}],[`path`,{d:`M21 17v2a2 2 0 0 1-2 2h-2`,key:`6vwrx8`}],[`path`,{d:`M7 21H5a2 2 0 0 1-2-2v-2`,key:`ioqczr`}],[`rect`,{width:`10`,height:`8`,x:`7`,y:`8`,rx:`1`,key:`vys8me`}]]),Tr=h(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),Er=h(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),Dr=h(`picture-in-picture-2`,[[`path`,{d:`M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4`,key:`daa4of`}],[`rect`,{width:`10`,height:`7`,x:`12`,y:`13`,rx:`2`,key:`1nb8gs`}]]),Or=h(`repeat`,[[`path`,{d:`m17 2 4 4-4 4`,key:`nntrym`}],[`path`,{d:`M3 11v-1a4 4 0 0 1 4-4h14`,key:`84bu3i`}],[`path`,{d:`m7 22-4-4 4-4`,key:`1wqhfi`}],[`path`,{d:`M21 13v1a4 4 0 0 1-4 4H3`,key:`1rx37r`}]]),kr=h(`signal`,[[`path`,{d:`M2 20h.01`,key:`4haj6o`}],[`path`,{d:`M7 20v-4`,key:`j294jx`}],[`path`,{d:`M12 20v-8`,key:`i3yub9`}],[`path`,{d:`M17 20V8`,key:`1tkaf5`}],[`path`,{d:`M22 4v16`,key:`sih9yq`}]]),Ar=h(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),jr=h(`snowflake`,[[`path`,{d:`m10 20-1.25-2.5L6 18`,key:`18frcb`}],[`path`,{d:`M10 4 8.75 6.5 6 6`,key:`7mghy3`}],[`path`,{d:`m14 20 1.25-2.5L18 18`,key:`1chtki`}],[`path`,{d:`m14 4 1.25 2.5L18 6`,key:`1b4wsy`}],[`path`,{d:`m17 21-3-6h-4`,key:`15hhxa`}],[`path`,{d:`m17 3-3 6 1.5 3`,key:`11697g`}],[`path`,{d:`M2 12h6.5L10 9`,key:`kv9z4n`}],[`path`,{d:`m20 10-1.5 2 1.5 2`,key:`1swlpi`}],[`path`,{d:`M22 12h-6.5L14 15`,key:`1mxi28`}],[`path`,{d:`m4 10 1.5 2L4 14`,key:`k9enpj`}],[`path`,{d:`m7 21 3-6-1.5-3`,key:`j8hb9u`}],[`path`,{d:`m7 3 3 6h4`,key:`1otusx`}]]),Mr=h(`square-minus`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),Nr=(e,t,n,r)=>tt(e,`xAxis`,t,r),Pr=(e,t,n,r)=>_t(e,`xAxis`,t,r),Fr=(e,t,n,r)=>tt(e,`yAxis`,n,r),Ir=(e,t,n,r)=>_t(e,`yAxis`,n,r),Lr=pt([Ze,Nr,Fr,Pr,Ir],(e,t,n,r,i)=>ft(e,`xAxis`)?ht(t,r,!1):ht(n,i,!1)),Rr=(e,t,n,r,i)=>i;function zr(e){return e.type===`line`}var Br=pt([Ze,Nr,Fr,Pr,Ir,pt([mt,Rr],(e,t)=>e.filter(zr).find(e=>e.id===t)),Lr,lt],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return di({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),X=e(n()),Vr=[`id`],Hr=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ur=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function Wr(){return Wr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Wr.apply(null,arguments)}function Gr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Gr(Object(n),!0).forEach(function(t){Kr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kr(e,t,n){return(t=qr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qr(e){var t=Jr(e,`string`);return typeof t==`symbol`?t:t+``}function Jr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Yr(e,t){if(e==null)return{};var n,r,i=Xr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Xr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var Zr=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:yt(n,t),payload:e}]},Qr=X.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:Ue,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:yt(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return X.createElement(Pe,{tooltipEntrySettings:d})}),$r=(e,t)=>`${t}px ${e-t}px`;function ei(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r=[...r,...n];return r}var ti=(e,t,n)=>{var r=n.reduce((e,t)=>e+t);if(!r)return $r(t,e);for(var i=Math.floor(e/r),a=e%r,o=t-e,s=[],c=0,l=0;c<n.length;l+=(u=n[c])??0,++c){var u,d=n[c];if(d!=null&&l+d>a){s=[...n.slice(0,c),a-l];break}}var f=s.length%2==0?[0,o]:[o];return[...ei(n,i),...s,...f].map(e=>`${e}px`).join(`, `)};function ni(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=Fe(Yr(r,Vr));return X.createElement(Tt,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Q(e){var{showLabels:t,children:n,points:r}=e,i=(0,X.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return X.createElement(ct,{value:t?i:void 0},n)}function ri(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},We(Yr(a,Hr))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return X.createElement(X.Fragment,null,r?.length>1&&X.createElement(pr,Wr({shapeType:`curve`,option:u},d,{pathRef:n})),X.createElement(ni,{points:r,clipPathId:t,props:a}))}function ii(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ai(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:m,onAnimationEnd:h,onAnimationStart:g}=n,_=i.current,v=Ie(o,`recharts-line-`),y=(0,X.useRef)(v),[b,x]=(0,X.useState)(!1),S=!b,C=(0,X.useCallback)(()=>{typeof h==`function`&&h(),x(!1)},[h]),w=(0,X.useCallback)(()=>{typeof g==`function`&&g(),x(!0)},[g]),T=ii(r.current),E=(0,X.useRef)(0);y.current!==v&&(E.current=a.current,y.current=v);var D=E.current;return X.createElement(Q,{points:o,showLabels:S},n.children,X.createElement(Be,{animationId:v,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:C,onAnimationStart:w,key:v},e=>{var l=Je(D,T+D,e),u=Math.min(l,T),d=c?s?ti(u,T,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):$r(T,u):s==null?void 0:String(s);if(e>0&&T>0&&(i.current=o,a.current=Math.max(a.current,u)),_){var h=_.length/o.length,g=e===1?o:o.map((t,n)=>{var r=Math.floor(n*h);if(_[r]){var i=_[r];return Z(Z({},t),{},{x:Je(i.x,t.x,e),y:Je(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:Je(p*2,t.x,e),y:Je(m/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=g,X.createElement(ri,{props:n,points:g,clipPathId:t,pathRef:r,strokeDasharray:d})}return X.createElement(ri,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),X.createElement(Ve,{label:n.label}))}function oi(e){var{clipPathId:t,props:n}=e,r=(0,X.useRef)(null),i=(0,X.useRef)(0),a=(0,X.useRef)(null);return X.createElement(ai,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var si=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:it(e.payload,t)}),ci=class extends X.Component{render(){var{hide:e,dot:t,points:n,className:r,xAxisId:i,yAxisId:a,top:o,left:s,width:c,height:l,id:u,needClip:d,zIndex:f}=this.props;if(e)return null;var p=ze(`recharts-line`,r),m=u,{r:h,strokeWidth:g}=xt(t),_=ut(t),v=h*2+g,y=d?`url(#clipPath-${_?``:`dots-`}${m})`:void 0;return X.createElement(Dt,{zIndex:f},X.createElement(He,{className:p},d&&X.createElement(`defs`,null,X.createElement(at,{clipPathId:m,xAxisId:i,yAxisId:a}),!_&&X.createElement(`clipPath`,{id:`clipPath-dots-${m}`},X.createElement(`rect`,{x:s-v/2,y:o-v/2,width:c+v,height:l+v}))),X.createElement(mr,{xAxisId:i,yAxisId:a,data:n,dataPointFormatter:si,errorBarOffset:0},X.createElement(oi,{props:this.props,clipPathId:m}))),X.createElement(Et,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:y}))}},li={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:Ye.line,type:`linear`};function ui(e){var t=St(e,li),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Yr(t,Ur),{needClip:_}=ot(p,m),v=nt(),y=Le(),b=$e(),x=st(e=>Br(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return X.createElement(ci,Wr({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function di(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=it(e,o);if(t===`horizontal`)return{x:et({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(wt(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=wt(l)?null:n.scale.map(l),d=et({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function fi(e){var t=St(e,li),n=$e();return X.createElement(Ct,{id:t.id,type:`line`},e=>X.createElement(X.Fragment,null,X.createElement(Xe,{legendPayload:Zr(t)}),X.createElement(Qr,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),X.createElement(qe,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),X.createElement(ui,Wr({},t,{id:e}))))}var pi=X.memo(fi,dt);pi.displayName=`Line`;var mi=[`axis`],hi=(0,X.forwardRef)((e,t)=>X.createElement(bt,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:mi,tooltipPayloadSearcher:Ge,categoricalChartProps:e,ref:t})),gi=e(d(),1);function _i(e,t){let n=e.split(`.`).map(e=>parseInt(e,10)||0),r=t.split(`.`).map(e=>parseInt(e,10)||0);for(;n.length<4;)n.push(0);for(;r.length<4;)r.push(0);for(let e=0;e<4;e++)if(n[e]!==r[e])return n[e]-r[e];return 0}function vi(e,t,n,r){if(!e)return``;if(r)return`${e} — ${r}`;if(!t)return e;let i=t.match(/plate_(\d+)\.gcode/);return i&&parseInt(i[1],10)>1?`${e} — ${n(`printers.plateNumber`,`Plate {{number}}`,{number:i[1]})}`:e}var yi=new Set([`A1`,`A1MINI`,`A2L`,`A1M`,`N1`,`N2S`,`N9`,`A04`,`A11`,`A12`]);function bi(e){return e?yi.has(e.toUpperCase().replace(/[^A-Z0-9]/g,``)):!1}function xi(e){let t=typeof window<`u`&&window.visualViewport?window.visualViewport.height:typeof window<`u`?window.innerHeight:0,{triggerRect:n,popoverWidth:r,estimatedHeight:i,viewportHeight:a=t,viewportWidth:o=window.innerWidth,margin:s=8,gap:c=4,horizontalAlign:l=`right`}=e,u=n.bottom+c,d=`below`;if(u+i>a-s){let e=n.top-c-i;e>=s&&(u=e,d=`above`)}let f=n.left+(n.right-n.left)/2,p=l===`center`?f-r/2:n.right-r;p<s?p=s:p+r>o-s&&(p=Math.max(s,o-r-s));let m=d===`above`?n.top-c:u,h=Math.max(14,Math.min(r-14,f-p));return{top:u,left:p,placement:d,anchorY:m,arrowLeft:h}}var Si=`cameraViewMode`,Ci=`cameraWindowState`;function wi(e){return e===`window`||e===`embedded`}function Ti(){try{let e=localStorage.getItem(Si);return wi(e)?e:null}catch{return null}}function Ei(e){try{localStorage.setItem(Si,e)}catch{}}function Di(e){let t={width:640,height:400};try{let e=localStorage.getItem(Ci);if(e){let n=JSON.parse(e);n&&typeof n==`object`&&(t=n)}}catch{}let n=[`width=${t.width??640}`,`height=${t.height??400}`,t.left===void 0?``:`left=${t.left}`,t.top===void 0?``:`top=${t.top}`,`menubar=no,toolbar=no,location=no,status=no`].filter(Boolean).join(`,`);window.open(`/camera/${e}`,`camera-${e}`,n)}var Oi={NYLON:`PA`,PA6:`PA`,PA11:`PA`,PA12:`PA`,PAHT:`PA`,PPA:`PA`};function ki(e,t){let n=(e||``).split(` `)[0].toUpperCase();for(let e of[n,n.split(`-`)[0]]){let n=Oi[e]??e;if(t[n])return n}return`PLA`}function Ai(e,t,n,r=new Date){return e===`now`?null:e===`delay`?new Date(r.getTime()+t*6e4).toISOString():new Date(n).toISOString()}var ji=`printerHiddenExternalSpools`;function Mi(){try{let e=localStorage.getItem(ji);if(!e)return{};let t=JSON.parse(e);return!t||typeof t!=`object`||Array.isArray(t)?{}:t}catch{return{}}}function Ni(e){return Mi()[String(e)]===!0}function Pi(e,t){let n=Mi();t?n[String(e)]=!0:delete n[String(e)];try{localStorage.setItem(ji,JSON.stringify(n))}catch{}}var $=t(),Fi=[{key:`printing`,dot:`bg-bambu-green`},{key:`paused`,dot:`bg-status-warning`},{key:`finished`,dot:`bg-blue-400`},{key:`idle`,dot:`bg-bambu-green`},{key:`error`,dot:`bg-status-error`},{key:`offline`,dot:`bg-gray-400`}];function Ii({selectedIds:e,printers:t,onClose:n,onSelectAll:r,onSelectByLocation:i,onSelectByState:a,onAction:o,actionPending:s}){let{t:c}=l(),{hasPermission:u}=lr(),d=f(),[p,m]=(0,X.useState)(!1),[h,g]=(0,X.useState)(!1),_=Array.from(e).map(e=>({id:e,status:d.getQueryData([`printerStatus`,e])})),v=_.some(({status:e})=>e?.connected&&e.state===`RUNNING`),y=_.some(({status:e})=>e?.connected&&e.state===`PAUSE`),b=v||y,x=_.some(({status:e})=>!!(e?.connected&&e.awaiting_plate_clear)),S=_.some(({status:e})=>!e?.connected||!e.hms_errors?!1:Mt(e.hms_errors).length>0),C=u(`printers:control`),w=u(`printers:clear_plate`),T=[...new Set(t.map(e=>e.location).filter(e=>!!e))].sort(),E={printing:0,paused:0,finished:0,idle:0,error:0,offline:0};t.forEach(e=>{let t=d.getQueryData([`printerStatus`,e.id]);if(!t||!t.connected){E.offline++;return}let n=t.hms_errors?Mt(t.hms_errors).length>0:!1;switch(n&&E.error++,t.state){case`RUNNING`:E.printing++;break;case`PAUSE`:E.paused++;break;case`FINISH`:E.finished++;break;case`FAILED`:n||E.finished++;break;default:E.idle++;break}});let O={printing:c(`printers.status.printing`),paused:c(`printers.status.paused`,`Paused`),finished:c(`printers.status.finished`,`Finished`),idle:c(`printers.status.idle`),error:c(`printers.status.problem`),offline:c(`printers.status.offline`)};return(0,$.jsxs)(`div`,{className:`fixed bottom-6 left-1/2 -translate-x-1/2 z-40 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl px-4 py-3 flex items-center gap-3 flex-wrap`,children:[(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:n,children:(0,$.jsx)(Pt,{className:`w-4 h-4`})}),(0,$.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,$.jsx)(`span`,{className:`text-white font-medium text-sm`,children:c(`printers.bulk.selected`,{count:e.size})}),(0,$.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:r,children:c(`printers.bulk.selectAll`)}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>{g(!h),m(!1)},children:[c(`printers.bulk.selectByState`),(0,$.jsx)(I,{className:`w-3 h-3 transition-transform ${h?`rotate-180`:``}`})]}),h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>g(!1)}),(0,$.jsx)(`div`,{className:`absolute bottom-full mb-2 left-0 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:Fi.filter(({key:e})=>E[e]>0).map(({key:e,dot:t})=>(0,$.jsxs)(`button`,{onClick:()=>{a(e),g(!1)},className:`w-full text-left px-3 py-2 text-sm text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white transition-colors flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t}`}),O[e],(0,$.jsx)(`span`,{className:`ml-auto text-bambu-gray text-xs`,children:E[e]})]},e))})]})]}),T.length>0&&(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>{m(!p),g(!1)},children:[c(`printers.bulk.selectByLocation`),(0,$.jsx)(I,{className:`w-3 h-3 transition-transform ${p?`rotate-180`:``}`})]}),p&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>m(!1)}),(0,$.jsx)(`div`,{className:`absolute bottom-full mb-2 left-0 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:T.map(e=>(0,$.jsx)(`button`,{onClick:()=>{i(e),m(!1)},className:`w-full text-left px-3 py-2 text-sm text-bambu-gray-light hover:bg-bambu-dark-tertiary hover:text-white transition-colors`,children:e},e))})]})]}),(0,$.jsx)(`div`,{className:`w-px h-6 bg-bambu-dark-tertiary`}),(0,$.jsxs)(Y,{size:`sm`,className:`bg-red-500 hover:bg-red-600`,onClick:()=>o(`stop`),disabled:s||!C||!b,title:C?b?void 0:c(`printers.bulk.noneApplicable`):c(`printers.permission.noControl`),children:[(0,$.jsx)(fn,{className:`w-3.5 h-3.5`}),c(`printers.bulk.actions.stop`)]}),(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>o(`pause`),disabled:s||!C||!v,title:C?v?void 0:c(`printers.bulk.noneApplicable`):c(`printers.permission.noControl`),children:[(0,$.jsx)(Oe,{className:`w-3.5 h-3.5`}),c(`printers.bulk.actions.pause`)]}),(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>o(`resume`),disabled:s||!C||!y,title:C?y?void 0:c(`printers.bulk.noneApplicable`):c(`printers.permission.noControl`),children:[(0,$.jsx)(ke,{className:`w-3.5 h-3.5`}),c(`printers.bulk.actions.resume`)]}),(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>o(`clearHMS`),disabled:s||!C||!S,title:C?S?void 0:c(`printers.bulk.noneApplicable`):c(`printers.permission.noControl`),children:[(0,$.jsx)(D,{className:`w-3.5 h-3.5`}),c(`printers.bulk.actions.clearHMS`)]}),(0,$.jsxs)(Y,{variant:`secondary`,size:`sm`,onClick:()=>o(`clearPlate`),disabled:s||!w||!x,title:w?x?void 0:c(`printers.bulk.noneApplicable`):c(`printers.permission.noControl`),children:[(0,$.jsx)(k,{className:`w-3.5 h-3.5`}),c(`printers.bulk.actions.clearPlate`)]})]})}function Li({printerId:e,filePath:t,filename:n,onClose:r}){let[a,o]=(0,X.useState)(null),[s,c]=(0,X.useState)([]),[l,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)(null),p=n.toLowerCase().split(`.`).pop()||``,m=p===`3mf`||p===`stl`,h=p===`gcode`||p===`3mf`;(0,X.useEffect)(()=>{o(m?`3d`:h?`gcode`:null)},[m,h]),(0,X.useEffect)(()=>{c([]),f(null),m&&(u(!0),i.getPrinterFilePlates(e,t).then(e=>c(e.plates||[])).catch(()=>c([])).finally(()=>u(!1)))},[t,m,e]);let g=s.length>1,_=d==null?null:s.find(e=>e.index===d)??null;return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-6`,onClick:r,children:(0,$.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary w-full max-w-4xl h-[80vh] flex flex-col`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white truncate flex-1 mr-4`,children:n}),(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:r,children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`div`,{className:`flex border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`button`,{onClick:()=>m&&o(`3d`),disabled:!m,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${a===`3d`?`text-bambu-green border-b-2 border-bambu-green`:m?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,$.jsx)(j,{className:`w-4 h-4`}),`3D Model`,!m&&(0,$.jsx)(`span`,{className:`text-xs`,children:`(not available)`})]}),(0,$.jsxs)(`button`,{onClick:()=>h&&o(`gcode`),disabled:!h,className:`flex items-center gap-2 px-6 py-3 text-sm font-medium transition-colors ${a===`gcode`?`text-bambu-green border-b-2 border-bambu-green`:h?`text-bambu-gray hover:text-white`:`text-bambu-gray/30 cursor-not-allowed`}`,children:[(0,$.jsx)(or,{className:`w-4 h-4`}),`G-code Preview`,!h&&(0,$.jsx)(`span`,{className:`text-xs`,children:`(not sliced)`})]})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-hidden p-4`,children:a===`3d`&&m?(0,$.jsxs)(`div`,{className:`w-full h-full flex flex-col gap-3`,children:[g&&(0,$.jsxs)(`div`,{className:`rounded-lg border border-bambu-dark-tertiary bg-bambu-dark p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-bambu-gray mb-2`,children:[(0,$.jsx)(j,{className:`w-4 h-4`}),`Plates`,l&&(0,$.jsx)(H,{className:`w-3 h-3 animate-spin`})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 md:grid-cols-3 gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f(null),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d==null?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[(0,$.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,$.jsx)(j,{className:`w-5 h-5 text-bambu-gray`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:`All Plates`}),(0,$.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[s.length,` plate`,s.length===1?``:`s`]})]}),d==null&&(0,$.jsx)(xn,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]}),s.map(n=>(0,$.jsxs)(`button`,{type:`button`,onClick:()=>f(n.index),className:`flex items-center gap-2 rounded-lg border p-2 text-left transition-colors ${d===n.index?`border-bambu-green bg-bambu-green/10`:`border-bambu-dark-tertiary bg-bambu-dark-secondary hover:border-bambu-gray`}`,children:[n.has_thumbnail?(0,$.jsx)(`img`,{src:i.getPrinterFilePlateThumbnail(e,n.index,t),alt:`Plate ${n.index}`,className:`w-10 h-10 rounded object-cover bg-bambu-dark-tertiary`}):(0,$.jsx)(`div`,{className:`w-10 h-10 rounded bg-bambu-dark-tertiary flex items-center justify-center`,children:(0,$.jsx)(j,{className:`w-5 h-5 text-bambu-gray`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-sm text-white font-medium truncate`,children:n.name||`Plate ${n.index}`}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray truncate`,children:n.objects.length>0?n.objects.slice(0,2).join(`, `)+(n.objects.length>2?`…`:``):`${n.filaments.length} filament${n.filaments.length===1?``:`s`}`})]}),d===n.index&&(0,$.jsx)(xn,{className:`w-4 h-4 text-bambu-green flex-shrink-0`})]},n.index))]}),_&&(0,$.jsxs)(`div`,{className:`mt-3 text-xs text-bambu-gray flex flex-wrap gap-x-4 gap-y-1`,children:[(0,$.jsxs)(`span`,{children:[`Plate `,_.index]}),_.print_time_seconds!=null&&(0,$.jsxs)(`span`,{children:[`ETA `,Math.round(_.print_time_seconds/60),` min`]}),_.filament_used_grams!=null&&(0,$.jsxs)(`span`,{children:[_.filament_used_grams.toFixed(1),` g`]}),_.filaments.length>0&&(0,$.jsxs)(`span`,{children:[_.filaments.length,` filament`,_.filaments.length===1?``:`s`]})]})]}),(0,$.jsx)(`div`,{className:`flex-1`,children:(0,$.jsx)(dr,{url:i.getPrinterFileDownloadUrl(e,t),fileType:p,selectedPlateId:d,className:`w-full h-full`})})]}):a===`gcode`&&h?(0,$.jsx)(ae,{gcodeUrl:i.getPrinterFileGcodeUrl(e,t),className:`w-full h-full`}):(0,$.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-bambu-gray`,children:`No preview available for this file`})})]})})}function Ri(e){if(e===0)return`0 GB`;let t=e/(1024*1024*1024);return t>=1?`${t.toFixed(1)} GB`:`${(e/(1024*1024)).toFixed(0)} MB`}function zi(e,t){if(t)return Fn;switch(e.toLowerCase().split(`.`).pop()||``){case`3mf`:return ie;case`gcode`:return or;case`mp4`:case`avi`:return se;case`png`:case`jpg`:case`jpeg`:return tr;default:return V}}var Bi=[{value:`name-asc`,label:`Name (A-Z)`},{value:`name-desc`,label:`Name (Z-A)`},{value:`size-asc`,label:`Size (smallest)`},{value:`size-desc`,label:`Size (largest)`},{value:`date-asc`,label:`Date (oldest)`},{value:`date-desc`,label:`Date (newest)`}];function Vi({printerId:e,printerName:t,onClose:n}){let{t:r}=l(),{showToast:a}=te(),o=f(),[s,c]=(0,X.useState)(`/`),[u,d]=(0,X.useState)(new Set),[h,g]=(0,X.useState)(``),[_,v]=(0,X.useState)([]),[y,b]=(0,X.useState)(`name-asc`),[x,S]=(0,X.useState)(null),[C,w]=(0,X.useState)(null),E=(0,X.useRef)(null),D=(0,X.useRef)(null);(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]);let{data:O,isLoading:k,refetch:A}=p({queryKey:[`printerFiles`,e,s],queryFn:()=>i.getPrinterFiles(e,s)}),{data:M}=p({queryKey:[`printerStorage`,e],queryFn:()=>i.getPrinterStorage(e),staleTime:3e4}),N=(0,X.useMemo)(()=>[...O?.files??[]].filter(e=>!h||e.name.toLowerCase().includes(h.toLowerCase())).sort((e,t)=>{if(e.is_directory&&!t.is_directory)return-1;if(!e.is_directory&&t.is_directory)return 1;switch(y){case`name-asc`:return e.name.localeCompare(t.name);case`name-desc`:return t.name.localeCompare(e.name);case`size-asc`:return e.size-t.size;case`size-desc`:return t.size-e.size;case`date-asc`:return(e.mtime?qt(e.mtime)?.getTime()??0:0)-(t.mtime?qt(t.mtime)?.getTime()??0:0);case`date-desc`:{let n=e.mtime?qt(e.mtime)?.getTime()??0:0;return(t.mtime?qt(t.mtime)?.getTime()??0:0)-n}default:return e.name.localeCompare(t.name)}}),[O?.files,h,y]),P=!!O&&!O.warnings?.includes(`printer_unavailable`);(0,X.useEffect)(()=>{if(!P)return;let e=new Set(N.filter(e=>!e.is_directory).map(e=>e.path));d(t=>new Set([...t].filter(t=>e.has(t)))),E.current&&!e.has(E.current)&&(E.current=null)},[N,P]),(0,X.useEffect)(()=>()=>D.current?.abort(),[]);let F=m({mutationFn:async t=>{for(let n of t)await i.deletePrinterFile(e,n)},onSuccess:()=>{a(r(`printerFiles.toast.filesDeleted`,{count:_.length})),o.invalidateQueries({queryKey:[`printerFiles`,e]}),d(new Set),E.current=null,v([])},onError:e=>{a(r(`printerFiles.toast.deleteFailed`,{error:e.message}),`error`)}}),I=e=>{c(e),d(new Set),E.current=null},L=()=>{if(s===`/`)return;let e=s.split(`/`).filter(Boolean);e.pop(),c(e.length?`/`+e.join(`/`):`/`),d(new Set),E.current=null},R=(e,t)=>{t.stopPropagation();let n=N.filter(e=>!e.is_directory).map(e=>e.path),r=E.current?n.indexOf(E.current):-1,i=n.indexOf(e),a=t.shiftKey&&r!==-1&&i!==-1;a||(E.current=e),d(t=>{let o=new Set(t);if(a){let e=Math.min(r,i),t=Math.max(r,i);n.slice(e,t+1).forEach(e=>o.add(e))}else o.has(e)?o.delete(e):o.add(e);return o})};return(0,$.jsxs)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:n,children:[(0,$.jsxs)(`div`,{className:`w-full max-w-3xl max-h-[85vh] flex flex-col bg-bambu-dark-secondary rounded-xl border border-bambu-dark-tertiary overflow-hidden`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary flex-shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(fe,{className:`w-5 h-5 text-bambu-green`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`printerFiles.title`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[M&&(M.used_bytes!=null||M.free_bytes!=null)&&(0,$.jsxs)(`div`,{className:`text-sm text-bambu-gray flex items-center gap-2`,children:[M.used_bytes!=null&&(0,$.jsxs)(`span`,{children:[r(`printerFiles.storageUsed`),` `,Ri(M.used_bytes)]}),M.used_bytes!=null&&M.free_bytes!=null&&(0,$.jsx)(`span`,{className:`text-bambu-dark-tertiary`,children:`|`}),M.free_bytes!=null&&(0,$.jsxs)(`span`,{children:[r(`printerFiles.storageFree`),` `,Ri(M.free_bytes)]})]}),(0,$.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,title:`Close file manager`,"aria-label":`Close file manager`,children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 p-3 border-b border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[[{path:`/`,label:`Root`},{path:`/cache`,label:`Cache`},{path:`/model`,label:`Models`},{path:`/timelapse`,label:`Timelapse`}].map(e=>(0,$.jsx)(`button`,{onClick:()=>{I(e.path),g(``)},className:`px-3 py-1 text-sm rounded-full transition-colors ${s===e.path?`bg-bambu-green text-white`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white`}`,children:e.label},e.path)),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,$.jsx)(`input`,{type:`text`,placeholder:r(`printerFiles.filterPlaceholder`),value:h,onChange:e=>g(e.target.value),className:`w-40 pl-8 pr-3 py-1.5 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm focus:border-bambu-green focus:outline-none`})]}),(0,$.jsxs)(`div`,{className:`relative flex items-center gap-1`,children:[(0,$.jsx)(T,{className:`w-4 h-4 text-bambu-gray`}),(0,$.jsx)(`select`,{value:y,onChange:e=>b(e.target.value),className:`appearance-none bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm py-1.5 pl-2 pr-6 focus:border-bambu-green focus:outline-none cursor-pointer`,title:`Sort files`,"aria-label":`Sort files`,children:Bi.map(e=>(0,$.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:()=>A(),disabled:k,"aria-label":r(`common.refresh`),title:r(`common.refresh`),children:(0,$.jsx)(dn,{className:`w-4 h-4 ${k?`animate-spin`:``}`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 bg-bambu-dark text-sm flex-shrink-0`,children:[(0,$.jsx)(`button`,{onClick:L,disabled:s===`/`,className:`p-1 rounded hover:bg-bambu-dark-tertiary disabled:opacity-50 disabled:cursor-not-allowed`,title:`Go to parent folder`,"aria-label":`Go to parent folder`,children:(0,$.jsx)(Yn,{className:`w-4 h-4`})}),(0,$.jsx)(`span`,{className:`text-bambu-gray font-mono`,children:s})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto p-2 min-h-0`,children:k?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,$.jsx)(H,{className:`w-8 h-8 text-bambu-green animate-spin`})}):O?.warnings?.includes(`printer_unavailable`)?(0,$.jsx)(`div`,{className:`text-center py-12 text-amber-600 dark:text-amber-400`,children:r(`printerFiles.printerUnavailable`)}):O?.files?.length?(0,$.jsx)(`div`,{className:`space-y-1`,children:N.map(e=>{let t=zi(e.name,e.is_directory),n=u.has(e.path);return(0,$.jsxs)(`div`,{className:`flex items-center gap-3 p-2 rounded-lg cursor-pointer transition-colors ${n?`bg-bambu-green/20 border border-bambu-green/50`:`hover:bg-bambu-dark-tertiary`}`,onClick:t=>{e.is_directory?I(e.path):R(e.path,t)},children:[e.is_directory?null:(0,$.jsx)(`button`,{onClick:t=>R(e.path,t),className:`flex-shrink-0 text-bambu-gray hover:text-white`,"aria-label":r(n?`printerFiles.deselectFile`:`printerFiles.selectFile`,{name:e.name}),title:r(`printerFiles.shiftSelectHint`),children:n?(0,$.jsx)(xn,{className:`w-5 h-5 text-bambu-green`}):(0,$.jsx)(fn,{className:`w-5 h-5`})}),(0,$.jsx)(t,{className:`w-5 h-5 flex-shrink-0 ${e.is_directory?`text-bambu-green`:`text-bambu-gray`}`}),(0,$.jsx)(`span`,{className:`flex-1 text-white truncate`,children:e.name}),!e.is_directory&&(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`text-sm text-bambu-gray`,children:zt(e.size)}),(e.name.toLowerCase().endsWith(`.3mf`)||e.name.toLowerCase().endsWith(`.gcode`)||e.name.toLowerCase().endsWith(`.stl`))&&(0,$.jsx)(`button`,{onClick:t=>{t.stopPropagation(),w({path:e.path,name:e.name})},className:`p-1 rounded hover:bg-bambu-dark text-bambu-gray hover:text-bambu-green`,title:`3D View`,children:(0,$.jsx)(j,{className:`w-4 h-4`})})]}),e.is_directory&&(0,$.jsx)(Yn,{className:`w-4 h-4 text-bambu-gray rotate-180`})]},e.path)})}):(0,$.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:r(`printerFiles.noFiles`)})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary bg-bambu-dark/50 flex-shrink-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,$.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:u.size>0?`${u.size} selected`:h?`${O?.files?.filter(e=>e.name.toLowerCase().includes(h.toLowerCase())).length||0} of ${O?.files?.length||0} items`:`${O?.files?.length||0} items`}),O?.files?.some(e=>!e.is_directory)&&(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:u.size>0?(0,$.jsxs)(`button`,{onClick:()=>{d(new Set),E.current=null},className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,$.jsx)(Mr,{className:`w-4 h-4`}),`Deselect All`]}):(0,$.jsxs)(`button`,{onClick:()=>{let e=N.filter(e=>!e.is_directory).map(e=>e.path);d(new Set(e)),E.current=null},className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,children:[(0,$.jsx)(xn,{className:`w-4 h-4`}),`Select All`]})})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,disabled:u.size===0||x!==null,onClick:async()=>{if(u.size===0)return;let n=N.filter(e=>!e.is_directory&&u.has(e.path)).map(e=>e.path);if(n.length===0)return;let o=new AbortController;D.current=o,S({current:0,total:n.length});try{let s=Object.fromEntries(n.map(e=>[e,O?.files.find(t=>t.path===e)?.size??0])),c=await i.downloadPrinterFilesAsZip(e,n,s,n.length===1?O?.files.find(e=>e.path===n[0])?.name??`printer-file`:`${t.replace(/[^a-zA-Z0-9]/g,`_`)}-files.zip`,n.length>1,o.signal,(e,t)=>S({current:e,total:t}));c.failed>0?a(r(`printerFiles.zipPartial`,{successful:c.successful,total:c.requested}),`warning`):a(r(`printerFiles.zipStarted`,{count:c.successful})),d(new Set),E.current=null}catch(e){a(r(`printerFiles.downloadFailed`,{error:e instanceof Error?e.message:r(`printerFiles.unknownError`)}),`error`)}finally{D.current===o&&(D.current=null),S(null)}},children:x?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-4 h-4 animate-spin`}),x.current,`/`,x.total]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ar,{className:`w-4 h-4`}),`Download`,u.size>1?` (${u.size})`:``]})}),(0,$.jsxs)(Y,{variant:`secondary`,disabled:u.size===0||F.isPending,onClick:()=>{u.size!==0&&v(N.filter(e=>!e.is_directory&&u.has(e.path)).map(e=>e.path))},className:`text-red-700 hover:text-red-800 dark:text-red-400 dark:hover:text-red-300`,children:[F.isPending?(0,$.jsx)(H,{className:`w-4 h-4 animate-spin`}):(0,$.jsx)(Qt,{className:`w-4 h-4`}),r(`printerFiles.deleteButton`),u.size>1?` (${u.size})`:``]})]})]})]}),_.length>0&&(0,$.jsx)(In,{title:_.length>1?r(`printerFiles.deleteFiles`,{count:_.length}):r(`fileManager.deleteFile`),message:_.length>1?r(`printerFiles.deleteFilesConfirm`,{count:_.length}):r(`printerFiles.deleteFileConfirm`,{name:_[0].split(`/`).pop()}),confirmText:r(`common.delete`),variant:`danger`,onConfirm:()=>{F.mutate(_)},onCancel:()=>v([])}),C&&(0,$.jsx)(Li,{printerId:e,filePath:C.path,filename:C.name,onClose:()=>w(null)})]})}var Hi=`embeddedCameraState_`,Ui=5,Wi=2e3,Gi=3e4,Ki=5e3,qi={x:window.innerWidth-420,y:20,width:400,height:300};function Ji({printerId:e,printerName:t,viewerIndex:n=0,onClose:a}){let{t:s}=l(),c=f(),{showToast:u}=te(),{hasPermission:d}=lr(),h=`${Hi}${e}`,[g,_]=(0,X.useState)(()=>{try{let e=localStorage.getItem(h);if(e){let t=JSON.parse(e);return{x:Math.min(Math.max(0,t.x),window.innerWidth-100),y:Math.min(Math.max(0,t.y),window.innerHeight-100),width:Math.max(200,Math.min(t.width,window.innerWidth-20)),height:Math.max(150,Math.min(t.height,window.innerHeight-20))}}}catch{}let e=n*30;return{...qi,x:Math.max(0,qi.x-e),y:Math.max(0,qi.y+e)}}),[v,y]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),[S,C]=(0,X.useState)({x:0,y:0}),[w,T]=(0,X.useState)(!1),[E,D]=(0,X.useState)(!1),[O,k]=(0,X.useState)(1),[A,j]=(0,X.useState)({x:0,y:0}),[M,N]=(0,X.useState)(!1),[P,F]=(0,X.useState)({x:0,y:0}),[I,L]=(0,X.useState)(null),[R,ee]=(0,X.useState)(null),[ne,z]=(0,X.useState)(!1),[re,B]=(0,X.useState)(!0),[ie,ae]=(0,X.useState)(Date.now()),[V,oe]=(0,X.useState)(0),[se,ce]=(0,X.useState)(!1),[le,ue]=(0,X.useState)(0),fe=(0,X.useRef)(null),pe=(0,X.useRef)(null),H=(0,X.useRef)(null),me=(0,X.useRef)(null),G=(0,X.useRef)(null),[be,xe]=(0,X.useState)(!1),[Se,K]=(0,X.useState)(!1),{data:Ce}=p({queryKey:[`printer`,e],queryFn:()=>i.getPrinter(e),enabled:e>0}),{data:we}=p({queryKey:[`printerStatus`,e],queryFn:()=>i.getPrinterStatus(e),refetchInterval:3e4,enabled:e>0}),Te=m({mutationFn:t=>i.setChamberLight(e,t),onMutate:async t=>{await c.cancelQueries({queryKey:[`printerStatus`,e]});let n=c.getQueryData([`printerStatus`,e]);return c.setQueryData([`printerStatus`,e],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{u(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&c.setQueryData([`printerStatus`,e],r.previousStatus),u(t.message||s(`printers.toast.failedToControlChamberLight`),`error`)}}),q=(we?.state===`RUNNING`||we?.state===`PAUSE`)&&(we?.printable_objects_count??0)>=2;(0,X.useEffect)(()=>{let e=setTimeout(()=>{localStorage.setItem(h,JSON.stringify(g))},500);return()=>clearTimeout(e)},[g,h]);let J=(0,X.useRef)(!1);(0,X.useEffect)(()=>{J.current=!1;let t=`/api/v1/printers/${e}/camera/stop`,n=()=>{if(e>0&&!J.current){J.current=!0;let e={},n=o();n&&(e.Authorization=`Bearer ${n}`),fetch(t,{method:`POST`,keepalive:!0,headers:e}).catch(()=>{})}},r=pe.current;return()=>{r&&(r.src=``),n(),H.current&&clearTimeout(H.current),me.current&&clearInterval(me.current),G.current&&clearInterval(G.current)}},[e]),(0,X.useEffect)(()=>{if(re){let e=setTimeout(()=>B(!1),3e3);return()=>clearTimeout(e)}},[re,ie]);let Ee=(0,X.useCallback)(()=>{if(V>=Ui){ce(!1),z(!0);return}let e=Math.min(Wi*2**V,Gi);ce(!0),ue(Math.ceil(e/1e3)),me.current=setInterval(()=>{ue(e=>e<=1?(me.current&&clearInterval(me.current),0):e-1)},1e3),H.current=setTimeout(()=>{oe(e=>e+1),ce(!1),B(!0),z(!1),pe.current&&(pe.current.src=``),ae(Date.now())},e)},[V]);(0,X.useEffect)(()=>{if(re||se||w){G.current&&=(clearInterval(G.current),null);return}return G.current=setInterval(async()=>{try{let t=await i.getCameraStatus(e);(t.stalled||!t.active&&!ne)&&(G.current&&=(clearInterval(G.current),null),B(!1),Ee())}catch{}},Ki),()=>{G.current&&=(clearInterval(G.current),null)}},[re,ne,se,w,e,Ee]),(0,X.useEffect)(()=>{let e=()=>{let e=!!document.fullscreenElement;D(e),e||(k(1),j({x:0,y:0}))};return document.addEventListener(`fullscreenchange`,e),()=>document.removeEventListener(`fullscreenchange`,e)},[]);let De=()=>{fe.current&&(document.fullscreenElement?document.exitFullscreen():fe.current.requestFullscreen())},Oe=()=>{k(e=>Math.min(e+.5,4))},ke=()=>{k(e=>{let t=Math.max(e-.5,1);return t===1&&j({x:0,y:0}),t})},Ae=e=>{e.preventDefault(),e.deltaY<0?Oe():ke()},je=e=>{O>1&&(e.preventDefault(),N(!0),F({x:e.clientX-A.x,y:e.clientY-A.y}))},Me=(0,X.useCallback)(()=>{if(!fe.current||!pe.current)return{x:200,y:150};let e=fe.current.getBoundingClientRect(),t=e.width*(O-1)/2,n=e.height*(O-1)/2;return{x:Math.max(50,t),y:Math.max(50,n)}},[O]),Ne=e=>{if(M&&O>1){let t=e.clientX-P.x,n=e.clientY-P.y,r=Me();j({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},Pe=()=>{N(!1)},Fe=e=>{if(e.length<2)return 0;let t=e[0].clientX-e[1].clientX,n=e[0].clientY-e[1].clientY;return Math.sqrt(t*t+n*n)},Ie=e=>e.length<2?{x:e[0].clientX,y:e[0].clientY}:{x:(e[0].clientX+e[1].clientX)/2,y:(e[0].clientY+e[1].clientY)/2},Le=e=>{e.touches.length===2?(e.preventDefault(),L(Fe(e.touches)),ee(Ie(e.touches))):e.touches.length===1&&O>1&&(e.preventDefault(),N(!0),F({x:e.touches[0].clientX-A.x,y:e.touches[0].clientY-A.y}))},Re=e=>{if(e.touches.length===2&&I!==null){e.preventDefault();let t=Fe(e.touches),n=t/I;k(e=>{let t=Math.max(1,Math.min(4,e*n));return t===1&&j({x:0,y:0}),t}),L(t);let r=Ie(e.touches);if(R){let e=Me();j(t=>({x:Math.max(-e.x,Math.min(e.x,t.x+(r.x-R.x))),y:Math.max(-e.y,Math.min(e.y,t.y+(r.y-R.y)))}))}ee(r)}else if(e.touches.length===1&&M&&O>1){e.preventDefault();let t=e.touches[0].clientX-P.x,n=e.touches[0].clientY-P.y,r=Me();j({x:Math.max(-r.x,Math.min(r.x,t)),y:Math.max(-r.y,Math.min(r.y,n))})}},ze=e=>{e.touches.length<2&&(L(null),ee(null)),e.touches.length===0&&N(!1)},Be=()=>{k(1),j({x:0,y:0})},Ve=()=>{B(!1),V<Ui?Ee():z(!0)},He=()=>{B(!1),z(!1),oe(0),ce(!1),H.current&&clearTimeout(H.current),me.current&&clearInterval(me.current)},Ue=()=>{B(!0),z(!1),oe(0),ce(!1),H.current&&clearTimeout(H.current),me.current&&clearInterval(me.current);let t={},n=o();n&&(t.Authorization=`Bearer ${n}`),fetch(`/api/v1/printers/${e}/camera/stop`,{method:`POST`,headers:t}).catch(()=>{}),pe.current&&(pe.current.src=``),setTimeout(()=>ae(Date.now()),100)},We=e=>{e.target.closest(`.no-drag`)||(y(!0),C({x:e.clientX-g.x,y:e.clientY-g.y}))},Ge=e=>{if(e.target.closest(`.no-drag`))return;let t=e.touches[0];y(!0),C({x:t.clientX-g.x,y:t.clientY-g.y})},Ke=e=>{e.stopPropagation(),x(!0)},qe=e=>{e.stopPropagation(),x(!0)};(0,X.useEffect)(()=>{let e=e=>{if(v)_(t=>({...t,x:Math.max(0,Math.min(e.clientX-S.x,window.innerWidth-t.width)),y:Math.max(0,Math.min(e.clientY-S.y,window.innerHeight-t.height))}));else if(b&&fe.current){let t=fe.current.getBoundingClientRect();_(n=>({...n,width:Math.max(200,Math.min(e.clientX-t.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(e.clientY-t.top,window.innerHeight-n.y-10))}))}},t=e=>{if(!v&&!b)return;e.preventDefault();let t=e.touches[0];if(v)_(e=>({...e,x:Math.max(0,Math.min(t.clientX-S.x,window.innerWidth-e.width)),y:Math.max(0,Math.min(t.clientY-S.y,window.innerHeight-e.height))}));else if(b&&fe.current){let e=fe.current.getBoundingClientRect();_(n=>({...n,width:Math.max(200,Math.min(t.clientX-e.left,window.innerWidth-n.x-10)),height:Math.max(150,Math.min(t.clientY-e.top,window.innerHeight-n.y-10))}))}},n=()=>{y(!1),x(!1)};if(v||b)return document.addEventListener(`mousemove`,e),document.addEventListener(`mouseup`,n),document.addEventListener(`touchmove`,t,{passive:!1}),document.addEventListener(`touchend`,n),document.addEventListener(`touchcancel`,n),()=>{document.removeEventListener(`mousemove`,e),document.removeEventListener(`mouseup`,n),document.removeEventListener(`touchmove`,t),document.removeEventListener(`touchend`,n),document.removeEventListener(`touchcancel`,n)}},[v,b,S]);let Je=r(`/api/v1/printers/${e}/camera/stream?fps=15&t=${ie}`);return(0,$.jsxs)(`div`,{ref:fe,className:`${E?`fixed inset-0 z-[100]`:`fixed z-40 rounded-lg shadow-2xl border border-bambu-dark-tertiary`} bg-bambu-dark-secondary overflow-hidden`,style:E?void 0:{left:g.x,top:g.y,width:w?200:g.width,height:w?40:g.height,cursor:v?`grabbing`:`default`},children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 bg-bambu-dark border-b border-bambu-dark-tertiary cursor-grab active:cursor-grabbing`,onMouseDown:We,onTouchStart:Ge,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-white truncate`,children:[(0,$.jsx)(de,{className:`w-4 h-4 text-bambu-gray flex-shrink-0`}),(0,$.jsx)(`span`,{className:`truncate`,children:Ce?.name||t})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 no-drag`,children:[(0,$.jsx)(`button`,{onClick:()=>Te.mutate(!we?.chamber_light),disabled:!we?.connected||Te.isPending||!d(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${we?.chamber_light?`bg-yellow-500/20 hover:bg-yellow-500/30`:`hover:bg-bambu-dark-tertiary`}`,title:d(`printers:control`)?s(`camera.chamberLight`):s(`printers.permission.noControl`),children:(0,$.jsx)(_e,{on:we?.chamber_light??!1,className:`w-3.5 h-3.5`})}),(0,$.jsx)(`button`,{onClick:()=>xe(!0),disabled:!q||!d(`printers:control`),className:`p-1 rounded disabled:opacity-50 ${q&&d(`printers:control`)?`hover:bg-bambu-dark-tertiary`:``}`,title:d(`printers:control`)?s(q?`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):s(`printers.permission.noControl`),children:(0,$.jsx)(ve,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,$.jsx)(`button`,{onClick:Ue,disabled:re||se,className:`p-1 hover:bg-bambu-dark-tertiary rounded disabled:opacity-50`,title:`Refresh stream`,children:(0,$.jsx)(dn,{className:`w-3.5 h-3.5 text-bambu-gray ${re?`animate-spin`:``}`})}),(0,$.jsx)(`button`,{onClick:()=>K(!0),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:s(`camera.diagnose.button`),children:(0,$.jsx)(an,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,$.jsx)(`button`,{onClick:De,className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:E?`Exit fullscreen`:`Fullscreen`,children:E?(0,$.jsx)(ge,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,$.jsx)(wr,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,$.jsx)(`button`,{onClick:()=>T(!w),className:`p-1 hover:bg-bambu-dark-tertiary rounded`,title:w?`Expand`:`Minimize`,children:w?(0,$.jsx)(he,{className:`w-3.5 h-3.5 text-bambu-gray`}):(0,$.jsx)(U,{className:`w-3.5 h-3.5 text-bambu-gray`})}),(0,$.jsx)(`button`,{onClick:a,className:`p-1 hover:bg-red-500/20 rounded`,title:`Close`,children:(0,$.jsx)(Pt,{className:`w-3.5 h-3.5 text-bambu-gray hover:text-red-600 dark:hover:text-red-400`})})]})]}),!w&&(0,$.jsxs)(`div`,{className:`relative w-full bg-black flex items-center justify-center overflow-hidden h-[calc(100%-40px)]`,onWheel:Ae,onMouseMove:Ne,onMouseUp:Pe,onMouseLeave:Pe,onTouchStart:Le,onTouchMove:Re,onTouchEnd:ze,style:{touchAction:`none`},children:[re&&!se&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/50 z-10`,children:(0,$.jsx)(dn,{className:`w-6 h-6 text-bambu-gray animate-spin`})}),se&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black/80 z-10`,children:(0,$.jsxs)(`div`,{className:`text-center p-2`,children:[(0,$.jsx)(en,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,$.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Reconnecting in `,le,`s...`]})]})}),ne&&!se&&(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center bg-black z-10`,children:(0,$.jsxs)(`div`,{className:`text-center p-2`,children:[(0,$.jsx)(Ot,{className:`w-6 h-6 text-orange-400 mx-auto mb-2`}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mb-2`,children:s(`camera.unavailable`)}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-center`,children:[(0,$.jsx)(`button`,{onClick:Ue,className:`px-2 py-1 text-xs bg-bambu-green text-white rounded hover:bg-bambu-green/80`,children:s(`camera.retry`)}),(0,$.jsx)(`button`,{onClick:()=>K(!0),className:`px-2 py-1 text-xs bg-bambu-dark border border-bambu-dark-tertiary text-bambu-gray hover:text-white rounded transition-colors`,children:s(`camera.diagnose.button`)})]})]})}),(0,$.jsx)(`img`,{ref:pe,src:Je,alt:`Camera stream`,className:`max-w-full max-h-full object-contain select-none`,style:{transform:`scale(${O}) translate(${A.x/O}px, ${A.y/O}px) rotate(${Ce?.camera_rotation||0}deg)`,...Ce?.camera_rotation===90||Ce?.camera_rotation===270?{maxWidth:`100%`,maxHeight:`100%`}:{},cursor:O>1?M?`grabbing`:`grab`:`default`},onError:Ve,onLoad:He,onMouseDown:je,draggable:!1},ie),(0,$.jsxs)(`div`,{className:`absolute bottom-2 left-2 flex items-center gap-1 bg-black/60 rounded px-1.5 py-1 no-drag`,children:[(0,$.jsx)(`button`,{onClick:ke,disabled:O<=1,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom out`,children:(0,$.jsx)(It,{className:`w-3.5 h-3.5 text-white`})}),(0,$.jsxs)(`button`,{onClick:Be,className:`px-1.5 py-0.5 text-xs text-white hover:bg-white/10 rounded min-w-[32px]`,title:`Reset zoom`,children:[Math.round(O*100),`%`]}),(0,$.jsx)(`button`,{onClick:Oe,disabled:O>=4,className:`p-1 hover:bg-white/10 rounded disabled:opacity-30`,title:`Zoom in`,children:(0,$.jsx)(Ft,{className:`w-3.5 h-3.5 text-white`})})]}),!E&&(0,$.jsx)(`div`,{className:`absolute bottom-0 right-0 w-6 h-6 cursor-se-resize no-drag hover:bg-white/10 rounded-tl transition-colors`,onMouseDown:Ke,onTouchStart:qe,title:`Drag to resize`,children:(0,$.jsx)(`svg`,{className:`w-6 h-6 text-bambu-gray/70 hover:text-bambu-gray`,viewBox:`0 0 24 24`,fill:`currentColor`,children:(0,$.jsx)(`path`,{d:`M22 22H20V20H22V22ZM22 18H20V16H22V18ZM18 22H16V20H18V22ZM22 14H20V12H22V14ZM18 18H16V16H18V18ZM14 22H12V20H14V22ZM22 10H20V8H22V10ZM18 14H16V12H18V14ZM14 18H12V16H14V18ZM10 22H8V20H10V22Z`})})})]}),(0,$.jsx)(ye,{printerId:e,isOpen:be,onClose:()=>xe(!1)}),Se&&(0,$.jsx)(W,{printerId:e,printerName:Ce?.name||null,onClose:()=>K(!1)})]})}function Yi({printerId:e,printerName:t,onClose:n}){let{t:r}=l(),a=f(),[o,s]=(0,X.useState)(!0),[c,u]=(0,X.useState)(new Set),[d,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(`all`),v=(0,X.useRef)(null),{data:y,isLoading:b,refetch:x}=p({queryKey:[`mqtt-logs`,e],queryFn:()=>i.getMQTTLogs(e),refetchInterval:1e3}),C=m({mutationFn:()=>i.enableMQTTLogging(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),w=m({mutationFn:()=>i.disableMQTTLogging(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`mqtt-logs`,e]})}}),T=m({mutationFn:()=>i.clearMQTTLogs(e),onSuccess:()=>{a.invalidateQueries({queryKey:[`mqtt-logs`,e]})}});(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n]),(0,X.useEffect)(()=>{o&&v.current&&(v.current.scrollTop=v.current.scrollHeight)},[y?.logs,o]);let D=e=>{u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},O=e=>new Date(e).toLocaleTimeString(`en-US`,{hour12:!1,fractionalSecondDigits:3}),k=(e,t)=>{if(e==null)return`<empty>`;let n=typeof e==`string`?JSON.parse(e):e,r=JSON.stringify(n,null,t?2:0);return!t&&r.length>100?r.substring(0,100)+`...`:r},A=y?.logging_enabled??!1,j=(0,X.useMemo)(()=>y?.logs??[],[y?.logs]),M=(0,X.useMemo)(()=>j.filter(e=>{if(g!==`all`&&e.direction!==g)return!1;if(d.trim()){let t=d.toLowerCase(),n=e.topic.toLowerCase().includes(t),r=JSON.stringify(e.payload).toLowerCase().includes(t);return n||r}return!0}),[j,d,g]);return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/70 flex items-center justify-center z-50 p-4`,children:(0,$.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg max-w-4xl w-full max-h-[85vh] flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:r(`mqttDebug.title`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:t})]}),(0,$.jsx)(`button`,{onClick:n,className:`text-bambu-gray hover:text-white transition-colors`,children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[A?(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:()=>w.mutate(),disabled:w.isPending,children:[(0,$.jsx)(fn,{className:`w-4 h-4`}),r(`mqttDebug.stopLogging`)]}):(0,$.jsxs)(Y,{size:`sm`,onClick:()=>C.mutate(),disabled:C.isPending,children:[(0,$.jsx)(ke,{className:`w-4 h-4`}),r(`mqttDebug.startLogging`)]}),(0,$.jsxs)(Y,{size:`sm`,variant:`secondary`,onClick:()=>T.mutate(),disabled:T.isPending||j.length===0,children:[(0,$.jsx)(Qt,{className:`w-4 h-4`}),r(`mqttDebug.clearLog`)]}),(0,$.jsx)(Y,{size:`sm`,variant:`secondary`,onClick:()=>x(),disabled:b,children:(0,$.jsx)(dn,{className:`w-4 h-4 ${b?`animate-spin`:``}`})}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-bambu-gray cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`rounded border-bambu-dark-tertiary`}),`Auto-scroll`]}),(0,$.jsxs)(`span`,{className:`text-sm text-bambu-gray`,children:[M.length,`/`,j.length]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1`,children:[(0,$.jsx)(Ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray`}),(0,$.jsx)(`input`,{type:`text`,placeholder:r(`mqttDebug.searchPlaceholder`),value:d,onChange:e=>h(e.target.value),className:`w-full pl-8 pr-3 py-1.5 text-sm bg-bambu-dark border border-bambu-dark-tertiary rounded text-white placeholder-bambu-gray focus:border-bambu-green focus:outline-none`}),d&&(0,$.jsx)(`button`,{onClick:()=>h(``),className:`absolute right-2 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,$.jsx)(Pt,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1 bg-bambu-dark rounded border border-bambu-dark-tertiary`,children:[(0,$.jsx)(`button`,{onClick:()=>_(`all`),className:`px-2 py-1.5 text-xs rounded-l transition-colors ${g===`all`?`bg-bambu-green text-white`:`text-bambu-gray hover:text-white`}`,children:r(`mqttDebug.all`)}),(0,$.jsxs)(`button`,{onClick:()=>_(`in`),className:`px-2 py-1.5 text-xs transition-colors flex items-center gap-1 ${g===`in`?`bg-blue-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,$.jsx)(S,{className:`w-3 h-3`}),r(`mqttDebug.incoming`)]}),(0,$.jsxs)(`button`,{onClick:()=>_(`out`),className:`px-2 py-1.5 text-xs rounded-r transition-colors flex items-center gap-1 ${g===`out`?`bg-green-500 text-white`:`text-bambu-gray hover:text-white`}`,children:[(0,$.jsx)(E,{className:`w-3 h-3`}),r(`mqttDebug.outgoing`)]})]})]})]}),(0,$.jsx)(`div`,{ref:v,className:`flex-1 overflow-auto p-4 font-mono text-xs bg-black min-h-[400px]`,children:j.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,$.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessages`)}),!A&&(0,$.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.startLoggingHint`)})]}):M.length===0?(0,$.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-bambu-gray`,children:[(0,$.jsx)(`p`,{className:`mb-2`,children:r(`mqttDebug.noMessagesMatch`)}),(0,$.jsx)(`p`,{className:`text-sm`,children:r(`mqttDebug.adjustFilterHint`)})]}):(0,$.jsx)(`div`,{className:`space-y-1`,children:M.map((e,t)=>{let n=c.has(t),i=e.direction===`in`;return(0,$.jsxs)(`div`,{className:`p-2 rounded cursor-pointer hover:bg-bambu-dark-secondary transition-colors ${n?`bg-bambu-dark-secondary`:``}`,onClick:()=>D(t),children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray shrink-0`,children:O(e.timestamp)}),(0,$.jsx)(`span`,{className:`shrink-0 ${i?`text-blue-400`:`text-green-400`}`,title:r(i?`mqttDebug.incoming`:`mqttDebug.outgoing`),children:i?(0,$.jsx)(S,{className:`w-3 h-3`}):(0,$.jsx)(E,{className:`w-3 h-3`})}),(0,$.jsx)(`span`,{className:`text-purple-400 shrink-0`,children:e.topic})]}),n?(0,$.jsx)(`pre`,{className:`mt-2 p-3 bg-gray-900 border border-gray-700 rounded text-green-400 overflow-x-auto whitespace-pre-wrap break-all max-h-96 overflow-y-auto text-xs`,children:k(e.payload,!0)}):(0,$.jsx)(`pre`,{className:`mt-1 text-white/80 truncate`,children:k(e.payload,!1)})]},t)})})}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-t border-bambu-dark-tertiary`,children:[(0,$.jsx)(`div`,{className:`text-sm text-bambu-gray`,children:A?(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`w-2 h-2 bg-green-500 rounded-full animate-pulse`}),r(`mqttDebug.loggingActive`)]}):(0,$.jsx)(`span`,{children:r(`mqttDebug.loggingStopped`)})}),(0,$.jsx)(Y,{variant:`secondary`,onClick:n,children:r(`common.close`)})]})]})})}function Xi(e){if(!e)return`idle`;switch(e.class){case`failure`:case`warning`:case`safe`:case`error`:return e.class;default:return`unknown`}}function Zi(e){return e===`failure`||e===`warning`||e===`safe`}function Qi({printerName:e,detection:t,lastError:n,onClose:r}){let{t:i}=l(),a=Tn();(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let o=Xi(t),s=o===`failure`?`text-status-error`:o===`warning`?`text-status-warning`:o===`safe`?`text-status-ok`:o===`error`?`text-amber-600 dark:text-amber-400`:`text-bambu-gray`,c=t?.error??n;return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,children:(0,$.jsxs)(`div`,{className:`bg-bambu-dark-secondary rounded-lg shadow-xl max-w-lg w-full max-h-[80vh] flex flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(K,{className:`w-5 h-5 text-bambu-green`}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:i(`printers.aiDetection.modalTitle`,{name:e})})]}),(0,$.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-bambu-dark-tertiary rounded-lg transition-colors`,"aria-label":i(`common.close`),children:(0,$.jsx)(Pt,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,$.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4 text-sm`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray`,children:i(`printers.aiDetection.currentStatus`)}),(0,$.jsx)(`span`,{className:`font-medium ${s}`,children:i(`printers.aiDetection.${o}`)})]}),t&&Zi(o)&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray`,children:i(`printers.aiDetection.score`)}),(0,$.jsx)(`span`,{className:`text-white font-mono`,children:t.score.toFixed(3)})]}),(0,$.jsxs)(`div`,{className:`flex justify-between`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray`,children:i(`printers.aiDetection.framesAnalyzed`)}),(0,$.jsx)(`span`,{className:`text-white font-mono`,children:t.frame_count})]})]}),o===`error`&&(0,$.jsx)(`p`,{className:`text-bambu-gray`,children:i(`printers.aiDetection.errorHint`)}),!t&&(0,$.jsx)(`p`,{className:`text-bambu-gray`,children:i(`printers.aiDetection.idleHint`)})]}),c&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 p-3 rounded-lg bg-red-50 dark:bg-red-500/10 border border-red-300 dark:border-red-500/30`,children:[(0,$.jsx)(R,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-red-700 dark:text-red-400`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`font-medium text-red-700 dark:text-red-400`,children:i(`printers.aiDetection.lastError`)}),(0,$.jsx)(`p`,{className:`text-red-700/80 dark:text-red-300/80 break-words mt-1`,children:c})]})]})]}),(0,$.jsx)(`div`,{className:`p-4 border-t border-bambu-dark-tertiary flex items-center justify-end`,children:(0,$.jsxs)(`button`,{onClick:()=>a(`/settings?tab=failure-detection`),className:`flex items-center gap-1.5 px-3 py-1.5 text-sm font-medium rounded-lg bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,children:[(0,$.jsx)(En,{className:`w-4 h-4`}),i(`printers.aiDetection.openSettings`)]})})]})})}function $i({printerId:e,printerModel:t,loadedFilamentTypes:n,loadedFilaments:r,loadedVariants:a,variant:o=`card`}){let{t:s}=l(),{data:c}=p({queryKey:[`queue`,e,`pending`,t],queryFn:()=>i.getQueue(e,`pending`,t||void 0),refetchInterval:3e4}),u=c?nn(c,n,r,a):void 0,d=u?.length||0;if(d===0)return null;let f=u?.[0];return(0,$.jsx)(bn,{to:`/queue`,className:o===`panelExtension`?`block mt-2 border-t border-bambu-dark-tertiary pt-2 pl-1 hover:opacity-90 transition-opacity`:`block mb-3 p-3 bg-bambu-dark rounded-lg hover:bg-bambu-dark-tertiary transition-colors`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,$.jsx)(P,{className:`w-5 h-5 text-yellow-600 dark:text-yellow-400 flex-shrink-0`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:s(`queue.nextInQueue`)}),(0,$.jsx)(`p`,{className:`text-sm text-white truncate`,children:f?_r(f):``})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-shrink-0`,children:[(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray flex items-center gap-1`,children:[(0,$.jsx)(vn,{className:`w-3 h-3`}),f?.scheduled_time?Kt(f.scheduled_time,`system`,s):s(`time.waiting`)]}),d>1&&(0,$.jsxs)(`span`,{className:`text-xs px-1.5 py-0.5 bg-yellow-100 dark:bg-yellow-400/20 text-yellow-700 dark:text-yellow-400 rounded`,children:[`+`,d-1]}),(0,$.jsx)(pn,{className:`w-4 h-4 text-bambu-gray`})]})]})})}function ea({printerId:e}){let{t}=l(),{data:n}=p({queryKey:[`haSensorReadings`,e],queryFn:()=>i.getHASensorReadings(e),refetchInterval:15e3});if(!n?.length)return null;let r=e=>v(e,t);return(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(ue,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] text-blue-600 dark:text-blue-400 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:t(`haSensors.label`)}),(0,$.jsx)(`div`,{className:`h-[2px] w-5 bg-bambu-dark-tertiary/50`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:n.map(e=>{let n=b(e),i=!e.reachable||e.state===null;return(0,$.jsxs)(`span`,{title:e.block_print?t(`haSensors.blocksPrints`,{entity:e.entity_id}):e.entity_id,className:`px-2 py-0.5 text-xs rounded flex items-center gap-1 ${i?`bg-bambu-dark-tertiary/50 text-bambu-gray`:e.alerting?`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:[(0,$.jsx)(n,{className:`w-[var(--pc-i25,0.625rem)] h-[var(--pc-i25,0.625rem)]`}),(0,$.jsx)(`span`,{children:e.name}),(0,$.jsx)(`span`,{className:`font-medium`,children:r(e)})]},e.id)})})]})}var ta=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}];function na({isOpen:e,onClose:t,printerId:n,printerName:r,amsId:a,amsLabel:o,initialMode:s=`humidity`,thresholds:c}){let{t:u}=l(),[d,f]=(0,X.useState)(`24h`),[m,h]=(0,X.useState)(s),{data:g}=p({queryKey:[`settings`],queryFn:i.getSettings}),v=g?.time_format||`system`;(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let b=ta.find(e=>e.value===d)?.hours||24,{data:x,isLoading:S,error:C}=p({queryKey:[`ams-history`,n,a,b],queryFn:()=>i.getAMSHistory(n,a,b),enabled:e,refetchInterval:6e4});if(!e)return null;let w=x?.data.map(e=>({time:(qt(e.recorded_at)||new Date).getTime(),humidity:e.humidity,temperature:e.temperature}))||[],T=Date.now()-b*60*60*1e3,E=Date.now(),D=[...w];if(D.length>0){let e=D[0];e.time>T&&D.unshift({...e,time:T});let t=D[D.length-1];t.time<E&&D.push({...t,time:E})}let k=c?.humidityGood||40,j=c?.humidityFair||60,M=c?.tempGood||30,N=c?.tempFair||35,P=D[D.length-1],F=P?.humidity,I=P?.temperature,L=e=>{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`},R=L(D.map(e=>e.humidity)),ee=L(D.map(e=>e.temperature)),te=({trend:e})=>e===`up`?(0,$.jsx)(_,{className:`w-4 h-4 text-red-600 dark:text-red-400`}):e===`down`?(0,$.jsx)(Ke,{className:`w-4 h-4 text-green-600 dark:text-green-400`}):(0,$.jsx)(G,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),ne=e=>e==null?`#9ca3af`:e<=k?`#22a352`:e<=j?`#d4a017`:`#c62828`,z=e=>e==null?`#9ca3af`:e<=M?`#22a352`:e<=N?`#d4a017`:`#c62828`,re=`var(--bg-secondary)`,B=`var(--bg-primary)`,ie=`var(--border-color)`,ae=`var(--text-primary)`,V=`var(--text-secondary)`,oe=`var(--text-muted)`;return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,$.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:re},onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:ie},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h2`,{className:`text-lg font-semibold`,style:{color:ae},children:[o,` `,u(`common.history`,`History`)]}),(0,$.jsx)(`p`,{className:`text-sm`,style:{color:V},children:r})]}),(0,$.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:V},children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,$.jsxs)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:B},children:[(0,$.jsxs)(`button`,{onClick:()=>h(`humidity`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m===`humidity`?`bg-blue-600 text-white`:``}`,style:m===`humidity`?void 0:{color:V},children:[(0,$.jsx)(y,{className:`w-4 h-4`}),u(`common.humidity`,`Humidity`)]}),(0,$.jsxs)(`button`,{onClick:()=>h(`temperature`),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${m===`temperature`?`bg-orange-600 text-white`:``}`,style:m===`temperature`?void 0:{color:V},children:[(0,$.jsx)(Me,{className:`w-4 h-4`}),u(`common.temperature`,`Temperature`)]})]}),(0,$.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:B},children:ta.map(e=>(0,$.jsx)(`button`,{onClick:()=>f(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${d===e.value?`bg-bambu-green text-white`:``}`,style:d===e.value?void 0:{color:V},children:e.label},e.value))})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:m===`humidity`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.current`,`Current`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:ne(F)},children:F==null?`—`:`${F}%`}),(0,$.jsx)(te,{trend:R})]})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.average`,`Average`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:ae},children:x?.avg_humidity==null?`—`:`${x.avg_humidity}%`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.min`,`Min`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold text-green-500`,children:x?.min_humidity==null?`—`:`${x.min_humidity}%`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.max`,`Max`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:x?.max_humidity==null?`—`:`${x.max_humidity}%`})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-2`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.current`,`Current`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:z(I)},children:I==null?`—`:`${I}°C`}),(0,$.jsx)(te,{trend:ee})]})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-4`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.average`,`Average`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:ae},children:x?.avg_temperature==null?`—`:`${x.avg_temperature}°C`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-1`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.min`,`Min`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold text-blue-500`,children:x?.min_temperature==null?`—`:`${x.min_temperature}°C`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4 max-[550px]:order-3`,style:{backgroundColor:B},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:V},children:u(`common.max`,`Max`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold text-red-500`,children:x?.max_temperature==null?`—`:`${x.max_temperature}°C`})]})]})}),(0,$.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:B},children:S?(0,$.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:u(`common.loading`,`Loading...`)}):C?(0,$.jsx)(`div`,{className:`h-[300px] flex items-center justify-center text-red-500`,children:u(`common.error`,`Error loading data`)}):D.length===0?(0,$.jsx)(`div`,{className:`h-[300px] flex items-center justify-center`,style:{color:V},children:u(`common.noData`,`No data available for this time range`)}):(0,$.jsx)(Qe,{width:`100%`,height:300,children:(0,$.jsxs)(hi,{data:D,children:[(0,$.jsx)(gt,{strokeDasharray:`3 3`,stroke:ie}),(0,$.jsx)(rt,{dataKey:`time`,type:`number`,domain:[Date.now()-b*60*60*1e3,Date.now()],tickFormatter:e=>{let t=new Date(e);return b>24?t.toLocaleDateString([],{day:`numeric`,month:`short`}):t.toLocaleTimeString([],Gt({hour:`2-digit`,minute:`2-digit`},v))},stroke:oe,tick:{fontSize:12}}),(0,$.jsx)(vt,{stroke:oe,tick:{fontSize:12},domain:m===`humidity`?[0,100]:[`auto`,`auto`],tickFormatter:e=>m===`humidity`?`${e}%`:`${e}°C`}),(0,$.jsx)(Re,{contentStyle:{backgroundColor:re,border:`1px solid ${ie}`,borderRadius:`8px`,color:ae},labelFormatter:e=>new Date(e).toLocaleString(void 0,Gt({year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},v)),formatter:e=>[m===`humidity`?`${e??0}%`:`${e??0}°C`,m===`humidity`?`Humidity`:`Temperature`]}),(0,$.jsx)(O,{}),m===`humidity`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{y:k,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,$.jsx)(A,{y:j,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(A,{y:M,stroke:`#22a352`,strokeDasharray:`5 5`,label:{value:`Good`,fill:`#22a352`,fontSize:10}}),(0,$.jsx)(A,{y:N,stroke:`#d4a017`,strokeDasharray:`5 5`,label:{value:`Fair`,fill:`#d4a017`,fontSize:10}})]}),(0,$.jsx)(pi,{type:`monotone`,dataKey:m,name:m===`humidity`?`Humidity`:`Temperature`,stroke:m===`humidity`?`#3b82f6`:`#f97316`,strokeWidth:2,dot:!1,activeDot:{r:4},connectNulls:!0})]})})}),(0,$.jsx)(`div`,{className:`text-xs text-center`,style:{color:V},children:u(`amsHistory.recordingInfo`,`Data is recorded every 5 minutes while the printer is connected`)})]})]})})}function ra(e,t,n){let r=n===1||e>=128,i=e>=128?e-128:e,a=String.fromCharCode(65+i);return r?`HT·${t+1}`:`${a}·${t+1}`}function ia(e){let t=(e||``).replace(`#`,``).slice(0,6);if(t.length!==6)return`#FFFFFF`;let n=parseInt(t.slice(0,2),16),r=parseInt(t.slice(2,4),16),i=parseInt(t.slice(4,6),16);return[n,r,i].some(Number.isNaN)?`#FFFFFF`:(.2126*n+.7152*r+.0722*i)/255>.55?`#1A1A1A`:`#FFFFFF`}function aa({group:e,trayCountByAms:t,innerBg:n,textPrimary:r,textSecondary:i,showExtruderBadge:a,extruderLabel:o}){let s=Mn(e.trayColor||void 0),c=ia(e.trayColor),l=c===`#FFFFFF`?`rgba(0,0,0,0.45)`:`rgba(255,255,255,0.7)`,u=e.members.length;return(0,$.jsxs)(`div`,{className:`relative flex flex-col items-center`,children:[a&&(0,$.jsx)(`span`,{className:`absolute -top-1 -left-1 z-10 w-6 h-6 rounded-full flex items-center justify-center text-xs font-bold shadow`,style:{backgroundColor:r,color:n},"aria-label":o,title:o,children:o}),(0,$.jsxs)(`svg`,{viewBox:`-100 -100 200 200`,className:`w-44 h-44`,children:[(0,$.jsx)(`circle`,{cx:`0`,cy:`0`,r:`95`,fill:`none`,stroke:i,strokeOpacity:`0.25`,strokeWidth:`1`}),(0,$.jsx)(`circle`,{cx:`0`,cy:`0`,r:`92`,fill:s}),(0,$.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:n}),(0,$.jsx)(`circle`,{cx:`0`,cy:`0`,r:`56`,fill:`none`,stroke:i,strokeOpacity:`0.3`,strokeWidth:`1`}),(0,$.jsx)(`text`,{x:`0`,y:`-4`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`14`,fontWeight:`700`,fill:r,children:e.displayName||`—`}),(0,$.jsx)(`text`,{x:`0`,y:`16`,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`11`,fontWeight:`500`,fill:i,children:`${u}× ↻`}),e.members.map((e,n)=>{let r=(n*360/u-90)*Math.PI/180,i=76*Math.cos(r),a=76*Math.sin(r),o=ra(e.amsId,e.slotIdx,t.get(e.amsId)??4),s=Math.max(22,o.length*7+8);return(0,$.jsxs)(`g`,{children:[(0,$.jsx)(`rect`,{x:i-s/2,y:a-9,width:s,height:18,rx:9,ry:9,fill:l}),(0,$.jsx)(`text`,{x:i,y:a,textAnchor:`middle`,dominantBaseline:`middle`,fontSize:`12`,fontWeight:`700`,fill:c,children:o})]},`${e.amsId}-${e.slotIdx}`)})]})]})}function oa({isOpen:e,state:t,amsUnits:n,amsExtruderMap:r,isDualNozzle:i,canToggle:a,pending:o,onToggle:s,onClose:c}){let{t:u}=l();if((0,X.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.stopPropagation(),c())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,c]),!e)return null;let d=`var(--bg-secondary)`,f=`var(--border-color)`,p=`var(--text-primary)`,m=`var(--text-secondary)`,h=(()=>{if(!i||!r)return!1;let e=new Set;for(let t of n||[]){let n=r[String(t.id)];if(n!==void 0&&(e.add(Number(n)),e.size>1))return!0}return!1})(),g=wn(n,r,h),_=new Map((n||[]).map(e=>[e.id,e.tray.length])),v=g.filter(e=>e.members.length>=2),y=t===!0,b=t===null;return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:c,"data-testid":`ams-backup-modal`,children:(0,$.jsxs)(`div`,{className:`rounded-xl w-full max-w-2xl max-h-[90vh] overflow-hidden shadow-xl flex flex-col`,style:{backgroundColor:d},onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,"aria-labelledby":`ams-backup-modal-title`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:f},children:[(0,$.jsx)(`h2`,{id:`ams-backup-modal-title`,className:`text-base font-semibold`,style:{color:p},children:u(`printers.amsBackup.modalTitle`)}),(0,$.jsx)(`button`,{type:`button`,onClick:c,className:`p-1 rounded-md transition-colors hover:bg-black/10`,style:{color:m},"aria-label":u(`common.close`),children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-b`,style:{borderColor:f,backgroundColor:`var(--bg-primary)`},children:[(0,$.jsxs)(`div`,{className:`min-w-0 mr-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium`,style:{color:p},children:u(b?`printers.amsBackup.stateUnknown`:y?`printers.amsBackup.stateOn`:`printers.amsBackup.stateOff`)}),(0,$.jsx)(`p`,{className:`text-xs mt-0.5`,style:{color:m},children:u(`printers.amsBackup.modalHelp`)})]}),(0,$.jsx)(hr,{checked:y,onChange:s,disabled:!a||b||o})]}),(0,$.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-6`,children:v.length===0?(0,$.jsx)(`p`,{className:`text-sm text-center py-8`,style:{color:m},children:u(`printers.amsBackup.modalNoPairs`)}):(0,$.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-6 justify-items-center`,children:v.map(e=>(0,$.jsx)(aa,{group:e,trayCountByAms:_,innerBg:d,textPrimary:p,textSecondary:m,showExtruderBadge:h,extruderLabel:e.extruder===0?u(`printers.amsBackup.extruderRightShort`):u(`printers.amsBackup.extruderLeftShort`)},e.key))})})]})})}var sa=[{value:`6h`,label:`6h`,hours:6},{value:`24h`,label:`24h`,hours:24},{value:`48h`,label:`48h`,hours:48},{value:`7d`,label:`7d`,hours:168}],ca={nozzle:`#fb923c`,nozzle_2:`#f97316`,bed:`#60a5fa`,chamber:`#34d399`},la={nozzle:`#fed7aa`,nozzle_2:`#fdba74`,bed:`#bfdbfe`,chamber:`#a7f3d0`};function ua({isOpen:e,onClose:t,printerId:n,printerName:r,initialKind:a=`nozzle`,availableKinds:o=[`nozzle`,`bed`,`chamber`]}){let{t:s}=l(),[c,u]=(0,X.useState)(`24h`),[d,f]=(0,X.useState)(a);(0,X.useEffect)(()=>{f(a)},[a]);let{data:m}=p({queryKey:[`settings`],queryFn:i.getSettings}),h=m?.time_format||`system`;(0,X.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let g=sa.find(e=>e.value===c)?.hours||24,{data:v,isLoading:y,error:b}=p({queryKey:[`printer-sensor-history`,n,g,o.join(`,`)],queryFn:()=>i.getPrinterSensorHistory(n,g,o),enabled:e,refetchInterval:6e4});if(!e)return null;let x=v?.series.find(e=>e.sensor_kind===d),S=(x?.data||[]).map(e=>({time:(qt(e.recorded_at)||new Date).getTime(),value:e.value,target:e.target})),C=Date.now()-g*60*60*1e3,w=Date.now(),T=[...S];if(T.length>0){let e=T[0];e.time>C&&T.unshift({...e,time:C});let t=T[T.length-1];t.time<w&&T.push({...t,time:w})}let E=T[T.length-1],D=E?.value,k=E?.target,A=(e=>{let t=e.filter(e=>e!=null);if(t.length<4)return`stable`;let n=t.slice(0,Math.floor(t.length/4)),r=t.slice(-Math.floor(t.length/4)),i=n.reduce((e,t)=>e+t,0)/n.length,a=r.reduce((e,t)=>e+t,0)/r.length-i;return Math.abs(a)<2?`stable`:a>0?`up`:`down`})(T.map(e=>e.value)),M=({trend:e})=>e===`up`?(0,$.jsx)(_,{className:`w-4 h-4 text-red-600 dark:text-red-400`}):e===`down`?(0,$.jsx)(Ke,{className:`w-4 h-4 text-green-600 dark:text-green-400`}):(0,$.jsx)(G,{className:`w-4 h-4 text-gray-400 dark:text-bambu-gray`}),N=`var(--bg-secondary)`,P=`var(--bg-primary)`,F=`var(--border-color)`,I=`var(--text-primary)`,L=`var(--text-secondary)`,R=`var(--text-muted)`,ee=e=>{switch(e){case`nozzle`:return s(`printers.heaterHistory.nozzle`,`Nozzle`);case`nozzle_2`:return s(`printers.heaterHistory.nozzle2`,`Nozzle 2`);case`bed`:return s(`printers.heaterHistory.bed`,`Bed`);case`chamber`:return s(`printers.heaterHistory.chamber`,`Chamber`)}},te=({k:e})=>e===`nozzle`||e===`nozzle_2`?(0,$.jsx)(Bn,{className:`w-4 h-4`}):e===`bed`?(0,$.jsx)(fn,{className:`w-4 h-4`}):(0,$.jsx)(j,{className:`w-4 h-4`});return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,onClick:t,children:(0,$.jsxs)(`div`,{className:`rounded-xl w-full max-w-4xl max-h-[90vh] overflow-hidden shadow-xl`,style:{backgroundColor:N},onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-6 py-4 border-b`,style:{borderColor:F},children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold`,style:{color:I},children:s(`printers.heaterHistory.title`,`Heater History`)}),(0,$.jsx)(`p`,{className:`text-sm`,style:{color:L},children:r})]}),(0,$.jsx)(`button`,{onClick:t,className:`p-2 rounded-lg transition-colors`,style:{color:L},"aria-label":s(`common.close`,`Close`),children:(0,$.jsx)(Pt,{className:`w-5 h-5`})})]}),(0,$.jsxs)(`div`,{className:`p-6 space-y-6 overflow-y-auto max-h-[calc(90vh-80px)]`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between max-[550px]:flex-col max-[550px]:items-start max-[550px]:gap-3`,children:[(0,$.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:P},children:o.map(e=>(0,$.jsxs)(`button`,{onClick:()=>f(e),className:`flex items-center gap-2 px-3 py-1.5 text-sm rounded-md transition-colors ${d===e?`text-white`:``}`,style:d===e?{backgroundColor:ca[e]}:{color:L},children:[(0,$.jsx)(te,{k:e}),ee(e)]},e))}),(0,$.jsx)(`div`,{className:`inline-flex gap-1 rounded-lg p-1 max-w-full flex-wrap w-fit`,style:{backgroundColor:P},children:sa.map(e=>(0,$.jsx)(`button`,{onClick:()=>u(e.value),className:`px-3 py-1 text-sm rounded-md transition-colors ${c===e.value?`bg-bambu-green text-white`:``}`,style:c===e.value?void 0:{color:L},children:e.label},e.value))})]}),(0,$.jsxs)(`div`,{className:`grid grid-cols-4 gap-4 max-[550px]:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:P},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:L},children:s(`common.current`,`Current`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:ca[d]},children:D==null?`—`:`${Math.round(D)}°C`}),(0,$.jsx)(M,{trend:A})]}),k!=null&&k>0&&(0,$.jsxs)(`p`,{className:`text-xs mt-1`,style:{color:L},children:[s(`common.target`,`Target`),`: `,Math.round(k),`°C`]})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:P},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:L},children:s(`common.average`,`Average`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:I},children:x?.avg_value==null?`—`:`${x.avg_value}°C`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:P},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:L},children:s(`common.min`,`Min`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:I},children:x?.min_value==null?`—`:`${Math.round(x.min_value)}°C`})]}),(0,$.jsxs)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:P},children:[(0,$.jsx)(`p`,{className:`text-xs`,style:{color:L},children:s(`common.max`,`Max`)}),(0,$.jsx)(`p`,{className:`text-2xl font-bold`,style:{color:I},children:x?.max_value==null?`—`:`${Math.round(x.max_value)}°C`})]})]}),(0,$.jsx)(`div`,{className:`rounded-lg p-4`,style:{backgroundColor:P},children:y?(0,$.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:L},children:s(`common.loading`,`Loading...`)}):b?(0,$.jsx)(`div`,{className:`h-64 flex items-center justify-center text-red-700 dark:text-red-400`,children:s(`printers.heaterHistory.error`,`Failed to load history`)}):T.length===0?(0,$.jsx)(`div`,{className:`h-64 flex items-center justify-center`,style:{color:L},children:s(`printers.heaterHistory.empty`,`No data recorded yet`)}):(0,$.jsx)(Qe,{width:`100%`,height:300,children:(0,$.jsxs)(hi,{data:T,margin:{top:5,right:10,left:0,bottom:5},children:[(0,$.jsx)(gt,{strokeDasharray:`3 3`,stroke:F}),(0,$.jsx)(rt,{dataKey:`time`,type:`number`,domain:[C,w],tickFormatter:e=>new Date(e).toLocaleTimeString([],Gt({hour:`2-digit`,minute:`2-digit`},h)),stroke:R,fontSize:11}),(0,$.jsx)(vt,{stroke:R,fontSize:11,domain:[0,`auto`],tickFormatter:e=>`${Math.round(e)}°`}),(0,$.jsx)(Re,{contentStyle:{backgroundColor:N,border:`1px solid ${F}`,borderRadius:6,color:I},labelFormatter:e=>new Date(e).toLocaleString(void 0,Gt({month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`},h)),formatter:e=>e==null?`—`:`${Math.round(Number(e))}°C`}),(0,$.jsx)(O,{}),(0,$.jsx)(pi,{type:`monotone`,dataKey:`value`,name:s(`common.current`,`Current`),stroke:ca[d],strokeWidth:2,dot:!1,isAnimationActive:!1}),(0,$.jsx)(pi,{type:`stepAfter`,dataKey:`target`,name:s(`common.target`,`Target`),stroke:la[d],strokeDasharray:`4 4`,strokeWidth:1.5,dot:!1,isAnimationActive:!1})]})})})]})]})})}function da({data:e,children:t,disabled:n,className:r=``,spoolman:i,inventory:a,configureSlot:o,actions:s}){let{t:c}=l(),u=Tn(),[d,f]=(0,X.useState)(!1),[p,m]=(0,X.useState)(`top`),[h,g]=(0,X.useState)(null),[_,v]=(0,X.useState)(!1),[b,x]=(0,X.useState)(!1),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null),T=()=>{let t=e.trayUuid;t&&(navigator.clipboard&&window.isSecureContext?navigator.clipboard.writeText(t).then(()=>{v(!0),setTimeout(()=>v(!1),2e3)}).catch(()=>{E(t)}):E(t))},E=e=>{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{document.execCommand(`copy`),v(!0),setTimeout(()=>v(!1),2e3)}catch{console.error(`Failed to copy to clipboard`)}document.body.removeChild(t)};(0,X.useLayoutEffect)(()=>{if(!d){g(null);return}let e=()=>{if(!S.current||!C.current)return;let e=S.current.getBoundingClientRect(),t=C.current.offsetHeight,n=C.current.offsetWidth,r=e.top-56,i=window.innerHeight-e.bottom,a=r<t+12&&i>r?`bottom`:`top`,o=e.left+e.width/2,s=Math.max(8,Math.min(o-n/2,window.innerWidth-n-8)),c=a===`top`?e.top-t-8:e.bottom+8;m(a),g({top:c,left:s})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[d]);let D=()=>{n||(w.current&&clearTimeout(w.current),w.current=setTimeout(()=>f(!0),80))},O=()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>f(!1),100)},k=()=>{w.current&&clearTimeout(w.current),f(!1)};(0,X.useEffect)(()=>()=>{w.current&&clearTimeout(w.current)},[]);let A=e=>e<=15?`#ef4444`:e<=30?`#f97316`:e<=50?`#eab308`:`#22c55e`,j=e.colorHex?`#${e.colorHex.replace(`#`,``)}`:null,M=(a?.assignedSpool?.color_name_is_synthesized?void 0:qn(a?.assignedSpool?.color_name??null,null)?.trim())||e.colorName,N=a?.assignedSpool?qn(a.assignedSpool.color_name,a.assignedSpool.rgba??null,a.assignedSpool.color_name_is_synthesized):null,P=a?.assignedSpool?.remainingWeightGrams??null,I=a?.assignedSpool??null,L=Yt(I?.extra_colors),R=!!I?.effect_type,ee=!!I&&(L.length>0||R),te=ee?Jt({effectSize:`card`,rgba:I?.rgba??j,extraColors:I?.extra_colors,effectType:I?.effect_type,subtype:I?.subtype}):null,ne=L.length>1,re=ee?L.length===1?L[0]:I?.rgba??j:j;return(0,$.jsxs)(`div`,{ref:S,"data-testid":`filament-slot`,className:`relative ${r}`,onMouseEnter:D,onMouseLeave:O,children:[t,d&&(0,gi.createPortal)((0,$.jsxs)(`div`,{ref:C,className:`fixed z-[60]`,style:{top:h?.top??-9999,left:h?.left??-9999,maxWidth:`calc(100vw - 24px)`,visibility:h?`visible`:`hidden`},onMouseEnter:D,onMouseLeave:O,children:[(0,$.jsxs)(`div`,{className:`
  2. w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary
  3. rounded-lg shadow-xl overflow-hidden
  4. backdrop-blur-sm
  5. `,children:[(0,$.jsxs)(`div`,{className:`h-12 relative overflow-hidden`,style:te?{...te,backgroundColor:j||`#3d3d3d`}:{backgroundColor:j||`#3d3d3d`},children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-gradient-to-b from-white/10 to-transparent`}),(0,$.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,$.jsx)(`span`,{className:ne?`px-2 py-0.5 rounded bg-black/60 text-white font-semibold text-sm tracking-wide`:`font-semibold text-sm tracking-wide ${nr(re)?`text-black/80`:`text-white/90`}`,children:M})}),(0,$.jsx)(`div`,{className:`
  6. absolute top-1.5 right-1.5 px-1.5 py-0.5 rounded text-[9px] font-bold uppercase tracking-wider
  7. ${e.vendor===`Bambu Lab`?`bg-black/60 text-white`:`bg-black/50 text-white/90`}
  8. `,children:e.vendor===`Bambu Lab`?`BBL`:`GEN`})]}),(0,$.jsxs)(`div`,{className:`p-3 space-y-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:c(`ams.profile`)}),(0,$.jsx)(`span`,{className:`text-xs text-white font-semibold truncate max-w-[120px]`,children:e.profile})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:c(`ams.kFactor`)}),(0,$.jsx)(`span`,{className:`text-xs text-bambu-green font-mono font-bold`,children:e.kFactor})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium flex items-center gap-1`,children:[(0,$.jsx)(y,{className:`w-3 h-3`}),c(`ams.fill`)]}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold flex items-center gap-1`,children:[(0,$.jsx)(`span`,{children:e.fillLevel===null?`—`:`${e.fillLevel}%`}),P!==null&&e.fillLevel!==null&&(0,$.jsxs)(`span`,{className:`text-[9px] text-bambu-gray font-normal`,children:[`• `,P,`g`]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 bg-black/40 rounded-full overflow-hidden`,children:e.fillLevel===null?(0,$.jsx)(`div`,{className:`h-full w-full bg-bambu-gray/30 rounded-full`}):(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-300`,style:{width:`${e.fillLevel}%`,backgroundColor:A(e.fillLevel)}})})]}),i?.enabled&&(0,$.jsxs)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:c(`spoolman.spoolId`)}),e.trayUuid?(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),T()},className:`flex items-center gap-1 text-xs text-bambu-gray hover:text-white transition-colors`,title:`Copy spool UUID`,children:[(0,$.jsxs)(`span`,{className:`font-mono text-[10px] truncate max-w-[80px]`,children:[e.trayUuid.slice(0,8),`...`]}),_?(0,$.jsx)(F,{className:`w-3 h-3 text-bambu-green`}):(0,$.jsx)(z,{className:`w-3 h-3`})]}):(0,$.jsx)(`span`,{className:`text-[10px] text-bambu-gray`,children:`—`})]}),i.linkedSpoolId&&(0,$.jsx)($.Fragment,{children:(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),k(),u(`/inventory?spool=${i.linkedSpoolId}`)},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-green/20 hover:bg-bambu-green/40 text-bambu-green`,title:c(`inventory.openInInventory`),children:[(0,$.jsx)(De,{className:`w-3.5 h-3.5`}),c(`inventory.openInInventory`)]})})]}),a&&(0,$.jsx)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-2`,children:a.assignedSpool?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(De,{className:`w-3 h-3 text-bambu-green`}),(0,$.jsx)(`span`,{className:`text-[10px] uppercase tracking-wider text-bambu-gray font-medium`,children:c(`inventory.assigned`)})]}),(0,$.jsxs)(`div`,{className:`flex items-baseline gap-1.5 min-w-0 mb-1`,children:[(0,$.jsxs)(`p`,{className:`text-xs text-white truncate`,children:[a.assignedSpool.brand?`${a.assignedSpool.brand} `:``,a.assignedSpool.material,a.assignedSpool.subtype?` ${a.assignedSpool.subtype}`:``,N?` - ${N}`:``]}),(0,$.jsxs)(`span`,{className:`text-[10px] font-mono text-bambu-gray shrink-0`,children:[`#`,a.assignedSpool.id]})]}),(!i?.linkedSpoolId||a.assignedSpool.id!==i.linkedSpoolId)&&(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),k(),u(`/inventory?spool=${a.assignedSpool.id}`)},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-green/20 hover:bg-bambu-green/40 text-bambu-green`,title:c(`inventory.openInInventory`),children:[(0,$.jsx)(De,{className:`w-3.5 h-3.5`}),c(`inventory.openInInventory`)]}),a.onUnassignSpool&&(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),k(),a.onUnassignSpool?.()},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-red-100 dark:bg-red-500/20 hover:bg-red-200 dark:hover:bg-red-500/40 text-red-700 dark:text-red-400`,children:[(0,$.jsx)(kt,{className:`w-3.5 h-3.5`}),c(`inventory.unassignSpool`)]})]}):a.onAssignSpool?(0,$.jsxs)(`button`,{onClick:a.isAssigned?void 0:e=>{e.stopPropagation(),k(),a.onAssignSpool?.()},disabled:!!a.isAssigned,className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 text-bambu-blue ${a.isAssigned?`opacity-50 cursor-not-allowed`:`hover:bg-bambu-blue/40`}`,children:[(0,$.jsx)(De,{className:`w-3.5 h-3.5`}),c(`inventory.assignSpool`)]}):null}),o?.enabled&&(0,$.jsx)(`div`,{className:`${i?.enabled&&e.trayUuid?``:`pt-2 mt-2 border-t border-bambu-dark-tertiary`}`,children:(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),k(),o.onConfigure?.()},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/40 text-bambu-blue`,title:c(`ams.configureSlot`),children:[(0,$.jsx)(je,{className:`w-3.5 h-3.5`}),c(`ams.configure`)]})}),s&&(0,$.jsx)(`div`,{className:`pt-2 mt-2 border-t border-bambu-dark-tertiary space-y-1`,children:s})]})]}),(0,$.jsx)(`div`,{className:`
  9. absolute left-1/2 -translate-x-1/2 w-0 h-0
  10. border-l-[6px] border-l-transparent
  11. border-r-[6px] border-r-transparent
  12. ${p===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`}
  13. `})]}),document.body),b&&(0,$.jsxs)(`div`,{className:`fixed inset-0 z-[100] flex items-center justify-center`,onClick:()=>x(!1),children:[(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`}),(0,$.jsx)(`div`,{className:`relative bg-bambu-dark-secondary rounded-lg shadow-xl w-full max-w-sm mx-4 border border-bambu-dark-tertiary`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-base font-semibold text-white`,children:c(`spoolman.unlinkConfirmTitle`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray`,children:c(`spoolman.unlinkConfirmMessage`)})]}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>x(!1),className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-bambu-dark hover:bg-bambu-dark-tertiary text-white`,children:c(`common.cancel`)}),(0,$.jsx)(`button`,{onClick:()=>{i?.onUnlinkSpool?.(),x(!1)},className:`flex-1 px-3 py-2 text-sm font-medium rounded transition-colors bg-red-100 dark:bg-red-500/20 hover:bg-red-200 dark:hover:bg-red-500/40 text-red-700 dark:text-red-400`,children:c(`inventory.unassignSpool`)})]})]})})]})]})}function fa({children:e,className:t=``,configureSlot:n,onAssignSpool:r,actions:i,kind:a}){let{t:o}=l(),[s,c]=(0,X.useState)(!1),[u,d]=(0,X.useState)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=(0,X.useRef)(null),h=()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(!0),80)},g=()=>{m.current&&clearTimeout(m.current),m.current=setTimeout(()=>c(!1),100)},_=()=>{m.current&&clearTimeout(m.current),c(!1)};return(0,X.useEffect)(()=>()=>{m.current&&clearTimeout(m.current)},[]),(0,X.useLayoutEffect)(()=>{if(!s){d(null);return}let e=()=>{if(!f.current||!p.current)return;let e=f.current.getBoundingClientRect(),t=p.current.offsetHeight,n=p.current.offsetWidth,r=e.left+e.width/2,i=Math.max(8,Math.min(r-n/2,window.innerWidth-n-8));d({top:e.top-t-8,left:i})};e();let t=requestAnimationFrame(e);return window.addEventListener(`scroll`,e,!0),window.addEventListener(`resize`,e),()=>{cancelAnimationFrame(t),window.removeEventListener(`scroll`,e,!0),window.removeEventListener(`resize`,e)}},[s]),(0,$.jsxs)(`div`,{ref:f,className:`relative ${t}`,onMouseEnter:h,onMouseLeave:g,children:[e,s&&(0,gi.createPortal)((0,$.jsxs)(`div`,{ref:p,className:`fixed z-[60]`,style:{top:u?.top??-9999,left:u?.left??-9999,visibility:u?`visible`:`hidden`},onMouseEnter:h,onMouseLeave:g,children:[(0,$.jsxs)(`div`,{className:`
  14. bg-bambu-dark-secondary border border-bambu-dark-tertiary
  15. rounded-md shadow-lg overflow-hidden
  16. `,children:[(0,$.jsx)(`div`,{className:`px-3 py-1.5 text-xs text-bambu-gray whitespace-nowrap`,children:o(a===`reset`?`ams.emptySlotReset`:`ams.emptySlot`)}),(n?.enabled||r||i)&&(0,$.jsxs)(`div`,{className:`px-2 pb-2 space-y-1`,children:[r&&(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),_(),r()},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/40 text-bambu-blue`,children:[(0,$.jsx)(De,{className:`w-3.5 h-3.5`}),o(`inventory.assignSpool`)]}),n?.enabled&&(0,$.jsxs)(`button`,{onClick:e=>{e.stopPropagation(),_(),n.onConfigure?.()},className:`w-full flex items-center justify-start gap-1.5 px-2 py-1.5 text-xs font-medium rounded transition-colors bg-bambu-blue/20 hover:bg-bambu-blue/40 text-bambu-blue`,title:o(`ams.configureSlot`),children:[(0,$.jsx)(je,{className:`w-3.5 h-3.5`}),o(`ams.configure`)]}),i&&(0,$.jsx)(`div`,{className:`pt-1 mt-1 border-t border-bambu-dark-tertiary space-y-1`,children:i})]})]}),(0,$.jsx)(`div`,{className:`
  17. absolute left-1/2 -translate-x-1/2 top-full w-0 h-0
  18. border-l-[5px] border-l-transparent
  19. border-r-[5px] border-r-transparent
  20. border-t-[5px] border-t-bambu-dark-tertiary
  21. `})]}),document.body)]})}function pa({className:e=`w-4 h-4`}){return(0,$.jsx)(`svg`,{viewBox:`0 0 1945 1370`,fill:`none`,className:e,"aria-hidden":`true`,children:(0,$.jsxs)(`g`,{transform:`translate(-754.293 -471.685)`,children:[(0,$.jsxs)(`g`,{transform:`translate(0.18191 255.976)`,children:[(0,$.jsx)(`g`,{transform:`matrix(1.05469 0 0 0.241063 -153.484 1120.2)`,children:(0,$.jsx)(`rect`,{x:`922.048`,y:`1195.15`,width:`1721.5`,height:`470.135`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`168.84`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,$.jsx)(`g`,{transform:`matrix(0.983656 0 0 1.0767 -62.2035 141.539)`,children:(0,$.jsx)(`path`,{d:`M2741.42,1175.93L895.832,1175.93L1125.16,621.902L2512.09,621.902L2741.42,1175.93Z`,fill:`currentColor`,fillOpacity:`0.05`,stroke:`currentColor`,strokeOpacity:`0.99`,strokeWidth:`125.26`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,$.jsx)(`g`,{transform:`translate(21.1916 0.684817)`,children:(0,$.jsx)(`path`,{d:`M1981.31,567.518C1954.86,567.518 1933.39,546.047 1933.39,519.601C1933.39,493.156 1954.86,471.685 1981.31,471.685L2146.61,471.685C2173.07,471.685 2194.53,493.138 2194.53,519.601L2194.53,688.741C2194.53,715.187 2173.05,736.658 2146.61,736.658C2120.16,736.658 2098.69,715.187 2098.69,688.741L2098.69,567.518L1981.31,567.518ZM2098.69,1252.54C2098.69,1226.1 2120.16,1204.62 2146.61,1204.62C2173.05,1204.62 2194.53,1226.1 2194.53,1252.54L2194.53,1421.68C2194.53,1448.14 2173.07,1469.6 2146.61,1469.6L1981.31,1469.6C1954.86,1469.6 1933.39,1448.13 1933.39,1421.68C1933.39,1395.24 1954.86,1373.76 1981.31,1373.76L2098.69,1373.76L2098.69,1252.54ZM1430.29,1373.76C1456.74,1373.76 1478.21,1395.24 1478.21,1421.68C1478.21,1448.13 1456.74,1469.6 1430.29,1469.6L1264.99,1469.6C1238.53,1469.6 1217.07,1448.14 1217.07,1421.68L1217.07,1252.54C1217.07,1226.1 1238.55,1204.62 1264.99,1204.62C1291.44,1204.62 1312.91,1226.1 1312.91,1252.54L1312.91,1373.76L1430.29,1373.76ZM1312.91,688.741C1312.91,715.187 1291.44,736.658 1264.99,736.658C1238.55,736.658 1217.07,715.187 1217.07,688.741L1217.07,519.601C1217.07,493.138 1238.53,471.685 1264.99,471.685L1430.29,471.685C1456.74,471.685 1478.21,493.156 1478.21,519.601C1478.21,546.047 1456.74,567.518 1430.29,567.518L1312.91,567.518L1312.91,688.741Z`,fill:`currentColor`,fillOpacity:`0.99`})})]})})}function ma({printer:e,status:t,totalPrintHours:n,onClose:r}){let{t:i}=l();(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r]);let a=[];if(a.push({label:i(`printers.model`),value:e.model??`—`}),a.push({label:i(`common.status`),value:(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium ${t?.connected?`bg-bambu-green/20 text-bambu-green`:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`}`,children:[(0,$.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${t?.connected?`bg-bambu-green`:`bg-red-400`}`}),t?.connected?i(`printers.status.available`):i(`printers.status.offline`)]})}),t?.state&&a.push({label:i(`printers.state`),value:i({IDLE:`printers.status.idle`,RUNNING:`printers.status.printing`,PAUSE:`printers.status.paused`,FINISH:`printers.status.finished`,FAILED:`printers.status.error`}[t.state]??`printers.status.unknown`)}),a.push({label:i(`printers.ipAddress`),value:(0,$.jsxs)(`span`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`font-mono`,children:e.ip_address}),(0,$.jsx)(q,{value:e.ip_address})]})}),a.push({label:i(`printers.serialNumber`),value:(0,$.jsxs)(`span`,{className:`flex items-center`,children:[(0,$.jsx)(`span`,{className:`font-mono truncate`,children:e.serial_number}),(0,$.jsx)(q,{value:e.serial_number})]})}),t?.wired_network)a.push({label:i(`printers.networkLabel`,`Network`),value:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(M,{className:`w-4 h-4 text-bambu-green`}),(0,$.jsx)(`span`,{className:`text-bambu-green`,children:i(`printers.connection.ethernet`,`Ethernet`)})]})});else if(t?.wifi_signal!=null){let e=_n(t.wifi_signal);a.push({label:i(`printers.wifiSignalLabel`),value:(0,$.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(kr,{className:`w-4 h-4 ${e.color}`}),(0,$.jsx)(`span`,{className:e.color,children:i(e.labelKey)}),(0,$.jsxs)(`span`,{className:`text-bambu-gray text-xs`,children:[`(`,t.wifi_signal,` dBm)`]})]})})}return a.push({label:i(`printers.firmware`),value:t?.firmware_version??`—`}),t?.developer_mode!=null&&a.push({label:i(`printers.developerMode`),value:(0,$.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${t.developer_mode?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:t.developer_mode?i(`printers.enabled`):i(`printers.disabled`)})}),a.push({label:i(`printers.nozzleCount`),value:e.nozzle_count}),a.push({label:i(`printers.autoArchive`),value:(0,$.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${e.auto_archive?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:e.auto_archive?i(`printers.enabled`):i(`printers.disabled`)})}),n!=null&&n>0&&a.push({label:i(`printers.totalPrintHours`),value:`${Math.round(n)}h`}),e.location&&a.push({label:i(`printers.sort.location`),value:e.location}),a.push({label:i(`printers.addedOn`),value:Ht(e.created_at)}),(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,role:`dialog`,"aria-modal":`true`,onClick:r,children:(0,$.jsx)(Rt,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(Lt,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:e.name}),(0,$.jsx)(`button`,{onClick:r,className:`p-1 hover:bg-bambu-dark rounded flex-shrink-0`,children:(0,$.jsx)(Pt,{className:`w-5 h-5 text-bambu-gray`})})]}),(0,$.jsx)(`div`,{className:`flex justify-center mb-4`,children:(0,$.jsx)(`img`,{src:tn(e.model),alt:e.model??e.name,className:`h-24 object-contain`})}),(0,$.jsx)(`div`,{className:`space-y-0`,children:a.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-2.5 border-b border-bambu-dark-tertiary last:border-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-bambu-gray whitespace-nowrap`,children:e.label}),(0,$.jsx)(`span`,{className:`text-sm text-white text-right`,children:e.value})]},t))})]})})})}var ha=0,ga=1;function _a({slotLabel:e,amsId:t,slotId:n,extruderSlots:r,isLoading:i=!1,onConfirm:a,onCancel:o}){let{t:s}=l(),[c,u]=(0,X.useState)(null);(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!i&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,i]);let d=e=>{let i=r[String(e)];return i?.ams_id===t&&i?.slot_id===n},f=[{extruderId:ga,label:s(`printers.ams.feedLeft`),taken:d(ga)},{extruderId:ha,label:s(`printers.ams.feedRight`),taken:d(ha)}],p=f.some(e=>e.extruderId===c&&e.taken);return(0,X.useEffect)(()=>{p&&u(null)},[p]),(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center p-4 z-50`,onClick:i?void 0:o,children:(0,$.jsx)(Rt,{className:`w-full max-w-md`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(Lt,{className:`p-6`,children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-white mb-2`,children:s(`printers.ams.feedTitle`,{slot:e})}),(0,$.jsx)(`p`,{className:`text-bambu-gray text-sm`,children:s(`printers.ams.feedPrompt`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-3 mt-4`,children:f.map(({extruderId:e,label:t,taken:n})=>{let r=c===e;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>u(e),disabled:n||i,title:n?s(`printers.ams.feedAlreadyLoaded`):void 0,className:`p-3 rounded-lg border text-sm transition-colors ${n?`border-transparent bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:r?`border-bambu-green/50 bg-bambu-green/10 text-white`:`border-transparent bg-bambu-dark text-white hover:bg-bambu-dark-tertiary`}`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t}),n&&(0,$.jsx)(`div`,{className:`text-xs mt-1`,children:s(`printers.ams.feedAlreadyLoaded`)})]},e)})}),(0,$.jsxs)(`div`,{className:`flex gap-3 mt-6`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:o,className:`flex-1`,disabled:i,children:s(`common.cancel`)}),(0,$.jsx)(Y,{onClick:()=>c!==null&&a(c),className:`flex-1`,disabled:c===null||i,children:i?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-4 h-4 mr-2 animate-spin`}),s(`common.loading`)]}):s(`common.confirm`)})]})]})})})}function va(e){if(!e||e.length<6)return!1;let t=parseInt(e.slice(0,2),16),n=parseInt(e.slice(2,4),16),r=parseInt(e.slice(4,6),16);return(.299*t+.587*n+.114*r)/255>.6}function ya({trayColor:e,trayType:t,isEmpty:n,emptyKind:r,slotNumber:i}){let a=r===`reset`?`#3d3d3d`:`#666`;return(0,$.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:e?`#${e}`:t?`#333`:`transparent`,borderColor:n?a:`rgba(255,255,255,0.1)`,borderStyle:n?`dashed`:`solid`},children:(0,$.jsx)(`span`,{className:`text-[6px] font-bold leading-none select-none`,style:{color:e&&va(e)?`#000`:`#fff`},children:i})})}var ba=240,xa=440,Sa=[30,60,120,240,480,720,1440],Ca=[`scheduled-dryings`],wa={ams_power_required:`printers.drying.powerRequired`,ams_retract_filament:`printers.drying.retractFilament`,ams_blocked:`printers.drying.cannotDryNow`,ams_not_found:`printers.drying.waitingAmsNotFound`,printer_offline:`printers.drying.waitingOffline`,printer_busy:`printers.drying.waitingPrinterBusy`,already_drying:`printers.drying.waitingAlreadyDrying`,interrupted:`printers.drying.waitingInterrupted`};function Ta(e){return e?wa[e]:void 0}var Ea={screen_only:`printers.drying.screenOnly`,unsupported:`printers.drying.notSupported`,did_not_start:`printers.drying.scheduleFailedDidNotStart`};function Da(e){return e?Ea[e]:void 0}function Oa(e){let t=(e??[]).map(e=>Number(e));return t.some(e=>e===1||e===8)?`printers.drying.powerRequired`:t.includes(3)?`printers.drying.retractFilament`:`printers.drying.cannotDryNow`}var ka=[{value:`all`,labelKey:`printers.filter.allStatuses`},{value:`printing`,labelKey:`printers.status.printing`},{value:`paused`,labelKey:`printers.status.paused`},{value:`idle`,labelKey:`printers.status.idle`},{value:`finished`,labelKey:`printers.status.finished`},{value:`error`,labelKey:`printers.status.error`},{value:`offline`,labelKey:`printers.status.offline`}];function Aa(e){return ka.some(t=>t.value===e)}function ja(e){return(e??.02).toFixed(3)}function Ma({k:e,reserve:t}){let{t:n}=l(),r=`text-[length:var(--pc-t8,8px)] text-bambu-gray tabular-nums leading-none truncate`;return e?(0,$.jsxs)(`div`,{className:r,title:n(`ams.kFactor`),children:[n(`ams.kFactorShort`),` `,ja(e)]}):t?(0,$.jsx)(`div`,{className:r,"aria-hidden":`true`,children:`\xA0`}):null}function Na({side:e}){let{mode:t}=ir(),{t:n}=l();return(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] text-[length:var(--pc-t10,10px)] font-bold rounded`,style:{backgroundColor:t===`dark`?`#1a4d2e`:`#e7f5e9`,color:`#00ae42`},title:n(e===`L`?`common.left`:`common.right`),children:e})}function Pa({inlet:e,title:t}){let{mode:n}=ir();return(0,$.jsx)(`span`,{className:`inline-flex items-center justify-center w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] text-[length:var(--pc-t10,10px)] font-bold rounded`,style:{backgroundColor:n===`dark`?`#1e3a5f`:`#e3f0fb`,color:`#3b82f6`},title:t,children:ur[e]})}function Fa(e,t,n,r){let i=n[String(e)];if(i)return{kind:`inlet`,inlet:i};let a=t[String(e)],o=a===void 0?r?void 0:e>=128?e-128:e:a;return o===1?{kind:`nozzle`,side:`L`}:o===0?{kind:`nozzle`,side:`R`}:null}function Ia(e,t){if(!e)return``;if(e.includes(`hardened`))return t(`printers.nozzleHardenedSteel`);if(e.includes(`stainless`))return t(`printers.nozzleStainlessSteel`);if(e.includes(`tungsten`))return t(`printers.nozzleTungstenCarbide`);if(e.length>=4){let n=e.slice(2,4);if(n===`00`)return t(`printers.nozzleStainlessSteel`);if(n===`01`)return t(`printers.nozzleHardenedSteel`);if(n===`05`)return t(`printers.nozzleTungstenCarbide`)}return e===`00`?t(`printers.nozzleStainlessSteel`):e===`01`?t(`printers.nozzleHardenedSteel`):e===`05`?t(`printers.nozzleTungstenCarbide`):e.startsWith(`H`)?t(`printers.nozzleHardenedSteel`):e}function La(e,t){return e?e.startsWith(`HH`)?t(`printers.nozzleHighFlow`):e.startsWith(`HS`)?t(`printers.nozzleStandardFlow`):``:``}function Ra({slot:e,index:t,activeStatus:n,filamentName:r,children:i}){let{t:a}=l(),[o,s]=(0,X.useState)(!1),[c,u]=(0,X.useState)(`top`),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null),m=!e.nozzle_diameter&&!e.nozzle_type,h=e.stat===1;(0,X.useEffect)(()=>{if(o&&d.current&&f.current){let e=d.current.getBoundingClientRect(),t=f.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;n<t+12&&r>n?u(`bottom`):u(`top`)}},[o]);let g=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!0),80)},_=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!1),100)};(0,X.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]);let v=Wn(e.filament_color),y=Ia(e.nozzle_type,a),b=La(e.nozzle_type,a);return(0,$.jsxs)(`div`,{ref:d,className:`relative`,onMouseEnter:g,onMouseLeave:_,children:[i,o&&(0,$.jsxs)(`div`,{ref:f,className:`
  22. absolute left-1/2 -translate-x-1/2 z-50
  23. ${c===`top`?`bottom-full mb-2`:`top-full mt-2`}
  24. animate-in fade-in-0 zoom-in-95 duration-150
  25. `,style:{maxWidth:`calc(100vw - 24px)`},children:[(0,$.jsx)(`div`,{className:`w-44 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm`,children:m?(0,$.jsxs)(`div`,{className:`px-3 py-2 text-xs text-bambu-gray text-center whitespace-nowrap`,children:[`Slot `,t+1,` — Empty`]}):(0,$.jsxs)(`div`,{className:`p-2.5 space-y-1.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleDiameter`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.nozzle_diameter,` mm`]})]}),y&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleType`)}),(0,$.jsx)(`span`,{className:`text-xs text-white font-semibold truncate max-w-[100px]`,children:y})]}),b&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleFlow`)}),(0,$.jsx)(`span`,{className:`text-xs text-white font-semibold`,children:b})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleStatus`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] font-bold px-1.5 py-0.5 rounded ${n||h?`bg-green-900/50 text-green-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:a(n?`printers.nozzleActive`:h?`printers.nozzleMounted`:`printers.nozzleDocked`)})]}),e.wear!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleWear`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.wear,`%`]})]}),e.max_temp>0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleMaxTemp`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.max_temp,`°C`]})]}),e.serial_number&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleSerial`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-mono truncate max-w-[80px]`,children:e.serial_number})]}),(v||e.filament_type)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:a(`printers.nozzleFilament`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[v&&(0,$.jsx)(`div`,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] rounded-sm border border-white/20`,style:{backgroundColor:v}}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-semibold truncate max-w-[100px]`,children:r||e.filament_type||e.filament_id||``})]})]})]})}),(0,$.jsx)(`div`,{className:`
  26. absolute left-1/2 -translate-x-1/2 w-0 h-0
  27. border-l-[6px] border-l-transparent
  28. border-r-[6px] border-r-transparent
  29. ${c===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`}
  30. `})]})]})}function za({leftSlot:e,rightSlot:t,activeNozzle:n,filamentInfo:r,children:i}){let{t:a}=l(),[o,s]=(0,X.useState)(!1),[c,u]=(0,X.useState)(`top`),d=(0,X.useRef)(null),f=(0,X.useRef)(null),p=(0,X.useRef)(null);(0,X.useEffect)(()=>{if(o&&d.current&&f.current){let e=d.current.getBoundingClientRect(),t=f.current.offsetHeight,n=e.top-56,r=window.innerHeight-e.bottom;n<t+12&&r>n?u(`bottom`):u(`top`)}},[o]);let m=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!0),80)},h=()=>{p.current&&clearTimeout(p.current),p.current=setTimeout(()=>s(!1),100)};if((0,X.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),!e&&!t)return(0,$.jsx)($.Fragment,{children:i});let g=(e,t)=>{let i=n===t,o=Ia(e.nozzle_type,a),s=La(e.nozzle_type,a),c=Wn(e.filament_color),l=e.filament_id?r?.[e.filament_id]?.name:void 0;return(0,$.jsxs)(`div`,{className:`flex-1 space-y-1.5`,children:[(0,$.jsx)(`div`,{className:`text-[length:var(--pc-t10,10px)] font-bold pb-1 border-b border-bambu-dark-tertiary/50 ${i?`text-amber-700 dark:text-amber-400`:`text-bambu-gray`}`,children:a(t===`L`?`common.left`:`common.right`)}),e.nozzle_diameter&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleDiameter`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.nozzle_diameter,` mm`]})]}),o&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleType`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-semibold`,children:o})]}),s&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleFlow`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-semibold`,children:s})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleStatus`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] font-bold px-1.5 py-0.5 rounded ${i?`bg-green-900/50 text-green-400`:`bg-bambu-dark-tertiary text-bambu-gray`}`,children:a(i?`printers.nozzleActive`:`printers.nozzleIdle`)})]}),e.wear!=null&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleWear`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.wear,`%`]})]}),t===`R`&&e.max_temp>0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleMaxTemp`)}),(0,$.jsxs)(`span`,{className:`text-xs text-white font-semibold`,children:[e.max_temp,`°C`]})]}),t===`R`&&e.serial_number&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleSerial`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-mono`,children:e.serial_number})]}),(c||e.filament_type||e.filament_id)&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:a(`printers.nozzleFilament`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[c&&(0,$.jsx)(`div`,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] rounded-sm border border-white/20`,style:{backgroundColor:c}}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-semibold truncate max-w-[100px]`,children:l||e.filament_type||e.filament_id||``})]})]})]})};return(0,$.jsxs)(`div`,{ref:d,className:`relative flex-1`,onMouseEnter:m,onMouseLeave:h,children:[i,o&&(0,$.jsxs)(`div`,{ref:f,className:`
  31. absolute left-1/2 -translate-x-1/2 z-50
  32. ${c===`top`?`bottom-full mb-2`:`top-full mt-2`}
  33. animate-in fade-in-0 zoom-in-95 duration-150
  34. `,style:{maxWidth:`calc(100vw - 24px)`},children:[(0,$.jsx)(`div`,{className:`w-96 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm`,children:(0,$.jsxs)(`div`,{className:`p-2.5 flex gap-3`,children:[e&&g(e,`L`),e&&t&&(0,$.jsx)(`div`,{className:`w-px bg-bambu-dark-tertiary/50`}),t&&g(t,`R`)]})}),(0,$.jsx)(`div`,{className:`
  35. absolute left-1/2 -translate-x-1/2 w-0 h-0
  36. border-l-[6px] border-l-transparent
  37. border-r-[6px] border-r-transparent
  38. ${c===`top`?`top-full border-t-[6px] border-t-bambu-dark-tertiary`:`bottom-full border-b-[6px] border-b-bambu-dark-tertiary`}
  39. `})]})]})}function Ba({slots:e,filamentInfo:t}){let{t:n}=l(),r=e.filter(e=>e.id>=2),i=Array.from({length:6},(e,t)=>r.find(e=>e.id===16+t)??{id:-(t+1),nozzle_type:``,nozzle_diameter:``,wear:null,stat:null,max_temp:0,serial_number:``,filament_color:``,filament_id:``,filament_type:``});return(0,$.jsxs)(`div`,{className:`text-center px-2.5 py-1.5 bg-bambu-dark rounded-lg flex-[0_1_auto] flex flex-col justify-center`,children:[(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray mb-1`,children:n(`printers.nozzleRack`)}),(0,$.jsx)(`div`,{className:`flex gap-[3px] justify-center`,children:i.map((e,n)=>{let r=!e.nozzle_diameter&&!e.nozzle_type,i=r?null:Wn(e.filament_color),a=i?nr(e.filament_color):!1;return(0,$.jsx)(Ra,{slot:e,index:n,filamentName:e.filament_id?t?.[e.filament_id]?.name:void 0,children:(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-0.5`,children:[(0,$.jsx)(`div`,{className:`w-[var(--pc-i7,28px)] h-[var(--pc-i7,28px)] rounded flex items-center justify-center cursor-default transition-colors border-b-2 ${r?`bg-bambu-dark-tertiary/20 border-bambu-dark-tertiary/20`:`bg-bambu-dark-tertiary/40 border-bambu-dark-tertiary/40`}`,style:i?{backgroundColor:i}:void 0,children:(0,$.jsx)(`span`,{"data-rack-diameter":!0,className:`text-[length:var(--pc-t10,10px)] font-semibold ${r?`text-bambu-gray/30`:a?`text-black/80`:`text-white`}`,style:i&&!a?{textShadow:`0 1px 3px rgba(0,0,0,0.9)`}:void 0,children:r?`—`:e.nozzle_diameter||`?`})}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t8,8px)] leading-none tabular-nums text-bambu-gray/70`,children:n+1})]})},e.id>=0?e.id:`empty-${n}`)})})]})}function Va({className:e}){return(0,$.jsx)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,$.jsx)(`path`,{d:`M17.8131 0.00538C18.4463 -0.15091 20.3648 3.14642 20.8264 3.84781C25.4187 10.816 35.3089 26.9368 35.9383 34.8694C37.4182 53.5822 11.882 61.3357 2.53721 45.3789C-1.73471 38.0791 0.016 32.2049 3.178 25.0232C6.99221 16.3662 12.6411 7.90372 17.8131 0.00538ZM18.3738 7.24807L17.5881 7.48441C14.4452 12.9431 10.917 18.2341 8.19369 23.9368C4.6808 31.29 1.18317 38.5479 7.69403 45.5657C17.3058 55.9228 34.9847 46.8808 31.4604 32.8681C29.2558 24.0969 22.4207 15.2913 18.3776 7.24807H18.3738Z`,fill:`#C3C2C1`})})}function Ha({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 35 53`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`path`,{d:`M17.3165 0.0038C17.932 -0.14959 19.7971 3.08645 20.2458 3.77481C24.7103 10.6135 34.3251 26.4346 34.937 34.2198C36.3757 52.5848 11.5505 60.1942 2.46584 44.534C-1.68714 37.3735 0.0148 31.6085 3.08879 24.5603C6.79681 16.0605 12.2884 7.75907 17.3165 0.0038ZM17.8615 7.11561L17.0977 7.34755C14.0423 12.7048 10.6124 17.8974 7.96483 23.4941C4.54975 30.7107 1.14949 37.8337 7.47908 44.721C16.8233 54.8856 34.01 46.0117 30.5838 32.2595C28.4405 23.6512 21.7957 15.0093 17.8652 7.11561H17.8615Z`,fill:`#C3C2C1`}),(0,$.jsx)(`path`,{d:`M5.03547 30.112C9.64453 30.4936 11.632 35.7985 16.4154 35.791C19.6339 35.7873 20.2161 33.2283 22.3853 31.6197C31.6776 24.7286 33.5835 37.4894 27.9881 44.4254C18.1878 56.5653 -1.16063 44.6013 5.03917 30.1158L5.03547 30.112Z`,fill:`#1F8FEB`})]})}function Ua({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 36 54`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`path`,{d:`M17.9625 4.48059L4.77216 26.3154L2.08228 40.2175L10.0224 50.8414H23.1594L33.3246 42.1693V30.2455L17.9625 4.48059Z`,fill:`#1F8FEB`}),(0,$.jsx)(`path`,{d:`M17.7948 0.00538C18.4273 -0.15091 20.3438 3.14642 20.8048 3.84781C25.3921 10.816 35.2715 26.9368 35.9001 34.8694C37.3784 53.5822 11.8702 61.3357 2.53562 45.3789C-1.73163 38.0829 0.0134 32.2087 3.1757 25.027C6.98574 16.3662 12.6284 7.90372 17.7948 0.00538ZM18.3549 7.24807L17.57 7.48441C14.4306 12.9431 10.9063 18.2341 8.1859 23.9368C4.67686 31.29 1.18305 38.5479 7.68679 45.5657C17.2881 55.9228 34.9476 46.8808 31.4271 32.8681C29.2249 24.0969 22.3974 15.2913 18.3587 7.24807H18.3549Z`,fill:`#C3C2C1`})]})}function Wa({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`}),(0,$.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function Ga({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`rect`,{x:`4.5`,y:`8`,width:`3`,height:`4.5`,fill:`#d4a017`,rx:`0.5`}),(0,$.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#d4a017`}),(0,$.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function Ka({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:`#c62828`,rx:`0.5`}),(0,$.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:`#c62828`}),(0,$.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:`#C3C2C1`,strokeWidth:`1`,fill:`none`})]})}function qa({className:e}){return(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,children:[(0,$.jsx)(`rect`,{x:`9.2`,y:`3.4`,width:`5.6`,height:`8.1`}),(0,$.jsx)(`rect`,{x:`6`,y:`11.5`,width:`12.1`,height:`3.7`}),(0,$.jsx)(`path`,{d:`M 7.3 15.2 L 12.1 19.6 L 16.7 15.2`})]})}function Ja({className:e,color:t,isHeating:n}){let r={"text-orange-400":`#fb923c`,"text-blue-400":`#60a5fa`,"text-green-400":`#4ade80`}[t]||`#888`,i=n?{filter:`drop-shadow(0 0 4px ${r}) drop-shadow(0 0 8px ${r})`}:{};return n?(0,$.jsxs)(`svg`,{className:e,style:i,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`rect`,{x:`4.5`,y:`3`,width:`3`,height:`9.5`,fill:r,rx:`0.5`}),(0,$.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2`,fill:r}),(0,$.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`})]}):(0,$.jsxs)(`svg`,{className:e,viewBox:`0 0 12 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:[(0,$.jsx)(`path`,{d:`M6 0.5C4.6 0.5 3.5 1.6 3.5 3V12.1C2.6 12.8 2 13.9 2 15C2 17.2 3.8 19 6 19C8.2 19 10 17.2 10 15C10 13.9 9.4 12.8 8.5 12.1V3C8.5 1.6 7.4 0.5 6 0.5Z`,stroke:r,strokeWidth:`1`,fill:`none`}),(0,$.jsx)(`circle`,{cx:`6`,cy:`15`,r:`2.5`,stroke:r,strokeWidth:`1`,fill:`none`})]})}function Ya({state:e,onClick:t}){let{t:n}=l(),r=e!==null,i=`flex items-center justify-center w-[18px] h-[18px] rounded text-[length:var(--pc-t10,10px)] transition-colors `,a;return e===!0?(i+=r?`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 hover:bg-blue-500/30 cursor-pointer`:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 cursor-default`,a=n(`printers.amsBackup.titleOn`)):e===!1?(i+=r?`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80 cursor-pointer`:`bg-bambu-dark text-bambu-gray cursor-default`,a=n(`printers.amsBackup.titleOff`)):(i+=`bg-bambu-dark text-bambu-gray/50 cursor-default`,a=n(`printers.amsBackup.titleUnknown`)),(0,$.jsx)(`button`,{type:`button`,disabled:!r,onClick:()=>r&&t(),className:i,title:a,"aria-label":a,children:r?(0,$.jsx)(Or,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(`span`,{children:`?`})})}function Xa({hidden:e,onClick:t}){let{t:n}=l(),r=n(e?`printers.externalSpool.show`:`printers.externalSpool.hide`);return(0,$.jsx)(`button`,{type:`button`,onClick:t,"aria-pressed":e,className:`flex items-center justify-center w-[18px] h-[18px] rounded transition-colors cursor-pointer ${e?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:r,"aria-label":r,children:e?(0,$.jsx)(B,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(Sn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})}function Za({humidity:e,goodThreshold:t=40,fairThreshold:n=60,onClick:r,compact:i}){let a=typeof e==`string`?parseInt(e,10):e,o=typeof t==`number`?t:40,s=typeof n==`number`?n:60,c,l;isNaN(a)?(c=`#C3C2C1`,l=`Unknown`):a<=o?(c=`#22a352`,l=`Good`):a<=s?(c=`#d4a017`,l=`Fair`):(c=`#c62828`,l=`Bad`);let u;return u=isNaN(a)||a<=o?Va:a<=s?Ha:Ua,(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Humidity: ${a}% - ${l}${r?` (click for history)`:``}`,children:[(0,$.jsx)(u,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,$.jsxs)(`span`,{className:`font-medium tabular-nums ${i?`text-[length:var(--pc-t10,10px)]`:`text-xs`}`,style:{color:c},children:[a,`%`]})]})}function Qa({temp:e,goodThreshold:t=28,fairThreshold:n=35,onClick:r,compact:i}){let a=typeof t==`number`?t:28,o=typeof n==`number`?n:35,s,c,l;return e<=a?(s=`#22a352`,c=`Good`,l=Wa):e<=o?(s=`#d4a017`,c=`Fair`,l=Ga):(s=`#c62828`,c=`Bad`,l=Ka),(0,$.jsxs)(`button`,{type:`button`,onClick:r,className:`flex items-center gap-1 ${r?`cursor-pointer hover:opacity-80 transition-opacity`:``}`,title:`Temperature: ${e}°C - ${c}${r?` (click for history)`:``}`,children:[(0,$.jsx)(l,{className:i?`w-2.5 h-3`:`w-3 h-4`}),(0,$.jsxs)(`span`,{className:`tabular-nums text-right ${i?`text-[length:var(--pc-t10,10px)] w-8`:`w-12`}`,style:{color:s},children:[e,`°C`]})]})}var $a=3e4;function eo({url:e,printName:t,className:n=`w-20 h-20`,radiusClass:r=`rounded-lg`}){let{t:i}=l(),[a,o]=(0,X.useState)(!1),[s,c]=(0,X.useState)(!1),[d,f]=(0,X.useState)(!1),p=(0,X.useRef)(null),m=(0,X.useMemo)(()=>e?u(`${e}${e.includes(`?`)?`&`:`?`}v=${encodeURIComponent(t||Date.now().toString())}`):null,[e,t]);return(0,X.useEffect)(()=>{c(!1);let e=p.current;o(!!(e?.complete&&e.naturalWidth>0))},[m]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`${n} flex-shrink-0 ${r} overflow-hidden bg-bambu-dark-tertiary flex items-center justify-center ${m&&a?`cursor-pointer`:``}`,onClick:()=>m&&a&&f(!0),children:m&&!s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`img`,{ref:p,src:m,alt:i(`printers.printPreview`),className:`w-full h-full object-cover ${a?`block`:`hidden`}`,onLoad:()=>o(!0),onError:()=>c(!0)}),!a&&(0,$.jsx)(j,{className:`w-8 h-8 text-bambu-gray`})]}):(0,$.jsx)(j,{className:`w-8 h-8 text-bambu-gray`})}),d&&m&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/80 flex items-center justify-center z-50 p-8`,onClick:()=>f(!1),children:(0,$.jsxs)(`div`,{className:`relative max-w-2xl max-h-full`,children:[(0,$.jsx)(`img`,{src:m,alt:i(`printers.printPreview`),className:`max-w-full max-h-[80vh] rounded-lg shadow-2xl`}),t&&(0,$.jsx)(`p`,{className:`text-white text-center mt-4 text-lg`,children:t})]})})]})}function to({printers:e}){let{t}=l(),n=f(),[r,i]=(0,X.useState)(0);(0,X.useEffect)(()=>{let e=!1,t=n.getQueryCache().subscribe(()=>{e||(e=!0,requestAnimationFrame(()=>{i(e=>e+1),e=!1}))});return()=>t()},[n]);let{counts:a,nextFinish:o}=(0,X.useMemo)(()=>{let t=0,r=0,i=0,a=0,o=0,s=0,c=0,l=null,u=null,d=0;return e?.forEach(e=>{let f=n.getQueryData([`printerStatus`,e.id]);if(f===void 0)s++;else if(!f.connected)o++;else{let n=f.hms_errors?Mt(f.hms_errors).length:0;switch(n>0&&c++,f.state){case`RUNNING`:t++,f.remaining_time!=null&&f.remaining_time>0&&(u===null||f.remaining_time<u)&&(u=f.remaining_time,l=e.name,d=f.progress||0);break;case`PAUSE`:r++;break;case`FINISH`:i++;break;case`FAILED`:n>0||i++;break;default:a++;break}}}),{counts:{printing:t,paused:r,finished:i,idle:a,offline:o,loading:s,error:c,total:e?.length||0},nextFinish:l&&u?{name:l,remainingMin:u,progress:d}:null}},[e,n,r]);return e?.length?(0,$.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-4 gap-y-2 text-bambu-gray`,children:[[{count:a.printing,dot:`bg-bambu-green animate-pulse`,label:t(`printers.status.printing`).toLowerCase()},{count:a.paused,dot:`bg-status-warning`,label:t(`printers.status.paused`,`paused`).toLowerCase()},{count:a.finished,dot:`bg-blue-400`,label:t(`printers.status.finished`,`finished`).toLowerCase()},{count:a.idle,dot:a.idle>0?`bg-bambu-green`:`bg-gray-500`,label:t(`printers.status.available`).toLowerCase()},{count:a.error,dot:`bg-status-error`,label:t(`printers.status.problem`).toLowerCase()},{count:a.offline,dot:`bg-gray-400`,label:t(`printers.status.offline`).toLowerCase()}].map(({count:e,dot:t,label:n})=>e>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(`div`,{className:`w-2 h-2 rounded-full ${t}`}),(0,$.jsxs)(`span`,{className:`text-bambu-gray`,children:[(0,$.jsx)(`span`,{className:`text-white font-medium`,children:e}),` `,n]})]},n)),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`w-px h-4 bg-bambu-dark-tertiary`}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-bambu-green font-medium`,children:[t(`printers.nextAvailable`),`:`]}),(0,$.jsx)(`span`,{className:`text-white font-medium`,children:o.name})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 w-full sm:w-auto`,children:[(0,$.jsx)(`div`,{className:`w-full sm:w-16 bg-bambu-dark-tertiary rounded-full h-1.5`,children:(0,$.jsx)(`div`,{className:`bg-bambu-green h-1.5 rounded-full transition-all`,style:{width:`${o.progress}%`}})}),(0,$.jsxs)(`span`,{className:`text-white font-medium`,children:[Math.round(o.progress),`%`]}),(0,$.jsxs)(`span`,{className:`text-bambu-gray`,children:[`(`,Ut(o.remainingMin*60),`)`]})]})]})]})]}):null}function no({value:e,options:t,onChange:n,fullWidth:r=!1}){let[i,a]=(0,X.useState)(!1),o=t.find(t=>t.value===e)??t[0];return(0,$.jsxs)(`div`,{className:`relative ${r?`w-full min-w-0`:``}`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`h-8 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white text-sm font-medium transition-colors hover:bg-bambu-dark-tertiary focus:outline-none focus:border-bambu-green flex items-center justify-between gap-2 ${r?`w-full`:`min-w-28`}`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:o?.label}),(0,$.jsx)(I,{className:`w-4 h-4 text-bambu-gray transition-transform ${i?`rotate-180`:``}`})]}),i&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>a(!1)}),(0,$.jsx)(`div`,{className:`absolute left-0 top-full z-20 mt-1 min-w-full rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary py-1 shadow-xl`,children:t.map(t=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>{n(t.value),a(!1)},className:`w-full px-3 py-2 text-left text-sm transition-colors hover:bg-bambu-dark-tertiary ${t.value===e?`text-bambu-green`:`text-white`}`,children:t.label},t.value))})]})]})}function ro({label:e,icon:t,children:n}){let[r,i]=(0,X.useState)(!1);return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`h-8 w-8 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,"aria-label":e,title:e,children:t}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,$.jsx)(`div`,{className:`absolute right-0 top-full z-20 mt-1 min-w-40 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark-secondary p-2 shadow-xl`,children:n})]})]})}function io({title:e,options:t=[],unit:n,customMin:r,customMax:i,customStep:a=1,widthClass:o=`w-[240px]`,popoverWidth:s=240,popoverHeight:c=280,isPending:l,onClose:u,onSubmit:d,children:f}){let p=(0,X.useRef)(null),[m,h]=(0,X.useState)(null),[g,_]=(0,X.useState)(``);(0,X.useLayoutEffect)(()=>{let e=p.current?.parentElement;if(!e)return;let t=()=>{h(xi({triggerRect:e.getBoundingClientRect(),popoverWidth:s,estimatedHeight:c,horizontalAlign:`center`}))};return t(),window.addEventListener(`resize`,t),window.addEventListener(`scroll`,t,!0),()=>{window.removeEventListener(`resize`,t),window.removeEventListener(`scroll`,t,!0)}},[s,c]);let v=n!==void 0,y=()=>{let e=Number(g);Number.isFinite(e)&&d?.(Math.round(Math.min(i??e,Math.max(r??e,e))))};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{ref:p,className:`hidden`,"aria-hidden":`true`}),(0,gi.createPortal)((0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-[1000]`,onClick:u}),(0,$.jsxs)(`div`,{className:`fixed z-[1001] flex ${o} flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,style:{top:m?.top??-9999,left:m?.left??-9999,visibility:m?`visible`:`hidden`},onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:e}),(0,$.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),t.length>0&&(0,$.jsx)(`div`,{className:`px-3 py-2.5`,children:(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-1.5`,children:t.map(e=>(0,$.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>d?.(e.value),className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:e.label},`${e.label}-${e.value}`))})}),f,v&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,$.jsxs)(`form`,{className:`flex gap-1.5 px-3 pt-2.5 pb-3`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,$.jsx)(`input`,{type:`number`,min:r,max:i,step:a,value:g,onChange:e=>_(e.target.value),placeholder:`Custom`,className:`h-8 min-w-0 flex-1 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,$.jsx)(`button`,{type:`submit`,disabled:l||g.trim()===``,className:`h-8 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})]})]}),document.body)]})}var ao=Te(be,`C`);function oo({label:e,current:t,target:n,isActive:r,isPending:i,onSubmit:a,options:o=ao}){let[s,c]=(0,X.useState)(``),l=()=>{let e=Number(s);Number.isFinite(e)&&a(Math.min(320,Math.max(0,Math.round(e))))};return(0,$.jsxs)(`div`,{className:`rounded-lg border p-2 ${r?`border-amber-500/60 dark:border-amber-400/60 bg-amber-50 dark:bg-amber-400/10`:`border-bambu-dark-tertiary bg-bambu-dark`}`,children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-xs font-medium ${r?`text-amber-700 dark:text-amber-300`:`text-white`}`,children:e}),(0,$.jsxs)(`span`,{className:`text-[10px] text-bambu-gray`,children:[Math.round(t??0),`°C`,n===void 0?``:` / ${Math.round(n)}°`]})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-2 gap-1`,children:o.map(t=>(0,$.jsx)(`button`,{type:`button`,disabled:i,onClick:()=>a(t.value),className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:t.label},`${e}-${t.value}`))}),(0,$.jsxs)(`form`,{className:`mt-1.5 flex gap-1`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,$.jsx)(`input`,{type:`number`,min:0,max:320,step:1,value:s,onChange:e=>c(e.target.value),placeholder:`Custom`,className:`h-7 min-w-0 flex-1 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-1.5 text-[11px] text-white placeholder:text-bambu-gray/60 focus:border-bambu-green focus:outline-none`}),(0,$.jsx)(`button`,{type:`submit`,disabled:i||s.trim()===``,className:`h-7 rounded-md border border-bambu-dark-tertiary bg-bambu-dark-secondary px-2 text-[11px] font-medium text-white transition-colors hover:bg-bambu-dark-tertiary disabled:cursor-not-allowed disabled:opacity-50`,children:`Set`})]})]})}var so=[`error`,`printing`,`paused`,`finished`,`idle`,`offline`],co={error:{labelKey:`printers.status.problem`,dot:`bg-status-error`},printing:{labelKey:`printers.status.printing`,dot:`bg-bambu-green animate-pulse`},paused:{labelKey:`printers.status.paused`,dot:`bg-status-warning`},finished:{labelKey:`printers.status.finished`,dot:`bg-blue-400`},idle:{labelKey:`printers.status.idle`,dot:`bg-bambu-green`},offline:{labelKey:`printers.status.offline`,dot:`bg-gray-400`}};function lo(e){if(!e?.connected)return`offline`;if((e.hms_errors?Mt(e.hms_errors):[]).length>0)return`error`;switch(e.state){case`RUNNING`:return`printing`;case`PAUSE`:return`paused`;case`FINISH`:return`finished`;case`FAILED`:return`finished`;default:return`idle`}}function uo(e,t){if(t)return t;switch(e){case`RUNNING`:return`Printing`;case`PAUSE`:return`Paused`;case`FINISH`:return`Finished`;case`FAILED`:return`Failed`;case`IDLE`:return`Idle`;default:return e?e.charAt(0)+e.slice(1).toLowerCase():`Idle`}}var fo=new Set([`X1C`,`X1`,`X1E`,`X2D`,`P1S`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`]),po=new Set([`P2S`,`X2D`]);function mo({ams:e,printerId:t,label:n,amsLabels:r,canEdit:a,onSaved:o,children:s}){let{t:c}=l(),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(`top`),[m,h]=(0,X.useState)(``),[g,_]=(0,X.useState)(!1),[v,y]=(0,X.useState)(null),[b,x]=(0,X.useState)(!1),S=(0,X.useRef)(null),C=(0,X.useRef)(null),w=(0,X.useRef)(null);(0,X.useEffect)(()=>{u&&(h(r?.[e.id]??``),y(null),requestAnimationFrame(()=>{if(S.current&&C.current){let e=S.current.getBoundingClientRect(),t=e.top-56,n=window.innerHeight-e.bottom;p(t<C.current.offsetHeight+12&&n>t?`bottom`:`top`)}}))},[u,r,e.id]);let T=()=>{w.current&&clearTimeout(w.current),w.current=setTimeout(()=>d(!0),80)},E=()=>{w.current&&clearTimeout(w.current),b||(w.current=setTimeout(()=>d(!1),200))};(0,X.useEffect)(()=>()=>{w.current&&clearTimeout(w.current)},[]);let D=async()=>{if(a){_(!0),y(null);try{let n=m.trim();n?await i.saveAmsLabel(t,e.id,n,e.serial_number):await i.deleteAmsLabel(t,e.id,e.serial_number),o(),d(!1)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}};return(0,$.jsxs)(`div`,{ref:S,className:`relative inline-block`,onMouseEnter:T,onMouseLeave:E,children:[s,u&&(0,$.jsx)(`div`,{ref:C,className:`
  40. absolute left-0 z-50
  41. ${f===`top`?`bottom-full mb-2`:`top-full mt-2`}
  42. animate-in fade-in-0 zoom-in-95 duration-150
  43. `,style:{maxWidth:`calc(100vw - 24px)`},onMouseEnter:T,onMouseLeave:E,children:(0,$.jsxs)(`div`,{className:`w-52 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-xl overflow-hidden backdrop-blur-sm p-2.5 space-y-2`,children:[(0,$.jsx)(`div`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:n}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] tracking-wide text-bambu-gray font-medium shrink-0`,children:c(`printers.amsPopup.serialNumber`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-mono truncate`,children:e.serial_number||`—`})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] tracking-wide text-bambu-gray font-medium shrink-0`,children:c(`printers.amsPopup.firmwareVersion`)}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-white font-mono truncate`,children:e.sw_ver||`—`})]}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray font-medium shrink-0`,children:c(`printers.amsPopup.friendlyName`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary/50`})]}),(0,$.jsx)(`input`,{type:`text`,value:m,onChange:e=>a&&h(e.target.value),onKeyDown:e=>e.key===`Enter`&&D(),onFocus:()=>x(!0),onBlur:()=>{x(!1),w.current&&clearTimeout(w.current),w.current=setTimeout(()=>d(!1),200)},placeholder:a?c(`printers.amsPopup.friendlyNamePlaceholder`):r?.[e.id]||`—`,disabled:!a,title:a?void 0:c(`printers.amsPopup.noEditPermission`),className:`w-full bg-bambu-dark border border-bambu-dark-tertiary rounded px-2 py-1 text-xs text-white placeholder-bambu-gray/60 focus:outline-none focus:border-bambu-green disabled:opacity-50 disabled:cursor-not-allowed`,maxLength:100}),a&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[v&&(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t10,10px)] text-red-700 dark:text-red-400 break-words`,children:v}),(0,$.jsxs)(`div`,{className:`flex gap-1 justify-end`,children:[(0,$.jsx)(`button`,{onClick:D,disabled:g,className:`px-2 py-0.5 text-[length:var(--pc-t10,10px)] bg-bambu-green text-white rounded hover:bg-bambu-green/80 disabled:opacity-50`,children:c(`printers.amsPopup.save`)}),r?.[e.id]&&(0,$.jsx)(`button`,{onClick:async()=>{if(a){_(!0),y(null);try{await i.deleteAmsLabel(t,e.id,e.serial_number),o(),d(!1)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(!1)}}},disabled:g,className:`px-2 py-0.5 text-[length:var(--pc-t10,10px)] bg-bambu-dark-tertiary text-bambu-gray rounded hover:bg-bambu-dark-tertiary/70 disabled:opacity-50`,children:c(`printers.amsPopup.clear`)})]})]})]})]})})]})}var ho={PLA:{n3f:45,n3s:45,n3f_hours:12,n3s_hours:12},PETG:{n3f:65,n3s:65,n3f_hours:12,n3s_hours:12},TPU:{n3f:65,n3s:75,n3f_hours:12,n3s_hours:18},ABS:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},ASA:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:12},PC:{n3f:65,n3s:80,n3f_hours:12,n3s_hours:8},PVA:{n3f:65,n3s:85,n3f_hours:12,n3s_hours:18}},go={1:1,2:1,3:1.2,4:1.4};function _o(e){let t=go[e]??1,n=e=>`${Math.round(e*t*10)/10}px`;return{"--pc-t8":n(8),"--pc-t9":n(9),"--pc-t10":n(10),"--pc-t11":n(11),"--pc-i2":n(8),"--pc-i25":n(10),"--pc-i3":n(12),"--pc-i35":n(14),"--pc-i4":n(16),"--pc-i5":n(20),"--pc-i7":n(28)}}function vo({printerId:e,dryingActive:t,timeFormat:n}){let{t:r}=l(),a=f(),{showToast:o}=te(),{data:s=[]}=p({queryKey:Ca,queryFn:()=>i.listScheduledDryings(),refetchInterval:3e4});(0,X.useEffect)(()=>{t&&a.invalidateQueries({queryKey:Ca})},[t,a]);let c=m({mutationFn:e=>i.cancelScheduledDrying(e),onSuccess:()=>a.invalidateQueries({queryKey:Ca}),onError:e=>o(e.message||r(`printers.drying.scheduleFailed`),`error`)}),u=s.filter(t=>t.printer_id===e&&(t.status===`pending`||t.status===`failed`));return u.length===0?null:(0,$.jsx)(`div`,{className:`mt-2 space-y-1`,children:u.map(e=>{let t=e.status===`failed`,i=Ta(e.waiting_reason),a=Da(e.error_code);return(0,$.jsxs)(`div`,{"data-testid":t?`scheduled-drying-failed`:`scheduled-drying-pending`,className:`flex items-center justify-between px-2 py-1 rounded-lg text-[length:var(--pc-t11,11px)] ${t?`bg-red-500/10 border border-red-500/30`:`bg-amber-500/10 border border-amber-500/30`}`,children:[(0,$.jsx)(`span`,{className:t?`text-red-700 dark:text-red-400`:`text-amber-700 dark:text-amber-400`,children:t?r(`printers.drying.scheduleFailedReason`,{reason:a?r(a):e.error_message||r(`printers.drying.scheduleFailedUnknown`)}):(0,$.jsxs)($.Fragment,{children:[e.start_after?r(`printers.drying.scheduledFor`,{time:Bt(e.start_after,n)}):r(`printers.drying.scheduledAsap`),i&&(0,$.jsx)(`span`,{className:`ml-1 opacity-80`,children:r(i)})]})}),(0,$.jsx)(`button`,{onClick:()=>c.mutate(e.id),disabled:c.isPending,title:r(t?`printers.drying.dismissFailed`:`printers.drying.cancelScheduled`),className:`text-bambu-gray hover:text-red-400 transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]},e.id)})})}function yo({printer:e,hideIfDisconnected:t,maintenanceInfo:n,viewMode:r=`expanded`,cardSize:o=2,amsThresholds:s,spoolmanEnabled:c=!1,linkedSpools:u,spoolmanUrl:d,spoolmanSyncMode:h,onGetAssignment:_,onUnassignSpool:v,spoolmanSpools:y,spoolmanSlotAssignments:b,spoolmanLoading:T=!1,onUnassignSpoolmanSpool:D,timeFormat:O=`system`,cameraViewMode:k=`window`,onOpenEmbeddedCamera:A,onSelectCameraViewMode:j,checkPrinterFirmware:P=!0,dryingPresets:F=ho,requirePlateClear:R=!1,selectionMode:z=!1,isSelected:ie=!1,onToggleSelect:ae,onOpenCompactCard:V,nozzleTempPresets:se=be,bedTempPresets:le=Ce,chamberTempPresets:de=we,fanSpeedPresets:pe=Se,aiDetectionEnabled:he=!1,aiDetection:U,aiLastError:ge=null}){let{t:W}=l(),G=f(),xe=Tn(),{showToast:q}=te(),{hasPermission:J,canModify:De,authEnabled:Ae,isAdmin:je}=lr(),[Me,Pe]=(0,X.useState)(!1),[Fe,Ie]=(0,X.useState)(!1),[Le,Re]=(0,X.useState)(!0),[ze,Be]=(0,X.useState)(!1),[Ve,He]=(0,X.useState)(!1),[Ue,We]=(0,X.useState)(!1),[Ge,Ke]=(0,X.useState)(!1),[qe,Je]=(0,X.useState)(!1),[Ye,Xe]=(0,X.useState)(null),[Ze,Qe]=(0,X.useState)(!1),[$e,et]=(0,X.useState)(!1),[tt,nt]=(0,X.useState)(!1),[rt,it]=(0,X.useState)(()=>Ni(e.id)),at=(0,X.useCallback)(()=>{it(t=>{let n=!t;return Pi(e.id,n),n})},[e.id]),[ot,st]=(0,X.useState)(!1),[ct,lt]=(0,X.useState)(!1),[ut,dt]=(0,X.useState)(null),[ft,pt]=(0,X.useState)(null),[mt,ht]=(0,X.useState)(null),[gt,_t]=(0,X.useState)(null),[vt,yt]=(0,X.useState)(10),[bt,xt]=(0,X.useState)(!1),[St,Ct]=(0,X.useState)(!1),[wt,Tt]=(0,X.useState)(!1),[Et,Dt]=(0,X.useState)(!1),[Nt,Ft]=(0,X.useState)(!1),It=(0,X.useCallback)(()=>Dt(!1),[]),[zt,Bt]=(0,X.useState)(null),[Gt,Kt]=(0,X.useState)(null),[Jt,Yt]=(0,X.useState)(`n3f`),[en,pn]=(0,X.useState)(`PLA`),[bn,Sn]=(0,X.useState)(50),[wn,En]=(0,X.useState)(4),[jn,Mn]=(0,X.useState)(!1),[Nn,Fn]=(0,X.useState)(`now`),[Rn,Wn]=(0,X.useState)(120),[qn,Jn]=(0,X.useState)(``),[Yn,tr]=(0,X.useState)(null),[nr,rr]=(0,X.useState)(null),ir=(0,X.useCallback)((e,t)=>{let n=ki(e.tray.find(e=>e.tray_type)?.tray_type,F),r=F[n]??ho.PLA,i=e.module_type;pn(n),Sn(r[i]||r.n3f),En(i===`n3s`?r.n3s_hours:r.n3f_hours),Mn(!1),Fn(`now`),Wn(120),Jn(``),Yt(e.module_type),Kt(e.id),rr(t)},[F]);(0,X.useLayoutEffect)(()=>{if(Gt===null||!nr)return;let e=()=>{tr(xi({triggerRect:nr.getBoundingClientRect(),popoverWidth:ba,estimatedHeight:xa,horizontalAlign:`center`}))};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[Gt,nr]);let or=(0,X.useRef)(null),dr=(0,X.useRef)(!1),[pr,mr]=(0,X.useState)(null),[hr,_r]=(0,X.useState)(!1),[Cr,wr]=(0,X.useState)(!1),Or=(0,X.useRef)(null),[Ar,Mr]=(0,X.useState)(null),Nr=(0,X.useRef)(0),[Pr,Fr]=(0,X.useState)(null),[Ir,Lr]=(0,X.useState)(null),[Rr,zr]=(0,X.useState)(null),[Br,Vr]=(0,X.useState)(null),[Hr,Ur]=(0,X.useState)(null),[Wr,Gr]=(0,X.useState)(!1),[Z,Kr]=(0,X.useState)(null),[qr,Jr]=(0,X.useState)(!1),[Yr,Xr]=(0,X.useState)(!1),[Zr,Qr]=(0,X.useState)(null),[$r,ei]=(0,X.useState)(!1),[ti,ni]=(0,X.useState)(!1),{data:Q}=p({queryKey:[`printerStatus`,e.id],queryFn:()=>i.getPrinterStatus(e.id),refetchInterval:3e4}),{data:ri}=p({queryKey:[`firmwareUpdate`,e.id],queryFn:()=>a.checkPrinterUpdate(e.id),staleTime:300*1e3,refetchInterval:300*1e3,enabled:P&&J(`firmware:read`)}),ii=(0,X.useMemo)(()=>{let e=new Set;if(Q?.ams)for(let t of Q.ams)for(let n of t.tray||[])n.tray_info_idx&&e.add(n.tray_info_idx);for(let t of Q?.vt_tray??[])t.tray_info_idx&&e.add(t.tray_info_idx);if(Q?.nozzle_rack)for(let t of Q.nozzle_rack)t.filament_id&&e.add(t.filament_id);return Array.from(e)},[Q?.ams,Q?.vt_tray,Q?.nozzle_rack]),ai=(0,X.useMemo)(()=>{let e=new Set;if(Q?.ams)for(let t of Q.ams)for(let n of t.tray||[])n.tray_type&&e.add(n.tray_type.toUpperCase());for(let t of Q?.vt_tray??[])t.tray_type&&e.add(t.tray_type.toUpperCase());return e},[Q?.ams,Q?.vt_tray]),oi=(0,X.useMemo)(()=>{let e=new Set;if(Q?.ams){for(let t of Q.ams)for(let n of t.tray||[])if(n.tray_type&&n.tray_color){let t=n.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${n.tray_type.toUpperCase()}:${t}`)}}for(let t of Q?.vt_tray??[])if(t.tray_type&&t.tray_color){let n=t.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${t.tray_type.toUpperCase()}:${n}`)}return e},[Q?.ams,Q?.vt_tray]),si=(0,X.useMemo)(()=>{let e=new Set;if(Q?.ams){for(let t of Q.ams)for(let n of t.tray||[])if(n.tray_type&&n.tray_color){let t=n.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${n.tray_type.toUpperCase()}:${t}:${n.tray_info_idx||``}`)}}for(let t of Q?.vt_tray??[])if(t.tray_type&&t.tray_color){let n=t.tray_color.replace(`#`,``).toLowerCase().slice(0,6);e.add(`${t.tray_type.toUpperCase()}:${n}:${t.tray_info_idx||``}`)}return e},[Q?.ams,Q?.vt_tray]),{data:ci}=p({queryKey:[`filamentInfo`,ii],queryFn:()=>i.getFilamentInfo(ii),enabled:ii.length>0,staleTime:300*1e3}),{data:li}=p({queryKey:[`slotPresets`,e.id],queryFn:()=>i.getSlotPresets(e.id),staleTime:120*1e3}),ui=Q?.state===`RUNNING`||Q?.state===`PAUSE`?Q?.current_archive_id??null:null,{data:di}=p({queryKey:[`archive-plates`,ui],queryFn:()=>i.getArchivePlates(ui),enabled:ui!=null,staleTime:300*1e3}),fi=!di?.is_multi_plate||Q?.current_plate_id==null?null:di.plates.find(e=>e.index===Q.current_plate_id)?.name||W(`printers.plateNumber`,`Plate {{number}}`,{number:Q.current_plate_id}),{data:pi,refetch:mi}=p({queryKey:[`amsLabels`,e.id],queryFn:()=>i.getAmsLabels(e.id),staleTime:300*1e3}),[hi,gi]=(0,X.useState)(null);(0,X.useEffect)(()=>{Q?.wifi_signal!=null&&gi(Q.wifi_signal)},[Q?.wifi_signal]);let _i=Q?.wifi_signal??hi,yi=(0,X.useRef)(void 0);(0,X.useEffect)(()=>{Q?.connected!==void 0&&(yi.current=Q.connected)},[Q?.connected]);let Si=Q?.connected??yi.current,Ci=(0,X.useRef)({});(0,X.useEffect)(()=>{Q?.ams_extruder_map&&Object.keys(Q.ams_extruder_map).length>0&&(Ci.current=Q.ams_extruder_map)},[Q?.ams_extruder_map]);let wi=Q?.ams_extruder_map&&Object.keys(Q.ams_extruder_map).length>0?Q.ams_extruder_map:Ci.current,Ti=(0,X.useRef)({});(0,X.useEffect)(()=>{Q?.ams_switch_inlet&&Object.keys(Q.ams_switch_inlet).length>0&&(Ti.current=Q.ams_switch_inlet)},[Q?.ams_switch_inlet]);let Ei=Q?.fila_switch?.installed===!0,Oi=Q?.ams_switch_inlet&&Object.keys(Q.ams_switch_inlet).length>0?Q.ams_switch_inlet:Ti.current,ji=(0,X.useRef)([]);(0,X.useEffect)(()=>{Q?.ams&&Q.ams.length>0&&(ji.current=Q.ams)},[Q?.ams]);let Mi=Q?.ams&&Q.ams.length>0?Q.ams:ji.current,Fi=Mi.some(e=>e.tray.some(e=>e.k))||(Q?.vt_tray??[]).some(e=>e.k);(0,X.useEffect)(()=>{if(!pr)return;let e=Mi.find(e=>e.id===pr.amsId);e&&(e.dry_time>0||e.dry_status>0)&&mr(null)},[pr,Mi]),(0,X.useEffect)(()=>{if(!pr)return;let e=setTimeout(()=>{mr(null),q(W(`printers.drying.toastNotStarted`),`error`)},$a);return()=>clearTimeout(e)},[pr,q,W]);let Ii=(0,X.useRef)(void 0),Li=Q?.tray_now;Li!==void 0&&Li!==255?Ii.current=Li:Li===255&&(Ii.current=void 0);let Ri=Li!==void 0&&Li!==255?Li:Ii.current,zi=Q?.expected_tray??null,Bi=Q?.previous_tray??null,Hi=e=>{if(e===null)return null;if(e===254)return W(`printers.expectedSlot.external`);if(e>=128&&e<=135)return pi?.[e]||Cn(e,1);let t=Math.floor(e/4),n=e%4;return W(`printers.expectedSlot.label`,{ams:pi?.[t]||Cn(t,4),slot:n+1})},Ui=Q?.state===`PAUSE`?{expectedSlotLabel:Hi(zi),ranOutSlotLabel:Hi(Bi)}:null,{data:Wi}=p({queryKey:[`smartPlugByPrinter`,e.id],queryFn:()=>i.getSmartPlugByPrinter(e.id)}),{data:Gi}=p({queryKey:[`scriptPlugsByPrinter`,e.id],queryFn:()=>i.getScriptPlugsByPrinter(e.id)}),{data:Ki}=p({queryKey:[`smartPlugStatus`,Wi?.id],queryFn:()=>Wi?i.getSmartPlugStatus(Wi.id):null,enabled:!!Wi,refetchInterval:1e4}),{data:qi}=p({queryKey:[`queue`,e.id,`pending`],queryFn:()=>i.getQueue(e.id,`pending`)}),Ji=(0,X.useMemo)(()=>qi?.length?nn(qi,ai,oi,si).length:0,[qi,ai,oi,si]),{data:Zi}=p({queryKey:[`queue`,e.id,`printing`],queryFn:()=>i.getQueue(e.id,`printing`),enabled:Q?.state===`RUNNING`}),{data:ta}=p({queryKey:[`currentPrintUser`,e.id],queryFn:()=>i.getCurrentPrintUser(e.id),enabled:Q?.state===`RUNNING`}),ra=Zi?.[0]?.created_by_username||ta?.username,{data:ia}=p({queryKey:[`archives`,`last-per-printer`],queryFn:()=>i.getLastArchivePerPrinter(),select:t=>t.find(t=>t.printer_id===e.id)}),aa=Q?.state===`RUNNING`||Q?.state===`PAUSE`,sa=R&&Q?.awaiting_plate_clear===!0,ca=ia&&ia.status===`completed`&&ia.confirm_requested&&ia.user_verdict==null&&De(`archives`,`update`,ia.created_by_id)?ia:null,la=sa&&!aa,ha=Q?.current_print&&aa?vi(Q.subtask_name||Q.current_print||null,Q.gcode_file,W,fi):null,[ga,va]=(0,X.useState)(null);(0,X.useEffect)(()=>{ha?va({name:ha,coverUrl:Q?.cover_url??null}):sa||va(null)},[ha,sa,Q?.cover_url]);let wa=!R||!Q?.connected?null:aa?{label:W(`printers.plateStatus.inUse`),className:`bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400`}:Q.awaiting_plate_clear?{label:W(`printers.plateStatus.notCleared`),className:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`}:{label:W(`printers.plateStatus.cleared`),className:`bg-status-ok/20 text-status-ok`},Ta=wa?(0,$.jsx)(`span`,{className:`inline-flex flex-shrink-0 items-center rounded-full px-2 py-0.5 text-[length:var(--pc-t10,10px)] font-medium ${wa.className}`,children:wa.label}):null,Ea=t&&Si===!1,Da=m({mutationFn:t=>i.deletePrinter(e.id,t.deleteArchives),onSuccess:()=>{G.invalidateQueries({queryKey:[`printers`]}),G.invalidateQueries({queryKey:[`archives`]}),G.invalidateQueries({queryKey:[`maintenanceOverview`]})},onError:e=>q(e.message||W(`printers.toast.failedToDelete`),`error`)}),ka=m({mutationFn:()=>i.connectPrinter(e.id),onSuccess:()=>{G.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),Aa=m({mutationFn:()=>i.refreshPrinterStatus(e.id),onSuccess:()=>{G.invalidateQueries({queryKey:[`printerStatus`,e.id]}),q(W(`printers.forceRefreshSuccess`),`success`)},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Ia=m({mutationFn:e=>i.unlinkSpool(e),onSuccess:e=>{q(W(`spoolman.unlinkSuccess`)||e?.message,`success`),G.invalidateQueries({queryKey:[`linked-spools`]}),G.invalidateQueries({queryKey:[`unlinked-spools`]}),G.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})},onError:e=>{q(e.message||W(`spoolman.unlinkFailed`),`error`)}}),La=m({mutationFn:({amsId:t,temp:n,duration:r,filament:a,rotateTray:o})=>i.startDrying(e.id,t,n,r,a,o),onSuccess:(t,{amsId:n})=>{Kt(null),mr({amsId:n}),q(W(`printers.drying.toastCommandSent`),`success`),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Va=m({mutationFn:t=>i.createScheduledDrying({printer_id:e.id,ams_id:t.amsId,temp:t.temp,duration_hours:t.duration,filament:t.filament,rotate_tray:t.rotateTray,start_after:t.startAfter}),onSuccess:()=>{G.invalidateQueries({queryKey:Ca}),Kt(null)},onError:e=>q(e.message||W(`printers.drying.scheduleFailed`),`error`)}),Ha=m({mutationFn:t=>i.stopDrying(e.id,t),onSuccess:()=>{mr(null),q(W(`printers.drying.toastStopped`),`success`),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Ua=m({mutationFn:t=>i.setAmsFilamentBackup(e.id,t),onSuccess:(t,n)=>{G.invalidateQueries({queryKey:[`printerStatus`,e.id]}),G.invalidateQueries({queryKey:[`printer-status`,e.id]}),q(W(n?`printers.amsBackup.toastEnabled`:`printers.amsBackup.toastDisabled`),`success`)},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Wa=m({mutationFn:e=>Wi?i.controlSmartPlug(Wi.id,e):Promise.reject(`No plug`),onSuccess:()=>{G.invalidateQueries({queryKey:[`smartPlugStatus`,Wi?.id]})}}),Ga=m({mutationFn:e=>Wi?i.updateSmartPlug(Wi.id,{auto_off:e}):Promise.reject(`No plug`),onSuccess:()=>{G.invalidateQueries({queryKey:[`smartPlugByPrinter`,e.id]}),G.invalidateQueries({queryKey:[`smart-plugs`]})}}),Ka=m({mutationFn:({id:e,action:t})=>i.controlSmartPlug(e,t),onSuccess:()=>{q(W(`printers.toast.scriptTriggered`))},onError:e=>q(e.message||W(`printers.toast.failedToRunScript`),`error`)}),to=m({mutationFn:()=>i.stopPrint(e.id),onSuccess:()=>{q(W(`printers.toast.printStopped`)),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToStopPrint`),`error`)}),ro=m({mutationFn:()=>i.pausePrint(e.id),onSuccess:()=>{q(W(`printers.toast.printPaused`)),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToPausePrint`),`error`)}),ao=m({mutationFn:()=>i.resumePrint(e.id),onSuccess:()=>{q(W(`printers.toast.printResumed`)),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToResumePrint`),`error`)}),so=m({mutationFn:()=>i.clearPlate(e.id),onSuccess:()=>{q(W(`queue.clearPlateSuccess`)),G.setQueryData([`printerStatus`,e.id],e=>e&&{...e,awaiting_plate_clear:!1}),G.invalidateQueries({queryKey:[`printerStatus`,e.id]}),G.invalidateQueries({queryKey:[`queue`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),[co,lo]=(0,X.useState)(!1),yo=m({mutationFn:e=>i.updateArchive(ca.id,{user_verdict:e,user_verdict_source:`printer_card`}),onSuccess:()=>{q(W(`confirmOutcome.savedGood`),`success`),G.invalidateQueries({queryKey:[`archives`]})},onError:e=>q(e.message||W(`confirmOutcome.saveFailed`),`error`)}),bo=(0,$.jsxs)($.Fragment,{children:[ca&&(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`flex-1 min-w-0 truncate text-xs text-bambu-gray`,title:ca.print_name||ca.filename,children:W(`confirmOutcome.cardPrompt`)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>lo(!0),disabled:yo.isPending,className:`p-1.5 rounded-lg border border-red-500/40 text-red-500 hover:bg-red-500/10 transition-colors`,title:W(`confirmOutcome.reject`),children:(0,$.jsx)(mn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>yo.mutate(`good`),disabled:yo.isPending,className:`p-1.5 rounded-lg border border-bambu-green/50 text-bambu-green hover:bg-bambu-green/10 transition-colors`,title:W(`confirmOutcome.good`),children:(0,$.jsx)(Xn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>so.mutate(),disabled:so.isPending||!J(`printers:clear_plate`),className:`mt-2 w-full inline-flex items-center justify-center gap-2 px-3 py-1.5 rounded-lg bg-yellow-100 dark:bg-yellow-500/20 border border-yellow-300 dark:border-yellow-400/40 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/30 transition-colors text-xs font-medium disabled:opacity-50`,title:J(`printers:clear_plate`)?W(`printers.plateStatus.markCleared`):W(`printers.permission.noControl`),children:[so.isPending?(0,$.jsx)(H,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] animate-spin`}):(0,$.jsx)(pa,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`printers.plateStatus.markCleared`)]}),co&&ca&&(0,$.jsx)(cr,{archiveId:ca.id,onClose:()=>lo(!1)})]}),Co=m({mutationFn:({target:t,nozzle:n})=>i.setNozzleTemperature(e.id,t,n),onSuccess:t=>{_t(null),q(t.message),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),wo=m({mutationFn:t=>i.setBedTemperature(e.id,t),onSuccess:t=>{_t(null),q(t.message),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),To=m({mutationFn:t=>i.setChamberTemperature(e.id,t),onSuccess:t=>{_t(null),q(t.message),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Eo=m({mutationFn:({fan:t,speed:n})=>i.setFanSpeed(e.id,t,n),onMutate:async({fan:t,speed:n})=>{await G.cancelQueries({queryKey:[`printerStatus`,e.id]});let r=G.getQueryData([`printerStatus`,e.id]),i={part:`cooling_fan_speed`,aux:`big_fan1_speed`,aux2:`left_aux_fan_speed`,chamber:`big_fan2_speed`}[t];return G.setQueryData([`printerStatus`,e.id],e=>e&&{...e,[i]:n}),{previousStatus:r}},onSuccess:t=>{_t(null),q(t.message),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&G.setQueryData([`printerStatus`,e.id],r.previousStatus),q(t.message||W(`printers.toast.failedToSendCommand`),`error`)}}),Do=m({mutationFn:t=>i.selectExtruder(e.id,t),onMutate:async t=>{await G.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=G.getQueryData([`printerStatus`,e.id]);return G.setQueryData([`printerStatus`,e.id],e=>e&&{...e,active_extruder:t}),{previousStatus:n}},onSuccess:t=>{_t(null),q(t.message),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})},onError:(t,n,r)=>{r?.previousStatus&&G.setQueryData([`printerStatus`,e.id],r.previousStatus),q(t.message||W(`printers.toast.failedToSendCommand`),`error`)}}),Oo=m({mutationFn:t=>i.setChamberLight(e.id,t),onMutate:async t=>{await G.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=G.getQueryData([`printerStatus`,e.id]);return G.setQueryData([`printerStatus`,e.id],e=>({...e,chamber_light:t})),{previousStatus:n}},onSuccess:(e,t)=>{q(`Chamber light ${t?`on`:`off`}`)},onError:(t,n,r)=>{r?.previousStatus&&G.setQueryData([`printerStatus`,e.id],r.previousStatus),q(t.message||W(`printers.toast.failedToControlChamberLight`),`error`)}}),ko=m({mutationFn:t=>i.setPrintSpeed(e.id,t),onMutate:async t=>{await G.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=G.getQueryData([`printerStatus`,e.id]);return G.setQueryData([`printerStatus`,e.id],e=>({...e,speed_level:t})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&G.setQueryData([`printerStatus`,e.id],r.previousStatus),q(t.message||W(`printers.toast.failedToSetSpeed`),`error`)}}),Ao=m({mutationFn:t=>i.setAirductMode(e.id,t),onMutate:async t=>{await G.cancelQueries({queryKey:[`printerStatus`,e.id]});let n=G.getQueryData([`printerStatus`,e.id]);return G.setQueryData([`printerStatus`,e.id],e=>({...e,airduct_mode:t===`cooling`?0:1})),{previousStatus:n}},onError:(t,n,r)=>{r?.previousStatus&&G.setQueryData([`printerStatus`,e.id],r.previousStatus),q(t.message||W(`printers.toast.failedToSendCommand`),`error`)}}),jo=m({mutationFn:({distance:t})=>i.bedJog(e.id,t),onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Mo=m({mutationFn:({x:t,y:n})=>i.xyJog(e.id,t,n),onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),No=m({mutationFn:t=>i.extruderJog(e.id,t),onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Po=m({mutationFn:t=>i.homeAxes(e.id,t),onSuccess:()=>{q(W(`printers.bedJog.homingStarted`))},onError:e=>q(e.message||W(`printers.toast.failedToSendCommand`),`error`)}),Fo=m({mutationFn:t=>i.updatePrinter(e.id,{plate_detection_enabled:t}),onSuccess:()=>{G.invalidateQueries({queryKey:[`printers`]}),q(Fo.variables?W(`printers.toast.plateCheckEnabled`):W(`printers.toast.plateCheckDisabled`))},onError:e=>q(e.message||W(`printers.toast.failedToUpdateSetting`),`error`)}),Io=m({mutationFn:t=>i.updatePrinter(e.id,{is_active:t}),onSuccess:(t,n)=>{G.invalidateQueries({queryKey:[`printers`]}),G.invalidateQueries({queryKey:[`printerStatus`,e.id]}),q(W(n?`printers.maintenance.toastExited`:`printers.maintenance.toastEntered`,{name:e.name}),`success`)},onError:e=>q(e.message||W(`printers.toast.failedToUpdateSetting`),`error`)}),[Lo,Ro]=(0,X.useState)(!1),zo=()=>{Q?.state===`RUNNING`||Q?.state===`PAUSE`?Ro(!0):Io.mutate(!1)},Bo=(Q?.state===`RUNNING`||Q?.state===`PAUSE`)&&(Q?.printable_objects_count??0)>=2,{data:Vo}=p({queryKey:[`printableObjects`,e.id],queryFn:()=>i.getPrintableObjects(e.id),enabled:St||Bo,refetchInterval:St?5e3:Bo?3e4:!1}),[Ho,Uo]=(0,X.useState)(null),Wo=(0,X.useRef)(!1),Go=(0,X.useRef)(null),Ko=(0,X.useRef)(!1),qo=m({mutationFn:({amsId:t,slotId:n})=>i.refreshAmsSlot(e.id,t,n),onMutate:({amsId:e,slotId:t})=>{Go.current&&clearTimeout(Go.current),Wo.current=!1,Ko.current=!1,Uo({amsId:e,slotId:t}),setTimeout(()=>{Ko.current=!0},2e3),Go.current=setTimeout(()=>{Uo(null)},3e4)},onSuccess:e=>{q(e.message||W(`printers.toast.rfidRereadInitiated`))},onError:e=>{q(e.message||W(`printers.toast.failedToRereadRfid`),`error`),Go.current&&clearTimeout(Go.current),Uo(null)}}),Jo=m({mutationFn:({trayId:t,extruderId:n})=>i.loadAmsTray(e.id,t,n),onSuccess:e=>{Zo(null),q(e.message||W(`printers.toast.loadInitiated`))},onError:e=>{Zo(null),q(e.message||W(`printers.toast.failedToLoad`),`error`)}}),Yo=m({mutationFn:({trayId:t})=>i.unloadAms(e.id,t),onSuccess:e=>{q(e.message||W(`printers.toast.unloadInitiated`))},onError:e=>{q(e.message||W(`printers.toast.failedToUnload`),`error`)}}),[Xo,Zo]=(0,X.useState)(null),Qo=!!Q?.fila_switch?.installed,$o=(e,t,n)=>{if(!Qo||e===255||e>=128){Jo.mutate({trayId:n});return}if(!Q?.fila_switch?.ready){q(W(`printers.ams.switchNotReady`),`warning`);return}Zo({trayId:n,amsId:e,slotId:t,slotLabel:sn(e,t,!1,!1)})},[es,ts]=(0,X.useState)(null),[ns,rs]=(0,X.useState)(null),is=async()=>{try{ts(await i.getPlateReferences(e.id))}catch{}},as=()=>{Fo.mutate(!e.plate_detection_enabled)},os=async()=>{Jr(!0),Kr(null);let t=Q?.chamber_light===!1;ni(t),t&&(await i.setChamberLight(e.id,!0),await new Promise(e=>setTimeout(e,2500)));try{Kr(await i.checkPlateEmpty(e.id,{includeDebugImage:!0})),is()}catch(n){q(n instanceof Error?n.message:W(`printers.toast.failedToCheckPlate`),`error`),t&&(await i.setChamberLight(e.id,!1),ni(!1))}finally{Jr(!1)}},ss=(0,X.useCallback)(async()=>{Kr(null),ti&&(await i.setChamberLight(e.id,!1),ni(!1))},[ti,e.id]),cs=async t=>{Xr(!0);try{let n=await i.calibratePlateDetection(e.id,{label:t});n.success?(q(n.message||W(`printers.toast.calibrationSaved`),`success`),is(),Kr(await i.checkPlateEmpty(e.id,{includeDebugImage:!0}))):q(n.message||W(`printers.toast.calibrationFailed`),`error`)}catch(e){q(e instanceof Error?e.message:W(`printers.toast.calibrationFailed`),`error`)}finally{Xr(!1)}},ls=async(t,n)=>{try{await i.updatePlateReferenceLabel(e.id,t,n),rs(null),is()}catch(e){q(e instanceof Error?e.message:W(`printers.toast.failedToUpdateLabel`),`error`)}},us=async t=>{try{await i.deletePlateReference(e.id,t),q(W(`printers.toast.referenceDeleted`),`success`),is(),Kr(await i.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){q(e instanceof Error?e.message:W(`printers.toast.failedToDeleteReference`),`error`)}},ds=async()=>{if(Zr){ei(!0);try{await i.updatePrinter(e.id,{plate_detection_roi:Zr}),q(W(`printers.toast.detectionAreaSaved`),`success`),Qr(null),Kr(await i.checkPlateEmpty(e.id,{includeDebugImage:!0}))}catch(e){q(e instanceof Error?e.message:W(`printers.toast.failedToSaveDetectionArea`),`error`)}finally{ei(!1)}}};(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&Z&&ss()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Z,ss]);let fs=(0,X.useRef)(null);if((0,X.useEffect)(()=>{if(!Ho)return;let e=Q?.ams_status_main??0;return e!==0&&(Wo.current=!0,fs.current&&=(clearTimeout(fs.current),null)),Wo.current&&e===0&&(Ko.current?(Go.current&&clearTimeout(Go.current),Uo(null)):fs.current||=setTimeout(()=>{Go.current&&clearTimeout(Go.current),Uo(null)},2e3)),()=>{fs.current&&clearTimeout(fs.current)}},[Q?.ams_status_main,Ho]),(0,X.useEffect)(()=>{if(!Me)return;let e=e=>{let t=e.target;Or.current?.contains(t)||Pe(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[Me]),Ea)return null;let ps=_o(o),ms=()=>{switch(o){case 1:return`w-10 h-10`;case 2:return`w-14 h-14`;case 3:return`w-16 h-16`;case 4:return`w-20 h-20`;default:return`w-14 h-14`}},hs=()=>{switch(o){case 1:return`text-base truncate`;case 2:return`text-lg`;case 3:return`text-xl`;case 4:return`text-2xl`;default:return`text-lg`}},gs=()=>{switch(o){case 1:return`mb-2`;case 2:return`mb-4`;case 3:return`mb-5`;case 4:return`mb-6`;default:return`mb-4`}},_s=J(`library:upload`)&&J(`queue:create`),vs=!Zn(Q),ys=e=>{e.preventDefault(),Nr.current++,Nr.current===1&&_r(!0)},bs=e=>{e.preventDefault(),e.dataTransfer.dropEffect=_s?`copy`:`none`},xs=e=>{e.preventDefault(),Nr.current--,Nr.current===0&&_r(!1)},Ss=async t=>{if(t.preventDefault(),Nr.current=0,_r(!1),!_s)return;let n=Array.from(t.dataTransfer.files)[0];if(!n)return;let r=n.name.toLowerCase();if(!r.endsWith(`.gcode`)&&!r.includes(`.gcode.`)){q(W(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`),`error`);return}wr(!0);try{let t=await i.uploadLibraryFile(n,null),r=t.metadata?.sliced_for_model,a=gr(e.model);if(r&&a&&r.toLowerCase()!==a.toLowerCase()){await i.deleteLibraryFile(t.id).catch(()=>{}),q(W(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:r,printerModel:a}),`error`);return}Bt({id:t.id,filename:t.filename})}catch{q(W(`common.uploadFailed`,`Upload failed`),`error`)}finally{wr(!1)}},Cs=t=>{r!==`compact`||z||t.target.closest(`button, a, input, select, textarea, [role="button"]`)||V?.(e.id)},ws=`!h-8 !min-h-8 !w-8 !px-0 !py-0`,Ts=t=>{t===`embedded`&&A?A(e.id,e.name):Di(e.id)},Es=[{mode:`window`,icon:(0,$.jsx)($t,{className:`w-4 h-4`}),label:W(`settings.newWindow`),title:W(`settings.cameraWindowDescription`)},{mode:`embedded`,icon:(0,$.jsx)(Dr,{className:`w-4 h-4`}),label:W(`settings.embeddedOverlay`),title:W(`settings.cameraOverlayDescription`)}].map(({mode:e,icon:t,label:n,title:r})=>({icon:t,label:e===k?`${n} ✓`:n,title:r,onClick:()=>{j?.(e),Ts(e)}})),Ds=({amsId:e,slotId:t,loadTrayId:n,isRefreshing:r,includeRfid:i=!0})=>{let a=Q?.state===`RUNNING`,o=e>=128&&e!==255?void 0:n;return(0,$.jsxs)($.Fragment,{children:[i&&(0,$.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${J(`printers:ams_rfid`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:n=>{n.stopPropagation(),!(a||!J(`printers:ams_rfid`))&&qo.mutate({amsId:e,slotId:t})},disabled:a||r||!J(`printers:ams_rfid`),title:a?W(`printers.bedJog.disabledWhilePrinting`):J(`printers:ams_rfid`)?void 0:W(`printers.permission.noAmsRfid`),children:[(0,$.jsx)(dn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] ${r?`animate-spin`:``}`}),W(`printers.rfid.reread`)]}),(0,$.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${J(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:r=>{r.stopPropagation(),!(a||!J(`printers:control`))&&$o(e,t,n)},disabled:a||!J(`printers:control`),title:a?W(`printers.bedJog.disabledWhilePrinting`):J(`printers:control`)?void 0:W(`printers.permission.noControl`),children:[(0,$.jsx)(me,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.ams.load`)]}),(0,$.jsxs)(`button`,{className:`w-full px-2 py-1.5 text-left text-xs flex items-center gap-2 rounded transition-colors ${J(`printers:control`)?`text-white hover:bg-bambu-dark-tertiary`:`text-bambu-gray/50 cursor-not-allowed`}`,onClick:e=>{e.stopPropagation(),!(a||!J(`printers:control`))&&Yo.mutate({trayId:o})},disabled:a||!J(`printers:control`),title:a?W(`printers.bedJog.disabledWhilePrinting`):J(`printers:control`)?void 0:W(`printers.permission.noControl`),children:[(0,$.jsx)(Ln,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.ams.unload`)]})]})},Os=(0,$.jsxs)(`div`,{ref:Or,className:`relative flex-shrink-0`,children:[(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:()=>Pe(!Me),title:W(`common.more`,`More`),className:ws,children:(0,$.jsx)(re,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),Me&&(0,$.jsxs)(`div`,{className:`absolute left-0 bottom-full mb-2 w-48 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg z-20`,children:[(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${J(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,onClick:()=>{J(`printers:update`)&&(Be(!0),Pe(!1))},title:J(`printers:update`)?void 0:W(`printers.permission.noEdit`),children:[(0,$.jsx)(Zt,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`common.edit`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Dt(!0),Pe(!1)},children:[(0,$.jsx)(ee,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`printers.printerInformation`)]}),Ae&&je&&(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Pe(!1),xe(`/settings?tab=users&sub=printer-access&view=printers&printer=${e.id}`)},children:[(0,$.jsx)(Er,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`printerAccess.whoHasAccess`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${J(`printers:update`)?`hover:bg-bambu-dark-tertiary`:`opacity-50 cursor-not-allowed`}`,disabled:Io.isPending||!J(`printers:update`),onClick:()=>{J(`printers:update`)&&(Pe(!1),e.is_active===!1?Io.mutate(!0):zo())},title:J(`printers:update`)?void 0:W(`printers.permission.noEdit`),children:[(0,$.jsx)(sr,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),e.is_active===!1?W(`printers.maintenance.menuExit`):W(`printers.maintenance.menuEnter`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{ka.mutate(),Pe(!1)},children:[(0,$.jsx)(dn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`printers.reconnect`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2 disabled:opacity-50`,disabled:Aa.isPending,onClick:()=>{Aa.mutate(),Pe(!1)},children:[(0,$.jsx)(On,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] ${Aa.isPending?`animate-spin`:``}`}),W(`printers.forceRefresh`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{We(!0),Pe(!1)},children:[(0,$.jsx)(gn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`printers.mqttDebug`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm hover:bg-bambu-dark-tertiary flex items-center gap-2`,onClick:()=>{Ft(!0),Pe(!1)},children:[(0,$.jsx)(an,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`diagnostic.runButton`)]}),(0,$.jsxs)(`button`,{className:`w-full px-4 py-2 text-left text-sm flex items-center gap-2 ${J(`printers:delete`)?`text-red-700 dark:text-red-400 hover:bg-bambu-dark-tertiary`:`text-red-700/50 dark:text-red-400/50 cursor-not-allowed`}`,onClick:()=>{J(`printers:delete`)&&(Ie(!0),Pe(!1))},title:J(`printers:delete`)?void 0:W(`printers.permission.noDelete`),children:[(0,$.jsx)(Qt,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`common.delete`)]})]})]});return(0,$.jsxs)(Rt,{id:`printer-card-${e.id}`,className:`relative flex h-full flex-col ${ie?`ring-2 ring-bambu-green`:``} ${z||r===`compact`?`cursor-pointer`:``}`,style:ps,onClick:Cs,onDragEnter:ys,onDragOver:bs,onDragLeave:xs,onDrop:Ss,children:[z&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-20 flex items-start p-2`,onClick:t=>{t.stopPropagation(),ae?.(e.id)},children:ie?(0,$.jsx)(xn,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-bambu-green`}):(0,$.jsx)(fn,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-bambu-gray`})}),(hr||Cr)&&(0,$.jsx)(`div`,{className:`absolute inset-0 z-10 rounded-xl border-2 border-dashed flex items-center justify-center transition-colors ${Cr?`bg-bambu-green/10 border-bambu-green/50`:_s?`bg-bambu-green/10 border-bambu-green`:`bg-red-50 dark:bg-red-500/10 border-red-300 dark:border-red-500/50`}`,children:(0,$.jsx)(`div`,{className:`text-center`,children:Cr?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green animate-spin`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:W(`common.uploading`,`Uploading...`)})]}):_s?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ln,{className:`w-8 h-8 mx-auto mb-2 text-bambu-green`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-bambu-green`,children:W(vs?`printers.dropToQueue`:`printers.dropToPrint`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pt,{className:`w-8 h-8 mx-auto mb-2 text-red-600 dark:text-red-400`}),(0,$.jsx)(`p`,{className:`text-sm font-medium text-red-700 dark:text-red-400`,children:J(`library:upload`)?W(`fileManager.noPermissionAddToQueue`):W(`fileManager.noPermissionUpload`)})]})})}),(0,$.jsxs)(Lt,{className:`${o>=3?`p-5`:``} flex flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:gs(),children:[(0,$.jsx)(`div`,{className:`flex items-start justify-between gap-2`,children:(0,$.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0 flex-1`,children:[(0,$.jsx)(`img`,{src:tn(e.model),alt:e.model||W(`common.printer`),className:`object-contain rounded-lg flex-shrink-0 ${ms()}`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`font-semibold text-white ${hs()}`,children:e.name}),r===`compact`&&(()=>{let e=Q?.connected&&Q.hms_errors?Mt(Q.hms_errors):[],t=e.some(At),n=e.length>0,r=Q?.connected?t?`bg-status-error`:n?`bg-status-warning`:`bg-status-ok`:`bg-status-error`,i=Q?.connected?n?`${e.length} HMS ${e.length===1?`error`:`errors`}`:W(`printers.connection.connected`):W(`printers.connection.offline`);return(0,$.jsx)(`div`,{className:`w-[var(--pc-i2,0.5rem)] h-[var(--pc-i2,0.5rem)] rounded-full flex-shrink-0 ${r}`,title:i})})()]}),r===`compact`&&la&&(0,$.jsx)(`button`,{type:`button`,onClick:()=>so.mutate(),disabled:so.isPending||!J(`printers:clear_plate`),"aria-label":W(`printers.plateStatus.markCleared`),className:`inline-flex h-5 w-5 flex-shrink-0 items-center justify-center rounded-md bg-yellow-100 dark:bg-yellow-500/20 border border-yellow-300 dark:border-yellow-400/40 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/30 transition-colors disabled:opacity-50`,title:J(`printers:clear_plate`)?W(`printers.plateStatus.markCleared`):W(`printers.permission.noControl`),children:so.isPending?(0,$.jsx)(H,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] animate-spin`}):(0,$.jsx)(pa,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]}),(0,$.jsxs)(`p`,{className:`text-sm text-bambu-gray`,children:[e.model||`Unknown Model`,r===`expanded`&&An(Q).length>0&&(0,$.jsxs)(`span`,{className:`ml-1.5 text-bambu-gray`,title:Q?.nozzles?.[0]?.nozzle_type||`Nozzle`,children:[`• `,An(Q).join(` / `),`mm`]}),r===`expanded`&&n&&n.total_print_hours>0&&(0,$.jsxs)(`span`,{className:`ml-2 text-bambu-gray`,children:[(0,$.jsx)(vn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] inline-block mr-1`}),Math.round(n.total_print_hours),`h`]})]})]})]})}),r===`expanded`&&(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.is_active===!1?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`,title:W(`printers.maintenance.subtitle`),children:[(0,$.jsx)(sr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.maintenance.pillLabel`)]}):(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5 px-2 py-1 rounded-full text-xs ${Q?.connected?`bg-status-ok/20 text-status-ok`:`bg-status-error/20 text-status-error`}`,children:[Q?.connected?(0,$.jsx)($n,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(kt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),Q?.connected?W(`printers.connection.connected`):W(`printers.connection.offline`)]}),e.is_active!==!1&&!Q?.connected&&(0,$.jsxs)(`button`,{onClick:()=>Ft(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer bg-bambu-dark-tertiary text-bambu-gray hover:text-white transition-colors`,title:W(`diagnostic.runButton`),children:[(0,$.jsx)(an,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`diagnostic.runButton`)]}),Q?.connected&&Q?.wired_network&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-status-ok/20 text-status-ok`,title:W(`printers.connection.ethernet`,`Ethernet`),children:[(0,$.jsx)(M,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.connection.ethernet`,`Ethernet`)]}),Q?.connected&&!Q?.wired_network&&_i!=null&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs ${_i>=-50||_i>=-60?`bg-status-ok/20 text-status-ok`:_i>=-70?`bg-status-warning/20 text-status-warning`:_i>=-80?`bg-orange-500/20 text-orange-600`:`bg-status-error/20 text-status-error`}`,title:`WiFi: ${_i} dBm - ${W(_n(_i).labelKey)}`,children:[(0,$.jsx)(kr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),_i,`dBm`]}),Q?.connected&&(()=>{let e=Q.hms_errors?Mt(Q.hms_errors):[];return(0,$.jsxs)(`button`,{onClick:()=>Qe(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${e.length>0?e.some(At)?`bg-status-error/20 text-status-error`:`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:W(`printers.clickToViewHmsErrors`),children:[(0,$.jsx)(Ot,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),e.length>0?e.length:`OK`]})})(),he&&(()=>{let e=Xi(U),t=e===`failure`?`bg-status-error/20 text-status-error`:e===`warning`?`bg-status-warning/20 text-status-warning`:e===`safe`?`bg-status-ok/20 text-status-ok`:e===`error`?`bg-amber-500/20 text-amber-600 dark:text-amber-400`:`bg-bambu-dark-tertiary text-bambu-gray`,n=e===`error`?W(`printers.aiDetection.tooltipError`,{reason:U?.error??W(`printers.aiDetection.error`)}):e===`unknown`?W(`printers.aiDetection.tooltipUnknown`):U?W(`printers.aiDetection.tooltip`,{status:W(`printers.aiDetection.${e}`),score:U.score.toFixed(3)}):W(`printers.aiDetection.tooltipIdle`),r=e===`error`?B:K;return(0,$.jsxs)(`button`,{onClick:()=>et(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${t}`,title:n,children:[(0,$.jsx)(r,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.aiDetection.${e}`)]})})(),n&&(0,$.jsxs)(`button`,{onClick:()=>xe(`/maintenance`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs cursor-pointer hover:opacity-80 transition-opacity ${n.due_count>0?`bg-status-error/20 text-status-error`:n.warning_count>0?`bg-status-warning/20 text-status-warning`:`bg-status-ok/20 text-status-ok`}`,title:n.due_count>0||n.warning_count>0?`${n.due_count>0?`${n.due_count} maintenance due`:``}${n.due_count>0&&n.warning_count>0?`, `:``}${n.warning_count>0?`${n.warning_count} due soon`:``} - Click to view`:W(`printers.maintenanceUpToDate`),children:[(0,$.jsx)(sr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),n.due_count>0||n.warning_count>0?n.due_count+n.warning_count:`OK`]}),Ji>0&&(0,$.jsxs)(`button`,{onClick:()=>xe(`/queue`),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-indigo-100 dark:bg-indigo-500/20 text-indigo-700 dark:text-indigo-400 hover:opacity-80 transition-opacity`,title:W(`printers.queue.inQueue`,{count:Ji}),children:[(0,$.jsx)(Hn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),Ji]}),P&&ri?.current_version&&ri?.latest_version?(0,$.jsxs)(`button`,{onClick:()=>Gr(!0),className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs hover:opacity-80 transition-opacity ${ri.update_available?`bg-orange-100 dark:bg-orange-500/20 text-orange-700 dark:text-orange-400`:`bg-status-ok/20 text-status-ok`}`,title:ri.update_available?W(`printers.firmwareUpdateAvailable`,{current:ri.current_version,latest:ri.latest_version}):W(`printers.firmwareUpToDate`,{version:ri.current_version}),children:[ri.update_available?(0,$.jsx)(ar,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(ne,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),ri.current_version]}):Q?.firmware_version?(0,$.jsx)(`span`,{className:`flex items-center gap-1 px-2 py-1 rounded-full text-xs bg-bambu-dark-tertiary/50 text-bambu-gray`,children:Q.firmware_version}):null,Q?.connected&&[`X1C`,`X1`,`X1E`,`X2D`,`P2S`,`H2D`,`H2D Pro`,`H2C`,`H2S`].includes(e.model??``)&&(0,$.jsx)(`span`,{className:`flex items-center px-2 py-1 rounded-full text-xs ${Q.door_open?`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400`:`bg-status-ok/20 text-status-ok`}`,title:Q.door_open?W(`printers.door.open`):W(`printers.door.closed`),children:Q.door_open?(0,$.jsx)(x,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(g,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]})})]}),Fe&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,$.jsx)(Rt,{className:`w-full max-w-md mx-4`,children:(0,$.jsxs)(Lt,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-full bg-red-100 dark:bg-red-500/20`,children:(0,$.jsx)(Ot,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-red-600 dark:text-red-400`})}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:W(`printers.confirm.deleteTitle`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:W(`printers.confirm.deleteMessage`,{name:e.name})})]})]}),(0,$.jsx)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:(0,$.jsxs)(`label`,{className:`flex items-start gap-3 cursor-pointer`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:Le,onChange:e=>Re(e.target.checked),className:`mt-0.5 w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] rounded border-bambu-gray bg-bambu-dark-secondary text-bambu-green focus:ring-bambu-green focus:ring-offset-0`}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`span`,{className:`text-sm text-white`,children:W(`printers.deleteArchives`)}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:W(Le?`printers.confirm.deleteArchivesNote`:`printers.confirm.keepArchivesNote`)})]})]})}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:()=>{Ie(!1),Re(!0)},children:W(`common.cancel`)}),(0,$.jsx)(Y,{variant:`danger`,onClick:()=>{Da.mutate({deleteArchives:Le}),Ie(!1),Re(!0)},children:`Delete`})]})]})})}),e.is_active===!1?(0,$.jsx)($.Fragment,{children:r===`compact`?(0,$.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 px-2 py-1.5 rounded-full bg-amber-50 dark:bg-amber-500/15 border border-amber-300 dark:border-amber-500/30`,children:[(0,$.jsx)(sr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-amber-600 dark:text-amber-400 shrink-0`}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t11,11px)] text-amber-700 dark:text-amber-400 font-medium truncate`,children:W(`printers.maintenance.pillLabel`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:W(`printers.status.title`,`Status`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,$.jsxs)(`div`,{className:`p-3 bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 rounded-[10px] flex items-center gap-3`,children:[(0,$.jsx)(sr,{className:`w-6 h-6 text-amber-600 dark:text-amber-400 shrink-0`}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-400 font-medium`,children:W(`printers.maintenance.title`)}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-0.5`,children:W(`printers.maintenance.subtitle`)})]}),(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,disabled:Io.isPending||!J(`printers:update`),onClick:()=>Io.mutate(!0),title:J(`printers:update`)?void 0:W(`printers.permission.noEdit`),children:W(`printers.maintenance.exitButton`)})]})]})}):Q?.connected&&(0,$.jsxs)($.Fragment,{children:[r===`compact`?(()=>{let e=Q.hms_errors?Mt(Q.hms_errors):[],t=Q.state===`FAILED`||e.length>0,n=Q.state===`RUNNING`||Q.state===`PAUSE`?Math.max(0,Math.min(100,Q.progress||0)):la||t?100:0,r=Q.state===`RUNNING`||Q.state===`PAUSE`,i=t?`bg-status-error`:Q.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`,a=r&&Q.remaining_time!=null&&Q.remaining_time>0,o=r&&Q.layer_num!=null&&Q.total_layers!=null&&Q.total_layers>0;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`relative mt-2 flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 overflow-hidden rounded-full bg-bambu-dark-tertiary`,children:(0,$.jsx)(`div`,{className:`${i} h-1.5 rounded-full transition-all`,style:{width:`${n}%`}})}),(0,$.jsx)(`span`,{className:`w-9 shrink-0 text-right text-[length:var(--pc-t11,11px)] leading-none ${r?`text-white`:`text-bambu-gray`}`,children:r?`${Math.round(n)}%`:`---%`})]}),(0,$.jsxs)(`div`,{className:`mt-1 flex min-h-[14px] items-center gap-2 overflow-hidden text-[length:var(--pc-t11,11px)] leading-none text-bambu-gray`,children:[a&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(vn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),Ut(Q.remaining_time*60)]}),(0,$.jsxs)(`span`,{className:`shrink-0 font-medium text-bambu-green`,title:W(`printers.estimatedCompletion`),children:[`ETA `,Vt(Q.remaining_time,O,W)]})]}),o&&(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 truncate`,children:[(0,$.jsx)(Hn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] shrink-0`}),Q.layer_num,`/`,Q.total_layers]})]})]})})():(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:W(`printers.status.title`,`Status`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(()=>{let t=!!(Q.current_print&&(Q.state===`RUNNING`||Q.state===`PAUSE`)),n=!t&&sa&&ga,r=t?ha:n?ga.name:null,i=t?Q.cover_url:n?ga.coverUrl:null,a=t?Q.progress||0:n?100:0,o=Q.printable_objects_count??0,s=t&&o!==1&&J(`printers:control`);return(0,$.jsxs)(`div`,{className:`p-2 bg-bambu-dark rounded-[10px] relative overflow-hidden`,children:[(0,$.jsxs)(`button`,{onClick:()=>Ct(!0),disabled:!s,className:`absolute top-2 right-2 p-1.5 rounded transition-colors z-10 ${s?`text-bambu-gray hover:text-white hover:bg-white/10`:`text-bambu-gray/30 cursor-not-allowed`}`,title:J(`printers:control`)?W(t?o===1?`printers.skipObjects.requiresMultiple`:`printers.skipObjects.tooltip`:`printers.skipObjects.onlyWhilePrinting`):W(`printers.permission.noControl`),children:[(0,$.jsx)(ve,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),Vo&&Vo.skipped_count>0&&(0,$.jsx)(`span`,{className:`absolute -top-1 -right-1 min-w-[16px] h-4 px-1 flex items-center justify-center text-[length:var(--pc-t10,10px)] font-bold bg-red-500 text-white rounded-full`,children:Vo.skipped_count})]}),(0,$.jsxs)(`div`,{className:`flex items-stretch gap-2`,children:[(0,$.jsx)(eo,{url:i,printName:r||void 0,className:`w-24 h-24 max-[520px]:w-20 max-[520px]:h-20`}),(0,$.jsxs)(`div`,{className:`flex h-24 max-[520px]:h-20 min-w-0 flex-1 flex-col justify-between pt-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-h-[18px] items-center gap-2 pr-8`,children:[(0,$.jsx)(`p`,{className:`min-w-0 truncate text-sm text-bambu-gray`,children:uo(Q.state,Q.stg_cur_name)}),Ta]}),(0,$.jsx)(`p`,{className:`min-h-[18px] truncate pr-8 text-sm ${r?`text-white`:`text-bambu-gray/70`}`,children:r||W(`printers.noActiveJob`,`No active job`)}),(0,$.jsxs)(`div`,{className:`flex h-3 items-center gap-2 text-sm`,children:[(0,$.jsx)(`div`,{className:`h-1.5 min-w-0 flex-1 rounded-full bg-bambu-dark-tertiary`,children:(0,$.jsx)(`div`,{className:`${t?Q.state===`PAUSE`?`bg-status-warning`:`bg-bambu-green`:n?`bg-bambu-green`:`bg-bambu-dark-tertiary`} h-1.5 rounded-full transition-all`,style:{width:`${a}%`}})}),(0,$.jsx)(`span`,{className:`w-9 shrink-0 pr-1 text-right text-[length:var(--pc-t11,11px)] leading-none ${t||n?`text-white`:`text-bambu-gray`}`,children:t||n?`${Math.round(a)}%`:`---%`})]}),(0,$.jsx)(`div`,{className:`flex min-h-[16px] items-center gap-2 text-xs text-bambu-gray`,children:t?(0,$.jsxs)($.Fragment,{children:[Q.remaining_time!=null&&Q.remaining_time>0&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(vn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),Ut(Q.remaining_time*60)]}),(0,$.jsxs)(`span`,{className:`text-bambu-green font-medium`,title:W(`printers.estimatedCompletion`),children:[`ETA `,Vt(Q.remaining_time,O,W)]})]}),Q.layer_num!=null&&Q.total_layers!=null&&Q.total_layers>0&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(Hn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),Q.layer_num,`/`,Q.total_layers]}),ra&&(0,$.jsxs)(`span`,{className:`flex items-center gap-1`,title:`Started by ${ra}`,children:[(0,$.jsx)(yn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),ra]})]}):ia?(0,$.jsxs)(`p`,{className:`truncate`,title:ia.print_name||ia.filename,children:[`Last: `,ia.print_name||ia.filename,ia.completed_at&&(0,$.jsxs)(`span`,{className:`ml-1 text-bambu-gray/60`,children:[`• `,Ht(ia.completed_at,{month:`short`,day:`numeric`})]})]}):(0,$.jsx)(`span`,{children:W(`printers.readyToPrint`)})})]})]}),(0,$.jsx)($i,{printerId:e.id,printerModel:e.model,loadedFilamentTypes:ai,loadedFilaments:oi,loadedVariants:si,variant:`panelExtension`})]})})()]}),Q.temperatures&&r===`expanded`&&(()=>{let t=Q.temperatures.nozzle_heating||Q.temperatures.nozzle_2_heating||!1,n=Q.temperatures.bed_heating||!1,r=Q.temperatures.chamber_heating||!1,i=e.nozzle_count===2||Q.temperatures.nozzle_2!==void 0,a=(()=>{let e=[`nozzle`];return Q.temperatures.nozzle_2!==void 0&&e.push(`nozzle_2`),e.push(`bed`),Q.temperatures.chamber!==void 0&&e.push(`chamber`),e})(),o=Q.active_extruder===1?`L`:`R`,s=Q.nozzle_rack?.find(e=>e.id===1),c=Q.nozzle_rack?.find(e=>e.id===0),l=c||s,u=Q.connected&&J(`printers:control`),d=u?void 0:W(`printers.permission.noControl`),f=`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,p=fo.has(e.model??``),m=po.has(e.model??``),h=W(m?`printers.fans.exhaust`:`printers.fans.chamber`),g=p&&(!m||Q.exhaust_fan_present),_=[{key:`part`,label:W(`printers.fans.partCooling`),value:Q.cooling_fan_speed??0,Icon:N,activeClass:`text-cyan-600 dark:text-cyan-400`},...Q.left_aux_fan_speed==null?[]:[{key:`aux2`,label:W(`printers.fans.leftAuxiliary`),value:Q.left_aux_fan_speed,Icon:Ne,activeClass:`text-indigo-600 dark:text-indigo-400`}],{key:`aux`,label:W(`printers.fans.auxiliary`),value:Q.big_fan1_speed??0,Icon:Ne,activeClass:`text-blue-600 dark:text-blue-400`},...g?[{key:`chamber`,label:h,value:Q.big_fan2_speed??0,Icon:xr,activeClass:`text-green-600 dark:text-green-400`}]:[]];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`mt-2 flex items-stretch gap-1.5 flex-wrap`,children:[(0,$.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&_t(gt===`nozzle-temp`?null:`nozzle-temp`),children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:W(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),Lr({initialKind:`nozzle`,availableKinds:a})},children:(0,$.jsx)(Sr,{className:`w-[var(--pc-i25,0.625rem)] h-[var(--pc-i25,0.625rem)]`})}),(0,$.jsx)(Ja,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] mb-0.5`,color:`text-orange-400`,isHeating:t}),Q.temperatures.nozzle_2===void 0?l?(0,$.jsx)(Ra,{slot:l,index:0,activeStatus:!0,filamentName:l.filament_id?ci?.[l.filament_id]?.name:void 0,children:(0,$.jsxs)(`div`,{className:`cursor-default`,children:[(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:W(`printers.temperatures.nozzle`)}),(0,$.jsxs)(`p`,{className:`text-[length:var(--pc-t11,11px)] text-white`,children:[Math.round(Q.temperatures.nozzle||0),`°C`]})]})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:W(`printers.temperatures.nozzle`)}),(0,$.jsxs)(`p`,{className:`text-[length:var(--pc-t11,11px)] text-white`,children:[Math.round(Q.temperatures.nozzle||0),`°C`]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:`L / R`}),(0,$.jsxs)(`p`,{className:`text-[length:var(--pc-t11,11px)] text-white`,children:[Math.round(Q.temperatures.nozzle||0),`° / `,Math.round(Q.temperatures.nozzle_2||0),`°`]})]}),gt===`nozzle-temp`&&(i?(0,$.jsx)(io,{title:`Set Nozzle Temperatures`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:260,isPending:Co.isPending,onClose:()=>_t(null),children:(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 px-3 py-2.5`,children:[(0,$.jsx)(oo,{label:`Left Temp`,current:Q.temperatures.nozzle,target:Q.temperatures.nozzle_target,isActive:o===`L`,isPending:Co.isPending,onSubmit:e=>Co.mutate({target:e,nozzle:1}),options:Te(se,`C`)}),(0,$.jsx)(oo,{label:`Right Temp`,current:Q.temperatures.nozzle_2,target:Q.temperatures.nozzle_2_target,isActive:o===`R`,isPending:Co.isPending,onSubmit:e=>Co.mutate({target:e,nozzle:0}),options:Te(se,`C`)})]})}):(0,$.jsx)(io,{title:`Set Nozzle Temperature`,unit:`°C`,customMin:0,customMax:320,isPending:Co.isPending,options:Te(se,`C`),onClose:()=>_t(null),onSubmit:e=>Co.mutate({target:e,nozzle:Q.active_extruder??0})}))]}),(0,$.jsxs)(`div`,{className:f,title:d,onClick:()=>u&&_t(gt===`bed-temp`?null:`bed-temp`),children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:W(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),Lr({initialKind:`bed`,availableKinds:a})},children:(0,$.jsx)(Sr,{className:`w-[var(--pc-i25,0.625rem)] h-[var(--pc-i25,0.625rem)]`})}),(0,$.jsx)(Ja,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] mb-0.5`,color:`text-blue-400`,isHeating:n}),(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:W(`printers.temperatures.bed`)}),(0,$.jsxs)(`p`,{className:`text-[length:var(--pc-t11,11px)] text-white`,children:[Math.round(Q.temperatures.bed||0),`°C`]}),gt===`bed-temp`&&(0,$.jsx)(io,{title:`Set Bed Temperature`,unit:`°C`,customMin:0,customMax:140,isPending:wo.isPending,options:Te(le,`C`),onClose:()=>_t(null),onSubmit:e=>wo.mutate(e)})]}),Q.temperatures.chamber!==void 0&&(()=>{let e=Q.supports_chamber_heater===!0;return(0,$.jsxs)(`div`,{className:e?f:`relative text-center px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 flex flex-col justify-center items-center`,title:e?d:void 0,onClick:e?()=>u&&_t(gt===`chamber-temp`?null:`chamber-temp`):void 0,children:[(0,$.jsx)(`button`,{type:`button`,className:`absolute top-0.5 right-0.5 p-0.5 rounded text-bambu-gray hover:text-white hover:bg-white/10 transition-colors`,title:W(`printers.heaterHistory.openLabel`,`View heater history`),onClick:e=>{e.stopPropagation(),Lr({initialKind:`chamber`,availableKinds:a})},children:(0,$.jsx)(Sr,{className:`w-[var(--pc-i25,0.625rem)] h-[var(--pc-i25,0.625rem)]`})}),(0,$.jsx)(Ja,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] mb-0.5`,color:`text-green-400`,isHeating:r}),(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:W(`printers.temperatures.chamber`)}),(0,$.jsxs)(`p`,{className:`text-[length:var(--pc-t11,11px)] text-white`,children:[Math.round(Q.temperatures.chamber||0),`°C`]}),e&&gt===`chamber-temp`&&(0,$.jsx)(io,{title:`Set Chamber Temperature`,unit:`°C`,customMin:0,customMax:65,isPending:To.isPending,options:Te(de,`C`),onClose:()=>_t(null),onSubmit:e=>To.mutate(e)})]})})(),i&&(0,$.jsx)(za,{leftSlot:s,rightSlot:c,activeNozzle:o,filamentInfo:ci,children:(0,$.jsxs)(`div`,{className:`relative text-center px-3 py-1.5 bg-bambu-dark rounded-lg h-full flex flex-col justify-center items-center transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?W(`printers.activeNozzle`,{nozzle:W(o===`L`?`common.left`:`common.right`)}):d,onClick:()=>u&&_t(gt===`nozzle-select`?null:`nozzle-select`),children:[(0,$.jsx)(qa,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] mb-0.5 text-amber-600 dark:text-amber-400`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-[length:var(--pc-t11,11px)] font-bold ${o===`L`?`text-amber-700 dark:text-amber-400`:`text-gray-500`}`,children:[`L`,s?.nozzle_diameter?` ${s.nozzle_diameter}`:``]}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray/40`,children:`·`}),(0,$.jsxs)(`span`,{className:`text-[length:var(--pc-t11,11px)] font-bold ${o===`R`?`text-amber-700 dark:text-amber-400`:`text-gray-500`}`,children:[`R`,c?.nozzle_diameter?` ${c.nozzle_diameter}`:``]})]}),(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t9,9px)] text-bambu-gray`,children:W(`printers.temperatures.nozzle`)}),gt===`nozzle-select`&&(0,$.jsx)(io,{title:`Set Nozzle Selection`,widthClass:`w-[300px]`,popoverWidth:300,popoverHeight:140,isPending:Do.isPending,options:[{label:`Left`,value:1},{label:`Right`,value:0}],onClose:()=>_t(null),onSubmit:e=>Do.mutate(e)})]})}),Q.nozzle_rack&&Q.nozzle_rack.some(e=>e.id>=2)&&(0,$.jsx)(Ba,{slots:Q.nozzle_rack,filamentInfo:ci})]}),(0,$.jsx)(`div`,{className:`mt-2 flex items-center gap-1.5`,children:_.map(({key:e,label:t,value:n,Icon:r,activeClass:i})=>{let a=n>0;return(0,$.jsxs)(`div`,{className:`relative px-2 py-1.5 bg-bambu-dark rounded-lg flex-1 min-w-0 flex items-center justify-center gap-1 transition-colors ${u?`cursor-pointer hover:bg-bambu-dark-tertiary`:`cursor-default opacity-80`}`,title:u?t:d,onClick:()=>u&&_t(gt===`fan-${e}`?null:`fan-${e}`),children:[(0,$.jsx)(r,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] shrink-0 ${a?i:`text-bambu-gray/50`}`}),(0,$.jsxs)(`span`,{className:`text-[length:var(--pc-t10,10px)] leading-none ${a?`text-white`:`text-bambu-gray/50`}`,children:[n,`%`]}),gt===`fan-${e}`&&(0,$.jsx)(io,{title:`Set ${t} Speed`,unit:`%`,customMin:0,customMax:100,isPending:Eo.isPending,options:Te(pe,`%`),onClose:()=>_t(null),onSubmit:t=>Eo.mutate({fan:e,speed:t})})]},e)})})]})})(),r===`expanded`&&la&&bo,r===`expanded`&&(()=>{let t=Q.state===`RUNNING`,n=Q.state===`PAUSE`,r=t||n,i=to.isPending||ro.isPending||ao.isPending,a=`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed opacity-50`,o=`flex h-8 w-8 items-center justify-center rounded-lg text-xs font-medium transition-colors disabled:opacity-50 disabled:cursor-not-allowed`,s=`flex h-8 w-20 items-center justify-center gap-1 px-2 rounded-lg text-xs font-medium transition-colors`;return(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:W(`printers.controls`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-x-2 gap-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 min-w-0`,children:[(0,$.jsx)(`button`,{onClick:()=>Oo.mutate(!Q.chamber_light),disabled:!Q.connected||Oo.isPending||!J(`printers:control`),className:`${o} ${Q.chamber_light?`bg-yellow-50 dark:bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:J(`printers:control`)?Q.chamber_light?W(`printers.chamberLightOff`):W(`printers.chamberLightOn`):W(`printers.permission.noControl`),children:(0,$.jsx)(_e,{on:Q.chamber_light??!1,className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),[`P2S`,`X2D`,`H2D`,`H2C`,`H2S`].includes(e.model??``)&&(()=>{let t=Q.airduct_mode===1,n=t?Bn:jr,r=t?`text-orange-600 dark:text-orange-400`:`text-sky-600 dark:text-sky-400`,i=t?`bg-orange-50 dark:bg-orange-500/10 text-orange-700 dark:text-orange-400 hover:bg-orange-500/20`:`bg-sky-50 dark:bg-sky-500/10 text-sky-700 dark:text-sky-400 hover:bg-sky-500/20`;return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{onClick:()=>pt(ft===e.id?null:e.id),disabled:!J(`printers:control`),className:`${o} ${i}`,title:`${W(`printers.airduct.title`)}: ${W(t?`printers.airduct.heating`:`printers.airduct.cooling`)}`,children:(0,$.jsx)(n,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] ${r}`})}),ft===e.id&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>pt(null)}),(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:`cooling`,label:W(`printers.airduct.cooling`),modeId:0},{mode:`heating`,label:W(`printers.airduct.heating`),modeId:1}].map(({mode:e,label:t,modeId:n})=>(0,$.jsxs)(`button`,{onClick:()=>{Ao.mutate(e),pt(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors flex items-center gap-2 ${Q.airduct_mode===n?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:[e===`heating`?(0,$.jsx)(Bn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(jr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),t]},e))})]})]})})(),(()=>{let t=J(`printers:control`),n=r||!t,i=`flex h-8 w-8 items-center justify-center rounded bg-indigo-100 dark:bg-indigo-500/15 text-indigo-700 dark:text-indigo-300 transition-colors hover:bg-indigo-200 dark:hover:bg-indigo-500/30 disabled:cursor-not-allowed disabled:opacity-50`,a=bi(e.model),s=e=>{let t=a?e===`up`:e===`down`;jo.mutate({distance:t?vt:-vt})},c=(e,t)=>{Mo.mutate({x:e,y:t})},l=e=>{No.mutate(e)};return(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{onClick:()=>ht(mt===e.id?null:e.id),disabled:n,className:`${o} ${n?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-indigo-50 dark:bg-indigo-500/10 text-indigo-700 dark:text-indigo-400 hover:bg-indigo-500/20`}`,title:W(t?r?`printers.bedJog.disabledWhilePrinting`:`printers.bedJog.title`:`printers.permission.noControl`),children:(0,$.jsx)(Ee,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),mt===e.id&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>ht(null)}),(0,$.jsxs)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 flex w-[216px] flex-col overflow-hidden rounded-xl border border-bambu-dark-tertiary bg-bambu-dark-secondary shadow-2xl`,children:[(0,$.jsx)(`div`,{className:`shrink-0 px-3 py-2.5 text-center text-sm font-medium text-white`,children:W(`printers.bedJog.title`)}),(0,$.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,$.jsxs)(`div`,{className:`flex items-start gap-1.5 bg-yellow-500/10 px-3 py-2 text-[length:var(--pc-t11,11px)] leading-snug text-yellow-700 dark:text-yellow-400`,children:[(0,$.jsx)(Ot,{className:`mt-0.5 h-3.5 w-3.5 shrink-0`}),(0,$.jsx)(`span`,{children:W(`printers.bedJog.limitWarning`)})]}),(0,$.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,$.jsx)(`div`,{className:`flex justify-center px-3 py-2.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-3 gap-1`,children:[(0,$.jsx)(`div`,{}),(0,$.jsx)(`button`,{onClick:()=>c(0,vt),disabled:Mo.isPending,className:i,"aria-label":`Move Y forward`,children:(0,$.jsx)(E,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`div`,{}),(0,$.jsx)(`button`,{onClick:()=>c(-vt,0),disabled:Mo.isPending,className:i,"aria-label":`Move X left`,children:(0,$.jsx)(C,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{onClick:()=>{ht(null),Po.mutate(`all`)},disabled:Po.isPending,className:i,"aria-label":W(`printers.bedJog.homeZ`),children:(0,$.jsx)(Kn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{onClick:()=>c(vt,0),disabled:Mo.isPending,className:i,"aria-label":`Move X right`,children:(0,$.jsx)(w,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`div`,{}),(0,$.jsx)(`button`,{onClick:()=>c(0,-vt),disabled:Mo.isPending,className:i,"aria-label":`Move Y back`,children:(0,$.jsx)(S,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`div`,{})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>s(`up`),disabled:jo.isPending,className:i,"aria-label":W(a?`printers.bedJog.toolheadUp`:`printers.bedJog.up`),children:(0,$.jsx)(E,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,$.jsx)(Hn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{onClick:()=>s(`down`),disabled:jo.isPending,className:i,"aria-label":W(a?`printers.bedJog.toolheadDown`:`printers.bedJog.down`),children:(0,$.jsx)(S,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,$.jsx)(`button`,{onClick:()=>l(-vt),disabled:No.isPending,className:i,"aria-label":`Retract filament`,children:(0,$.jsx)(E,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center text-bambu-gray/80`,children:(0,$.jsx)(`span`,{className:`text-sm font-semibold leading-none`,children:`E`})}),(0,$.jsx)(`button`,{onClick:()=>l(vt),disabled:No.isPending,className:i,"aria-label":`Extrude filament`,children:(0,$.jsx)(S,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})})]})]})}),(0,$.jsx)(`div`,{className:`h-px bg-bambu-dark-tertiary`}),(0,$.jsxs)(`div`,{className:`px-3 pt-2.5 pb-3`,children:[(0,$.jsx)(`div`,{className:`mb-1 text-[length:var(--pc-t9,9px)] uppercase tracking-wider text-bambu-gray/70`,children:W(`printers.bedJog.step`)}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:[1,10,50].map(e=>(0,$.jsx)(`button`,{onClick:()=>yt(e),className:`flex-1 px-1 py-1 rounded text-[length:var(--pc-t10,10px)] transition-colors ${vt===e?`bg-bambu-green/20 text-bambu-green`:`bg-bambu-dark text-bambu-gray hover:bg-bambu-dark-tertiary`}`,children:e},e))})]})]})]})]})})(),(0,$.jsxs)(`div`,{className:`inline-flex rounded-lg ${e.plate_detection_enabled?`ring-1 ring-green-500`:``}`,children:[(0,$.jsx)(`button`,{onClick:as,disabled:!Q.connected||Fo.isPending||!J(`printers:update`),className:`${o} rounded-r-none ${e.plate_detection_enabled?`bg-green-50 dark:bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:J(`printers:update`)?e.plate_detection_enabled?W(`printers.plateDetection.enabledClick`):W(`printers.plateDetection.disabledClick`):W(`printers.plateDetection.noPermission`),children:Fo.isPending?(0,$.jsx)(H,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] animate-spin`}):(0,$.jsx)(ce,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{onClick:os,disabled:!Q.connected||qr||!J(`printers:update`),className:`flex h-8 w-8 items-center justify-center rounded-r-lg border-l border-bambu-dark-tertiary transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${e.plate_detection_enabled?`bg-green-50 dark:bg-green-500/10 text-green-700 dark:text-green-400 hover:bg-green-500/20`:`bg-bambu-dark text-bambu-gray/50 hover:bg-bambu-dark-tertiary hover:text-white`}`,title:J(`printers:update`)?W(`printers.plateDetection.manageCalibration`):W(`printers.plateDetection.noPermission`),children:qr?(0,$.jsx)(H,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] animate-spin`}):(0,$.jsx)(I,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})})]}),(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(`button`,{"data-testid":`speed-control`,onClick:()=>dt(ut===e.id?null:e.id),disabled:!r||!J(`printers:control`),className:`${o} ${r?`bg-amber-50 dark:bg-amber-500/10 text-amber-700 dark:text-amber-400 hover:bg-amber-500/20`:`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`}`,title:r?W(`printers.speed.title`):void 0,children:(0,$.jsx)(ue,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),ut===e.id&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-40`,onClick:()=>dt(null)}),(0,$.jsx)(`div`,{className:`absolute bottom-full left-0 mb-1 z-50 bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-lg shadow-lg py-1 min-w-[130px]`,children:[{mode:1,label:W(`printers.speed.silent`)},{mode:2,label:W(`printers.speed.standard`)},{mode:3,label:W(`printers.speed.sport`)},{mode:4,label:W(`printers.speed.ludicrous`)}].map(({mode:e,label:t})=>(0,$.jsx)(`button`,{onClick:()=>{ko.mutate(e),dt(null)},className:`w-full text-left px-3 py-1.5 text-xs transition-colors ${Q.speed_level===e?`text-bambu-green bg-bambu-green/10`:`text-white hover:bg-bambu-dark-tertiary`}`,children:t},e))})]})]})]}),(0,$.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-2 flex-shrink-0`,children:[(()=>{let e=!r||i||!J(`printers:control`);return(0,$.jsxs)(`button`,{onClick:()=>n?xt(!0):lt(!0),disabled:e,className:`
  44. ${s}
  45. ${e?a:n?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-yellow-100 dark:bg-yellow-500/20 text-yellow-700 dark:text-yellow-400 hover:bg-yellow-500/30`}
  46. `,title:J(`printers:control`)?W(n?`printers.resume`:`printers.pause`):W(`printers.permission.noControl`),children:[n?(0,$.jsx)(ke,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}):(0,$.jsx)(Oe,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(n?`printers.resume`:`printers.pause`)]})})(),(()=>{let e=!r||i||!J(`printers:control`);return(0,$.jsxs)(`button`,{onClick:()=>st(!0),disabled:e,className:`
  47. ${s}
  48. ${e?a:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400 hover:bg-red-500/30`}
  49. `,title:J(`printers:control`)?W(`printers.stop`):W(`printers.permission.noControl`),children:[(0,$.jsx)(fn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`}),W(`printers.stop`)]})})()]})]})]})})(),(Mi?.length>0||Q.vt_tray.length>0)&&r===`expanded`&&(()=>{let t=Mi.filter(e=>e.tray.length>1),n=Mi.filter(e=>e.tray.length===1),r=Mi.length>0&&Q.vt_tray.length>0,i=!(r&&rt),a=e.nozzle_count===2||Q?.temperatures?.nozzle_2!==void 0,l=go[o]??1,f=e=>`${Math.round(e*l*1e3)/1e3}rem`,p=`3.5rem`,m={minWidth:p},g={minWidth:p,maxWidth:f(7.25)},x=e=>({gridTemplateColumns:`repeat(${e}, minmax(${p}, 1fr))`}),S=(Q.state===`RUNNING`||Q.state===`PAUSE`)&&Array.isArray(Q.ams_mapping)?Q.ams_mapping:[],C=e=>{let t=Math.max(1,e),n=`calc(${t} * ${p} + ${Math.max(0,t-1)} * 0.25rem + 1rem)`;return{flex:`1 1 ${n}`,minWidth:n}};return(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:W(`printers.filaments`)}),(0,$.jsx)(Ya,{state:Q.ams_filament_backup,onClick:()=>nt(!0)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`}),r&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Xa,{hidden:rt,onClick:at}),(0,$.jsx)(`div`,{className:`w-3 h-[2px] bg-bambu-dark-tertiary`})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[t.map(t=>{let n=Fa(t.id,wi,Oi,Ei);return(0,$.jsxs)(`div`,{style:C(4),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-full min-h-7 items-center justify-between gap-2 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(mo,{ams:t,printerId:e.id,label:Cn(t.id,t.tray.length),amsLabels:pi,canEdit:J(`printers:update`),onSaved:mi,children:(0,$.jsx)(`span`,{className:`block truncate text-[length:var(--pc-t10,10px)] text-white font-medium cursor-default select-none`,children:pi?.[t.id]||Cn(t.id,t.tray.length)})}),n?.kind===`inlet`?(0,$.jsx)(Pa,{inlet:n.inlet,title:W(`printers.amsSwitchInletTooltip`,{inlet:n.inlet,side:ur[n.inlet]})}):a&&n?.kind===`nozzle`?(0,$.jsx)(Na,{side:n.side}):null]}),(t.humidity!=null||t.temp!=null)&&(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[t.humidity!=null&&(0,$.jsx)(Za,{humidity:t.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Fr({amsId:t.id,amsLabel:Cn(t.id,t.tray.length),mode:`humidity`}),compact:!0}),t.temp!=null&&(0,$.jsx)(`div`,{className:`mr-1`,children:(0,$.jsx)(Qa,{temp:t.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Fr({amsId:t.id,amsLabel:Cn(t.id,t.tray.length),mode:`temperature`}),compact:!0})}),(Q.supports_drying||Q.drying_screen_only)&&(t.module_type===`n3f`||t.module_type===`n3s`)&&J(`printers:control`)&&(0,$.jsx)(`button`,{disabled:Q.drying_screen_only||!!(t.dry_sf_reason?.length&&t.dry_time===0),onClick:e=>{t.dry_time>0?Ha.mutate(t.id):Gt===t.id?Kt(null):ir(t,e.currentTarget)},className:`ml-1 flex items-center gap-0.5 px-1 py-0.5 rounded text-[length:var(--pc-t9,9px)] transition-colors ${t.dry_time>0?`bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`:Q.drying_screen_only||t.dry_sf_reason?.length?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:Q.drying_screen_only?W(`printers.drying.screenOnly`):t.dry_time>0?W(`printers.drying.stop`):t.dry_sf_reason?.length?W(Oa(t.dry_sf_reason)):W(`printers.drying.start`),children:(0,$.jsx)(Bn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]})]}),t.dry_time>0&&t.dry_countdown_stalled&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-slate-100 dark:bg-slate-500/10 px-2 py-1 text-[length:var(--pc-t9,9px)]`,title:W(`printers.drying.notRunningHint`),children:[(0,$.jsx)(Tr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-slate-500 dark:text-slate-400 shrink-0`}),(0,$.jsx)(`span`,{className:`text-slate-600 dark:text-slate-300 font-medium`,children:W(`printers.drying.notRunning`)}),t.dry_filament&&(0,$.jsx)(`span`,{className:`text-slate-500/90 dark:text-slate-400/80`,children:t.dry_target_temp==null?t.dry_filament:W(`printers.drying.targetSummary`,{filament:t.dry_filament,temp:t.dry_target_temp})}),!Q.drying_screen_only&&(0,$.jsx)(`button`,{onClick:()=>Ha.mutate(t.id),disabled:Ha.isPending,className:`ml-auto text-slate-500 dark:text-slate-400 hover:text-slate-700 dark:hover:text-slate-200 transition-colors disabled:opacity-50`,title:W(`printers.drying.stop`),children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]}),t.dry_time>0&&!t.dry_countdown_stalled&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-amber-50 dark:bg-amber-500/10 px-2 py-1 text-[length:var(--pc-t9,9px)]`,children:[(0,$.jsx)(Bn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-amber-600 dark:text-amber-400 shrink-0`}),(0,$.jsx)(`span`,{className:`text-amber-700 dark:text-amber-400 font-medium`,children:W(`printers.drying.active`)}),t.dry_filament&&(0,$.jsx)(`span`,{className:`text-amber-700/80 dark:text-amber-300/70`,children:t.dry_target_temp==null?t.dry_filament:W(`printers.drying.targetSummary`,{filament:t.dry_filament,temp:t.dry_target_temp})}),(0,$.jsx)(`span`,{className:`text-amber-700/80 dark:text-amber-300/70`,children:W(`printers.drying.timeRemaining`,{time:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`})}),!Q.drying_screen_only&&(0,$.jsx)(`button`,{onClick:()=>Ha.mutate(t.id),disabled:Ha.isPending,className:`ml-auto text-amber-700 dark:text-amber-400 hover:text-amber-900 dark:hover:text-amber-300 transition-colors disabled:opacity-50`,title:W(`printers.drying.stop`),children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]}),(0,$.jsx)(`div`,{className:`grid w-full gap-1`,style:x(4),children:[0,1,2,3].map(n=>{let r=t.tray[n]||t.tray.find(e=>e.id===n),i=r?.tray_type&&r.remain>=0,a=!r?.tray_type,o=Dn(r),s=t.id*4+n,l=Ri===s,f=zi!==null&&zi===s,p=Bi!==null&&Bi===s,g=r?.tray_info_idx?ci?.[r.tray_info_idx]:null,x=li?.[s],C=er(x?.preset_id,r?.tray_info_idx,x?.tray_info_idx)?x?.preset_name:void 0,w=(r?.tray_uuid||r?.tag_uid||on(e.serial_number,t.id,n))?.toUpperCase(),E=w?u?.[w]:void 0,O=cn(E),k=c&&!T?b?.find(r=>r.printer_id===e.id&&r.ams_id===t.id&&r.tray_id===n):void 0,A=k?y?.find(e=>e.id===k.spoolman_spool_id):void 0,j=A&&(A.label_weight??0)>0?Math.round(Math.max(0,(A.label_weight??0)-A.weight_used)/(A.label_weight??1)*100):null,M=_?.(e.id,t.id,n),N=(()=>{let e=M?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),P=N===0&&i&&r.remain>0?null:N,F=O??j??P??(i?r.remain:null),I=O!==null||j!==null?`spoolman`:P===null?i?`ams`:void 0:`inventory`,L=r?.tray_type?{vendor:kn(r)?`Bambu Lab`:`Generic`,profile:C||(A?[A.brand,A.slicer_filament_name?.split(`@`)[0].trim()||A.material].filter(Boolean).join(` `).trim():null)||M?.spool?.slicer_filament_name||g?.name||r.tray_sub_brands||r.tray_type,colorName:Un(r.tray_color||``,r.tray_sub_brands),colorHex:r.tray_color||null,kFactor:ja(r.k),fillLevel:F,trayUuid:r.tray_uuid||null,tagUid:r.tag_uid||null,fillSource:I}:null,R=Ho?.amsId===t.id&&Ho?.slotId===n,ee=S.indexOf(s),te=ee>=0?`P${ee+1}`:null,ne=(0,$.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${a?`opacity-50`:``} ${f?`ring-2 ring-amber-400 ring-offset-1 ring-offset-bambu-dark animate-pulse`:p?`ring-2 ring-red-500/60 ring-offset-1 ring-offset-bambu-dark`:l?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[f&&(0,$.jsx)(`span`,{"aria-label":W(`printers.expectedSlot.ariaLabel`,{n:n+1}),title:W(`printers.expectedSlot.title`),className:`absolute top-0.5 left-0.5 px-1 py-px text-[length:var(--pc-t8,8px)] font-bold text-bambu-dark bg-amber-400 rounded pointer-events-none leading-none`,children:`↓`}),te&&(0,$.jsx)(`span`,{"aria-label":W(`printers.activeJobSlot.ariaLabel`,{n:ee+1}),title:W(`printers.activeJobSlot.title`,{n:ee+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[length:var(--pc-t8,8px)] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:te}),(0,$.jsx)(ya,{trayColor:r?.tray_color,trayType:r?.tray_type,isEmpty:a,emptyKind:o,slotNumber:n+1}),(0,$.jsx)(`div`,{className:`text-[length:var(--pc-t9,9px)] text-white font-bold truncate`,children:r?.tray_type||W(o===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,$.jsx)(Ma,{k:L?r?.k:null,reserve:Fi}),(0,$.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:F!==null&&F>=0&&!a&&r&&(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${F}%`,backgroundColor:un(F)}})})]});return(0,$.jsxs)(`div`,{className:`relative group w-full`,style:m,children:[R&&(0,$.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,$.jsx)(dn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] text-bambu-green animate-spin`})}),L?(0,$.jsx)(da,{data:L,actions:Ds({amsId:t.id,slotId:n,loadTrayId:t.id*4+n,isRefreshing:R}),spoolman:{enabled:c,linkedSpoolId:k?.spoolman_spool_id??(w?u?.[w]?.id:void 0),spoolmanUrl:d,syncMode:h,onLinkSpool:c&&!k&&!M?()=>{let r=(L.trayUuid||L.tagUid||on(e.serial_number,t.id,n)).toUpperCase();zr({tagUid:L.tagUid||r,trayUuid:L.trayUuid||``,printerId:e.id,amsId:t.id,trayId:n})}:void 0,onUnlinkSpool:E?.id?()=>Ia.mutate(E.id):void 0},inventory:(()=>{if(c){if(T)return;let i=k,a=A;return{assignedSpool:a?{id:a.id,material:a.material,subtype:a.subtype,brand:a.brand??null,color_name:a.color_name??null,color_name_is_synthesized:a.color_name_is_synthesized,rgba:a.rgba??null,extra_colors:a.extra_colors??null,effect_type:a.effect_type??null,remainingWeightGrams:a.label_weight?Math.max(0,Math.round(a.label_weight-a.weight_used)):void 0}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:n,trayInfo:{type:r?.tray_type||L.profile,material:r?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Cn(t.id,t.tray.length)} Slot ${n+1}`}}),onUnassignSpool:a&&!kn(r)?()=>D?.(a.id):void 0,isAssigned:!!i||kn(r)}}let i=_?.(e.id,t.id,n);return{assignedSpool:i?.spool?{id:i.spool.id,material:i.spool.material,subtype:i.spool.subtype,brand:i.spool.brand,color_name:i.spool.color_name,rgba:i.spool.rgba??null,extra_colors:i.spool.extra_colors??null,effect_type:i.spool.effect_type??null,remainingWeightGrams:Math.max(0,Math.round(i.spool.label_weight-i.spool.weight_used))}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:n,trayInfo:{type:r?.tray_type||L.profile,material:r?.tray_type??void 0,profile:L.profile,color:L.colorHex||``,location:`${Cn(t.id,t.tray.length)} Slot ${n+1}`}}),onUnassignSpool:i&&!kn(r)?()=>v?.(e.id,t.id,n):void 0,isAssigned:!!i||kn(r)}})(),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:t.id,trayId:n,trayCount:t.tray.length,trayType:r?.tray_type||void 0,trayColor:r?.tray_color||void 0,traySubBrands:r?.tray_sub_brands||void 0,trayInfoIdx:r?.tray_info_idx||void 0,extruderId:Xt(t.id,r?.id??0,wi,Oi),caliIdx:r?.cali_idx,savedPresetId:er(x?.preset_id,r?.tray_info_idx,x?.tray_info_idx)?x?.preset_id:void 0})},children:ne}):(0,$.jsx)(fa,{kind:o??void 0,actions:Ds({amsId:t.id,slotId:n,loadTrayId:t.id*4+n,isRefreshing:R}),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:t.id,trayId:n,trayCount:t.tray.length,extruderId:Xt(t.id,r?.id??0,wi,Oi)})},onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:n,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`${Cn(t.id,t.tray.length)} Slot ${n+1}`}}),children:ne})]},n)})})]},t.id)}),n.map(t=>{let n=Fa(t.id,wi,Oi,Ei),r=t.tray[0],i=r?.tray_type&&r.remain>=0,o=!r?.tray_type,l=Dn(r),m=Qn(t.id,r?.id??0,!1),x=Ri===m,C=zi!==null&&zi===m,w=Bi!==null&&Bi===m,E=r?.tray_info_idx?ci?.[r.tray_info_idx]:null,O=li?.[m],k=er(O?.preset_id,r?.tray_info_idx,O?.tray_info_idx)?O?.preset_name:void 0,A=r?.id??0,j=(r?.tray_uuid||r?.tag_uid||on(e.serial_number,t.id,A))?.toUpperCase(),M=j?u?.[j]:void 0,N=cn(M),P=_?.(e.id,t.id,A),F=(()=>{let e=P?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),I=F===0&&i&&r.remain>0?null:F,L=c&&!T?b?.find(n=>n.printer_id===e.id&&n.ams_id===t.id&&n.tray_id===A):void 0,R=L?y?.find(e=>e.id===L.spoolman_spool_id):void 0,ee=R&&(R.label_weight??0)>0?Math.round(Math.max(0,(R.label_weight??0)-R.weight_used)/(R.label_weight??1)*100):null,te=N??ee??I??(i?r.remain:null),ne=N!==null||ee!==null?`spoolman`:I===null?i?`ams`:void 0:`inventory`,z=r?.tray_type?{vendor:kn(r)?`Bambu Lab`:`Generic`,profile:k||(R?[R.brand,R.slicer_filament_name?.split(`@`)[0].trim()||R.material].filter(Boolean).join(` `).trim():null)||P?.spool?.slicer_filament_name||E?.name||r.tray_sub_brands||r.tray_type,colorName:Un(r.tray_color||``,r.tray_sub_brands),colorHex:r.tray_color||null,kFactor:ja(r.k),fillLevel:te,trayUuid:r.tray_uuid||null,tagUid:r.tag_uid||null,fillSource:ne}:null,re=Ho?.amsId===t.id&&Ho?.slotId===A,B=S.indexOf(m),ie=B>=0?`P${B+1}`:null,ae=(0,$.jsxs)(`div`,{className:`relative w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${o?`opacity-50`:``} ${C?`ring-2 ring-amber-400 ring-offset-1 ring-offset-bambu-dark animate-pulse`:w?`ring-2 ring-red-500/60 ring-offset-1 ring-offset-bambu-dark`:x?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[C&&(0,$.jsx)(`span`,{"aria-label":W(`printers.expectedSlot.ariaLabel`,{n:1}),title:W(`printers.expectedSlot.title`),className:`absolute top-0.5 left-0.5 px-1 py-px text-[length:var(--pc-t8,8px)] font-bold text-bambu-dark bg-amber-400 rounded pointer-events-none leading-none`,children:`↓`}),ie&&(0,$.jsx)(`span`,{"aria-label":W(`printers.activeJobSlot.ariaLabel`,{n:B+1}),title:W(`printers.activeJobSlot.title`,{n:B+1}),className:`absolute top-0.5 right-0.5 px-1 py-px text-[length:var(--pc-t8,8px)] font-bold text-bambu-dark bg-bambu-green rounded pointer-events-none leading-none`,children:ie}),(0,$.jsx)(ya,{trayColor:r?.tray_color,trayType:r?.tray_type,isEmpty:o,emptyKind:l,slotNumber:1}),(0,$.jsx)(`div`,{className:`text-[length:var(--pc-t9,9px)] text-white font-bold truncate`,children:r?.tray_type||W(l===`reset`?`ams.slotUnconfigured`:`ams.slotEmpty`)}),(0,$.jsx)(Ma,{k:z?r?.k:null,reserve:Fi}),(0,$.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:te!==null&&te>=0&&!o&&(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${te}%`,backgroundColor:un(te)}})})]}),V=f(11);return(0,$.jsxs)(`div`,{style:{flex:`1 1 ${V}`,minWidth:V,maxWidth:`calc(4 * ${p} + 3 * 0.25rem + 1rem)`},className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,$.jsxs)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(mo,{ams:t,printerId:e.id,label:Cn(t.id,t.tray.length),amsLabels:pi,canEdit:J(`printers:update`),onSaved:mi,children:(0,$.jsx)(`span`,{className:`block truncate text-[length:var(--pc-t10,10px)] text-white font-medium cursor-default select-none`,children:pi?.[t.id]||Cn(t.id,t.tray.length)})}),n?.kind===`inlet`?(0,$.jsx)(Pa,{inlet:n.inlet,title:W(`printers.amsSwitchInletTooltip`,{inlet:n.inlet,side:ur[n.inlet]})}):a&&n?.kind===`nozzle`?(0,$.jsx)(Na,{side:n.side}):null]}),(Q.supports_drying||Q.drying_screen_only)&&(t.module_type===`n3f`||t.module_type===`n3s`)&&J(`printers:control`)&&(0,$.jsx)(`div`,{className:`relative ml-auto`,children:(0,$.jsx)(`button`,{disabled:Q.drying_screen_only,onClick:e=>{t.dry_time>0?Ha.mutate(t.id):Gt===t.id?Kt(null):ir(t,e.currentTarget)},className:`flex items-center gap-0.5 px-1 py-0.5 rounded text-[length:var(--pc-t9,9px)] transition-colors ${t.dry_time>0?`bg-amber-100 dark:bg-amber-500/20 text-amber-700 dark:text-amber-400`:Q.drying_screen_only?`bg-bambu-dark text-bambu-gray/50 cursor-not-allowed`:`bg-bambu-dark text-bambu-gray hover:text-white hover:bg-bambu-dark/80`}`,title:Q.drying_screen_only?W(`printers.drying.screenOnly`):t.dry_time>0?W(`printers.drying.stop`):W(`printers.drying.start`),children:(0,$.jsx)(Bn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})})]}),t.dry_time>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 overflow-hidden whitespace-nowrap rounded-lg px-2 py-1 text-[length:var(--pc-t9,9px)] ${t.dry_countdown_stalled?`bg-slate-100 dark:bg-slate-500/10`:`bg-amber-50 dark:bg-amber-500/10`}`,title:t.dry_countdown_stalled?W(`printers.drying.notRunningHint`):void 0,children:[t.dry_countdown_stalled?(0,$.jsx)(Tr,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-slate-500 dark:text-slate-400 shrink-0`}):(0,$.jsx)(Bn,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-amber-600 dark:text-amber-400 shrink-0`}),t.dry_countdown_stalled&&(0,$.jsx)(`span`,{className:`text-slate-600 dark:text-slate-300 text-[length:var(--pc-t8,8px)] font-medium truncate`,children:W(`printers.drying.notRunning`)}),t.dry_filament&&(0,$.jsx)(`span`,{className:`${t.dry_countdown_stalled?`text-slate-500/90 dark:text-slate-400/80`:`text-amber-700/80 dark:text-amber-300/70`} text-[length:var(--pc-t8,8px)] truncate`,children:t.dry_target_temp==null?t.dry_filament:W(`printers.drying.targetSummary`,{filament:t.dry_filament,temp:t.dry_target_temp})}),!t.dry_countdown_stalled&&(0,$.jsx)(`span`,{className:`text-amber-700/80 dark:text-amber-300/70 text-[length:var(--pc-t8,8px)] truncate`,children:t.dry_time>=60?`${Math.floor(t.dry_time/60)}h ${t.dry_time%60}m`:`${t.dry_time}m`}),!Q.drying_screen_only&&(0,$.jsx)(`button`,{onClick:()=>Ha.mutate(t.id),disabled:Ha.isPending,className:`ml-auto text-amber-700 dark:text-amber-400 hover:text-amber-900 dark:hover:text-amber-300 transition-colors disabled:opacity-50 shrink-0`,title:W(`printers.drying.stop`),children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)]`})})]}),(0,$.jsxs)(`div`,{className:`flex gap-1.5 max-[550px]:flex-col max-[550px]:items-start`,children:[(0,$.jsxs)(`div`,{className:`relative group flex-1`,style:g,children:[re&&(0,$.jsx)(`div`,{className:`absolute inset-0 bg-bambu-dark-tertiary/80 rounded flex items-center justify-center z-20`,children:(0,$.jsx)(dn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] text-bambu-green animate-spin`})}),z?(0,$.jsx)(da,{data:z,actions:Ds({amsId:t.id,slotId:A,loadTrayId:t.id*4+A,isRefreshing:re}),spoolman:{enabled:c,linkedSpoolId:L?.spoolman_spool_id??(j?u?.[j]?.id:void 0),spoolmanUrl:d,syncMode:h,onLinkSpool:c&&!L&&!P?()=>{let n=(z.trayUuid||z.tagUid||on(e.serial_number,t.id,A)).toUpperCase();zr({tagUid:z.tagUid||n,trayUuid:z.trayUuid||``,printerId:e.id,amsId:t.id,trayId:A})}:void 0,onUnlinkSpool:M?.id?()=>Ia.mutate(M.id):void 0},inventory:(()=>{if(c){if(T)return;let n=L,i=R;return{assignedSpool:i?{id:i.id,material:i.material,subtype:i.subtype,brand:i.brand??null,color_name:i.color_name??null,color_name_is_synthesized:i.color_name_is_synthesized,rgba:i.rgba??null,extra_colors:i.extra_colors??null,effect_type:i.effect_type??null,remainingWeightGrams:i.label_weight?Math.max(0,Math.round(i.label_weight-i.weight_used)):void 0}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:A,trayInfo:{type:r?.tray_type||z.profile,material:r?.tray_type??void 0,profile:z.profile,color:z.colorHex||``,location:Cn(t.id,t.tray.length)}}),onUnassignSpool:i&&!kn(r)?()=>D?.(i.id):void 0,isAssigned:!!n||kn(r)}}let n=_?.(e.id,t.id,A);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,subtype:n.spool.subtype,brand:n.spool.brand,color_name:n.spool.color_name,rgba:n.spool.rgba??null,extra_colors:n.spool.extra_colors??null,effect_type:n.spool.effect_type??null,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:A,trayInfo:{type:r?.tray_type||z.profile,material:r?.tray_type??void 0,profile:z.profile,color:z.colorHex||``,location:Cn(t.id,t.tray.length)}}),onUnassignSpool:n&&!kn(r)?()=>v?.(e.id,t.id,A):void 0,isAssigned:!!n||kn(r)}})(),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:t.id,trayId:A,trayCount:t.tray.length,trayType:r?.tray_type||void 0,trayColor:r?.tray_color||void 0,traySubBrands:r?.tray_sub_brands||void 0,trayInfoIdx:r?.tray_info_idx||void 0,extruderId:Xt(t.id,r?.id??0,wi,Oi),caliIdx:r?.cali_idx,savedPresetId:er(O?.preset_id,r?.tray_info_idx,O?.tray_info_idx)?O?.preset_id:void 0})},children:ae}):(0,$.jsx)(fa,{kind:l??void 0,actions:Ds({amsId:t.id,slotId:A,loadTrayId:t.id*4+A,isRefreshing:re}),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:t.id,trayId:A,trayCount:t.tray.length,extruderId:Xt(t.id,r?.id??0,wi,Oi)})},onAssignSpool:()=>Vr({printerId:e.id,amsId:t.id,trayId:A,trayInfo:{type:``,material:void 0,profile:``,color:``,location:Cn(t.id,t.tray.length)}}),children:ae})]}),(t.humidity!=null||t.temp!=null)&&(0,$.jsxs)(`div`,{className:`flex flex-col justify-center gap-1 shrink-0 max-[550px]:w-full`,children:[t.temp!=null&&(0,$.jsx)(Qa,{temp:t.temp,goodThreshold:s?.tempGood,fairThreshold:s?.tempFair,onClick:()=>Fr({amsId:t.id,amsLabel:Cn(t.id,t.tray.length),mode:`temperature`}),compact:!0}),t.humidity!=null&&(0,$.jsx)(Za,{humidity:t.humidity,goodThreshold:s?.humidityGood,fairThreshold:s?.humidityFair,onClick:()=>Fr({amsId:t.id,amsLabel:Cn(t.id,t.tray.length),mode:`humidity`}),compact:!0})]})]})]},t.id)}),Q.vt_tray.length>0&&i&&(0,$.jsxs)(`div`,{style:C(Q.vt_tray.length),className:`min-w-0 p-2 bg-bambu-dark rounded-[10px] space-y-1`,children:[(0,$.jsx)(`div`,{className:`flex w-full min-h-7 items-center gap-1.5 rounded-lg bg-bambu-dark-secondary px-2 py-1`,children:(0,$.jsx)(`span`,{className:`block min-w-0 flex-1 truncate text-[length:var(--pc-t10,10px)] text-white font-medium`,children:W(`printers.external`)})}),(0,$.jsx)(`div`,{className:`grid w-full gap-1`,style:x(Q.vt_tray.length>1?2:1),children:[...Q.vt_tray].sort((e,t)=>(e.id??254)-(t.id??254)).map(t=>{let n=t.id??254,r=a&&Ri===254?n===254&&Q.active_extruder===1||n===255&&Q.active_extruder===0:Ri===n,i=n-254,o=a?W(n===254?`printers.extL`:`printers.extR`):``,s=t.tray_info_idx?ci?.[t.tray_info_idx]:null,l=li?.[1020+i],f=er(l?.preset_id,t.tray_info_idx,l?.tray_info_idx)?l?.preset_name:void 0,p=(t.tray_uuid||t.tag_uid||on(e.serial_number,255,i))?.toUpperCase(),g=p?u?.[p]:void 0,x=cn(g),S=_?.(e.id,255,i),C=(()=>{let e=S?.spool;return e&&e.label_weight>0&&e.weight_used!=null?Math.round(Math.max(0,e.label_weight-e.weight_used)/e.label_weight*100):null})(),w=t.tray_type&&t.remain>=0,E=C===0&&w&&t.remain>0?null:C,O=c&&!T?b?.find(t=>t.printer_id===e.id&&t.ams_id===255&&t.tray_id===i):void 0,k=O?y?.find(e=>e.id===O.spoolman_spool_id):void 0,A=k&&(k.label_weight??0)>0?Math.round(Math.max(0,(k.label_weight??0)-k.weight_used)/(k.label_weight??1)*100):null,j=x??A??E??(w?t.remain:null),M=x!==null||A!==null?`spoolman`:E===null?w?`ams`:void 0:`inventory`,N={vendor:kn(t)?`Bambu Lab`:`Generic`,profile:f||(k?[k.brand,k.slicer_filament_name?.split(`@`)[0].trim()||k.material].filter(Boolean).join(` `).trim():null)||S?.spool?.slicer_filament_name||s?.name||t.tray_sub_brands||t.tray_type||`Unknown`,colorName:Un(t.tray_color||``,t.tray_sub_brands),colorHex:t.tray_color||null,kFactor:ja(t.k),fillLevel:j,trayUuid:t.tray_uuid||null,tagUid:t.tag_uid||null,fillSource:M},P=!t.tray_type,F=Dn(t),I=(0,$.jsxs)(`div`,{className:`w-full bg-bambu-dark-secondary rounded-lg p-1 text-center ${P?`opacity-50`:``} ${r?`ring-2 ring-bambu-green ring-offset-1 ring-offset-bambu-dark`:``}`,children:[(0,$.jsx)(ya,{trayColor:t.tray_color,trayType:t.tray_type,isEmpty:P,emptyKind:F,slotNumber:a?n===254?`L`:`R`:i+1}),(0,$.jsx)(`div`,{className:`text-[length:var(--pc-t9,9px)] font-bold truncate ${P?`text-white/40`:`text-white`}`,children:t.tray_type||W(`ams.slotEmpty`)}),(0,$.jsx)(Ma,{k:P?null:t.k,reserve:Fi}),(0,$.jsx)(`div`,{className:`mt-1 h-1.5 bg-black/30 rounded-full overflow-hidden`,children:j!==null&&j>=0&&!P&&(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${j}%`,backgroundColor:un(j)}})})]});return(0,$.jsx)(`div`,{className:`relative group w-full`,style:m,children:P?(0,$.jsx)(fa,{kind:F??void 0,actions:Ds({amsId:255,slotId:i,loadTrayId:n,includeRfid:!1}),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:255,trayId:i,trayCount:1,extruderId:a?+(n===254):void 0})},onAssignSpool:()=>Vr({printerId:e.id,amsId:255,trayId:i,trayInfo:{type:``,material:void 0,profile:``,color:``,location:`External Slot ${i+1}`}}),children:I}):(0,$.jsx)(da,{data:N,actions:Ds({amsId:255,slotId:i,loadTrayId:n,includeRfid:!1}),spoolman:{enabled:c,linkedSpoolId:O?.spoolman_spool_id??(p?u?.[p]?.id:void 0),spoolmanUrl:d,syncMode:h,onLinkSpool:c&&!O&&!S?()=>{let t=(N.trayUuid||N.tagUid||on(e.serial_number,255,i)).toUpperCase();zr({tagUid:N.tagUid||t,trayUuid:N.trayUuid||``,printerId:e.id,amsId:255,trayId:i})}:void 0,onUnlinkSpool:g?.id?()=>Ia.mutate(g.id):void 0},inventory:(()=>{if(c){if(T)return;let n=O,r=k;return{assignedSpool:r?{id:r.id,material:r.material,subtype:r.subtype,brand:r.brand??null,color_name:r.color_name??null,color_name_is_synthesized:r.color_name_is_synthesized,rgba:r.rgba??null,extra_colors:r.extra_colors??null,effect_type:r.effect_type??null,remainingWeightGrams:r.label_weight?Math.max(0,Math.round(r.label_weight-r.weight_used)):void 0}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:255,trayId:i,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:o||W(`printers.external`)}}),onUnassignSpool:r&&!kn(t)?()=>D?.(r.id):void 0,isAssigned:!!n||kn(t)}}let n=_?.(e.id,255,i);return{assignedSpool:n?.spool?{id:n.spool.id,material:n.spool.material,subtype:n.spool.subtype,brand:n.spool.brand,color_name:n.spool.color_name,rgba:n.spool.rgba??null,extra_colors:n.spool.extra_colors??null,effect_type:n.spool.effect_type??null,remainingWeightGrams:Math.max(0,Math.round(n.spool.label_weight-n.spool.weight_used))}:null,onAssignSpool:()=>Vr({printerId:e.id,amsId:255,trayId:i,trayInfo:{type:t.tray_type||N.profile,material:t.tray_type??void 0,profile:N.profile,color:N.colorHex||``,location:o||W(`printers.external`)}}),onUnassignSpool:n&&!kn(t)?()=>v?.(e.id,255,i):void 0,isAssigned:!!n||kn(t)}})(),configureSlot:{enabled:J(`printers:control`),onConfigure:()=>Ur({amsId:255,trayId:i,trayCount:1,trayType:t.tray_type||void 0,trayColor:t.tray_color||void 0,traySubBrands:t.tray_sub_brands||void 0,trayInfoIdx:t.tray_info_idx||void 0,extruderId:a?+(n===254):void 0,caliIdx:t.cali_idx,savedPresetId:er(l?.preset_id,t.tray_info_idx,l?.tray_info_idx)?l?.preset_id:void 0})},children:I})},n)})})]})]})]})})()]}),e.is_active!==!1&&!Q?.connected&&r===`expanded`&&la&&bo,r===`expanded`&&(0,$.jsxs)(`div`,{className:`mt-auto`,children:[Wi&&(0,$.jsxs)(`div`,{className:`pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] uppercase tracking-wider text-bambu-gray font-medium`,children:W(`printers.power`,`Power`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2 rounded-[10px] bg-bambu-dark p-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0 pl-1`,children:[(0,$.jsx)(Vn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] text-bambu-gray flex-shrink-0`}),(0,$.jsx)(`span`,{className:`text-sm text-white truncate`,children:Wi.name}),(0,$.jsx)(`span`,{className:`px-1.5 py-0.5 rounded-full bg-bambu-dark-tertiary text-bambu-gray text-[length:var(--pc-t10,10px)] font-medium flex-shrink-0`,title:W(`smartPlugs.power`),children:Ki?.energy?.power!==null&&Ki?.energy?.power!==void 0?`${Math.round(Ki.energy.power)}W`:`--`})]}),(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`button`,{onClick:()=>Ga.mutate(!Wi.auto_off),disabled:Ga.isPending||Wi.auto_off_executed||!J(`smart_plugs:control`),title:J(`smart_plugs:control`)?Wi.auto_off_executed?W(`printers.autoOffExecuted`):W(`printers.autoOffAfterPrint`):W(`printers.permission.noSmartPlugControl`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs font-bold transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${J(`smart_plugs:control`)?Wi.auto_off||Wi.auto_off_executed?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,children:(0,$.jsx)(vn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(`button`,{onClick:()=>{Ki?.state===`ON`?Je(!0):Ke(!0)},disabled:Wa.isPending||!J(`smart_plugs:control`),className:`flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-lg text-xs transition-colors disabled:opacity-50 disabled:cursor-not-allowed ${J(`smart_plugs:control`)?Ki?.state===`ON`?`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green/30`:`bg-bambu-dark-tertiary text-bambu-gray hover:text-white hover:bg-bambu-dark-tertiary/80`:`bg-bambu-dark-tertiary/50 text-bambu-gray/50`}`,title:J(`smart_plugs:control`)?Ki?.state===`ON`?`Turn off`:`Turn on`:W(`printers.permission.noSmartPlugControl`),children:(0,$.jsx)(Vn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})})]})]}),Gi&&Gi.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mt-2`,children:[(0,$.jsx)(Kn,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] text-blue-600 dark:text-blue-400 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs text-bambu-gray`,children:`HA:`}),(0,$.jsx)(`div`,{className:`h-[2px] w-5 bg-bambu-dark-tertiary/50`}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:Gi.map(e=>{let t=e.ha_entity_id?.startsWith(`script.`);return(0,$.jsxs)(`button`,{onClick:()=>{t?Ka.mutate({id:e.id,action:`on`}):Xe(e)},disabled:Ka.isPending,title:`${t?`Run`:`Toggle`} ${e.ha_entity_id}`,className:`px-2 py-0.5 text-xs bg-blue-100 dark:bg-blue-500/20 text-blue-700 dark:text-blue-400 hover:bg-blue-500/30 rounded transition-colors flex items-center gap-1`,children:[(0,$.jsx)(ke,{className:`w-[var(--pc-i25,0.625rem)] h-[var(--pc-i25,0.625rem)]`}),e.name]},e.id)})})]})]}),(0,$.jsx)(ea,{printerId:e.id}),(0,$.jsxs)(`div`,{className:`pt-4`,children:[(0,$.jsx)(`div`,{className:`mb-3 h-[2px] bg-bambu-dark-tertiary`}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[Os,(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2 flex-wrap`,children:[(0,$.jsxs)(`div`,{className:`flex items-center flex-shrink-0`,children:[(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:()=>Ts(k),disabled:!Q?.connected||!J(`camera:view`),title:J(`camera:view`)?W(k===`embedded`?`printers.openCameraOverlay`:`printers.openCameraWindow`):W(`printers.permission.noCamera`),className:`${ws} !rounded-r-none`,children:(0,$.jsx)(rn,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();Mr({x:t.left,y:t.bottom+4})},disabled:!Q?.connected||!J(`camera:view`),title:J(`camera:view`)?W(`settings.cameraViewMode`):W(`printers.permission.noCamera`),"aria-label":W(`settings.cameraViewMode`),className:`!h-8 !min-h-8 !w-6 !px-0 !py-0 !rounded-l-none border-l border-bambu-dark`,children:(0,$.jsx)(I,{className:`w-3 h-3`})})]}),Ar&&(0,$.jsx)(oe,{x:Ar.x,y:Ar.y,items:Es,onClose:()=>Mr(null)}),(0,$.jsx)(Y,{variant:`secondary`,size:`sm`,onClick:()=>He(!0),disabled:!J(`printers:files`),title:J(`printers:files`)?W(`printers.browseFiles`):W(`printers.permission.noFiles`),className:ws,children:(0,$.jsx)(fe,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`})}),(0,$.jsxs)(Y,{size:`sm`,onClick:()=>Tt(!0),disabled:!J(`library:upload`)||!J(`queue:create`),title:J(`library:upload`)?J(`queue:create`)?W(`common.print`):W(`fileManager.noPermissionAddToQueue`):W(`fileManager.noPermissionUpload`),className:`!h-8 !min-h-8 !px-2 !py-0 !bg-bambu-green hover:!bg-bambu-green/80 !text-white`,children:[(0,$.jsx)(ln,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)]`}),W(`common.print`)]})]})]})]})]}),(0,$.jsx)(vo,{printerId:e.id,dryingActive:Mi.some(e=>(e.dry_time??0)>0),timeFormat:O})]}),Ve&&(0,$.jsx)(Vi,{printerId:e.id,printerName:e.name,onClose:()=>He(!1)}),wt&&(0,$.jsx)(fr,{folderId:null,onClose:()=>Tt(!1),onUploadComplete:()=>{},autoUpload:!0,accept:`.gcode,.3mf`,validateFile:e=>{let t=e.name.toLowerCase();if(!t.endsWith(`.gcode`)&&!t.includes(`.gcode.`))return W(`printers.dropNotPrintable`,`Only .gcode and .gcode.3mf files can be printed`)},onFileUploaded:t=>{let n=t.metadata?.sliced_for_model,r=gr(e.model);if(n&&r&&n.toLowerCase()!==r.toLowerCase())return i.deleteLibraryFile(t.id).catch(()=>{}),W(`printers.incompatibleFile`,`This file was sliced for {{slicedFor}}, but this printer is a {{printerModel}}`,{slicedFor:n,printerModel:r});Bt({id:t.id,filename:t.filename})}}),zt&&(0,$.jsx)(zn,{mode:`create`,libraryFileId:zt.id,archiveName:zt.filename,initialSelectedPrinterIds:[e.id],onClose:()=>Bt(null),onSuccess:()=>Bt(null),cleanupLibraryAfterDispatch:!0}),Ue&&(0,$.jsx)(Yi,{printerId:e.id,printerName:e.name,onClose:()=>We(!1)}),Nt&&(0,$.jsx)(Pn,{printerId:e.id,printerName:e.name,onClose:()=>Ft(!1)}),Et&&(0,$.jsx)(ma,{printer:e,status:Q,totalPrintHours:n?.total_print_hours,onClose:It}),Z&&(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4`,onClick:()=>ss(),children:(0,$.jsxs)(`div`,{className:`bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl max-w-lg w-full`,onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Z.needs_calibration?(0,$.jsx)(ce,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-blue-500`}):Z.is_empty?(0,$.jsx)(ne,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-green-500`}):(0,$.jsx)(L,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)] text-yellow-500`}),(0,$.jsx)(`h2`,{className:`text-lg font-semibold text-white`,children:`Build Plate Check`}),Z.reference_count!==void 0&&Z.max_references&&(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray bg-bambu-dark-tertiary px-2 py-1 rounded`,children:[Z.reference_count,`/`,Z.max_references,` refs`]})]}),(0,$.jsx)(`button`,{onClick:()=>ss(),className:`p-1 text-bambu-gray hover:text-white rounded transition-colors`,children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i5,1.25rem)] h-[var(--pc-i5,1.25rem)]`})})]}),(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[Z.needs_calibration?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`p-3 rounded-lg bg-blue-100 dark:bg-blue-500/20 border border-blue-300 dark:border-blue-500/50`,children:[(0,$.jsx)(`p`,{className:`font-medium text-blue-700 dark:text-blue-400`,children:W(`printers.plateDetection.calibrationRequired`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,dangerouslySetInnerHTML:{__html:W(`printers.plateDetection.calibrationInstructions`)}})]}),(0,$.jsxs)(`div`,{className:`text-sm text-bambu-gray space-y-2`,children:[(0,$.jsx)(`p`,{children:W(`printers.plateDetection.calibrationDescription`)}),(0,$.jsx)(`p`,{dangerouslySetInnerHTML:{__html:W(`printers.plateDetection.calibrationTip`)}})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`p-3 rounded-lg ${Z.is_empty?`bg-green-100 dark:bg-green-500/20 border border-green-300 dark:border-green-500/50`:`bg-yellow-100 dark:bg-yellow-500/20 border border-yellow-300 dark:border-yellow-500/50`}`,children:[(0,$.jsx)(`p`,{className:`font-medium ${Z.is_empty?`text-green-700 dark:text-green-400`:`text-yellow-700 dark:text-yellow-400`}`,children:Z.is_empty?W(`printers.plateDetection.plateEmpty`):W(`printers.plateDetection.objectsDetected`)}),(0,$.jsxs)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:[W(`printers.plateDetection.confidence`),`: `,Math.round(Z.confidence*100),`% | `,W(`printers.plateDetection.difference`),`: `,Z.difference_percent.toFixed(1),`%`]})]}),Z.debug_image_url&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray mb-2`,children:W(`printers.plateDetection.analysisPreview`)}),(0,$.jsx)(`img`,{src:Z.debug_image_url,alt:W(`printers.plateDetection.analysisPreview`),className:`w-full rounded-lg border border-bambu-dark-tertiary`}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-2`,children:W(`printers.plateDetection.analysisLegend`)})]}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:Z.message})]}),es&&es.references.length>0&&(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:W(`printers.plateDetection.savedReferences`,{count:es.references.length,max:es.max_references})}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),(0,$.jsx)(`div`,{className:`grid grid-cols-5 gap-2`,children:es.references.map(t=>(0,$.jsxs)(`div`,{className:`relative group`,children:[(0,$.jsx)(`img`,{src:i.getPlateReferenceThumbnailUrl(e.id,t.index),alt:t.label||`Reference ${t.index+1}`,className:`w-full aspect-video object-cover rounded border border-bambu-dark-tertiary`}),(0,$.jsx)(`button`,{onClick:()=>us(t.index),className:`absolute top-1 right-1 p-0.5 bg-red-500/80 rounded can-hover:opacity-0 group-hover:opacity-100 focus-visible:opacity-100 transition-opacity`,title:W(`printers.plateDetection.deleteReference`),children:(0,$.jsx)(Pt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] text-white`})}),ns?.index===t.index?(0,$.jsx)(`input`,{type:`text`,value:ns.label,onChange:e=>rs({...ns,label:e.target.value}),onBlur:()=>ls(t.index,ns.label),onKeyDown:e=>{e.key===`Enter`&&ls(t.index,ns.label),e.key===`Escape`&&rs(null)},className:`w-full mt-1 px-1 py-0.5 text-xs bg-bambu-dark-tertiary border border-bambu-green rounded text-white`,autoFocus:!0,placeholder:W(`printers.plateDetection.labelPlaceholder`)}):(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1 truncate cursor-pointer hover:text-white`,onClick:()=>rs({index:t.index,label:t.label}),title:t.label?W(`printers.plateDetection.clickToEdit`,{label:t.label}):W(`printers.plateDetection.clickToAddLabel`),children:t.label||(0,$.jsx)(`span`,{className:`italic opacity-50`,children:W(`printers.noLabel`)})}),(0,$.jsx)(`p`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray/60`,children:t.timestamp?qt(t.timestamp)?.toLocaleDateString()??``:``})]},t.index))})]}),!Z.needs_calibration&&(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-white shrink-0`,children:W(`printers.roi.title`)}),(0,$.jsx)(`div`,{className:`flex-1 h-[2px] bg-bambu-dark-tertiary`})]}),Zr?(0,$.jsxs)(`div`,{className:`flex gap-1`,children:[(0,$.jsx)(Y,{variant:`ghost`,size:`sm`,onClick:()=>Qr(null),disabled:$r,children:W(`common.cancel`)}),(0,$.jsx)(Y,{size:`sm`,onClick:ds,disabled:$r,children:$r?(0,$.jsx)(H,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] animate-spin`}):W(`common.save`)})]}):(0,$.jsxs)(Y,{variant:`ghost`,size:`sm`,onClick:()=>Qr(Z.roi||{x:.15,y:.35,w:.7,h:.55}),children:[(0,$.jsx)(Zt,{className:`w-[var(--pc-i3,0.75rem)] h-[var(--pc-i3,0.75rem)] mr-1`}),W(`common.edit`)]})]}),Zr?(0,$.jsxs)(`div`,{className:`space-y-3 bg-bambu-dark-tertiary/50 p-3 rounded-lg`,children:[(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:W(`printers.roi.xStart`)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Zr.x,onChange:e=>Qr({...Zr,x:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Zr.x*100),`%`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:W(`printers.roi.yStart`)}),(0,$.jsx)(`input`,{type:`range`,min:`0`,max:`0.9`,step:`0.01`,value:Zr.y,onChange:e=>Qr({...Zr,y:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Zr.y*100),`%`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:W(`printers.width`)}),(0,$.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Zr.w,onChange:e=>Qr({...Zr,w:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Zr.w*100),`%`]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-xs text-bambu-gray`,children:W(`printers.height`)}),(0,$.jsx)(`input`,{type:`range`,min:`0.1`,max:`1`,step:`0.01`,value:Zr.h,onChange:e=>Qr({...Zr,h:parseFloat(e.target.value)}),className:`w-full h-1.5 bg-bambu-dark-tertiary rounded-lg cursor-pointer accent-green-500`}),(0,$.jsxs)(`span`,{className:`text-xs text-bambu-gray`,children:[Math.round(Zr.h*100),`%`]})]})]}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:W(`printers.roi.instruction`)})]}):(0,$.jsxs)(`p`,{className:`text-xs text-bambu-gray`,children:[`Current: X=`,Math.round((Z.roi?.x||.15)*100),`%, Y=`,Math.round((Z.roi?.y||.35)*100),`%, W=`,Math.round((Z.roi?.w||.7)*100),`%, H=`,Math.round((Z.roi?.h||.55)*100),`%`]})]})]}),(0,$.jsx)(`div`,{className:`flex justify-end gap-2 p-4`,children:Z.needs_calibration?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>ss(),children:W(`common.cancel`)}),(0,$.jsx)(Y,{onClick:()=>cs(),disabled:Yr,children:Yr?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-[var(--pc-i4,1rem)] h-[var(--pc-i4,1rem)] mr-2 animate-spin`}),`Calibrating...`]}):`Calibrate Empty Plate`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>cs(),disabled:Yr,children:Yr?`Adding...`:`Add Reference (${es?.references.length||0}/${es?.max_references||5})`}),(0,$.jsx)(Y,{onClick:()=>ss(),children:`Close`})]})})]})}),Ge&&Wi&&(0,$.jsx)(In,{title:W(`printers.confirm.powerOnTitle`),message:W(`printers.confirm.powerOnMessage`,{name:e.name}),confirmText:W(`printers.confirm.powerOnButton`),variant:`default`,onConfirm:()=>{Wa.mutate(`on`),Ke(!1)},onCancel:()=>Ke(!1)}),Lo&&(0,$.jsx)(In,{title:W(`printers.maintenance.confirmMidPrintTitle`),message:W(`printers.maintenance.confirmMidPrintMessage`,{name:e.name}),confirmText:W(`printers.maintenance.menuEnter`),variant:`danger`,onConfirm:()=>{Io.mutate(!1),Ro(!1)},onCancel:()=>Ro(!1)}),qe&&Wi&&(0,$.jsx)(In,{title:W(`printers.confirm.powerOffTitle`),message:Q?.state===`RUNNING`?W(`printers.confirm.powerOffWarning`,{name:e.name}):W(`printers.confirm.powerOffMessage`,{name:e.name}),confirmText:W(`printers.confirm.powerOffButton`),variant:`danger`,onConfirm:()=>{Wa.mutate(`off`),Je(!1)},onCancel:()=>Je(!1)}),Ye&&(0,$.jsx)(In,{title:W(`printers.confirm.haToggleTitle`,{name:Ye.name}),message:Q?.state===`RUNNING`?W(`printers.confirm.haToggleWarning`,{name:e.name,entity:Ye.ha_entity_id||Ye.name}):W(`printers.confirm.haToggleMessage`,{entity:Ye.ha_entity_id||Ye.name}),confirmText:W(`printers.confirm.haToggleButton`),variant:Q?.state===`RUNNING`?`danger`:`default`,onConfirm:()=>{Ka.mutate({id:Ye.id,action:`toggle`}),Xe(null)},onCancel:()=>Xe(null)}),ot&&(0,$.jsx)(In,{title:W(`printers.confirm.stopTitle`),message:W(`printers.confirm.stopMessage`,{name:e.name}),confirmText:W(`printers.confirm.stopButton`),variant:`danger`,onConfirm:()=>{to.mutate(),st(!1)},onCancel:()=>st(!1)}),ct&&(0,$.jsx)(In,{title:W(`printers.confirm.pauseTitle`),message:W(`printers.confirm.pauseMessage`,{name:e.name}),confirmText:W(`printers.confirm.pauseButton`),variant:`default`,onConfirm:()=>{ro.mutate(),lt(!1)},onCancel:()=>lt(!1)}),bt&&(0,$.jsx)(In,{title:W(`printers.confirm.resumeTitle`),message:W(`printers.confirm.resumeMessage`,{name:e.name}),confirmText:W(`printers.confirm.resumeButton`),variant:`default`,onConfirm:()=>{ao.mutate(),xt(!1)},onCancel:()=>xt(!1)}),(0,$.jsx)(ye,{printerId:e.id,isOpen:St,onClose:()=>Ct(!1)}),Ze&&(0,$.jsx)(jt,{printerName:e.name,errors:Q?.hms_errors||[],onClose:()=>Qe(!1),printerId:e.id,hasPermission:J,runoutGuidance:Ui}),$e&&(0,$.jsx)(Qi,{printerName:e.name,detection:U,lastError:ge,onClose:()=>et(!1)}),tt&&Q&&(0,$.jsx)(oa,{isOpen:tt,state:Q.ams_filament_backup,amsUnits:Q.ams,amsExtruderMap:Q.ams_extruder_map,isDualNozzle:e.nozzle_count===2||Q?.temperatures?.nozzle_2!==void 0,canToggle:J(`printers:control`),pending:Ua.isPending,onToggle:e=>Ua.mutate(e),onClose:()=>nt(!1)}),Pr&&(0,$.jsx)(na,{isOpen:!!Pr,onClose:()=>Fr(null),printerId:e.id,printerName:e.name,amsId:Pr.amsId,amsLabel:Pr.amsLabel,initialMode:Pr.mode,thresholds:s}),Ir&&(0,$.jsx)(ua,{isOpen:!!Ir,onClose:()=>Lr(null),printerId:e.id,printerName:e.name,initialKind:Ir.initialKind,availableKinds:Ir.availableKinds}),Rr&&(0,$.jsx)(yr,{isOpen:!!Rr,onClose:()=>zr(null),tagUid:Rr.tagUid,trayUuid:Rr.trayUuid,printerId:Rr.printerId,amsId:Rr.amsId,trayId:Rr.trayId}),Br&&(0,$.jsx)(vr,{isOpen:!!Br,onClose:()=>Vr(null),printerId:Br.printerId,amsId:Br.amsId,trayId:Br.trayId,trayInfo:Br.trayInfo,spoolmanEnabled:!!c}),Hr&&(0,$.jsx)(br,{isOpen:!!Hr,onClose:()=>Ur(null),printerId:e.id,slotInfo:Hr,printerModel:gr(e.model)||void 0,nozzleDiameter:Gn(Q,Hr.amsId),onSuccess:()=>{G.invalidateQueries({queryKey:[`slotPresets`,e.id]}),G.invalidateQueries({queryKey:[`printerStatus`,e.id]})}}),Xo&&(0,$.jsx)(_a,{slotLabel:Xo.slotLabel,amsId:Xo.amsId,slotId:Xo.slotId,extruderSlots:Q?.extruder_slots??{},isLoading:Jo.isPending,onConfirm:e=>Jo.mutate({trayId:Xo.trayId,extruderId:e}),onCancel:()=>Zo(null)}),ze&&(0,$.jsx)(So,{printer:e,onClose:()=>Be(!1)}),Wr&&ri&&(0,$.jsx)(xo,{printer:e,firmwareInfo:ri,onClose:()=>Gr(!1)}),Gt!==null&&Yn&&(()=>{let e=Jt===`n3s`?85:65,t=e+10;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-[100]`,"data-testid":`drying-popover-backdrop`,onMouseDown:()=>{dr.current=or.current!==null&&document.activeElement===or.current},onClick:()=>{if(dr.current){dr.current=!1;return}Kt(null)}}),(0,$.jsxs)(`div`,{className:`fixed z-[101] flex flex-col w-[240px] bg-bambu-dark-secondary border border-bambu-dark-tertiary rounded-xl shadow-2xl overflow-hidden`,style:{left:Yn.left,...Yn.placement===`above`?{bottom:`calc(100dvh - ${Yn.anchorY}px)`,maxHeight:`${Yn.anchorY-8}px`}:{top:Yn.top,maxHeight:`calc(100dvh - ${Yn.top}px - 8px)`}},onClick:e=>e.stopPropagation(),children:[(0,$.jsxs)(`div`,{className:`shrink-0 flex items-center justify-center gap-2 px-3 py-2.5`,children:[(0,$.jsx)(Bn,{className:`w-[var(--pc-i35,0.875rem)] h-[var(--pc-i35,0.875rem)] text-bambu-green`}),(0,$.jsx)(`span`,{className:`text-sm text-white font-medium text-center`,children:W(`printers.drying.start`)})]}),(0,$.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,$.jsxs)(`div`,{className:`px-3 py-2.5 space-y-2.5 overflow-y-auto min-h-0`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[length:var(--pc-t10,10px)] text-white/70 font-medium mb-1 block`,children:W(`printers.filaments`)}),(0,$.jsx)(no,{value:en,options:Object.keys(F).map(e=>({value:e,label:e})),onChange:e=>{pn(e);let t=F[e];t&&(Sn(t[Jt===`n3s`?`n3s`:`n3f`]),En(Jt===`n3s`?t.n3s_hours:t.n3f_hours))},fullWidth:!0})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`label`,{className:`text-[length:var(--pc-t10,10px)] text-white/70 font-medium`,children:W(`printers.drying.temperature`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(hn,{min:45,max:e,value:bn,onChange:Sn,fallback:45,className:`w-12 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[length:var(--pc-t11,11px)] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:`°C`})]})]}),(0,$.jsx)(`input`,{type:`range`,min:35,max:t,value:bn,onChange:t=>Sn(Math.min(e,Math.max(45,Number(t.target.value)))),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,$.jsxs)(`div`,{className:`flex justify-between text-[length:var(--pc-t9,9px)] text-bambu-gray/50 mt-0.5`,children:[(0,$.jsx)(`span`,{children:`45°C`}),(0,$.jsxs)(`span`,{children:[e,`°C`]})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-1`,children:[(0,$.jsx)(`label`,{className:`text-[length:var(--pc-t10,10px)] text-white/70 font-medium`,children:W(`printers.drying.duration`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,$.jsx)(hn,{min:1,max:24,value:wn,onChange:En,fallback:1,className:`w-10 px-1 py-0.5 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[length:var(--pc-t11,11px)] text-center focus:outline-none focus:border-bambu-green [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`}),(0,$.jsx)(`span`,{className:`text-[length:var(--pc-t10,10px)] text-bambu-gray`,children:W(`printers.drying.hours`)})]})]}),(0,$.jsx)(`input`,{type:`range`,min:1,max:24,value:wn,onChange:e=>En(Number(e.target.value)),className:`w-full h-1 accent-bambu-green cursor-pointer`}),(0,$.jsxs)(`div`,{className:`flex justify-between text-[length:var(--pc-t9,9px)] text-bambu-gray/50 mt-0.5`,children:[(0,$.jsx)(`span`,{children:`1h`}),(0,$.jsx)(`span`,{children:`24h`})]})]}),(()=>{let e=((Gt===null?void 0:Mi.find(e=>e.id===Gt))?.tray??[]).some(e=>e.state===11),t=jn&&!e;return(0,$.jsx)(`button`,{type:`button`,onClick:()=>Mn(e=>!e),"aria-pressed":t,disabled:e,title:e?W(`printers.drying.rotateUnavailableReason`):void 0,className:`h-8 w-full rounded-lg border px-2 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50 ${t?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary disabled:hover:bg-bambu-dark`}`,children:W(`printers.drying.rotateTray`)})})(),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`text-[10px] text-white/70 font-medium mb-1 block`,children:W(`printers.drying.startMode`)}),(0,$.jsx)(`div`,{className:`grid grid-cols-3 gap-1`,children:[`now`,`delay`,`at_time`].map(e=>(0,$.jsx)(`button`,{type:`button`,onClick:()=>Fn(e),className:`py-1 rounded-lg border text-[10px] font-medium transition-colors ${Nn===e?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:W(e===`now`?`printers.drying.modeNow`:e===`delay`?`printers.drying.modeDelay`:`printers.drying.modeAtTime`)},e))}),Nn===`delay`&&(0,$.jsx)(`div`,{className:`mt-1.5 grid grid-cols-4 gap-1`,children:Sa.map(e=>(0,$.jsx)(`button`,{type:`button`,"aria-pressed":Rn===e,onClick:()=>Wn(e),className:`py-1 rounded-lg border text-[10px] font-medium transition-colors ${Rn===e?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:Wt(e/60)},e))}),Nn===`at_time`&&(0,$.jsx)(`input`,{ref:or,type:`datetime-local`,"data-testid":`drying-start-at`,value:qn,onChange:e=>Jn(e.target.value),className:`mt-1.5 w-full px-2 py-1 bg-bambu-dark border border-bambu-dark-tertiary rounded text-white text-[11px] focus:outline-none focus:border-bambu-green [color-scheme:dark]`})]})]}),(0,$.jsx)(`div`,{className:`shrink-0 h-px bg-bambu-dark-tertiary`}),(0,$.jsx)(`div`,{className:`shrink-0 px-3 pt-2.5 pb-3`,children:(0,$.jsx)(`button`,{onClick:()=>{if(Gt!==null){let e=(Mi.find(e=>e.id===Gt)?.tray??[]).some(e=>e.state===11),t=jn&&!e;if(Nn===`now`)La.mutate({amsId:Gt,temp:bn,duration:wn,filament:en,rotateTray:t});else{let e=Ai(Nn,Rn,qn);e&&Va.mutate({amsId:Gt,temp:bn,duration:wn,filament:en,rotateTray:t,startAfter:e})}}},disabled:La.isPending||Va.isPending||Nn===`at_time`&&!qn,"data-testid":`drying-start-confirm`,className:`w-full py-1.5 bg-bambu-green hover:bg-bambu-green/80 text-white text-xs font-medium rounded-lg transition-colors disabled:opacity-50`,children:Nn===`now`?La.isPending?W(`printers.drying.startingDrying`):W(`printers.drying.start`):W(`printers.drying.schedule`)})})]}),(0,$.jsx)(`div`,{className:`fixed z-[102] w-2.5 h-2.5 rotate-45 bg-bambu-dark-secondary border-bambu-dark-tertiary pointer-events-none`,style:{left:Yn.left+Yn.arrowLeft-5,top:Yn.anchorY-5,...Yn.placement===`above`?{borderRightWidth:1,borderBottomWidth:1}:{borderLeftWidth:1,borderTopWidth:1}}})]})})()]})}function bo({onClose:e,onAdd:t,existingSerials:n}){let{t:r}=l(),[a,o]=(0,X.useState)({name:``,serial_number:``,ip_address:``,access_code:``,model:``,location:``,auto_archive:!0}),[c,u]=(0,X.useState)(!1),[d,f]=(0,X.useState)([]),[p,m]=(0,X.useState)(``),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(!1),[y,b]=(0,X.useState)([]),[x,S]=(0,X.useState)(``),[C,w]=(0,X.useState)(``),[T,E]=(0,X.useState)(!1),[D,O]=(0,X.useState)({scanned:0,total:0}),[k,A]=(0,X.useState)(!1),[j,M]=(0,X.useState)(!1),[N,P]=(0,X.useState)(null);(0,X.useEffect)(()=>{s.getInfo().then(e=>{v(e.is_docker),e.subnets.length>0&&(b(e.subnets),S(e.subnets[0]))}).catch(()=>{});try{let e=localStorage.getItem(`bambuddy.discovery.customSubnet`);e&&w(e)}catch{}},[]);let F=d.filter(e=>!n.includes(e.serial)),L=async e=>{e.preventDefault(),M(!0);try{let e=await i.diagnoseConnection({ip_address:a.ip_address.trim(),serial_number:a.serial_number.trim()||void 0,access_code:a.access_code||void 0});if(e.checks.some(e=>e.status===`fail`)){P(e);return}}catch{}finally{M(!1)}t(a)},R=async()=>{m(``),f([]),u(!0),g(!1),O({scanned:0,total:0});let e=T?C.trim():x,t=_||T;if(t&&T)try{localStorage.setItem(`bambuddy.discovery.customSubnet`,e)}catch{}try{if(t){await s.startSubnetScan(e);let t=setInterval(async()=>{try{let e=await s.getScanStatus();O({scanned:e.scanned,total:e.total}),f(await s.getDiscoveredPrinters()),e.running||(clearInterval(t),u(!1),g(!0))}catch(e){console.error(`Failed to get scan status:`,e)}},500)}else{await s.startDiscovery(10);let e=setInterval(async()=>{try{f(await s.getDiscoveredPrinters())}catch(e){console.error(`Failed to get discovered printers:`,e)}},1e3);setTimeout(async()=>{clearInterval(e);try{await s.stopDiscovery()}catch{}u(!1),g(!0);try{f(await s.getDiscoveredPrinters())}catch(e){console.error(`Failed to get final discovered printers:`,e)}},1e4)}}catch(e){console.error(`Failed to start discovery:`,e),m(e instanceof Error?e.message:r(`printers.discovery.failedToStart`)),u(!1),g(!0)}},ee=e=>{let t=e.serial.startsWith(`unknown-`)?``:e.serial;o({...a,name:e.name||``,serial_number:t,ip_address:e.ip_address,model:gr(e.model)}),f([])};return(0,X.useEffect)(()=>()=>{s.stopDiscovery().catch(()=>{}),s.stopSubnetScan().catch(()=>{})},[]),(0,X.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:e,children:(0,$.jsx)(Rt,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(Lt,{children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:r(`printers.addPrinter`)}),(0,$.jsxs)(`div`,{className:`mb-4 pb-4 border-b border-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.discovery.subnetToScan`)}),y.length>0?(0,$.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:T?`__custom__`:x,onChange:e=>{e.target.value===`__custom__`?E(!0):(E(!1),S(e.target.value))},disabled:c,children:[y.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e)),(0,$.jsx)(`option`,{value:`__custom__`,children:r(`printers.discovery.customSubnetOption`)})]}):(0,$.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:x,onChange:e=>S(e.target.value),placeholder:`192.168.1.0/24`,disabled:c}),T&&(0,$.jsx)(`input`,{type:`text`,"aria-label":r(`printers.discovery.customSubnetLabel`),className:`mt-2 w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none text-sm`,value:C,onChange:e=>w(e.target.value),placeholder:`10.1.1.0/24`,disabled:c}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-bambu-gray`,children:r(_?`printers.discovery.dockerNote`:`printers.discovery.customSubnetNote`)})]}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:R,disabled:c,className:`w-full`,children:c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-4 h-4 animate-spin`}),(_||T)&&D.total>0?r(`printers.discovery.scanProgress`,{scanned:D.scanned,total:D.total}):r(`printers.discovery.scanning`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ae,{className:`w-4 h-4`}),r(_||T?`printers.discovery.scanSubnet`:`printers.discovery.discoverNetwork`)]})}),p&&(0,$.jsx)(`div`,{className:`mt-2 text-sm text-red-700 dark:text-red-400`,children:p}),F.length>0&&(0,$.jsx)(`div`,{className:`mt-3 space-y-2 max-h-40 overflow-y-auto`,children:F.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between p-2 bg-bambu-dark rounded-lg hover:bg-bambu-dark-secondary cursor-pointer transition-colors`,onClick:()=>ee(e),children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`font-medium text-white text-sm truncate`,children:e.name||e.serial}),(0,$.jsxs)(`p`,{className:`text-xs text-bambu-gray truncate`,children:[gr(e.model)||r(`printers.discovery.unknown`),` • `,e.ip_address,e.serial.startsWith(`unknown-`)&&(0,$.jsxs)(`span`,{className:`text-yellow-500`,children:[` • `,r(`printers.discovery.serialRequired`)]})]})]}),(0,$.jsx)(I,{className:`w-4 h-4 text-bambu-gray -rotate-90 flex-shrink-0 ml-2`})]},e.serial))}),c&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(_||T?`printers.discovery.scanningSubnet`:`printers.discovery.scanningNetwork`)}),h&&!c&&d.length===0&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(_||T?`printers.discovery.noPrintersFoundSubnet`:`printers.discovery.noPrintersFoundNetwork`)}),h&&!c&&d.length>0&&F.length===0&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-bambu-gray text-center`,children:r(`printers.discovery.allConfigured`)})]}),(0,$.jsxs)(`form`,{onSubmit:L,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.name`)}),(0,$.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.name,onChange:e=>o({...a,name:e.target.value}),placeholder:r(`printers.modal.myPrinter`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.ipAddress`)}),(0,$.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.ip_address,onChange:e=>o({...a,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.serialNumber`)}),(0,$.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.serial_number,onChange:e=>o({...a,serial_number:e.target.value}),placeholder:`01P00A000000000`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.accessCode`)}),(0,$.jsx)(`input`,{type:`password`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.access_code,onChange:e=>o({...a,access_code:e.target.value}),placeholder:r(`printers.modal.fromPrinterSettings`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.modelOptional`)}),(0,$.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.model||``,onChange:e=>o({...a,model:e.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:r(`printers.modal.selectModel`)}),(0,$.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,$.jsx)(`option`,{value:`A1`,children:`A1`}),(0,$.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,$.jsx)(`optgroup`,{label:`A2 Series`,children:(0,$.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,$.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,$.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,$.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,$.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,$.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,$.jsxs)(`optgroup`,{label:`P Series`,children:[(0,$.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,$.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,$.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,$.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,$.jsx)(`option`,{value:`X1`,children:`X1`}),(0,$.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,$.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,$.jsx)(`optgroup`,{label:`X2 Series`,children:(0,$.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:r(`printers.modal.locationGroup`)}),(0,$.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:a.location||``,onChange:e=>o({...a,location:e.target.value}),placeholder:r(`printers.modal.locationPlaceholder`),maxLength:100}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:r(`printers.locationHelp`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`auto_archive`,checked:a.auto_archive,onChange:e=>o({...a,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,$.jsx)(`label`,{htmlFor:`auto_archive`,className:`text-sm text-bambu-gray`,children:r(`printers.modal.autoArchiveLabel`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>A(!0),disabled:!a.ip_address.trim(),className:`w-full flex items-center justify-center gap-2 px-3 py-2 text-sm text-bambu-gray hover:text-white disabled:opacity-40 disabled:cursor-not-allowed border border-bambu-dark-tertiary rounded-lg transition-colors`,children:[(0,$.jsx)(an,{className:`w-4 h-4`}),r(`diagnostic.runButton`)]}),N?(0,$.jsxs)(`div`,{className:`rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 p-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Ot,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-300`,children:r(`printers.addPreflight.warning`)})]}),(0,$.jsx)(rr,{result:N}),(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>P(null),className:`flex-1`,children:r(`printers.addPreflight.back`)}),(0,$.jsx)(Y,{type:`button`,onClick:()=>t(a),className:`flex-1`,children:r(`printers.addPreflight.saveAnyway`)})]})]}):(0,$.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:e,className:`flex-1`,children:r(`common.cancel`)}),(0,$.jsx)(Y,{type:`submit`,disabled:j,className:`flex-1`,children:r(j?`printers.addPreflight.checking`:`printers.addPrinter`)})]})]})]})})}),k&&(0,$.jsx)(Pn,{connection:{ip_address:a.ip_address.trim(),serial_number:a.serial_number.trim()||void 0,access_code:a.access_code||void 0},printerName:a.name||null,onClose:()=>A(!1)})]})}function xo({printer:e,firmwareInfo:t,onClose:n}){let{t:r}=l(),i=f(),{showToast:o}=te(),{hasPermission:s}=lr(),c=s(`firmware:update`),[u,d]=(0,X.useState)(null),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(t.update_available?t.latest_version:null),{data:x,isLoading:S}=p({queryKey:[`firmwarePrepare`,e.id,y],queryFn:()=>a.prepareUpload(e.id,y??void 0),staleTime:3e4,enabled:!!y&&c&&!h}),C=m({mutationFn:()=>a.startUpload(e.id,y??void 0),onSuccess:()=>{g(!0);let t=setInterval(async()=>{try{let n=await a.getUploadStatus(e.id);d(n),(n.status===`complete`||n.status===`error`)&&(clearInterval(t),v(null),g(!1),n.status===`complete`&&(o(r(`printers.firmwareModal.uploadedToast`),`success`),i.invalidateQueries({queryKey:[`firmwareUpdate`,e.id]})))}catch{}},2e3);v(t)},onError:e=>{o(r(`printers.firmwareModal.uploadFailed`,{error:e.message}),`error`),g(!1)}});return(0,X.useEffect)(()=>()=>{_&&clearInterval(_)},[_]),(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-center justify-center z-50`,children:(0,$.jsx)(Rt,{className:`w-full max-w-md mx-4`,children:(0,$.jsxs)(Lt,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 mb-4`,children:[(0,$.jsx)(`div`,{className:`p-2 rounded-full ${t.update_available?`bg-orange-100 dark:bg-orange-500/20`:`bg-status-ok/20`}`,children:t.update_available?(0,$.jsx)(ar,{className:`w-5 h-5 text-orange-600 dark:text-orange-400`}):(0,$.jsx)(ne,{className:`w-5 h-5 text-status-ok`})}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-lg font-semibold text-white`,children:t.update_available?r(`printers.firmwareModal.title`):r(`printers.firmwareModal.titleUpToDate`)}),(0,$.jsx)(`p`,{className:`text-sm text-bambu-gray mt-1`,children:e.name})]})]}),(()=>{let e=y?t.available_versions?.find(e=>e.version===y):null,n=y??t.latest_version,i=e?.release_notes??t.release_notes,a=!!n&&n!==t.current_version;return(0,$.jsxs)(`div`,{className:`bg-bambu-dark rounded-lg p-3 mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex justify-between items-center text-sm`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.currentVersion`)}),(0,$.jsx)(`span`,{className:`font-mono ${a?`text-white`:`text-status-ok`}`,children:t.current_version||r(`common.unknown`)})]}),a&&(0,$.jsxs)(`div`,{className:`flex justify-between items-center text-sm mt-1`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray`,children:r(`printers.firmwareModal.latestVersion`)}),(0,$.jsx)(`span`,{className:`text-orange-700 dark:text-orange-400 font-mono`,children:n})]}),i&&(0,$.jsxs)(`details`,{className:`mt-3 text-sm`,open:!a,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer hover:underline ${a?`text-orange-700 dark:text-orange-400`:`text-status-ok`}`,children:r(`printers.firmwareModal.releaseNotes`)}),(0,$.jsx)(`div`,{className:`mt-2 text-bambu-gray text-xs max-h-40 overflow-y-auto whitespace-pre-wrap`,children:i})]},n??`none`)]})})(),t.available_versions&&t.available_versions.length>0&&!h&&u?.status!==`complete`&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsx)(`div`,{className:`text-xs text-bambu-gray mb-2`,children:r(`printers.firmwareModal.availableVersions`)}),(0,$.jsx)(`div`,{className:`max-h-56 overflow-y-auto border border-bambu-dark-tertiary rounded-lg divide-y divide-bambu-dark-tertiary`,children:t.available_versions.map(e=>{let n=t.current_version===e.version,i=y===e.version,a=t.current_version?_i(e.version,t.current_version):0,o=r(n?`printers.firmwareModal.currentBadge`:a>0?`printers.firmwareModal.newerBadge`:`printers.firmwareModal.olderBadge`),s=n?`text-bambu-gray`:a>0?`text-orange-700 dark:text-orange-400`:`text-blue-700 dark:text-blue-400`;return(0,$.jsxs)(`button`,{type:`button`,disabled:!e.file_available||!c||n,onClick:()=>b(e.version),className:`w-full text-left px-3 py-2 text-sm flex items-center justify-between gap-2 transition-colors ${i?`bg-orange-50 dark:bg-orange-500/10`:`hover:bg-bambu-dark`} ${!e.file_available||!c||n?`opacity-60 cursor-not-allowed`:`cursor-pointer`}`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`font-mono text-white`,children:e.version}),(0,$.jsx)(`span`,{className:`text-xs ${s}`,children:o})]}),(0,$.jsx)(`span`,{className:`text-xs px-2 py-0.5 rounded-full ${n?`bg-blue-50 dark:bg-blue-500/15 text-blue-700 dark:text-blue-400 border border-blue-300 dark:border-blue-500/30`:e.file_available?`bg-bambu-green/15 text-bambu-green border border-bambu-green/30`:`bg-bambu-gray/10 text-bambu-gray border border-bambu-gray/30`}`,children:n?r(`printers.firmwareModal.installed`):e.file_available?r(`printers.firmwareModal.usable`):r(`printers.firmwareModal.unavailable`)})]},e.version)})})]}),y?S?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-gray text-sm mb-4`,children:[(0,$.jsx)(H,{className:`w-4 h-4 animate-spin`}),r(`printers.firmwareModal.checkingPrereqs`)]}):x&&!h&&!u?(0,$.jsx)(`div`,{className:`mb-4`,children:x.can_proceed?(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-bambu-green text-sm`,children:[(0,$.jsx)(j,{className:`w-4 h-4`}),r(`printers.firmwareModal.sdCardReady`)]}):(0,$.jsx)(`div`,{className:`space-y-1`,children:x.errors.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-red-700 dark:text-red-400 text-sm`,children:[(0,$.jsx)(R,{className:`w-4 h-4 flex-shrink-0`}),e]},t))})}):null:null,(h||u)&&u&&(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-sm mb-1`,children:[(0,$.jsx)(`span`,{className:`text-bambu-gray capitalize`,children:u.status}),(0,$.jsxs)(`span`,{className:`text-white`,children:[u.progress,`%`]})]}),(0,$.jsx)(`div`,{className:`w-full bg-bambu-dark-tertiary rounded-full h-2`,children:(0,$.jsx)(`div`,{className:`h-2 rounded-full transition-all ${u.status===`error`?`bg-status-error`:u.status===`complete`?`bg-status-ok`:`bg-orange-500`} ${u.status===`uploading`?`animate-pulse`:``}`,style:{width:`${u.progress}%`}})}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:u.message}),u.error&&(0,$.jsx)(`p`,{className:`text-xs text-red-700 dark:text-red-400 mt-1`,children:u.error})]}),u?.status===`complete`&&(0,$.jsxs)(`div`,{className:`bg-bambu-green/10 border border-bambu-green/30 rounded-lg p-3 mb-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-bambu-green font-medium mb-2`,children:r(`printers.firmwareModal.uploadedSuccess`)}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray`,children:r(`printers.firmwareModal.applyInstructions`)}),(0,$.jsxs)(`ol`,{className:`text-xs text-bambu-gray mt-1 list-decimal list-inside space-y-1`,children:[(0,$.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step1`)}}),(0,$.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step2`)}}),(0,$.jsx)(`li`,{dangerouslySetInnerHTML:{__html:r(`printers.firmwareModal.step3`)}}),(0,$.jsx)(`li`,{children:r(`printers.firmwareModal.step4`)})]})]}),(0,$.jsxs)(`div`,{className:`flex gap-2 justify-end`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:n,children:u?.status===`complete`?r(`printers.firmwareModal.done`):r(`common.cancel`)}),x?.can_proceed&&!h&&u?.status!==`complete`&&c&&(0,$.jsx)(Y,{onClick:()=>{d(null),C.mutate()},disabled:C.isPending,children:C.isPending?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(H,{className:`w-4 h-4 animate-spin mr-2`}),r(`printers.firmwareModal.starting`)]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(ar,{className:`w-4 h-4 mr-2`}),r(`printers.firmwareModal.uploadFirmware`)]})})]})]})})})}function So({printer:e,onClose:t}){let{t:n}=l(),r=f(),{showToast:a}=te(),{authEnabled:o,isAdmin:s}=lr(),[c,u]=(0,X.useState)({name:e.name,ip_address:e.ip_address,access_code:``,model:e.model||``,location:e.location||``,auto_archive:e.auto_archive,is_active:e.is_active,wear_cost_per_hour:e.wear_cost_per_hour?String(e.wear_cost_per_hour):``}),{data:d}=p({queryKey:[`settings`],queryFn:i.getSettings}),h=Rn(d?.currency||`USD`),{data:g}=p({queryKey:[`groups`],queryFn:()=>i.getGroups(),enabled:o&&s}),_=c.location.trim(),v=_===(e.location||``)?[]:(g??[]).filter(t=>t.restrict_printers&&(t.locations??[]).some(t=>t===e.location||t===_)).map(e=>e.name),[y,b]=(0,X.useState)(!1),[x,S]=(0,X.useState)(null),C=m({mutationFn:t=>i.updatePrinter(e.id,t),onSuccess:()=>{r.invalidateQueries({queryKey:[`printers`]}),r.invalidateQueries({queryKey:[`printerStatus`,e.id]}),t()},onError:e=>a(e.message||n(`printers.toast.failedToUpdate`),`error`)});(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let w=()=>{let e={name:c.name,ip_address:c.ip_address,model:c.model||void 0,location:c.location.trim()||null,auto_archive:c.auto_archive,is_active:c.is_active,wear_cost_per_hour:Number(c.wear_cost_per_hour)>0?Number(c.wear_cost_per_hour):null};c.access_code&&(e.access_code=c.access_code),C.mutate(e)};return(0,$.jsx)(`div`,{className:`fixed inset-0 bg-black/50 flex items-start sm:items-center justify-center z-50 p-4 overflow-y-auto`,onClick:t,children:(0,$.jsx)(Rt,{className:`w-full max-w-md my-auto max-h-[calc(100vh-2rem)] overflow-y-auto`,onClick:e=>e.stopPropagation(),children:(0,$.jsxs)(Lt,{children:[(0,$.jsx)(`h2`,{className:`text-xl font-semibold mb-4`,children:n(`printers.editPrinter`)}),(0,$.jsxs)(`form`,{onSubmit:async t=>{t.preventDefault(),b(!0);try{let t=await i.diagnoseConnection({ip_address:c.ip_address.trim(),serial_number:e.serial_number,access_code:c.access_code||void 0});if(t.checks.some(e=>e.status===`fail`)){S(t);return}}catch{}finally{b(!1)}w()},className:`space-y-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.name`)}),(0,$.jsx)(`input`,{type:`text`,required:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.name,onChange:e=>u({...c,name:e.target.value}),placeholder:n(`printers.modal.myPrinter`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.ipAddress`)}),(0,$.jsx)(`input`,{type:`text`,required:!0,pattern:`(\\d{1,3}(\\.\\d{1,3}){3}|[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?(\\.[a-zA-Z0-9]([a-zA-Z0-9\\-]{0,61}[a-zA-Z0-9])?)*)`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.ip_address,onChange:e=>u({...c,ip_address:e.target.value}),placeholder:`192.168.1.100 or printer.local`})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.serialNumber`)}),(0,$.jsx)(`input`,{type:`text`,disabled:!0,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-bambu-gray cursor-not-allowed`,value:e.serial_number}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.serialCannotBeChanged`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.accessCode`)}),(0,$.jsx)(`input`,{type:`password`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.access_code,onChange:e=>u({...c,access_code:e.target.value}),placeholder:n(`printers.accessCodePlaceholder`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.model`)}),(0,$.jsxs)(`select`,{className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.model,onChange:e=>u({...c,model:e.target.value}),children:[(0,$.jsx)(`option`,{value:``,children:n(`printers.modal.selectModel`)}),(0,$.jsxs)(`optgroup`,{label:`A1 Series`,children:[(0,$.jsx)(`option`,{value:`A1`,children:`A1`}),(0,$.jsx)(`option`,{value:`A1 Mini`,children:`A1 Mini`})]}),(0,$.jsx)(`optgroup`,{label:`A2 Series`,children:(0,$.jsx)(`option`,{value:`A2L`,children:`A2L`})}),(0,$.jsxs)(`optgroup`,{label:`H2 Series`,children:[(0,$.jsx)(`option`,{value:`H2C`,children:`H2C`}),(0,$.jsx)(`option`,{value:`H2D`,children:`H2D`}),(0,$.jsx)(`option`,{value:`H2D Pro`,children:`H2D Pro`}),(0,$.jsx)(`option`,{value:`H2S`,children:`H2S`})]}),(0,$.jsxs)(`optgroup`,{label:`P Series`,children:[(0,$.jsx)(`option`,{value:`P1P`,children:`P1P`}),(0,$.jsx)(`option`,{value:`P1S`,children:`P1S`}),(0,$.jsx)(`option`,{value:`P2S`,children:`P2S`})]}),(0,$.jsxs)(`optgroup`,{label:`X1 Series`,children:[(0,$.jsx)(`option`,{value:`X1`,children:`X1`}),(0,$.jsx)(`option`,{value:`X1C`,children:`X1 Carbon`}),(0,$.jsx)(`option`,{value:`X1E`,children:`X1E`})]}),(0,$.jsx)(`optgroup`,{label:`X2 Series`,children:(0,$.jsx)(`option`,{value:`X2D`,children:`X2D`})})]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{className:`block text-sm text-bambu-gray mb-1`,children:`Location / Group`}),(0,$.jsx)(`input`,{type:`text`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.location,onChange:e=>u({...c,location:e.target.value}),placeholder:n(`printers.modal.locationPlaceholder`),maxLength:100}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.locationHelp`)}),v.length>0&&(0,$.jsxs)(`p`,{className:`flex items-start gap-1.5 text-xs text-yellow-700 dark:text-yellow-400 mt-1`,children:[(0,$.jsx)(Ot,{className:`w-3.5 h-3.5 shrink-0 mt-px`}),n(`printerAccess.moveWarning`,{groups:v.join(`, `)})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`edit_auto_archive`,checked:c.auto_archive,onChange:e=>u({...c,auto_archive:e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-bambu-green focus:ring-bambu-green`}),(0,$.jsx)(`label`,{htmlFor:`edit_auto_archive`,className:`text-sm text-bambu-gray`,children:n(`printers.modal.autoArchiveLabel`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`label`,{htmlFor:`edit_wear_cost`,className:`block text-sm text-bambu-gray mb-1`,children:n(`printers.modal.wearCostLabel`,{currency:h})}),(0,$.jsx)(`input`,{id:`edit_wear_cost`,type:`number`,min:0,step:`0.01`,inputMode:`decimal`,className:`w-full px-3 py-2 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white focus:border-bambu-green focus:outline-none`,value:c.wear_cost_per_hour,onChange:e=>u({...c,wear_cost_per_hour:e.target.value}),placeholder:`0.00`}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray mt-1`,children:n(`printers.modal.wearCostHelp`)})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,id:`edit_maintenance_mode`,checked:!c.is_active,onChange:e=>u({...c,is_active:!e.target.checked}),className:`rounded border-bambu-dark-tertiary bg-bambu-dark text-amber-400 focus:ring-amber-400`}),(0,$.jsxs)(`label`,{htmlFor:`edit_maintenance_mode`,className:`text-sm text-bambu-gray flex items-center gap-1.5`,children:[(0,$.jsx)(sr,{className:`w-3.5 h-3.5 text-amber-600 dark:text-amber-400`}),n(`printers.maintenance.editFieldLabel`)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-bambu-gray/70 mt-1 ml-6`,children:n(`printers.maintenance.editFieldHelp`)})]}),x?(0,$.jsxs)(`div`,{className:`rounded-lg bg-amber-50 dark:bg-amber-500/10 border border-amber-300 dark:border-amber-500/30 p-3 space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Ot,{className:`w-4 h-4 mt-0.5 flex-shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{className:`text-sm text-amber-700 dark:text-amber-300`,children:n(`printers.addPreflight.warning`)})]}),(0,$.jsx)(rr,{result:x}),(0,$.jsxs)(`div`,{className:`flex gap-3`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>S(null),className:`flex-1`,children:n(`printers.addPreflight.back`)}),(0,$.jsx)(Y,{type:`button`,onClick:w,className:`flex-1`,disabled:C.isPending,children:n(`printers.addPreflight.saveAnyway`)})]})]}):(0,$.jsxs)(`div`,{className:`flex gap-3 pt-4`,children:[(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:t,className:`flex-1`,children:n(`common.cancel`)}),(0,$.jsx)(Y,{type:`submit`,className:`flex-1`,disabled:C.isPending||y,children:y?n(`printers.addPreflight.checking`):C.isPending?n(`common.saving`):n(`printers.modal.saveChanges`)})]})]})]})})})}function Co(e){let{data:t}=p({queryKey:[`printerStatus`,e],queryFn:()=>i.getPrinterStatus(e),refetchInterval:3e4});return!t?.connected}function wo({printer:e,plug:t,onPowerOn:n,isPowering:r}){let a=Co(e.id),{data:o}=p({queryKey:[`smartPlugStatus`,t.id],queryFn:()=>i.getSmartPlugStatus(t.id),refetchInterval:1e4});return a?(0,$.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 hover:bg-gray-100 dark:hover:bg-bambu-dark-tertiary`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,$.jsx)(`span`,{className:`text-sm text-white truncate`,children:e.name}),o&&(0,$.jsx)(`span`,{className:`text-xs px-1.5 py-0.5 rounded ${o.state===`ON`?`bg-bambu-green/20 text-bambu-green`:`bg-red-100 dark:bg-red-500/20 text-red-700 dark:text-red-400`}`,children:o.state||`?`})]}),(0,$.jsxs)(`button`,{onClick:()=>n(t.id),disabled:r||o?.state===`ON`,className:`px-2 py-1 text-xs rounded transition-colors flex items-center gap-1 ${o?.state===`ON`?`bg-bambu-green/20 text-bambu-green cursor-default`:`bg-bambu-green/20 text-bambu-green hover:bg-bambu-green hover:text-white`}`,children:[(0,$.jsx)(jn,{className:`w-3 h-3`}),r?`...`:`On`]})]}):null}function To(){let{t:e}=l(),{resolvedMode:t,darkAccent:n,lightAccent:r}=ir(),a={green:`bg-green-500 text-white hover:bg-green-400 border-green-400/60`,teal:`bg-teal-500 text-white hover:bg-teal-400 border-teal-400/60`,blue:`bg-blue-500 text-white hover:bg-blue-400 border-blue-400/60`,orange:`bg-orange-500 text-white hover:bg-orange-400 border-orange-400/60`,purple:`bg-purple-500 text-white hover:bg-purple-400 border-purple-400/60`,red:`bg-red-500 text-white hover:bg-red-400 border-red-400/60`}[t===`dark`?n:r],[o,s]=(0,X.useState)(!1),[u,d]=(0,X.useState)(()=>localStorage.getItem(`hideDisconnectedPrinters`)===`true`),[h,g]=(0,X.useState)(!1),[_,v]=(0,X.useState)(null),[y,b]=(0,X.useState)(()=>localStorage.getItem(`printerSortBy`)||`name`),[x,w]=(0,X.useState)(()=>localStorage.getItem(`printerSortAsc`)!==`false`),[T,D]=(0,X.useState)(()=>{let e=localStorage.getItem(`printerCardSize`);return e?parseInt(e,10):2}),[O,k]=(0,X.useState)(()=>localStorage.getItem(`printerPageView`)===`camwall`?`camwall`:`cards`),[A,M]=(0,X.useState)(()=>{let e=parseInt(localStorage.getItem(`camWallMaxLive`)||``,10);return Number.isFinite(e)&&e>0?e:4}),[N,P]=(0,X.useState)(()=>{let e=parseInt(localStorage.getItem(`camWallSnapshotSec`)||``,10);return Number.isFinite(e)&&e>0?e:8}),[F,L]=(0,X.useState)(()=>{let e=parseInt(localStorage.getItem(`camWallTileSize`)||``,10);return e>=1&&e<=4?e:2}),[R,ee]=(0,X.useState)(()=>{let e=localStorage.getItem(`camWallStatusMode`);return e===`off`||e===`compact`||e===`full`?e:`full`}),ne=T===1?`compact`:`expanded`,[z,re]=(0,X.useState)(null),B=(0,X.useCallback)(e=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{let t=document.getElementById(`printer-card-${e}`);if(!t)return;let n=document.querySelector(`header`)?.getBoundingClientRect().height??56,r=t.getBoundingClientRect().top+window.scrollY-n-16;window.scrollTo({top:Math.max(0,r),behavior:`smooth`})})})},[]),ie=(0,X.useCallback)(e=>{re(e),D(2),localStorage.setItem(`printerCardSize`,`2`),B(e)},[B]),ae=(0,X.useCallback)(()=>{let e=z;re(null),D(1),localStorage.setItem(`printerCardSize`,`1`),e!=null&&B(e)},[z,B]),[V,oe]=(0,X.useState)(``),[se,ce]=(0,X.useState)(()=>{let e=localStorage.getItem(`printerStatusFilter`);return Aa(e)?e:`all`}),[ue,de]=(0,X.useState)(()=>localStorage.getItem(`printerLocationFilter`)||`all`),[fe,H]=(0,X.useState)(0),[me,he]=(0,X.useState)(()=>{try{let e=localStorage.getItem(`printerCollapsedSections`);return e?JSON.parse(e):{}}catch{return{}}}),U=f(),{showToast:ge}=te(),{hasPermission:_e}=lr(),[ve,ye]=(0,X.useState)(()=>Ti()),[W,G]=(0,X.useState)(()=>{let e=localStorage.getItem(`openEmbeddedCameras`);if(e)try{let t=JSON.parse(e);return new Map(t.map(e=>[e.id,e]))}catch{return new Map}return new Map});(0,X.useEffect)(()=>{let e=Array.from(W.values());e.length>0?localStorage.setItem(`openEmbeddedCameras`,JSON.stringify(e)):localStorage.removeItem(`openEmbeddedCameras`)},[W]);let{data:K,isLoading:Te}=p({queryKey:[`printers`],queryFn:i.getPrinters}),{data:q}=p({queryKey:[`ui-preferences`],queryFn:i.getUiPreferences}),Ee=q!==void 0&&q.check_printer_firmware!==!1,De=(0,X.useMemo)(()=>xe(q?.nozzle_temp_presets,be,0,320),[q?.nozzle_temp_presets]),Oe=(0,X.useMemo)(()=>xe(q?.bed_temp_presets,Ce,0,140),[q?.bed_temp_presets]),ke=(0,X.useMemo)(()=>xe(q?.chamber_temp_presets,we,0,65),[q?.chamber_temp_presets]),je=(0,X.useMemo)(()=>xe(q?.fan_speed_presets,Se,0,100),[q?.fan_speed_presets]),Me=(0,X.useMemo)(()=>{if(q?.drying_presets)try{let e=JSON.parse(q.drying_presets);if(typeof e==`object`&&e&&Object.keys(e).length>0)return{...ho,...e}}catch{}return ho},[q?.drying_presets]),Ne=ve??(q?.camera_view_mode===`embedded`?`embedded`:`window`),Pe=(0,X.useCallback)(e=>{Ei(e),ye(e),_e(`settings:update`)&&i.updateSettings({camera_view_mode:e}).then(()=>U.invalidateQueries({queryKey:[`ui-preferences`]})).catch(e=>console.warn(`Could not save camera view mode as the default:`,e))},[_e,U]),{data:Fe}=p({queryKey:[`smart-plugs`],queryFn:i.getSmartPlugs}),{data:Ie}=p({queryKey:[`maintenanceOverview`],queryFn:i.getMaintenanceOverview,staleTime:60*1e3}),{data:Le}=p({queryKey:[`obico-printer-status`],queryFn:i.getObicoPrinterStatus,refetchInterval:1e4}),Re=(0,X.useCallback)(e=>Le?.enabled===!0&&(Le.monitored_printers===null||Le.monitored_printers.includes(e)),[Le]),{data:ze}=p({queryKey:[`spoolman-status`],queryFn:i.getSpoolmanStatus,staleTime:60*1e3}),Be=ze?.enabled&&ze?.connected,{data:Ve}=p({queryKey:[`spoolman-settings`],queryFn:i.getSpoolmanSettings,enabled:!!Be,staleTime:60*1e3}),He=Ve?.spoolman_sync_mode,{data:Ue}=p({queryKey:[`unlinked-spools`],queryFn:i.getUnlinkedSpools,enabled:!!Be,staleTime:30*1e3}),We=Ue&&Ue.length>0,{data:Ge}=p({queryKey:[`linked-spools`],queryFn:i.getLinkedSpools,enabled:!!Be,staleTime:30*1e3}),Ke=Ge?.linked,{data:qe}=p({queryKey:[`spool-assignments`],queryFn:()=>i.getAssignments(),enabled:_e(`inventory:view_assignments`),staleTime:30*1e3}),Je=m({mutationFn:({printerId:e,amsId:t,trayId:n})=>i.unassignSpool(e,t,n),onSuccess:()=>{U.invalidateQueries({queryKey:[`spool-assignments`]})}}),{data:Ye,isLoading:Xe}=p({queryKey:[`spoolman-inventory-spools`],queryFn:()=>i.getSpoolmanInventorySpools(!1),enabled:!!Be,staleTime:30*1e3}),{data:Ze,isLoading:Qe}=p({queryKey:[`spoolman-slot-assignments`],queryFn:()=>i.getSpoolmanSlotAssignments(),enabled:!!Be,staleTime:30*1e3}),$e=m({mutationFn:e=>i.unassignSpoolmanSlot(e),onSuccess:()=>{U.invalidateQueries({queryKey:[`spoolman-inventory-spools`]}),U.invalidateQueries({queryKey:[`spoolman-slot-assignments`]})}}),et=(e,t,n)=>qe?.find(r=>r.printer_id===e&&r.ams_id===Number(t)&&r.tray_id===Number(n)),tt=Ie?.reduce((e,t)=>(e[t.printer_id]={due_count:t.due_count,warning_count:t.warning_count,total_print_hours:t.total_print_hours},e),{})||{},nt=Fe?.reduce((e,t)=>(t.printer_id&&(e[t.printer_id]=t),e),{})||{},rt=m({mutationFn:i.createPrinter,onSuccess:()=>{U.invalidateQueries({queryKey:[`printers`]}),U.invalidateQueries({queryKey:[`maintenanceOverview`]}),s(!1)},onError:t=>{if(t instanceof c&&t.code===`printer_connection_failed`){ge(e(`printers.toast.connectionFailedNotAdded`),`error`);return}ge(t.message||e(`printers.toast.failedToAdd`),`error`)}}),it=m({mutationFn:e=>i.controlSmartPlug(e,`on`),onSuccess:()=>{U.invalidateQueries({queryKey:[`smart-plugs`]}),v(null)},onError:()=>{v(null)}}),[at,ot]=(0,X.useState)(new Set),[st,ct]=(0,X.useState)(!1),[lt,ut]=(0,X.useState)(null),[dt,ft]=(0,X.useState)(!1),pt=st||at.size>0,mt=(0,X.useCallback)(e=>{ot(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),ht=(0,X.useCallback)(()=>{ot(new Set),ct(!1)},[]);(0,X.useEffect)(()=>{let e=e=>{e.key===`Escape`&&pt&&ht()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[pt,ht]);let gt=(0,X.useCallback)(async t=>{ft(!0);let n=Array.from(at).filter(e=>{let n=U.getQueryData([`printerStatus`,e]);if(t===`clearPlate`)return!!n?.awaiting_plate_clear;if(!n?.connected)return!1;switch(t){case`stop`:return n.state===`RUNNING`||n.state===`PAUSE`;case`pause`:return n.state===`RUNNING`;case`resume`:return n.state===`PAUSE`;case`clearHMS`:return n.hms_errors&&Mt(n.hms_errors).length>0;default:return!1}});if(n.length===0){ge(e(`printers.bulk.noneApplicable`),`error`),ft(!1),ut(null);return}let r={stop:i.stopPrint,pause:i.pausePrint,resume:i.resumePrint,clearPlate:i.clearPlate,clearHMS:i.clearHMSErrors}[t],a=await Promise.allSettled(n.map(e=>r(e))),o=a.filter(e=>e.status===`fulfilled`).length,s=a.filter(e=>e.status===`rejected`).length;s===0?ge(e(`printers.bulk.success`,{action:e(`printers.bulk.actions.${t}`),count:o})):ge(e(`printers.bulk.partial`,{succeeded:o,failed:s}),`error`),n.forEach(e=>{U.invalidateQueries({queryKey:[`printerStatus`,e]})}),ft(!1),ut(null)},[at,U,ge,e]),_t=(0,X.useCallback)(e=>{e===`stop`||e===`pause`||e===`clearPlate`?ut(e):gt(e)},[gt]),vt=()=>{let e=!u;d(e),localStorage.setItem(`hideDisconnectedPrinters`,String(e))},yt=e=>{b(e),localStorage.setItem(`printerSortBy`,e)},bt=e=>{ce(e),localStorage.setItem(`printerStatusFilter`,e)},xt=e=>{de(e),localStorage.setItem(`printerLocationFilter`,e)},St=()=>{let e=!x;w(e),localStorage.setItem(`printerSortAsc`,String(e))},Ct=()=>{switch(T){case 1:return`grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`;case 2:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`;case 3:return`grid-cols-1 lg:grid-cols-2`;case 4:return`grid-cols-1`;default:return`grid-cols-1 md:grid-cols-2 xl:grid-cols-3`}},wt=[`S`,`M`,`L`,`XL`];(0,X.useEffect)(()=>U.getQueryCache().subscribe(e=>{e.type===`updated`&&Array.isArray(e.query.queryKey)&&e.query.queryKey[0]===`printerStatus`&&H(e=>e+1)}),[U]);let Tt=(0,X.useMemo)(()=>{if(!K)return[];let e=K;if(V.trim()){let t=V.trim().toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||(e.model||``).toLowerCase().includes(t)||(e.location||``).toLowerCase().includes(t)||(e.serial_number||``).toLowerCase().includes(t))}return ue!==`all`&&(e=e.filter(e=>(e.location||``)===ue)),se!==`all`&&(e=e.filter(e=>{let t=U.getQueryData([`printerStatus`,e.id]);if(!t?.connected)return se===`offline`;let n=t.hms_errors?Mt(t.hms_errors):[];switch(se){case`printing`:return t.state===`RUNNING`;case`paused`:return t.state===`PAUSE`;case`finished`:return t.state===`FINISH`;case`error`:return t.state===`FAILED`||n.length>0;case`idle`:return t.state!==`RUNNING`&&t.state!==`PAUSE`&&t.state!==`FINISH`&&t.state!==`FAILED`&&n.length===0;case`offline`:return!1;default:return!0}})),e},[K,V,se,ue,U,fe]),Et=(0,X.useMemo)(()=>K?[...new Set(K.map(e=>e.location||``).filter(Boolean))].sort():[],[K]);(0,X.useEffect)(()=>{!K||ue===`all`||Et.includes(ue)||(de(`all`),localStorage.setItem(`printerLocationFilter`,`all`))},[K,Et,ue]);let Dt=(0,X.useMemo)(()=>{let e=[...Tt];switch(y){case`name`:e.sort((e,t)=>e.name.localeCompare(t.name));break;case`model`:e.sort((e,t)=>(e.model||``).localeCompare(t.model||``));break;case`location`:e.sort((e,t)=>{let n=e.location||``,r=t.location||``;return!n&&r?1:n&&!r?-1:n.localeCompare(r)||e.name.localeCompare(t.name)});break;case`status`:e.sort((e,t)=>{let n=U.getQueryData([`printerStatus`,e.id]),r=U.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?(e.hms_errors?Mt(e.hms_errors):[]).length>0?0:e.state===`RUNNING`?1:2:3;return i(n)-i(r)});break;case`eta`:e.sort((e,t)=>{let n=U.getQueryData([`printerStatus`,e.id]),r=U.getQueryData([`printerStatus`,t.id]),i=e=>e?.connected?e.state===`RUNNING`&&e.remaining_time!=null&&e.remaining_time>0?0:e.state===`RUNNING`?1:2:3,a=i(n),o=i(r);if(a!==o)return a-o;if(a===0){let e=(n.remaining_time??0)-(r.remaining_time??0);if(e!==0)return e}return e.name.localeCompare(t.name)});break}return x||e.reverse(),e},[Tt,y,x,U]),Ot=(0,X.useCallback)(()=>{ot(new Set(Dt.map(e=>e.id))),ct(!0)},[Dt]),kt=(0,X.useCallback)(e=>{ot(t=>{let n=new Set(t);return Dt.forEach(t=>{lo(U.getQueryData([`printerStatus`,t.id]))===e&&n.add(t.id)}),n}),ct(!0)},[Dt,U]),At=(0,X.useCallback)(e=>{ot(t=>{let n=new Set(t);return Dt.filter(t=>(t.location||``)===e).forEach(e=>n.add(e.id)),n}),ct(!0)},[Dt]),jt=(0,X.useCallback)(e=>{ot(t=>{let n=new Set(t);return Dt.filter(t=>(t.model||`Unknown`)===e).forEach(e=>n.add(e.id)),n}),ct(!0)},[Dt]),Ft=(0,X.useCallback)(e=>{he(t=>{let n={...t,[e]:!t[e]};try{localStorage.setItem(`printerCollapsedSections`,JSON.stringify(n))}catch{}return n})},[]),It=(0,X.useMemo)(()=>{if(y===`name`||y===`eta`)return null;let e={};return y===`location`?Dt.forEach(t=>{let n=t.location||`Ungrouped`;e[n]||(e[n]=[]),e[n].push(t)}):y===`model`?Dt.forEach(t=>{let n=t.model||`Unknown`;e[n]||(e[n]=[]),e[n].push(t)}):y===`status`&&Dt.forEach(t=>{let n=lo(U.getQueryData([`printerStatus`,t.id]));e[n]||(e[n]=[]),e[n].push(t)}),e},[y,Dt,U,fe]),zt=(0,X.useRef)(null),Bt=(0,X.useRef)(null),Vt=(0,X.useRef)(0),[Ht,Ut]=(0,X.useState)(!1),Wt=(0,X.useCallback)(()=>{let e=zt.current;if(!e)return;let t=Bt.current?.offsetWidth;t&&(Vt.current=t);let n=Vt.current>0&&e.clientWidth<Vt.current+220+8;Ut(e=>e===n?e:n)},[]),Gt=Object.keys(nt).length;(0,X.useLayoutEffect)(()=>{Wt();let e=zt.current;if(!e)return;if(typeof ResizeObserver>`u`)return window.addEventListener(`resize`,Wt),()=>window.removeEventListener(`resize`,Wt);let t=new ResizeObserver(()=>Wt());return t.observe(e),window.addEventListener(`resize`,Wt),()=>{t.disconnect(),window.removeEventListener(`resize`,Wt)}},[Wt,K?.length,Et.length,u,Gt]);let Kt=(t=!1)=>(0,$.jsxs)($.Fragment,{children:[K&&K.length>0&&(0,$.jsx)(no,{value:se,onChange:bt,fullWidth:t,options:ka.map(t=>({value:t.value,label:e(t.labelKey)}))}),K&&K.length>0&&Et.length>0&&(0,$.jsx)(no,{value:ue,onChange:xt,fullWidth:t,options:[{value:`all`,label:e(`printers.filter.allLocations`)},...Et.map(e=>({value:e,label:e}))]}),(0,$.jsx)(`button`,{type:`button`,onClick:vt,"aria-pressed":u,className:`h-8 px-2 rounded-lg border text-sm font-medium transition-colors ${t?`w-full`:``} ${u?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:e(`printers.hideOffline`)})]}),qt=(t=!1)=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1 ${t?`w-full`:``}`,children:[(0,$.jsx)(no,{value:y,onChange:yt,fullWidth:t,options:[{value:`name`,label:e(`printers.sort.name`)},{value:`status`,label:e(`printers.sort.status`)},{value:`model`,label:e(`printers.sort.model`)},{value:`location`,label:e(`printers.sort.location`)},{value:`eta`,label:e(`printers.sort.eta`)}]}),(0,$.jsx)(`button`,{onClick:St,className:`h-8 shrink-0 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,title:e(x?`printers.sort.descending`:`printers.sort.ascending`),children:x?(0,$.jsx)(E,{className:`w-4 h-4 text-white`}):(0,$.jsx)(S,{className:`w-4 h-4 text-white`})}),(0,$.jsx)(bn,{to:`/printer-locations`,className:`h-8 shrink-0 px-2 rounded-lg border bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary transition-colors flex items-center justify-center`,title:e(`printers.locations.title`),"aria-label":e(`printers.locations.title`),children:(0,$.jsx)(j,{className:`w-4 h-4 text-bambu-green`})})]}),(0,$.jsxs)(`div`,{className:`flex h-8 items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary ${t?`w-full`:``}`,children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{k(`cards`),localStorage.setItem(`printerPageView`,`cards`)},className:`flex h-full items-center gap-1 rounded-l-lg px-2 text-xs font-medium transition-colors ${t?`flex-1 justify-center`:``} ${O===`cards`?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.pageView.cards`),"aria-pressed":O===`cards`,children:[(0,$.jsx)(pe,{className:`w-3.5 h-3.5`}),t&&(0,$.jsx)(`span`,{children:e(`printers.pageView.cards`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{k(`camwall`),localStorage.setItem(`printerPageView`,`camwall`)},className:`flex h-full items-center gap-1 rounded-r-lg px-2 text-xs font-medium transition-colors ${t?`flex-1 justify-center`:``} ${O===`camwall`?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.pageView.camWall`),"aria-pressed":O===`camwall`,disabled:!_e(`camera:view`),children:[(0,$.jsx)(J,{className:`w-3.5 h-3.5`}),t&&(0,$.jsx)(`span`,{children:e(`printers.pageView.camWall`)})]})]}),O===`camwall`&&_e(`camera:view`)&&(0,$.jsxs)(bn,{to:`/camwall`,className:`flex h-8 items-center gap-1 rounded-lg border border-bambu-dark-tertiary bg-bambu-dark px-2 text-xs font-medium text-white transition-colors hover:bg-bambu-dark-tertiary ${t?`w-full justify-center`:``}`,title:e(`printers.pageView.openCamWallPage`),children:[(0,$.jsx)($t,{className:`w-3.5 h-3.5`}),t&&(0,$.jsx)(`span`,{children:e(`printers.pageView.openCamWallPage`)})]}),(0,$.jsx)(`div`,{className:`flex h-8 items-center bg-bambu-dark rounded-lg border border-bambu-dark-tertiary ${t?`w-full`:``}`,children:wt.map((n,r)=>{let i=r+1,a=(O===`camwall`?F:T)===i;return(0,$.jsx)(`button`,{onClick:()=>{if(O===`camwall`){L(i),localStorage.setItem(`camWallTileSize`,String(i));return}re(null),D(i),localStorage.setItem(`printerCardSize`,String(i))},className:`h-full px-2 text-xs font-medium transition-colors ${t?`flex-1`:``} ${r===0?`rounded-l-lg`:``} ${r===wt.length-1?`rounded-r-lg`:``} ${a?`bg-bambu-green text-white`:`text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.${O===`camwall`?`camWall.tileSize`:`cardSize`}.${[`small`,`medium`,`large`,`extraLarge`][r]}`),children:n},n)})})]}),Jt=(t=!1)=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{onClick:()=>{pt?ht():ct(!0)},className:`h-8 px-2 rounded-lg border transition-colors ${t?`w-full justify-center gap-1.5 text-sm font-medium flex items-center`:``} ${pt?`bg-bambu-green border-bambu-green text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,title:e(`printers.bulk.select`),disabled:!_e(`printers:control`),children:[(0,$.jsx)(xn,{className:`w-4 h-4`}),t&&(0,$.jsx)(`span`,{children:e(`printers.bulk.select`)})]}),u&&Object.keys(nt).length>0&&(0,$.jsxs)(`div`,{className:`relative ${t?`w-full`:``}`,children:[(0,$.jsxs)(`button`,{onClick:()=>g(!h),className:`h-8 flex items-center gap-1.5 px-2 text-sm rounded-lg border transition-colors ${t?`w-full justify-between bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary hover:text-white`:`bg-bambu-dark border-bambu-dark-tertiary text-white hover:bg-bambu-dark-tertiary`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(jn,{className:`w-4 h-4`}),e(`printers.powerOn`)]}),(0,$.jsx)(I,{className:`w-3 h-3 transition-transform ${h?`rotate-180`:``}`})]}),h&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>g(!1)}),(0,$.jsxs)(`div`,{className:`absolute right-0 mt-2 w-56 bg-white dark:bg-bambu-dark-secondary border border-gray-200 dark:border-bambu-dark-tertiary rounded-lg shadow-lg z-20 py-1`,children:[(0,$.jsx)(`div`,{className:`px-3 py-2 text-xs text-gray-500 dark:text-bambu-gray border-b border-gray-200 dark:border-bambu-dark-tertiary`,children:e(`printers.offlinePrintersWithPlugs`)}),K?.filter(e=>nt[e.id]).map(e=>(0,$.jsx)(wo,{printer:e,plug:nt[e.id],onPowerOn:e=>{v(e),it.mutate(e)},isPowering:_===nt[e.id]?.id},e.id)),K?.filter(e=>nt[e.id]).length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 text-sm text-bambu-gray`,children:`No printers with smart plugs`})]})]})]}),(0,$.jsxs)(Y,{onClick:()=>s(!0),disabled:!_e(`printers:create`),title:_e(`printers:create`)?void 0:e(`printers.permission.noAdd`),className:`!h-8 !min-h-8 px-2 py-0 ${t?`w-full`:``}`,children:[(0,$.jsx)(Nn,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]});return(0,$.jsxs)(`div`,{className:`p-4 md:p-8`,children:[(0,$.jsxs)(`div`,{className:`space-y-3 mb-6`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`h1`,{className:`text-2xl font-bold text-white flex items-center gap-3`,children:[(0,$.jsx)(ln,{className:`w-7 h-7 text-bambu-green`}),e(`printers.title`)]}),(0,$.jsx)(to,{printers:K})]}),(0,$.jsxs)(`div`,{ref:zt,className:`relative flex items-center gap-2`,children:[K&&K.length>0&&(0,$.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,$.jsx)(Ae,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-bambu-gray/50`}),(0,$.jsx)(`input`,{type:`search`,name:`printer-search`,autoComplete:`off`,"data-1p-ignore":!0,"data-lpignore":`true`,value:V,onChange:e=>oe(e.target.value),placeholder:e(`printers.search`),"aria-label":e(`printers.search`),className:`w-full h-8 pl-9 pr-8 bg-bambu-dark border border-bambu-dark-tertiary rounded-lg text-white text-sm placeholder:text-bambu-gray/50 focus:outline-none focus:border-bambu-green`}),V&&(0,$.jsx)(`button`,{type:`button`,"aria-label":e(`common.clear`),onClick:()=>oe(``),className:`absolute right-3 top-1/2 -translate-y-1/2 text-bambu-gray hover:text-white`,children:(0,$.jsx)(Pt,{className:`w-4 h-4`})})]}),(0,$.jsxs)(`div`,{ref:Bt,"aria-hidden":Ht,inert:Ht,className:`${Ht?`absolute -left-[9999px] top-0 flex w-max pointer-events-none opacity-0`:`flex`} ml-auto items-center justify-end gap-2 flex-nowrap [&>*]:shrink-0`,children:[(0,$.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:Kt()}),(0,$.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:qt()}),(0,$.jsx)(`div`,{className:`h-6 w-px bg-bambu-dark-tertiary`}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:Jt()})]}),Ht&&(0,$.jsxs)(`div`,{className:`ml-auto flex items-center justify-end gap-1`,children:[(0,$.jsx)(ro,{label:e(`printers.toolbar.filters`,`Filters`),icon:(0,$.jsx)(le,{className:`w-4 h-4`}),children:(0,$.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:Kt(!0)})}),(0,$.jsx)(ro,{label:e(`printers.toolbar.view`,`View`),icon:(0,$.jsx)(Ar,{className:`w-4 h-4`}),children:(0,$.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:qt(!0)})}),(0,$.jsx)(ro,{label:e(`printers.toolbar.actions`,`Actions`),icon:(0,$.jsx)(Cr,{className:`w-4 h-4`}),children:(0,$.jsx)(`div`,{className:`flex w-48 flex-col gap-2`,children:Jt(!0)})})]})]})]}),Te?(0,$.jsx)(`div`,{className:`text-center py-12 text-bambu-gray`,children:e(`common.loading`)}):K?.length===0?(0,$.jsx)(Rt,{children:(0,$.jsxs)(Lt,{className:`text-center py-12`,children:[(0,$.jsx)(`p`,{className:`text-bambu-gray mb-4`,children:e(`printers.noPrintersConfigured`)}),(0,$.jsxs)(Y,{onClick:()=>s(!0),disabled:!_e(`printers:create`),title:_e(`printers:create`)?void 0:e(`printers.permission.noAdd`),children:[(0,$.jsx)(Nn,{className:`w-4 h-4`}),e(`printers.addPrinter`)]})]})}):Dt.length===0&&(V.trim()||se!==`all`||ue!==`all`)?(0,$.jsx)(Rt,{children:(0,$.jsx)(Lt,{className:`text-center py-12`,children:(0,$.jsx)(`p`,{className:`text-bambu-gray`,children:e(`printers.noSearchResults`)})})}):O===`camwall`?(0,$.jsx)(Nt,{printers:Dt,maxLive:A,snapshotIntervalSec:N,tileSize:F,onTileClick:(e,t)=>{Ne===`embedded`?G(n=>new Map(n).set(e,{id:e,name:t})):Di(e)},statusMode:R,onChangeMaxLive:e=>{M(e),localStorage.setItem(`camWallMaxLive`,String(e))},onChangeSnapshotIntervalSec:e=>{P(e),localStorage.setItem(`camWallSnapshotSec`,String(e))},onChangeStatusMode:e=>{ee(e),localStorage.setItem(`camWallStatusMode`,e)}}):It?(0,$.jsx)(`div`,{className:`space-y-6`,children:(()=>{let e=y===`status`?so.filter(e=>It[e]?.length>0):Object.keys(It);return x?e:[...e].reverse()})().map(t=>{let n=It[t],r=`${y}:${t}`,i=!me[r],a=y===`status`&&co[t]?.dot||`bg-bambu-green`,o=y===`status`?e(co[t]?.labelKey||t):t;return(0,$.jsx)(Jn,{open:i,onToggle:()=>Ft(r),summaryClassName:`py-1`,summary:(0,$.jsxs)(`h2`,{className:`text-lg font-semibold text-white flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`w-2 h-2 rounded-full ${a}`}),o,(0,$.jsxs)(`span`,{className:`text-sm font-normal text-bambu-gray`,children:[`(`,n.length,`)`]}),pt&&(0,$.jsx)(`button`,{onClick:e=>{e.stopPropagation(),y===`location`?At(t===`Ungrouped`?``:t):y===`status`?kt(t):y===`model`&&jt(t)},className:`text-xs text-bambu-green hover:text-bambu-green-light transition-colors ml-1`,children:e(`printers.bulk.selectAll`)})]}),children:(0,$.jsx)(`div`,{className:`grid gap-4 ${T>=3?`gap-6`:``} ${Ct()}`,children:n.map(e=>(0,$.jsx)(yo,{printer:e,hideIfDisconnected:u,maintenanceInfo:tt[e.id],viewMode:ne,cardSize:T,amsThresholds:q?{humidityGood:Number(q.ams_humidity_good)||40,humidityFair:Number(q.ams_humidity_fair)||60,tempGood:Number(q.ams_temp_good)||28,tempFair:Number(q.ams_temp_fair)||35}:void 0,spoolmanEnabled:Be,hasUnlinkedSpools:We,linkedSpools:Ke,spoolmanUrl:ze?.url,spoolmanSyncMode:He,onGetAssignment:et,onUnassignSpool:(e,t,n)=>Je.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:Ye,spoolmanSlotAssignments:Ze,spoolmanLoading:Xe||Qe,onUnassignSpoolmanSpool:e=>$e.mutate(e),timeFormat:q?.time_format||`system`,cameraViewMode:Ne,onOpenEmbeddedCamera:(e,t)=>G(n=>new Map(n).set(e,{id:e,name:t})),onSelectCameraViewMode:Pe,checkPrinterFirmware:Ee,dryingPresets:Me,nozzleTempPresets:De,bedTempPresets:Oe,chamberTempPresets:ke,fanSpeedPresets:je,requirePlateClear:q?.require_plate_clear===!0,selectionMode:pt,isSelected:at.has(e.id),onToggleSelect:mt,onOpenCompactCard:ie,aiDetectionEnabled:Re(e.id),aiDetection:Le?.enabled?Le.per_printer[String(e.id)]:void 0,aiLastError:Le?.last_error??null},e.id))})},t)})}):(0,$.jsx)(`div`,{className:`grid gap-4 ${T>=3?`gap-6`:``} ${Ct()}`,children:Dt.map(e=>(0,$.jsx)(yo,{printer:e,hideIfDisconnected:u,maintenanceInfo:tt[e.id],viewMode:ne,cardSize:T,spoolmanEnabled:Be,hasUnlinkedSpools:We,linkedSpools:Ke,spoolmanUrl:ze?.url,spoolmanSyncMode:He,onGetAssignment:et,onUnassignSpool:(e,t,n)=>Je.mutate({printerId:e,amsId:t,trayId:n}),spoolmanSpools:Ye,spoolmanSlotAssignments:Ze,spoolmanLoading:Xe||Qe,onUnassignSpoolmanSpool:e=>$e.mutate(e),amsThresholds:q?{humidityGood:Number(q.ams_humidity_good)||40,humidityFair:Number(q.ams_humidity_fair)||60,tempGood:Number(q.ams_temp_good)||28,tempFair:Number(q.ams_temp_fair)||35}:void 0,timeFormat:q?.time_format||`system`,cameraViewMode:Ne,onOpenEmbeddedCamera:(e,t)=>G(n=>new Map(n).set(e,{id:e,name:t})),onSelectCameraViewMode:Pe,checkPrinterFirmware:Ee,dryingPresets:Me,nozzleTempPresets:De,bedTempPresets:Oe,chamberTempPresets:ke,fanSpeedPresets:je,requirePlateClear:q?.require_plate_clear===!0,selectionMode:pt,isSelected:at.has(e.id),onToggleSelect:mt,onOpenCompactCard:ie,aiDetectionEnabled:Re(e.id),aiDetection:Le?.enabled?Le.per_printer[String(e.id)]:void 0,aiLastError:Le?.last_error??null},e.id))}),T===2&&z!=null&&(0,$.jsxs)(`button`,{type:`button`,onClick:ae,className:`fixed bottom-5 left-1/2 z-40 inline-flex -translate-x-1/2 items-center gap-2 rounded-full border px-4 py-2 text-sm font-medium shadow-xl transition-colors ${a}`,title:e(`common.back`,`Back`),children:[(0,$.jsx)(C,{className:`w-4 h-4`}),e(`common.back`,`Back`)]}),o&&(0,$.jsx)(bo,{onClose:()=>s(!1),onAdd:e=>rt.mutate(e),existingSerials:K?.map(e=>e.serial_number)||[]}),pt&&K&&(0,$.jsx)(Ii,{selectedIds:at,printers:K,onClose:ht,onSelectAll:Ot,onSelectByLocation:At,onSelectByState:kt,onAction:_t,actionPending:dt}),lt===`stop`&&(0,$.jsx)(In,{title:e(`printers.bulk.confirm.stopTitle`,{count:at.size}),message:e(`printers.bulk.confirm.stopMessage`,{count:at.size}),confirmText:e(`printers.bulk.confirm.stopButton`),variant:`danger`,isLoading:dt,onConfirm:()=>gt(`stop`),onCancel:()=>ut(null)}),lt===`pause`&&(0,$.jsx)(In,{title:e(`printers.bulk.confirm.pauseTitle`,{count:at.size}),message:e(`printers.bulk.confirm.pauseMessage`,{count:at.size}),confirmText:e(`printers.bulk.confirm.pauseButton`),isLoading:dt,onConfirm:()=>gt(`pause`),onCancel:()=>ut(null)}),lt===`clearPlate`&&(0,$.jsx)(In,{title:e(`printers.bulk.confirm.clearPlateTitle`,{count:at.size}),message:e(`printers.bulk.confirm.clearPlateMessage`,{count:at.size}),confirmText:e(`printers.bulk.confirm.clearPlateButton`),isLoading:dt,onConfirm:()=>gt(`clearPlate`),onCancel:()=>ut(null)}),Array.from(W.values()).map((e,t)=>(0,$.jsx)(Ji,{printerId:e.id,printerName:e.name,viewerIndex:t,onClose:()=>G(t=>{let n=new Map(t);return n.delete(e.id),n})},e.id))]})}export{bo as AddPrinterModal,mo as AmsNameHoverCard,eo as CoverImage,To as PrintersPage};