diff --git a/app/dist/assets/event-Cyr5rmj6.js b/app/dist/assets/event-DJ2yZWXo.js similarity index 94% rename from app/dist/assets/event-Cyr5rmj6.js rename to app/dist/assets/event-DJ2yZWXo.js index 94fd441..d87a116 100644 --- a/app/dist/assets/event-Cyr5rmj6.js +++ b/app/dist/assets/event-DJ2yZWXo.js @@ -1 +1 @@ -import{i as D,t as i}from"./index-f_l0OPwu.js";var _;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WINDOW_SUSPENDED="tauri://suspended",r.WINDOW_RESUMED="tauri://resumed",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(_||(_={}));async function l(r,a){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(r,a),await D("plugin:event|unlisten",{event:r,eventId:a})}async function n(r,a,e){var t;const W=typeof e?.target=="string"?{kind:"AnyLabel",label:e.target}:(t=e?.target)!==null&&t!==void 0?t:{kind:"Any"};return D("plugin:event|listen",{event:r,target:W,handler:i(a)}).then(d=>async()=>l(r,d))}export{_ as TauriEvent,n as listen}; +import{i as D,t as i}from"./index-DjStOWCE.js";var _;(function(r){r.WINDOW_RESIZED="tauri://resize",r.WINDOW_MOVED="tauri://move",r.WINDOW_CLOSE_REQUESTED="tauri://close-requested",r.WINDOW_DESTROYED="tauri://destroyed",r.WINDOW_FOCUS="tauri://focus",r.WINDOW_BLUR="tauri://blur",r.WINDOW_SCALE_FACTOR_CHANGED="tauri://scale-change",r.WINDOW_THEME_CHANGED="tauri://theme-changed",r.WINDOW_CREATED="tauri://window-created",r.WINDOW_SUSPENDED="tauri://suspended",r.WINDOW_RESUMED="tauri://resumed",r.WEBVIEW_CREATED="tauri://webview-created",r.DRAG_ENTER="tauri://drag-enter",r.DRAG_OVER="tauri://drag-over",r.DRAG_DROP="tauri://drag-drop",r.DRAG_LEAVE="tauri://drag-leave"})(_||(_={}));async function l(r,a){window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(r,a),await D("plugin:event|unlisten",{event:r,eventId:a})}async function n(r,a,e){var t;const W=typeof e?.target=="string"?{kind:"AnyLabel",label:e.target}:(t=e?.target)!==null&&t!==void 0?t:{kind:"Any"};return D("plugin:event|listen",{event:r,target:W,handler:i(a)}).then(d=>async()=>l(r,d))}export{_ as TauriEvent,n as listen}; diff --git a/app/dist/assets/index-f_l0OPwu.js b/app/dist/assets/index-DjStOWCE.js similarity index 92% rename from app/dist/assets/index-f_l0OPwu.js rename to app/dist/assets/index-DjStOWCE.js index 584dcff..9ffd30a 100644 --- a/app/dist/assets/index-f_l0OPwu.js +++ b/app/dist/assets/index-DjStOWCE.js @@ -1,12 +1,12 @@ -(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const j of document.querySelectorAll('link[rel="modulepreload"]'))r(j);new MutationObserver(j=>{for(const A of j)if(A.type==="childList")for(const Y of A.addedNodes)Y.tagName==="LINK"&&Y.rel==="modulepreload"&&r(Y)}).observe(document,{childList:!0,subtree:!0});function N(j){const A={};return j.integrity&&(A.integrity=j.integrity),j.referrerPolicy&&(A.referrerPolicy=j.referrerPolicy),j.crossOrigin==="use-credentials"?A.credentials="include":j.crossOrigin==="anonymous"?A.credentials="omit":A.credentials="same-origin",A}function r(j){if(j.ep)return;j.ep=!0;const A=N(j);fetch(j.href,A)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Us={exports:{}},Pn={};var Vd;function z0(){if(Vd)return Pn;Vd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function N(r,j,A){var Y=null;if(A!==void 0&&(Y=""+A),j.key!==void 0&&(Y=""+j.key),"key"in j){A={};for(var G in j)G!=="key"&&(A[G]=j[G])}else A=j;return j=A.ref,{$$typeof:f,type:r,key:Y,ref:j!==void 0?j:null,props:A}}return Pn.Fragment=b,Pn.jsx=N,Pn.jsxs=N,Pn}var Zd;function T0(){return Zd||(Zd=1,Us.exports=z0()),Us.exports}var c=T0(),ws={exports:{}},ae={};var Kd;function M0(){if(Kd)return ae;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),V=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=V&&d[V]||d["@@iterator"],typeof d=="function"?d:null)}var X={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,re={};function I(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||X}I.prototype.isReactComponent={},I.prototype.setState=function(d,z){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,z,"setState")},I.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function ne(){}ne.prototype=I.prototype;function ce(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||X}var Ge=ce.prototype=new ne;Ge.constructor=ce,F(Ge,I.prototype),Ge.isPureReactComponent=!0;var Ze=Array.isArray;function ke(){}var $={H:null,A:null,T:null,S:null},je=Object.prototype.hasOwnProperty;function ot(d,z,B){var H=B.ref;return{$$typeof:f,type:d,key:z,ref:H!==void 0?H:null,props:B}}function qe(d,z){return ot(d.type,z,d.props)}function Me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ke(d){var z={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return z[B]})}var $e=/\/+/g;function tt(d,z){return typeof d=="object"&&d!==null&&d.key!=null?Ke(""+d.key):z.toString(36)}function Je(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(ke,ke):(d.status="pending",d.then(function(z){d.status==="pending"&&(d.status="fulfilled",d.value=z)},function(z){d.status==="pending"&&(d.status="rejected",d.reason=z)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,z,B,H,P){var te=typeof d;(te==="undefined"||te==="boolean")&&(d=null);var le=!1;if(d===null)le=!0;else switch(te){case"bigint":case"string":case"number":le=!0;break;case"object":switch(d.$$typeof){case f:case b:le=!0;break;case D:return le=d._init,x(le(d._payload),z,B,H,P)}}if(le)return P=P(d),le=H===""?"."+tt(d,0):H,Ze(P)?(B="",le!=null&&(B=le.replace($e,"$&/")+"/"),x(P,z,B,"",function(ct){return ct})):P!=null&&(Me(P)&&(P=qe(P,B+(P.key==null||d&&d.key===P.key?"":(""+P.key).replace($e,"$&/")+"/")+le)),z.push(P)),1;le=0;var Ue=H===""?".":H+":";if(Ze(d))for(var ze=0;ze>>1,de=x[se];if(0>>1;sej(B,K))Hj(P,B)?(x[se]=P,x[H]=K,se=H):(x[se]=B,x[z]=K,se=z);else if(Hj(P,K))x[se]=P,x[H]=K,se=H;else break e}}return O}function j(x,O){var K=x.sortIndex-O.sortIndex;return K!==0?K:x.id-O.id}if(f.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var A=performance;f.unstable_now=function(){return A.now()}}else{var Y=Date,G=Y.now();f.unstable_now=function(){return Y.now()-G}}var R=[],y=[],D=1,U=null,V=3,ee=!1,X=!1,F=!1,re=!1,I=typeof setTimeout=="function"?setTimeout:null,ne=typeof clearTimeout=="function"?clearTimeout:null,ce=typeof setImmediate<"u"?setImmediate:null;function Ge(x){for(var O=N(y);O!==null;){if(O.callback===null)r(y);else if(O.startTime<=x)r(y),O.sortIndex=O.expirationTime,b(R,O);else break;O=N(y)}}function Ze(x){if(F=!1,Ge(x),!X)if(N(R)!==null)X=!0,ke||(ke=!0,Ke());else{var O=N(y);O!==null&&Je(Ze,O.startTime-x)}}var ke=!1,$=-1,je=5,ot=-1;function qe(){return re?!0:!(f.unstable_now()-otx&&qe());){var se=U.callback;if(typeof se=="function"){U.callback=null,V=U.priorityLevel;var de=se(U.expirationTime<=x);if(x=f.unstable_now(),typeof de=="function"){U.callback=de,Ge(x),O=!0;break t}U===N(R)&&r(R),Ge(x)}else r(R);U=N(R)}if(U!==null)O=!0;else{var d=N(y);d!==null&&Je(Ze,d.startTime-x),O=!1}}break e}finally{U=null,V=K,ee=!1}O=void 0}}finally{O?Ke():ke=!1}}}var Ke;if(typeof ce=="function")Ke=function(){ce(Me)};else if(typeof MessageChannel<"u"){var $e=new MessageChannel,tt=$e.port2;$e.port1.onmessage=Me,Ke=function(){tt.postMessage(null)}}else Ke=function(){I(Me,0)};function Je(x,O){$=I(function(){x(f.unstable_now())},O)}f.unstable_IdlePriority=5,f.unstable_ImmediatePriority=1,f.unstable_LowPriority=4,f.unstable_NormalPriority=3,f.unstable_Profiling=null,f.unstable_UserBlockingPriority=2,f.unstable_cancelCallback=function(x){x.callback=null},f.unstable_forceFrameRate=function(x){0>x||125se?(x.sortIndex=K,b(y,x),N(R)===null&&x===N(y)&&(F?(ne($),$=-1):F=!0,Je(Ze,K-se))):(x.sortIndex=de,b(R,x),X||ee||(X=!0,ke||(ke=!0,Ke()))),x},f.unstable_shouldYield=qe,f.unstable_wrapCallback=function(x){var O=V;return function(){var K=V;V=O;try{return x.apply(this,arguments)}finally{V=K}}}})(Hs)),Hs}var Wd;function A0(){return Wd||(Wd=1,Rs.exports=N0()),Rs.exports}var Gs={exports:{}},jt={};var Fd;function D0(){if(Fd)return jt;Fd=1;var f=Qs();function b(R){var y="https://react.dev/errors/"+R;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(b){console.error(b)}}return f(),Gs.exports=D0(),Gs.exports}var Pd;function O0(){if(Pd)return ei;Pd=1;var f=A0(),b=Qs(),N=C0();function r(e){var t="https://react.dev/errors/"+e;if(1de||(e.current=se[de],se[de]=null,de--)}function B(e,t){de++,se[de]=e.current,e.current=t}var H=d(null),P=d(null),te=d(null),le=d(null);function Ue(e,t){switch(B(te,t),B(P,e),B(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=hd(t),e=yd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}z(H),B(H,e)}function ze(){z(H),z(P),z(te)}function ct(e){e.memoizedState!==null&&B(le,e);var t=H.current,l=yd(t,e.type);t!==l&&(B(P,e),B(H,l))}function yt(e){P.current===e&&(z(H),z(P)),le.current===e&&(z(le),$n._currentValue=K)}var wt,Al;function rt(e){if(wt===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);wt=t&&t[1]||"",Al=-1{for(const A of j)if(A.type==="childList")for(const Y of A.addedNodes)Y.tagName==="LINK"&&Y.rel==="modulepreload"&&r(Y)}).observe(document,{childList:!0,subtree:!0});function N(j){const A={};return j.integrity&&(A.integrity=j.integrity),j.referrerPolicy&&(A.referrerPolicy=j.referrerPolicy),j.crossOrigin==="use-credentials"?A.credentials="include":j.crossOrigin==="anonymous"?A.credentials="omit":A.credentials="same-origin",A}function r(j){if(j.ep)return;j.ep=!0;const A=N(j);fetch(j.href,A)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Us={exports:{}},Pn={};var Vd;function z0(){if(Vd)return Pn;Vd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function N(r,j,A){var Y=null;if(A!==void 0&&(Y=""+A),j.key!==void 0&&(Y=""+j.key),"key"in j){A={};for(var G in j)G!=="key"&&(A[G]=j[G])}else A=j;return j=A.ref,{$$typeof:f,type:r,key:Y,ref:j!==void 0?j:null,props:A}}return Pn.Fragment=b,Pn.jsx=N,Pn.jsxs=N,Pn}var Zd;function T0(){return Zd||(Zd=1,Us.exports=z0()),Us.exports}var c=T0(),ws={exports:{}},ae={};var Kd;function M0(){if(Kd)return ae;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),j=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),G=Symbol.for("react.forward_ref"),R=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),U=Symbol.for("react.activity"),V=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=V&&d[V]||d["@@iterator"],typeof d=="function"?d:null)}var k={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F=Object.assign,re={};function I(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||k}I.prototype.isReactComponent={},I.prototype.setState=function(d,z){if(typeof d!="object"&&typeof d!="function"&&d!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,d,z,"setState")},I.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function ne(){}ne.prototype=I.prototype;function ce(d,z,B){this.props=d,this.context=z,this.refs=re,this.updater=B||k}var Ge=ce.prototype=new ne;Ge.constructor=ce,F(Ge,I.prototype),Ge.isPureReactComponent=!0;var Ze=Array.isArray;function Xe(){}var $={H:null,A:null,T:null,S:null},je=Object.prototype.hasOwnProperty;function ot(d,z,B){var H=B.ref;return{$$typeof:f,type:d,key:z,ref:H!==void 0?H:null,props:B}}function qe(d,z){return ot(d.type,z,d.props)}function Me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ke(d){var z={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return z[B]})}var $e=/\/+/g;function tt(d,z){return typeof d=="object"&&d!==null&&d.key!=null?Ke(""+d.key):z.toString(36)}function Je(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Xe,Xe):(d.status="pending",d.then(function(z){d.status==="pending"&&(d.status="fulfilled",d.value=z)},function(z){d.status==="pending"&&(d.status="rejected",d.reason=z)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,z,B,H,P){var te=typeof d;(te==="undefined"||te==="boolean")&&(d=null);var le=!1;if(d===null)le=!0;else switch(te){case"bigint":case"string":case"number":le=!0;break;case"object":switch(d.$$typeof){case f:case b:le=!0;break;case D:return le=d._init,x(le(d._payload),z,B,H,P)}}if(le)return P=P(d),le=H===""?"."+tt(d,0):H,Ze(P)?(B="",le!=null&&(B=le.replace($e,"$&/")+"/"),x(P,z,B,"",function(ct){return ct})):P!=null&&(Me(P)&&(P=qe(P,B+(P.key==null||d&&d.key===P.key?"":(""+P.key).replace($e,"$&/")+"/")+le)),z.push(P)),1;le=0;var Ue=H===""?".":H+":";if(Ze(d))for(var ze=0;ze>>1,de=x[se];if(0>>1;sej(B,K))Hj(P,B)?(x[se]=P,x[H]=K,se=H):(x[se]=B,x[z]=K,se=z);else if(Hj(P,K))x[se]=P,x[H]=K,se=H;else break e}}return O}function j(x,O){var K=x.sortIndex-O.sortIndex;return K!==0?K:x.id-O.id}if(f.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var A=performance;f.unstable_now=function(){return A.now()}}else{var Y=Date,G=Y.now();f.unstable_now=function(){return Y.now()-G}}var R=[],y=[],D=1,U=null,V=3,ee=!1,k=!1,F=!1,re=!1,I=typeof setTimeout=="function"?setTimeout:null,ne=typeof clearTimeout=="function"?clearTimeout:null,ce=typeof setImmediate<"u"?setImmediate:null;function Ge(x){for(var O=N(y);O!==null;){if(O.callback===null)r(y);else if(O.startTime<=x)r(y),O.sortIndex=O.expirationTime,b(R,O);else break;O=N(y)}}function Ze(x){if(F=!1,Ge(x),!k)if(N(R)!==null)k=!0,Xe||(Xe=!0,Ke());else{var O=N(y);O!==null&&Je(Ze,O.startTime-x)}}var Xe=!1,$=-1,je=5,ot=-1;function qe(){return re?!0:!(f.unstable_now()-otx&&qe());){var se=U.callback;if(typeof se=="function"){U.callback=null,V=U.priorityLevel;var de=se(U.expirationTime<=x);if(x=f.unstable_now(),typeof de=="function"){U.callback=de,Ge(x),O=!0;break t}U===N(R)&&r(R),Ge(x)}else r(R);U=N(R)}if(U!==null)O=!0;else{var d=N(y);d!==null&&Je(Ze,d.startTime-x),O=!1}}break e}finally{U=null,V=K,ee=!1}O=void 0}}finally{O?Ke():Xe=!1}}}var Ke;if(typeof ce=="function")Ke=function(){ce(Me)};else if(typeof MessageChannel<"u"){var $e=new MessageChannel,tt=$e.port2;$e.port1.onmessage=Me,Ke=function(){tt.postMessage(null)}}else Ke=function(){I(Me,0)};function Je(x,O){$=I(function(){x(f.unstable_now())},O)}f.unstable_IdlePriority=5,f.unstable_ImmediatePriority=1,f.unstable_LowPriority=4,f.unstable_NormalPriority=3,f.unstable_Profiling=null,f.unstable_UserBlockingPriority=2,f.unstable_cancelCallback=function(x){x.callback=null},f.unstable_forceFrameRate=function(x){0>x||125se?(x.sortIndex=K,b(y,x),N(R)===null&&x===N(y)&&(F?(ne($),$=-1):F=!0,Je(Ze,K-se))):(x.sortIndex=de,b(R,x),k||ee||(k=!0,Xe||(Xe=!0,Ke()))),x},f.unstable_shouldYield=qe,f.unstable_wrapCallback=function(x){var O=V;return function(){var K=V;V=O;try{return x.apply(this,arguments)}finally{V=K}}}})(Hs)),Hs}var Wd;function A0(){return Wd||(Wd=1,Rs.exports=N0()),Rs.exports}var Gs={exports:{}},jt={};var Fd;function D0(){if(Fd)return jt;Fd=1;var f=Qs();function b(R){var y="https://react.dev/errors/"+R;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(b){console.error(b)}}return f(),Gs.exports=D0(),Gs.exports}var Pd;function O0(){if(Pd)return ei;Pd=1;var f=A0(),b=Qs(),N=C0();function r(e){var t="https://react.dev/errors/"+e;if(1de||(e.current=se[de],se[de]=null,de--)}function B(e,t){de++,se[de]=e.current,e.current=t}var H=d(null),P=d(null),te=d(null),le=d(null);function Ue(e,t){switch(B(te,t),B(P,e),B(H,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?hd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=hd(t),e=yd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}z(H),B(H,e)}function ze(){z(H),z(P),z(te)}function ct(e){e.memoizedState!==null&&B(le,e);var t=H.current,l=yd(t,e.type);t!==l&&(B(P,e),B(H,l))}function yt(e){P.current===e&&(z(H),z(P)),le.current===e&&(z(le),$n._currentValue=K)}var wt,Al;function rt(e){if(wt===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);wt=t&&t[1]||"",Al=-1)":-1n||o[a]!==g[n]){var _=` `+o[a].replace(" at new "," at ");return e.displayName&&_.includes("")&&(_=_.replace("",e.displayName)),_}while(1<=a&&0<=n);break}}}finally{al=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?rt(l):""}function T(e,t){switch(e.tag){case 26:case 27:case 5:return rt(e.type);case 16:return rt("Lazy");case 13:return e.child!==t&&t!==null?rt("Suspense Fallback"):rt("Suspense");case 19:return rt("SuspenseList");case 0:case 15:return sl(e.type,!1);case 11:return sl(e.type.render,!1);case 1:return sl(e.type,!0);case 31:return rt("Activity");default:return""}}function C(e){try{var t="",l=null;do t+=T(e,l),l=e,e=e.return;while(e);return t}catch(a){return` Error generating stack: `+a.message+` -`+a.stack}}var q=Object.prototype.hasOwnProperty,Q=f.unstable_scheduleCallback,He=f.unstable_cancelCallback,zt=f.unstable_shouldYield,st=f.unstable_requestPaint,ge=f.unstable_now,sn=f.unstable_getCurrentPriorityLevel,ni=f.unstable_ImmediatePriority,ii=f.unstable_UserBlockingPriority,L=f.unstable_NormalPriority,ve=f.unstable_LowPriority,we=f.unstable_IdlePriority,pt=f.log,Tt=f.unstable_setDisableYieldValue,Bt=null,dt=null;function Rt(e){if(typeof pt=="function"&&Tt(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Bt,e)}catch{}}var Ee=Math.clz32?Math.clz32:Qe,Te=Math.log,xe=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Te(e)/xe|0)|0}var ye=256,lt=262144,Be=4194304;function We(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function _t(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,i=e.suspendedLanes,u=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~i,a!==0?n=We(a):(u&=s,u!==0?n=We(u):l||(l=s&~e,l!==0&&(n=We(l))))):(s=a&~i,s!==0?n=We(s):u!==0?n=We(u):l||(l=a&~e,l!==0&&(n=We(l)))),n===0?0:t!==0&&t!==n&&(t&i)===0&&(i=n&-n,l=t&-t,i>=l||i===32&&(l&4194048)!==0)?t:n}function fl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Su(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ks(){var e=Be;return Be<<=1,(Be&62914560)===0&&(Be=4194304),e}function xu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function fn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function dm(e,t,l,a,n,i){var u=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,o=e.expirationTimes,g=e.hiddenUpdates;for(l=u&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var vm=/[\n"\\]/g;function Vt(e){return e.replace(vm,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eu(e,t,l,a,n,i,u,s){e.name="",u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"?e.type=u:e.removeAttribute("type"),t!=null?u==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Qt(t)):e.value!==""+Qt(t)&&(e.value=""+Qt(t)):u!=="submit"&&u!=="reset"||e.removeAttribute("value"),t!=null?Nu(e,u,Qt(t)):l!=null?Nu(e,u,Qt(l)):a!=null&&e.removeAttribute("value"),n==null&&i!=null&&(e.defaultChecked=!!i),n!=null&&(e.checked=n&&typeof n!="function"&&typeof n!="symbol"),s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.name=""+Qt(s):e.removeAttribute("name")}function cf(e,t,l,a,n,i,u,s){if(i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(e.type=i),t!=null||l!=null){if(!(i!=="submit"&&i!=="reset"||t!=null)){Mu(e);return}l=l!=null?""+Qt(l):"",t=t!=null?""+Qt(t):l,s||t===e.value||(e.value=t),e.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=s?e.checked:!!a,e.defaultChecked=!!a,u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.name=u),Mu(e)}function Nu(e,t,l){t==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Ea(e,t,l,a){if(e=e.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Uu=!1;if(dl)try{var mn={};Object.defineProperty(mn,"passive",{get:function(){Uu=!0}}),window.addEventListener("test",mn,mn),window.removeEventListener("test",mn,mn)}catch{Uu=!1}var Cl=null,wu=null,oi=null;function hf(){if(oi)return oi;var e,t=wu,l=t.length,a,n="value"in Cl?Cl.value:Cl.textContent,i=n.length;for(e=0;e=pn),Sf=" ",xf=!1;function _f(e,t){switch(e){case"keyup":return Zm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ca=!1;function Jm(e,t){switch(e){case"compositionend":return jf(t);case"keypress":return t.which!==32?null:(xf=!0,Sf);case"textInput":return e=t.data,e===Sf&&xf?null:e;default:return null}}function $m(e,t){if(Ca)return e==="compositionend"||!qu&&_f(e,t)?(e=hf(),oi=wu=Cl=null,Ca=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:l,offset:t-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Cf(l)}}function Uf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Uf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wf(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=si(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=si(e.document)}return t}function Xu(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var ah=dl&&"documentMode"in document&&11>=document.documentMode,Oa=null,ku=null,Sn=null,Qu=!1;function Bf(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Qu||Oa==null||Oa!==si(a)||(a=Oa,"selectionStart"in a&&Xu(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Sn&&bn(Sn,a)||(Sn=a,a=au(ku,"onSelect"),0>=u,n-=u,nl=1<<32-Ee(t)+n|l<ue?(he=Z,Z=null):he=Z.sibling;var Se=v(h,Z,p[ue],M);if(Se===null){Z===null&&(Z=he);break}e&&Z&&Se.alternate===null&&t(h,Z),m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se,Z=he}if(ue===p.length)return l(h,Z),pe&&hl(h,ue),J;if(Z===null){for(;ueue?(he=Z,Z=null):he=Z.sibling;var Pl=v(h,Z,Se.value,M);if(Pl===null){Z===null&&(Z=he);break}e&&Z&&Pl.alternate===null&&t(h,Z),m=i(Pl,m,ue),be===null?J=Pl:be.sibling=Pl,be=Pl,Z=he}if(Se.done)return l(h,Z),pe&&hl(h,ue),J;if(Z===null){for(;!Se.done;ue++,Se=p.next())Se=E(h,Se.value,M),Se!==null&&(m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se);return pe&&hl(h,ue),J}for(Z=a(Z);!Se.done;ue++,Se=p.next())Se=S(Z,h,ue,Se.value,M),Se!==null&&(e&&Se.alternate!==null&&Z.delete(Se.key===null?ue:Se.key),m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se);return e&&Z.forEach(function(j0){return t(h,j0)}),pe&&hl(h,ue),J}function Oe(h,m,p,M){if(typeof p=="object"&&p!==null&&p.type===F&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case ee:e:{for(var J=p.key;m!==null;){if(m.key===J){if(J=p.type,J===F){if(m.tag===7){l(h,m.sibling),M=n(m,p.props.children),M.return=h,h=M;break e}}else if(m.elementType===J||typeof J=="object"&&J!==null&&J.$$typeof===je&&da(J)===m.type){l(h,m.sibling),M=n(m,p.props),Mn(M,p),M.return=h,h=M;break e}l(h,m);break}else t(h,m);m=m.sibling}p.type===F?(M=ca(p.props.children,h.mode,M,p.key),M.return=h,h=M):(M=Si(p.type,p.key,p.props,null,h.mode,M),Mn(M,p),M.return=h,h=M)}return u(h);case X:e:{for(J=p.key;m!==null;){if(m.key===J)if(m.tag===4&&m.stateNode.containerInfo===p.containerInfo&&m.stateNode.implementation===p.implementation){l(h,m.sibling),M=n(m,p.children||[]),M.return=h,h=M;break e}else{l(h,m);break}else t(h,m);m=m.sibling}M=Fu(p,h.mode,M),M.return=h,h=M}return u(h);case je:return p=da(p),Oe(h,m,p,M)}if(Je(p))return k(h,m,p,M);if(Ke(p)){if(J=Ke(p),typeof J!="function")throw Error(r(150));return p=J.call(p),W(h,m,p,M)}if(typeof p.then=="function")return Oe(h,m,Ei(p),M);if(p.$$typeof===ce)return Oe(h,m,ji(h,p),M);Ni(h,p)}return typeof p=="string"&&p!==""||typeof p=="number"||typeof p=="bigint"?(p=""+p,m!==null&&m.tag===6?(l(h,m.sibling),M=n(m,p),M.return=h,h=M):(l(h,m),M=Wu(p,h.mode,M),M.return=h,h=M),u(h)):l(h,m)}return function(h,m,p,M){try{Tn=0;var J=Oe(h,m,p,M);return ka=null,J}catch(Z){if(Z===Xa||Z===Ti)throw Z;var be=Gt(29,Z,null,h.mode);return be.lanes=M,be.return=h,be}}}var ha=no(!0),io=no(!1),Rl=!1;function fc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Hl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Gl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(_e&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=bi(e),Xf(e,null,l),t}return vi(e,a,t,l),bi(e)}function En(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,$s(e,l)}}function rc(e,t){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,i=null;if(l=l.firstBaseUpdate,l!==null){do{var u={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};i===null?n=i=u:i=i.next=u,l=l.next}while(l!==null);i===null?n=i=t:i=i.next=t}else n=i=t;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:i,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var dc=!1;function Nn(){if(dc){var e=Ya;if(e!==null)throw e}}function An(e,t,l,a){dc=!1;var n=e.updateQueue;Rl=!1;var i=n.firstBaseUpdate,u=n.lastBaseUpdate,s=n.shared.pending;if(s!==null){n.shared.pending=null;var o=s,g=o.next;o.next=null,u===null?i=g:u.next=g,u=o;var _=e.alternate;_!==null&&(_=_.updateQueue,s=_.lastBaseUpdate,s!==u&&(s===null?_.firstBaseUpdate=g:s.next=g,_.lastBaseUpdate=o))}if(i!==null){var E=n.baseState;u=0,_=g=o=null,s=i;do{var v=s.lane&-536870913,S=v!==s.lane;if(S?(me&v)===v:(a&v)===v){v!==0&&v===La&&(dc=!0),_!==null&&(_=_.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var k=e,W=s;v=t;var Oe=l;switch(W.tag){case 1:if(k=W.payload,typeof k=="function"){E=k.call(Oe,E,v);break e}E=k;break e;case 3:k.flags=k.flags&-65537|128;case 0:if(k=W.payload,v=typeof k=="function"?k.call(Oe,E,v):k,v==null)break e;E=U({},E,v);break e;case 2:Rl=!0}}v=s.callback,v!==null&&(e.flags|=64,S&&(e.flags|=8192),S=n.callbacks,S===null?n.callbacks=[v]:S.push(v))}else S={lane:v,tag:s.tag,payload:s.payload,callback:s.callback,next:null},_===null?(g=_=S,o=E):_=_.next=S,u|=v;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;S=s,s=S.next,S.next=null,n.lastBaseUpdate=S,n.shared.pending=null}}while(!0);_===null&&(o=E),n.baseState=o,n.firstBaseUpdate=g,n.lastBaseUpdate=_,i===null&&(n.shared.lanes=0),kl|=u,e.lanes=u,e.memoizedState=E}}function uo(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function co(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;ei?i:8;var u=x.T,s={};x.T=s,Cc(e,!1,t,l);try{var o=n(),g=x.S;if(g!==null&&g(s,o),o!==null&&typeof o=="object"&&typeof o.then=="function"){var _=dh(o,a);On(e,t,_,kt(e))}else On(e,t,a,kt(e))}catch(E){On(e,t,{then:function(){},status:"rejected",reason:E},kt())}finally{O.p=i,u!==null&&s.types!==null&&(u.types=s.types),x.T=u}}function vh(){}function Ac(e,t,l,a){if(e.tag!==5)throw Error(r(476));var n=Lo(e).queue;qo(e,n,t,K,l===null?vh:function(){return Yo(e),l(a)})}function Lo(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:K},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Yo(e){var t=Lo(e);t.next===null&&(t=e.alternate.memoizedState),On(e,t.next.queue,{},kt())}function Dc(){return bt($n)}function Xo(){return et().memoizedState}function ko(){return et().memoizedState}function bh(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=kt();e=Hl(l);var a=Gl(t,e,l);a!==null&&(Ut(a,t,l),En(a,t,l)),t={cache:ic()},e.payload=t;return}t=t.return}}function Sh(e,t,l){var a=kt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Gi(e)?Vo(t,l):(l=Ju(e,t,l,a),l!==null&&(Ut(l,e,a),Zo(l,t,a)))}function Qo(e,t,l){var a=kt();On(e,t,l,a)}function On(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Gi(e))Vo(t,n);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var u=t.lastRenderedState,s=i(u,l);if(n.hasEagerState=!0,n.eagerState=s,Ht(s,u))return vi(e,t,n,0),Re===null&&gi(),!1}catch{}if(l=Ju(e,t,n,a),l!==null)return Ut(l,e,a),Zo(l,t,a),!0}return!1}function Cc(e,t,l,a){if(a={lane:2,revertLane:fs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Gi(e)){if(t)throw Error(r(479))}else t=Ju(e,l,a,2),t!==null&&Ut(t,e,2)}function Gi(e){var t=e.alternate;return e===ie||t!==null&&t===ie}function Vo(e,t){Va=Ci=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Zo(e,t,l){if((l&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,$s(e,l)}}var Un={readContext:bt,use:wi,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useLayoutEffect:Fe,useInsertionEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useSyncExternalStore:Fe,useId:Fe,useHostTransitionStatus:Fe,useFormState:Fe,useActionState:Fe,useOptimistic:Fe,useMemoCache:Fe,useCacheRefresh:Fe};Un.useEffectEvent=Fe;var Ko={readContext:bt,use:wi,useCallback:function(e,t){return Mt().memoizedState=[e,t===void 0?null:t],e},useContext:bt,useEffect:Do,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Ri(4194308,4,wo.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Ri(4194308,4,e,t)},useInsertionEffect:function(e,t){Ri(4,2,e,t)},useMemo:function(e,t){var l=Mt();t=t===void 0?null:t;var a=e();if(ya){Rt(!0);try{e()}finally{Rt(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=Mt();if(l!==void 0){var n=l(t);if(ya){Rt(!0);try{l(t)}finally{Rt(!1)}}}else n=t;return a.memoizedState=a.baseState=n,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=Sh.bind(null,ie,e),[a.memoizedState,e]},useRef:function(e){var t=Mt();return e={current:e},t.memoizedState=e},useState:function(e){e=zc(e);var t=e.queue,l=Qo.bind(null,ie,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Ec,useDeferredValue:function(e,t){var l=Mt();return Nc(l,e,t)},useTransition:function(){var e=zc(!1);return e=qo.bind(null,ie,e.queue,!0,!1),Mt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=ie,n=Mt();if(pe){if(l===void 0)throw Error(r(407));l=l()}else{if(l=t(),Re===null)throw Error(r(349));(me&127)!==0||ho(a,t,l)}n.memoizedState=l;var i={value:l,getSnapshot:t};return n.queue=i,Do(po.bind(null,a,i,e),[e]),a.flags|=2048,Ka(9,{destroy:void 0},yo.bind(null,a,i,l,t),null),l},useId:function(){var e=Mt(),t=Re.identifierPrefix;if(pe){var l=il,a=nl;l=(a&~(1<<32-Ee(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Oi++,0<\/script>",i=i.removeChild(i.firstChild);break;case"select":i=typeof a.is=="string"?u.createElement("select",{is:a.is}):u.createElement("select"),a.multiple?i.multiple=!0:a.size&&(i.size=a.size);break;default:i=typeof a.is=="string"?u.createElement(n,{is:a.is}):u.createElement(n)}}i[gt]=t,i[Et]=a;e:for(u=t.child;u!==null;){if(u.tag===5||u.tag===6)i.appendChild(u.stateNode);else if(u.tag!==4&&u.tag!==27&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===t)break e;for(;u.sibling===null;){if(u.return===null||u.return===t)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}t.stateNode=i;e:switch(xt(i,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Sl(t)}}return Ye(t),Vc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Sl(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=te.current,Ga(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=vt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[gt]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||dd(e.nodeValue,l)),e||wl(t,!0)}else e=nu(e).createTextNode(a),e[gt]=t,t.stateNode=e}return Ye(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=Ga(t),l!==null){if(e===null){if(!a)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[gt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),e=!1}else l=tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(Lt(t),t):(Lt(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Ye(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=Ga(t),a!==null&&a.dehydrated!==null){if(e===null){if(!n)throw Error(r(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));n[gt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),n=!1}else n=tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(Lt(t),t):(Lt(t),null)}return Lt(t),(t.flags&128)!==0?(t.lanes=l,t):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),i=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(i=a.memoizedState.cachePool.pool),i!==n&&(a.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),ki(t,t.updateQueue),Ye(t),null);case 4:return ze(),e===null&&ms(t.stateNode.containerInfo),Ye(t),null;case 10:return pl(t.type),Ye(t),null;case 19:if(z(Pe),a=t.memoizedState,a===null)return Ye(t),null;if(n=(t.flags&128)!==0,i=a.rendering,i===null)if(n)Bn(a,!1);else{if(Ie!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=Di(e),i!==null){for(t.flags|=128,Bn(a,!1),e=i.updateQueue,t.updateQueue=e,ki(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)kf(l,e),l=l.sibling;return B(Pe,Pe.current&1|2),pe&&hl(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&ge()>Ji&&(t.flags|=128,n=!0,Bn(a,!1),t.lanes=4194304)}else{if(!n)if(e=Di(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,ki(t,e),Bn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!pe)return Ye(t),null}else 2*ge()-a.renderingStartTime>Ji&&l!==536870912&&(t.flags|=128,n=!0,Bn(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(e=a.last,e!==null?e.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=ge(),e.sibling=null,l=Pe.current,B(Pe,n?l&1|2:l&1),pe&&hl(t,a.treeForkCount),e):(Ye(t),null);case 22:case 23:return Lt(t),hc(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(l&536870912)!==0&&(t.flags&128)===0&&(Ye(t),t.subtreeFlags&6&&(t.flags|=8192)):Ye(t),l=t.updateQueue,l!==null&&ki(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==l&&(t.flags|=2048),e!==null&&z(ra),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),pl(at),Ye(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Th(e,t){switch(Pu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pl(at),ze(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return yt(t),null;case 31:if(t.memoizedState!==null){if(Lt(t),t.alternate===null)throw Error(r(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Lt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return z(Pe),null;case 4:return ze(),null;case 10:return pl(t.type),null;case 22:case 23:return Lt(t),hc(),e!==null&&z(ra),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return pl(at),null;case 25:return null;default:return null}}function gr(e,t){switch(Pu(t),t.tag){case 3:pl(at),ze();break;case 26:case 27:case 5:yt(t);break;case 4:ze();break;case 31:t.memoizedState!==null&&Lt(t);break;case 13:Lt(t);break;case 19:z(Pe);break;case 10:pl(t.type);break;case 22:case 23:Lt(t),hc(),e!==null&&z(ra);break;case 24:pl(at)}}function Rn(e,t){try{var l=t.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&e)===e){a=void 0;var i=l.create,u=l.inst;a=i(),u.destroy=a}l=l.next}while(l!==n)}}catch(s){Ae(t,t.return,s)}}function Yl(e,t,l){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var i=n.next;a=i;do{if((a.tag&e)===e){var u=a.inst,s=u.destroy;if(s!==void 0){u.destroy=void 0,n=t;var o=l,g=s;try{g()}catch(_){Ae(n,o,_)}}}a=a.next}while(a!==i)}}catch(_){Ae(t,t.return,_)}}function vr(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{co(t,l)}catch(a){Ae(e,e.return,a)}}}function br(e,t,l){l.props=pa(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){Ae(e,t,a)}}function Hn(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(n){Ae(e,t,n)}}function ul(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){Ae(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){Ae(e,t,n)}else l.current=null}function Sr(e){var t=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){Ae(e,e.return,n)}}function Zc(e,t,l){try{var a=e.stateNode;Kh(a,e.type,l,t),a[Et]=t}catch(n){Ae(e,e.return,n)}}function xr(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Jl(e.type)||e.tag===4}function Kc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Jl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=rl));else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,l),e=e.sibling;e!==null;)Jc(e,t,l),e=e.sibling}function Qi(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Qi(e,t,l),e=e.sibling;e!==null;)Qi(e,t,l),e=e.sibling}function _r(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);xt(t,a,l),t[gt]=e,t[Et]=l}catch(i){Ae(e,e.return,i)}}var xl=!1,ut=!1,$c=!1,jr=typeof WeakSet=="function"?WeakSet:Set,ht=null;function Mh(e,t){if(e=e.containerInfo,ps=ru,e=wf(e),Xu(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var u=0,s=-1,o=-1,g=0,_=0,E=e,v=null;t:for(;;){for(var S;E!==l||n!==0&&E.nodeType!==3||(s=u+n),E!==i||a!==0&&E.nodeType!==3||(o=u+a),E.nodeType===3&&(u+=E.nodeValue.length),(S=E.firstChild)!==null;)v=E,E=S;for(;;){if(E===e)break t;if(v===l&&++g===n&&(s=u),v===i&&++_===a&&(o=u),(S=E.nextSibling)!==null)break;E=v,v=E.parentNode}E=S}l=s===-1||o===-1?null:{start:s,end:o}}else l=null}l=l||{start:0,end:0}}else l=null;for(gs={focusedElem:e,selectionRange:l},ru=!1,ht=t;ht!==null;)if(t=ht,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ht=e;else for(;ht!==null;){switch(t=ht,i=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),xt(i,a,l),i[gt]=e,mt(i),a=i;break e;case"link":var u=Ad("link","href",n).get(a+(l.href||""));if(u){for(var s=0;sOe&&(u=Oe,Oe=W,W=u);var h=Of(s,W),m=Of(s,Oe);if(h&&m&&(S.rangeCount!==1||S.anchorNode!==h.node||S.anchorOffset!==h.offset||S.focusNode!==m.node||S.focusOffset!==m.offset)){var p=E.createRange();p.setStart(h.node,h.offset),S.removeAllRanges(),W>Oe?(S.addRange(p),S.extend(m.node,m.offset)):(p.setEnd(m.node,m.offset),S.addRange(p))}}}}for(E=[],S=s;S=S.parentNode;)S.nodeType===1&&E.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;sl?32:l,x.T=null,l=ls,ls=null;var i=Vl,u=Ml;if(ft=0,Ia=Vl=null,Ml=0,(_e&6)!==0)throw Error(r(331));var s=_e;if(_e|=4,wr(i.current),Cr(i,i.current,u,l),_e=s,kn(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(Bt,i)}catch{}return!0}finally{O.p=n,x.T=a,Ir(e,t)}}function ed(e,t,l){t=Kt(l,t),t=Bc(e.stateNode,t,2),e=Gl(e,t,2),e!==null&&(fn(e,2),cl(e))}function Ae(e,t,l){if(e.tag===3)ed(e,e,l);else for(;t!==null;){if(t.tag===3){ed(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Ql===null||!Ql.has(a))){e=Kt(l,e),l=tr(2),a=Gl(t,l,2),a!==null&&(lr(l,a,t,e),fn(a,2),cl(a));break}}t=t.return}}function us(e,t,l){var a=e.pingCache;if(a===null){a=e.pingCache=new Ah;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(l)||(Ic=!0,n.add(l),e=wh.bind(null,e,t,l),t.then(e,e))}function wh(e,t,l){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,Re===e&&(me&l)===l&&(Ie===4||Ie===3&&(me&62914560)===me&&300>ge()-Ki?(_e&2)===0&&Pa(e,0):Pc|=l,Fa===me&&(Fa=0)),cl(e)}function td(e,t){t===0&&(t=Ks()),e=ua(e,t),e!==null&&(fn(e,t),cl(e))}function Bh(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),td(e,l)}function Rh(e,t){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,n=e.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}a!==null&&a.delete(t),td(e,l)}function Hh(e,t){return Q(e,t)}var eu=null,tn=null,cs=!1,tu=!1,ss=!1,Kl=0;function cl(e){e!==tn&&e.next===null&&(tn===null?eu=tn=e:tn=tn.next=e),tu=!0,cs||(cs=!0,qh())}function kn(e,t){if(!ss&&tu){ss=!0;do for(var l=!1,a=eu;a!==null;){if(e!==0){var n=a.pendingLanes;if(n===0)var i=0;else{var u=a.suspendedLanes,s=a.pingedLanes;i=(1<<31-Ee(42|e)+1)-1,i&=n&~(u&~s),i=i&201326741?i&201326741|1:i?i|2:0}i!==0&&(l=!0,id(a,i))}else i=me,i=_t(a,a===Re?i:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(i&3)===0||fl(a,i)||(l=!0,id(a,i));a=a.next}while(l);ss=!1}}function Gh(){ld()}function ld(){tu=cs=!1;var e=0;Kl!==0&&$h()&&(e=Kl);for(var t=ge(),l=null,a=eu;a!==null;){var n=a.next,i=ad(a,t);i===0?(a.next=null,l===null?eu=n:l.next=n,n===null&&(tn=l)):(l=a,(e!==0||(i&3)!==0)&&(tu=!0)),a=n}ft!==0&&ft!==5||kn(e),Kl!==0&&(Kl=0)}function ad(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,i=e.pendingLanes&-62914561;0s)break;var _=o.transferSize,E=o.initiatorType;_&&md(E)&&(o=o.responseEnd,u+=_*(o"u"?null:document;function Td(e,t,l){var a=ln;if(a&&typeof t=="string"&&t){var n=Vt(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),zd.has(n)||(zd.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),xt(t,"link",e),mt(t),a.head.appendChild(t)))}}function n0(e){El.D(e),Td("dns-prefetch",e,null)}function i0(e,t){El.C(e,t),Td("preconnect",e,t)}function u0(e,t,l){El.L(e,t,l);var a=ln;if(a&&e&&t){var n='link[rel="preload"][as="'+Vt(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Vt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Vt(l.imageSizes)+'"]')):n+='[href="'+Vt(e)+'"]';var i=n;switch(t){case"style":i=an(e);break;case"script":i=nn(e)}Pt.has(i)||(e=U({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Pt.set(i,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(Kn(i))||t==="script"&&a.querySelector(Jn(i))||(t=a.createElement("link"),xt(t,"link",e),mt(t),a.head.appendChild(t)))}}function c0(e,t){El.m(e,t);var l=ln;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+Vt(a)+'"][href="'+Vt(e)+'"]',i=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=nn(e)}if(!Pt.has(i)&&(e=U({rel:"modulepreload",href:e},t),Pt.set(i,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Jn(i)))return}a=l.createElement("link"),xt(a,"link",e),mt(a),l.head.appendChild(a)}}}function s0(e,t,l){El.S(e,t,l);var a=ln;if(a&&e){var n=Ta(a).hoistableStyles,i=an(e);t=t||"default";var u=n.get(i);if(!u){var s={loading:0,preload:null};if(u=a.querySelector(Kn(i)))s.loading=5;else{e=U({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Pt.get(i))&&zs(e,l);var o=u=a.createElement("link");mt(o),xt(o,"link",e),o._p=new Promise(function(g,_){o.onload=g,o.onerror=_}),o.addEventListener("load",function(){s.loading|=1}),o.addEventListener("error",function(){s.loading|=2}),s.loading|=4,uu(u,t,a)}u={type:"stylesheet",instance:u,count:1,state:s},n.set(i,u)}}}function f0(e,t){El.X(e,t);var l=ln;if(l&&e){var a=Ta(l).hoistableScripts,n=nn(e),i=a.get(n);i||(i=l.querySelector(Jn(n)),i||(e=U({src:e,async:!0},t),(t=Pt.get(n))&&Ts(e,t),i=l.createElement("script"),mt(i),xt(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function o0(e,t){El.M(e,t);var l=ln;if(l&&e){var a=Ta(l).hoistableScripts,n=nn(e),i=a.get(n);i||(i=l.querySelector(Jn(n)),i||(e=U({src:e,async:!0,type:"module"},t),(t=Pt.get(n))&&Ts(e,t),i=l.createElement("script"),mt(i),xt(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function Md(e,t,l,a){var n=(n=te.current)?iu(n):null;if(!n)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=an(l.href),l=Ta(n).hoistableStyles,a=l.get(t),a||(a={type:"style",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=an(l.href);var i=Ta(n).hoistableStyles,u=i.get(e);if(u||(n=n.ownerDocument||n,u={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},i.set(e,u),(i=n.querySelector(Kn(e)))&&!i._p&&(u.instance=i,u.state.loading=5),Pt.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Pt.set(e,l),i||r0(n,e,l,u.state))),t&&a===null)throw Error(r(528,""));return u}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=nn(l),l=Ta(n).hoistableScripts,a=l.get(t),a||(a={type:"script",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function an(e){return'href="'+Vt(e)+'"'}function Kn(e){return'link[rel="stylesheet"]['+e+"]"}function Ed(e){return U({},e,{"data-precedence":e.precedence,precedence:null})}function r0(e,t,l,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),xt(t,"link",l),mt(t),e.head.appendChild(t))}function nn(e){return'[src="'+Vt(e)+'"]'}function Jn(e){return"script[async]"+e}function Nd(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Vt(l.href)+'"]');if(a)return t.instance=a,mt(a),a;var n=U({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),mt(a),xt(a,"style",n),uu(a,l.precedence,e),t.instance=a;case"stylesheet":n=an(l.href);var i=e.querySelector(Kn(n));if(i)return t.state.loading|=4,t.instance=i,mt(i),i;a=Ed(l),(n=Pt.get(n))&&zs(a,n),i=(e.ownerDocument||e).createElement("link"),mt(i);var u=i;return u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),xt(i,"link",a),t.state.loading|=4,uu(i,l.precedence,e),t.instance=i;case"script":return i=nn(l.src),(n=e.querySelector(Jn(i)))?(t.instance=n,mt(n),n):(a=l,(n=Pt.get(i))&&(a=U({},l),Ts(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),mt(n),xt(n,"link",a),e.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,uu(a,l.precedence,e));return t.instance}function uu(e,t,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,i=n,u=0;u title"):null)}function d0(e,t,l){if(l===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Cd(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function m0(e,t,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=an(a.href),i=t.querySelector(Kn(n));if(i){t=i._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=su.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=i,mt(i);return}i=t.ownerDocument||t,a=Ed(a),(n=Pt.get(n))&&zs(a,n),i=i.createElement("link"),mt(i);var u=i;u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),xt(i,"link",a),l.instance=i}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=su.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Ms=0;function h0(e,t){return e.stylesheets&&e.count===0&&ou(e,e.stylesheets),0Ms?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ou(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fu=null;function ou(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fu=new Map,t.forEach(y0,e),fu=null,su.call(e))}function y0(e,t){if(!(t.state.loading&4)){var l=fu.get(e);if(l)var a=l.get(null);else{l=new Map,fu.set(e,l);for(var n=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(b){console.error(b)}}return f(),Bs.exports=O0(),Bs.exports}var w0=U0();const B0=sm(w0);const fm=(...f)=>f.filter((b,N,r)=>!!b&&b.trim()!==""&&r.indexOf(b)===N).join(" ").trim();const R0=f=>f.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const H0=f=>f.replace(/^([A-Z])|[\s-_]+(\w)/g,(b,N,r)=>r?r.toUpperCase():N.toLowerCase());const tm=f=>{const b=H0(f);return b.charAt(0).toUpperCase()+b.slice(1)};var qs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const G0=f=>{for(const b in f)if(b.startsWith("aria-")||b==="role"||b==="title")return!0;return!1},q0=w.createContext({}),L0=()=>w.useContext(q0),Y0=w.forwardRef(({color:f,size:b,strokeWidth:N,absoluteStrokeWidth:r,className:j="",children:A,iconNode:Y,...G},R)=>{const{size:y=24,strokeWidth:D=2,absoluteStrokeWidth:U=!1,color:V="currentColor",className:ee=""}=L0()??{},X=r??U?Number(N??D)*24/Number(b??y):N??D;return w.createElement("svg",{ref:R,...qs,width:b??y??qs.width,height:b??y??qs.height,stroke:f??V,strokeWidth:X,className:fm("lucide",ee,j),...!A&&!G0(G)&&{"aria-hidden":"true"},...G},[...Y.map(([F,re])=>w.createElement(F,re)),...Array.isArray(A)?A:[A]])});const Xe=(f,b)=>{const N=w.forwardRef(({className:r,...j},A)=>w.createElement(Y0,{ref:A,iconNode:b,className:fm(`lucide-${R0(tm(f))}`,`lucide-${f}`,r),...j}));return N.displayName=tm(f),N};const X0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ls=Xe("check",X0);const k0=[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]],lm=Xe("cloud-download",k0);const Q0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],V0=Xe("copy",Q0);const Z0=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],om=Xe("cpu",Z0);const K0=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],J0=Xe("crop",K0);const $0=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ys=Xe("database",$0);const W0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],am=Xe("download",W0);const F0=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],I0=Xe("folder-down",F0);const P0=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],nm=Xe("folder-open",P0);const ey=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],bu=Xe("hard-drive",ey);const ty=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],ly=Xe("image-plus",ty);const ay=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ny=Xe("image",ay);const iy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],uy=Xe("info",iy);const cy=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],sy=Xe("layers",cy);const fy=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],oy=Xe("library",fy);const ry=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],dy=Xe("moon",ry);const my=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ta=Xe("refresh-cw",my);const hy=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],yy=Xe("shield",hy);const py=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],Vs=Xe("sliders-vertical",py);const gy=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],vu=Xe("sparkles",gy);const vy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Xs=Xe("square",vy);const by=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Sy=Xe("sun",by);const xy=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],_y=Xe("terminal",xy);const jy=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ti=Xe("trash-2",jy);const zy=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ty=Xe("triangle-alert",zy);function My({activeTab:f,setActiveTab:b,specs:N}){return c.jsxs("div",{className:"sidebar",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"sidebar-logo",children:[c.jsx(yy,{className:"sidebar-logo-icon"}),c.jsx("span",{className:"sidebar-logo-text",children:"Local AI Studio"})]}),c.jsxs("div",{className:"nav-list",children:[c.jsxs("div",{className:`nav-item ${f==="generator"?"active":""}`,onClick:()=>b("generator"),children:[c.jsx(ny,{size:20}),c.jsx("span",{children:"Image Generator"})]}),c.jsxs("div",{className:`nav-item ${f==="models"?"active":""}`,onClick:()=>b("models"),children:[c.jsx(I0,{size:20}),c.jsx("span",{children:"Model Manager"})]}),c.jsxs("div",{className:`nav-item ${f==="constraints"?"active":""}`,onClick:()=>b("constraints"),children:[c.jsx(Vs,{size:20}),c.jsx("span",{children:"Image Constraints"})]})]})]}),c.jsxs("div",{className:"sidebar-footer",children:[c.jsxs("div",{className:"sidebar-specs-header",children:[c.jsx(_y,{size:12}),c.jsx("span",{children:"Host Specifications"})]}),c.jsxs("div",{className:"sidebar-specs-item",title:N.cpu_name,children:["CPU: ",N.cpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",title:N.gpu_name,children:["GPU: ",N.gpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",children:["Memory: ",N.ram_total_gb.toFixed(0)," GB RAM (",N.cpu_cores_physical," Cores)"]}),c.jsxs("div",{className:"sidebar-specs-os",children:["OS: ",N.os_name]})]})]})}const Ey=w.memo(My);function Ny({telemetry:f,serverRunning:b,activeModel:N,onStopServer:r,isStoppingServer:j=!1,theme:A,setTheme:Y}){const G=D=>{const U=Number(D);return Number.isFinite(U)&&U>0?U.toFixed(U>=10?0:1):"--"},R=()=>b?"Server Active":"Local Mode",y=()=>b?"status-indicator busy":"status-indicator offline";return c.jsxs("div",{className:"top-status-bar",children:[c.jsxs("div",{className:"current-model-info",children:[c.jsx("div",{className:y()}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.95rem"},children:R()}),N&&c.jsxs(c.Fragment,{children:[c.jsx("span",{style:{color:"var(--md-sys-color-outline-variant)"},children:"|"}),c.jsx("span",{style:{color:"var(--md-sys-color-primary)",fontWeight:700},children:N})]})]}),c.jsxs("div",{className:"telemetry-group",children:[c.jsx("button",{className:"theme-toggle-btn",onClick:()=>Y(A==="dark"?"light":"dark"),title:`Switch to ${A==="dark"?"light":"dark"} theme`,children:A==="dark"?c.jsx(Sy,{size:18}):c.jsx(dy,{size:18})}),b&&c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:r,disabled:j,title:"Stop local model server",children:[j?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(Xs,{size:14}),c.jsx("span",{children:j?"Stopping":"Stop Server"})]}),c.jsxs("div",{className:"telemetry-chip",title:"CPU Utilization",children:[c.jsx(om,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-primary)"}}),c.jsxs("span",{children:["CPU: ",Number.isFinite(Number(f.cpu_usage))?f.cpu_usage:"--","%"]})]}),c.jsxs("div",{className:"telemetry-chip",title:"System Memory Usage",children:[c.jsx(bu,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-secondary)"}}),c.jsxs("span",{children:["RAM: ",G(f.ram_used_gb)," / ",G(f.ram_total_gb)," GB"]})]}),f.vram_total_gb>0&&c.jsxs("div",{className:"telemetry-chip",title:`${f.gpu_name} VRAM`,children:[c.jsx(Ys,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-tertiary)"}}),c.jsxs("span",{children:["VRAM: ",G(f.vram_used_gb)," / ",G(f.vram_total_gb)," GB"]})]})]})]})}const Ay=w.memo(Ny),Dy="modulepreload",Cy=function(f){return"/"+f},im={},Oy=function(b,N,r){let j=Promise.resolve();if(N&&N.length>0){let R=function(y){return Promise.all(y.map(D=>Promise.resolve(D).then(U=>({status:"fulfilled",value:U}),U=>({status:"rejected",reason:U}))))};document.getElementsByTagName("link");const Y=document.querySelector("meta[property=csp-nonce]"),G=Y?.nonce||Y?.getAttribute("nonce");j=R(N.map(y=>{if(y=Cy(y),y in im)return;im[y]=!0;const D=y.endsWith(".css"),U=D?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${U}`))return;const V=document.createElement("link");if(V.rel=D?"stylesheet":Dy,D||(V.as="script"),V.crossOrigin="",V.href=y,G&&V.setAttribute("nonce",G),document.head.appendChild(V),D)return new Promise((ee,X)=>{V.addEventListener("load",ee),V.addEventListener("error",()=>X(new Error(`Unable to preload CSS for ${y}`)))})}))}function A(Y){const G=new Event("vite:preloadError",{cancelable:!0});if(G.payload=Y,window.dispatchEvent(G),!G.defaultPrevented)throw Y}return j.then(Y=>{for(const G of Y||[])G.status==="rejected"&&A(G.reason);return b().catch(A)})};function o1(f,b=!1){return window.__TAURI_INTERNALS__.transformCallback(f,b)}async function xa(f,b={},N){return window.__TAURI_INTERNALS__.invoke(f,b,N)}const Nl=()=>typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0;let ea=null;const Uy="polish-setup-v1",Sa=()=>typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function li(f){const b=Number(f)||0;if(b<=0)return"0 B";const N=["B","KB","MB","GB","TB"],r=Math.min(N.length-1,Math.floor(Math.log(b)/Math.log(1024)));return`${(b/1024**r).toFixed(r===0?0:1)} ${N[r]}`}function ai(f){return typeof f=="string"?{filename:f,sizeBytes:0,size:"Unknown"}:{filename:f?.filename||f?.name||"",sizeBytes:Number(f?.sizeBytes||0),size:f?.size||(f?.sizeBytes?li(f.sizeBytes):"Unknown")}}async function cn(f,b="The local server returned an invalid response."){const N=await f.text();let r={};try{r=JSON.parse(N||"{}")}catch{const A=N.trim().startsWith("{const ee=y.steps;for(let $=1;$<=ee;$++){if(Y&&Y.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(je=>setTimeout(je,3e3/ee)),A&&A(Math.round($/ee*100))}const X=f.toLowerCase(),F=Math.abs(y.seed)||Math.floor(Math.random()*1e3);let re="#3B82F6",I="#8B5CF6",ne="",ce="Abstract Generation";X.includes("moon")||X.includes("space")||X.includes("astronomy")||X.includes("sky")?(re="#1E293B",I="#0F172A",ce="Luminous Moon in Starry Sky",ne=` +`+a.stack}}var q=Object.prototype.hasOwnProperty,Q=f.unstable_scheduleCallback,He=f.unstable_cancelCallback,zt=f.unstable_shouldYield,st=f.unstable_requestPaint,ge=f.unstable_now,sn=f.unstable_getCurrentPriorityLevel,ni=f.unstable_ImmediatePriority,ii=f.unstable_UserBlockingPriority,L=f.unstable_NormalPriority,ve=f.unstable_LowPriority,we=f.unstable_IdlePriority,pt=f.log,Tt=f.unstable_setDisableYieldValue,Bt=null,dt=null;function Rt(e){if(typeof pt=="function"&&Tt(e),dt&&typeof dt.setStrictMode=="function")try{dt.setStrictMode(Bt,e)}catch{}}var Ee=Math.clz32?Math.clz32:Qe,Te=Math.log,xe=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Te(e)/xe|0)|0}var ye=256,lt=262144,Be=4194304;function We(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function _t(e,t,l){var a=e.pendingLanes;if(a===0)return 0;var n=0,i=e.suspendedLanes,u=e.pingedLanes;e=e.warmLanes;var s=a&134217727;return s!==0?(a=s&~i,a!==0?n=We(a):(u&=s,u!==0?n=We(u):l||(l=s&~e,l!==0&&(n=We(l))))):(s=a&~i,s!==0?n=We(s):u!==0?n=We(u):l||(l=a&~e,l!==0&&(n=We(l)))),n===0?0:t!==0&&t!==n&&(t&i)===0&&(i=n&-n,l=t&-t,i>=l||i===32&&(l&4194048)!==0)?t:n}function fl(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Su(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ks(){var e=Be;return Be<<=1,(Be&62914560)===0&&(Be=4194304),e}function xu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function fn(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function dm(e,t,l,a,n,i){var u=e.pendingLanes;e.pendingLanes=l,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=l,e.entangledLanes&=l,e.errorRecoveryDisabledLanes&=l,e.shellSuspendCounter=0;var s=e.entanglements,o=e.expirationTimes,g=e.hiddenUpdates;for(l=u&~l;0"u")return null;try{return e.activeElement||e.body}catch{return e.body}}var vm=/[\n"\\]/g;function Vt(e){return e.replace(vm,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Eu(e,t,l,a,n,i,u,s){e.name="",u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"?e.type=u:e.removeAttribute("type"),t!=null?u==="number"?(t===0&&e.value===""||e.value!=t)&&(e.value=""+Qt(t)):e.value!==""+Qt(t)&&(e.value=""+Qt(t)):u!=="submit"&&u!=="reset"||e.removeAttribute("value"),t!=null?Nu(e,u,Qt(t)):l!=null?Nu(e,u,Qt(l)):a!=null&&e.removeAttribute("value"),n==null&&i!=null&&(e.defaultChecked=!!i),n!=null&&(e.checked=n&&typeof n!="function"&&typeof n!="symbol"),s!=null&&typeof s!="function"&&typeof s!="symbol"&&typeof s!="boolean"?e.name=""+Qt(s):e.removeAttribute("name")}function cf(e,t,l,a,n,i,u,s){if(i!=null&&typeof i!="function"&&typeof i!="symbol"&&typeof i!="boolean"&&(e.type=i),t!=null||l!=null){if(!(i!=="submit"&&i!=="reset"||t!=null)){Mu(e);return}l=l!=null?""+Qt(l):"",t=t!=null?""+Qt(t):l,s||t===e.value||(e.value=t),e.defaultValue=t}a=a??n,a=typeof a!="function"&&typeof a!="symbol"&&!!a,e.checked=s?e.checked:!!a,e.defaultChecked=!!a,u!=null&&typeof u!="function"&&typeof u!="symbol"&&typeof u!="boolean"&&(e.name=u),Mu(e)}function Nu(e,t,l){t==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Ea(e,t,l,a){if(e=e.options,t){t={};for(var n=0;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Uu=!1;if(dl)try{var mn={};Object.defineProperty(mn,"passive",{get:function(){Uu=!0}}),window.addEventListener("test",mn,mn),window.removeEventListener("test",mn,mn)}catch{Uu=!1}var Cl=null,wu=null,oi=null;function hf(){if(oi)return oi;var e,t=wu,l=t.length,a,n="value"in Cl?Cl.value:Cl.textContent,i=n.length;for(e=0;e=pn),Sf=" ",xf=!1;function _f(e,t){switch(e){case"keyup":return Zm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function jf(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Ca=!1;function Jm(e,t){switch(e){case"compositionend":return jf(t);case"keypress":return t.which!==32?null:(xf=!0,Sf);case"textInput":return e=t.data,e===Sf&&xf?null:e;default:return null}}function $m(e,t){if(Ca)return e==="compositionend"||!qu&&_f(e,t)?(e=hf(),oi=wu=Cl=null,Ca=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:l,offset:t-e};e=a}e:{for(;l;){if(l.nextSibling){l=l.nextSibling;break e}l=l.parentNode}l=void 0}l=Cf(l)}}function Uf(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Uf(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function wf(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=si(e.document);t instanceof e.HTMLIFrameElement;){try{var l=typeof t.contentWindow.location.href=="string"}catch{l=!1}if(l)e=t.contentWindow;else break;t=si(e.document)}return t}function ku(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}var ah=dl&&"documentMode"in document&&11>=document.documentMode,Oa=null,Xu=null,Sn=null,Qu=!1;function Bf(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Qu||Oa==null||Oa!==si(a)||(a=Oa,"selectionStart"in a&&ku(a)?a={start:a.selectionStart,end:a.selectionEnd}:(a=(a.ownerDocument&&a.ownerDocument.defaultView||window).getSelection(),a={anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),Sn&&bn(Sn,a)||(Sn=a,a=au(Xu,"onSelect"),0>=u,n-=u,nl=1<<32-Ee(t)+n|l<ue?(he=Z,Z=null):he=Z.sibling;var Se=v(h,Z,p[ue],M);if(Se===null){Z===null&&(Z=he);break}e&&Z&&Se.alternate===null&&t(h,Z),m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se,Z=he}if(ue===p.length)return l(h,Z),pe&&hl(h,ue),J;if(Z===null){for(;ueue?(he=Z,Z=null):he=Z.sibling;var Pl=v(h,Z,Se.value,M);if(Pl===null){Z===null&&(Z=he);break}e&&Z&&Pl.alternate===null&&t(h,Z),m=i(Pl,m,ue),be===null?J=Pl:be.sibling=Pl,be=Pl,Z=he}if(Se.done)return l(h,Z),pe&&hl(h,ue),J;if(Z===null){for(;!Se.done;ue++,Se=p.next())Se=E(h,Se.value,M),Se!==null&&(m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se);return pe&&hl(h,ue),J}for(Z=a(Z);!Se.done;ue++,Se=p.next())Se=S(Z,h,ue,Se.value,M),Se!==null&&(e&&Se.alternate!==null&&Z.delete(Se.key===null?ue:Se.key),m=i(Se,m,ue),be===null?J=Se:be.sibling=Se,be=Se);return e&&Z.forEach(function(j0){return t(h,j0)}),pe&&hl(h,ue),J}function Oe(h,m,p,M){if(typeof p=="object"&&p!==null&&p.type===F&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case ee:e:{for(var J=p.key;m!==null;){if(m.key===J){if(J=p.type,J===F){if(m.tag===7){l(h,m.sibling),M=n(m,p.props.children),M.return=h,h=M;break e}}else if(m.elementType===J||typeof J=="object"&&J!==null&&J.$$typeof===je&&da(J)===m.type){l(h,m.sibling),M=n(m,p.props),Mn(M,p),M.return=h,h=M;break e}l(h,m);break}else t(h,m);m=m.sibling}p.type===F?(M=ca(p.props.children,h.mode,M,p.key),M.return=h,h=M):(M=Si(p.type,p.key,p.props,null,h.mode,M),Mn(M,p),M.return=h,h=M)}return u(h);case k:e:{for(J=p.key;m!==null;){if(m.key===J)if(m.tag===4&&m.stateNode.containerInfo===p.containerInfo&&m.stateNode.implementation===p.implementation){l(h,m.sibling),M=n(m,p.children||[]),M.return=h,h=M;break e}else{l(h,m);break}else t(h,m);m=m.sibling}M=Fu(p,h.mode,M),M.return=h,h=M}return u(h);case je:return p=da(p),Oe(h,m,p,M)}if(Je(p))return X(h,m,p,M);if(Ke(p)){if(J=Ke(p),typeof J!="function")throw Error(r(150));return p=J.call(p),W(h,m,p,M)}if(typeof p.then=="function")return Oe(h,m,Ei(p),M);if(p.$$typeof===ce)return Oe(h,m,ji(h,p),M);Ni(h,p)}return typeof p=="string"&&p!==""||typeof p=="number"||typeof p=="bigint"?(p=""+p,m!==null&&m.tag===6?(l(h,m.sibling),M=n(m,p),M.return=h,h=M):(l(h,m),M=Wu(p,h.mode,M),M.return=h,h=M),u(h)):l(h,m)}return function(h,m,p,M){try{Tn=0;var J=Oe(h,m,p,M);return Xa=null,J}catch(Z){if(Z===ka||Z===Ti)throw Z;var be=Gt(29,Z,null,h.mode);return be.lanes=M,be.return=h,be}}}var ha=no(!0),io=no(!1),Rl=!1;function fc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function oc(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Hl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Gl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(_e&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=bi(e),kf(e,null,l),t}return vi(e,a,t,l),bi(e)}function En(e,t,l){if(t=t.updateQueue,t!==null&&(t=t.shared,(l&4194048)!==0)){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,$s(e,l)}}function rc(e,t){var l=e.updateQueue,a=e.alternate;if(a!==null&&(a=a.updateQueue,l===a)){var n=null,i=null;if(l=l.firstBaseUpdate,l!==null){do{var u={lane:l.lane,tag:l.tag,payload:l.payload,callback:null,next:null};i===null?n=i=u:i=i.next=u,l=l.next}while(l!==null);i===null?n=i=t:i=i.next=t}else n=i=t;l={baseState:a.baseState,firstBaseUpdate:n,lastBaseUpdate:i,shared:a.shared,callbacks:a.callbacks},e.updateQueue=l;return}e=l.lastBaseUpdate,e===null?l.firstBaseUpdate=t:e.next=t,l.lastBaseUpdate=t}var dc=!1;function Nn(){if(dc){var e=Ya;if(e!==null)throw e}}function An(e,t,l,a){dc=!1;var n=e.updateQueue;Rl=!1;var i=n.firstBaseUpdate,u=n.lastBaseUpdate,s=n.shared.pending;if(s!==null){n.shared.pending=null;var o=s,g=o.next;o.next=null,u===null?i=g:u.next=g,u=o;var _=e.alternate;_!==null&&(_=_.updateQueue,s=_.lastBaseUpdate,s!==u&&(s===null?_.firstBaseUpdate=g:s.next=g,_.lastBaseUpdate=o))}if(i!==null){var E=n.baseState;u=0,_=g=o=null,s=i;do{var v=s.lane&-536870913,S=v!==s.lane;if(S?(me&v)===v:(a&v)===v){v!==0&&v===La&&(dc=!0),_!==null&&(_=_.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var X=e,W=s;v=t;var Oe=l;switch(W.tag){case 1:if(X=W.payload,typeof X=="function"){E=X.call(Oe,E,v);break e}E=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=W.payload,v=typeof X=="function"?X.call(Oe,E,v):X,v==null)break e;E=U({},E,v);break e;case 2:Rl=!0}}v=s.callback,v!==null&&(e.flags|=64,S&&(e.flags|=8192),S=n.callbacks,S===null?n.callbacks=[v]:S.push(v))}else S={lane:v,tag:s.tag,payload:s.payload,callback:s.callback,next:null},_===null?(g=_=S,o=E):_=_.next=S,u|=v;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;S=s,s=S.next,S.next=null,n.lastBaseUpdate=S,n.shared.pending=null}}while(!0);_===null&&(o=E),n.baseState=o,n.firstBaseUpdate=g,n.lastBaseUpdate=_,i===null&&(n.shared.lanes=0),Xl|=u,e.lanes=u,e.memoizedState=E}}function uo(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function co(e,t){var l=e.callbacks;if(l!==null)for(e.callbacks=null,e=0;ei?i:8;var u=x.T,s={};x.T=s,Cc(e,!1,t,l);try{var o=n(),g=x.S;if(g!==null&&g(s,o),o!==null&&typeof o=="object"&&typeof o.then=="function"){var _=dh(o,a);On(e,t,_,Xt(e))}else On(e,t,a,Xt(e))}catch(E){On(e,t,{then:function(){},status:"rejected",reason:E},Xt())}finally{O.p=i,u!==null&&s.types!==null&&(u.types=s.types),x.T=u}}function vh(){}function Ac(e,t,l,a){if(e.tag!==5)throw Error(r(476));var n=Lo(e).queue;qo(e,n,t,K,l===null?vh:function(){return Yo(e),l(a)})}function Lo(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:K,baseState:K,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:K},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:vl,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Yo(e){var t=Lo(e);t.next===null&&(t=e.alternate.memoizedState),On(e,t.next.queue,{},Xt())}function Dc(){return bt($n)}function ko(){return et().memoizedState}function Xo(){return et().memoizedState}function bh(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=Xt();e=Hl(l);var a=Gl(t,e,l);a!==null&&(Ut(a,t,l),En(a,t,l)),t={cache:ic()},e.payload=t;return}t=t.return}}function Sh(e,t,l){var a=Xt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Gi(e)?Vo(t,l):(l=Ju(e,t,l,a),l!==null&&(Ut(l,e,a),Zo(l,t,a)))}function Qo(e,t,l){var a=Xt();On(e,t,l,a)}function On(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Gi(e))Vo(t,n);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var u=t.lastRenderedState,s=i(u,l);if(n.hasEagerState=!0,n.eagerState=s,Ht(s,u))return vi(e,t,n,0),Re===null&&gi(),!1}catch{}if(l=Ju(e,t,n,a),l!==null)return Ut(l,e,a),Zo(l,t,a),!0}return!1}function Cc(e,t,l,a){if(a={lane:2,revertLane:fs(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Gi(e)){if(t)throw Error(r(479))}else t=Ju(e,l,a,2),t!==null&&Ut(t,e,2)}function Gi(e){var t=e.alternate;return e===ie||t!==null&&t===ie}function Vo(e,t){Va=Ci=!0;var l=e.pending;l===null?t.next=t:(t.next=l.next,l.next=t),e.pending=t}function Zo(e,t,l){if((l&4194048)!==0){var a=t.lanes;a&=e.pendingLanes,l|=a,t.lanes=l,$s(e,l)}}var Un={readContext:bt,use:wi,useCallback:Fe,useContext:Fe,useEffect:Fe,useImperativeHandle:Fe,useLayoutEffect:Fe,useInsertionEffect:Fe,useMemo:Fe,useReducer:Fe,useRef:Fe,useState:Fe,useDebugValue:Fe,useDeferredValue:Fe,useTransition:Fe,useSyncExternalStore:Fe,useId:Fe,useHostTransitionStatus:Fe,useFormState:Fe,useActionState:Fe,useOptimistic:Fe,useMemoCache:Fe,useCacheRefresh:Fe};Un.useEffectEvent=Fe;var Ko={readContext:bt,use:wi,useCallback:function(e,t){return Mt().memoizedState=[e,t===void 0?null:t],e},useContext:bt,useEffect:Do,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Ri(4194308,4,wo.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Ri(4194308,4,e,t)},useInsertionEffect:function(e,t){Ri(4,2,e,t)},useMemo:function(e,t){var l=Mt();t=t===void 0?null:t;var a=e();if(ya){Rt(!0);try{e()}finally{Rt(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=Mt();if(l!==void 0){var n=l(t);if(ya){Rt(!0);try{l(t)}finally{Rt(!1)}}}else n=t;return a.memoizedState=a.baseState=n,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:n},a.queue=e,e=e.dispatch=Sh.bind(null,ie,e),[a.memoizedState,e]},useRef:function(e){var t=Mt();return e={current:e},t.memoizedState=e},useState:function(e){e=zc(e);var t=e.queue,l=Qo.bind(null,ie,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Ec,useDeferredValue:function(e,t){var l=Mt();return Nc(l,e,t)},useTransition:function(){var e=zc(!1);return e=qo.bind(null,ie,e.queue,!0,!1),Mt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=ie,n=Mt();if(pe){if(l===void 0)throw Error(r(407));l=l()}else{if(l=t(),Re===null)throw Error(r(349));(me&127)!==0||ho(a,t,l)}n.memoizedState=l;var i={value:l,getSnapshot:t};return n.queue=i,Do(po.bind(null,a,i,e),[e]),a.flags|=2048,Ka(9,{destroy:void 0},yo.bind(null,a,i,l,t),null),l},useId:function(){var e=Mt(),t=Re.identifierPrefix;if(pe){var l=il,a=nl;l=(a&~(1<<32-Ee(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=Oi++,0<\/script>",i=i.removeChild(i.firstChild);break;case"select":i=typeof a.is=="string"?u.createElement("select",{is:a.is}):u.createElement("select"),a.multiple?i.multiple=!0:a.size&&(i.size=a.size);break;default:i=typeof a.is=="string"?u.createElement(n,{is:a.is}):u.createElement(n)}}i[gt]=t,i[Et]=a;e:for(u=t.child;u!==null;){if(u.tag===5||u.tag===6)i.appendChild(u.stateNode);else if(u.tag!==4&&u.tag!==27&&u.child!==null){u.child.return=u,u=u.child;continue}if(u===t)break e;for(;u.sibling===null;){if(u.return===null||u.return===t)break e;u=u.return}u.sibling.return=u.return,u=u.sibling}t.stateNode=i;e:switch(xt(i,n,a),n){case"button":case"input":case"select":case"textarea":a=!!a.autoFocus;break e;case"img":a=!0;break e;default:a=!1}a&&Sl(t)}}return Ye(t),Vc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&Sl(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=te.current,Ga(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=vt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[gt]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||dd(e.nodeValue,l)),e||wl(t,!0)}else e=nu(e).createTextNode(a),e[gt]=t,t.stateNode=e}return Ye(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=Ga(t),l!==null){if(e===null){if(!a)throw Error(r(318));if(e=t.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(r(557));e[gt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),e=!1}else l=tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(Lt(t),t):(Lt(t),null);if((t.flags&128)!==0)throw Error(r(558))}return Ye(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=Ga(t),a!==null&&a.dehydrated!==null){if(e===null){if(!n)throw Error(r(318));if(n=t.memoizedState,n=n!==null?n.dehydrated:null,!n)throw Error(r(317));n[gt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Ye(t),n=!1}else n=tc(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(Lt(t),t):(Lt(t),null)}return Lt(t),(t.flags&128)!==0?(t.lanes=l,t):(l=a!==null,e=e!==null&&e.memoizedState!==null,l&&(a=t.child,n=null,a.alternate!==null&&a.alternate.memoizedState!==null&&a.alternate.memoizedState.cachePool!==null&&(n=a.alternate.memoizedState.cachePool.pool),i=null,a.memoizedState!==null&&a.memoizedState.cachePool!==null&&(i=a.memoizedState.cachePool.pool),i!==n&&(a.flags|=2048)),l!==e&&l&&(t.child.flags|=8192),Xi(t,t.updateQueue),Ye(t),null);case 4:return ze(),e===null&&ms(t.stateNode.containerInfo),Ye(t),null;case 10:return pl(t.type),Ye(t),null;case 19:if(z(Pe),a=t.memoizedState,a===null)return Ye(t),null;if(n=(t.flags&128)!==0,i=a.rendering,i===null)if(n)Bn(a,!1);else{if(Ie!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=Di(e),i!==null){for(t.flags|=128,Bn(a,!1),e=i.updateQueue,t.updateQueue=e,Xi(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)Xf(l,e),l=l.sibling;return B(Pe,Pe.current&1|2),pe&&hl(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&ge()>Ji&&(t.flags|=128,n=!0,Bn(a,!1),t.lanes=4194304)}else{if(!n)if(e=Di(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,Xi(t,e),Bn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!pe)return Ye(t),null}else 2*ge()-a.renderingStartTime>Ji&&l!==536870912&&(t.flags|=128,n=!0,Bn(a,!1),t.lanes=4194304);a.isBackwards?(i.sibling=t.child,t.child=i):(e=a.last,e!==null?e.sibling=i:t.child=i,a.last=i)}return a.tail!==null?(e=a.tail,a.rendering=e,a.tail=e.sibling,a.renderingStartTime=ge(),e.sibling=null,l=Pe.current,B(Pe,n?l&1|2:l&1),pe&&hl(t,a.treeForkCount),e):(Ye(t),null);case 22:case 23:return Lt(t),hc(),a=t.memoizedState!==null,e!==null?e.memoizedState!==null!==a&&(t.flags|=8192):a&&(t.flags|=8192),a?(l&536870912)!==0&&(t.flags&128)===0&&(Ye(t),t.subtreeFlags&6&&(t.flags|=8192)):Ye(t),l=t.updateQueue,l!==null&&Xi(t,l.retryQueue),l=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(l=e.memoizedState.cachePool.pool),a=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(a=t.memoizedState.cachePool.pool),a!==l&&(t.flags|=2048),e!==null&&z(ra),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),pl(at),Ye(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Th(e,t){switch(Pu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return pl(at),ze(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return yt(t),null;case 31:if(t.memoizedState!==null){if(Lt(t),t.alternate===null)throw Error(r(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Lt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));sa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return z(Pe),null;case 4:return ze(),null;case 10:return pl(t.type),null;case 22:case 23:return Lt(t),hc(),e!==null&&z(ra),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return pl(at),null;case 25:return null;default:return null}}function gr(e,t){switch(Pu(t),t.tag){case 3:pl(at),ze();break;case 26:case 27:case 5:yt(t);break;case 4:ze();break;case 31:t.memoizedState!==null&&Lt(t);break;case 13:Lt(t);break;case 19:z(Pe);break;case 10:pl(t.type);break;case 22:case 23:Lt(t),hc(),e!==null&&z(ra);break;case 24:pl(at)}}function Rn(e,t){try{var l=t.updateQueue,a=l!==null?l.lastEffect:null;if(a!==null){var n=a.next;l=n;do{if((l.tag&e)===e){a=void 0;var i=l.create,u=l.inst;a=i(),u.destroy=a}l=l.next}while(l!==n)}}catch(s){Ae(t,t.return,s)}}function Yl(e,t,l){try{var a=t.updateQueue,n=a!==null?a.lastEffect:null;if(n!==null){var i=n.next;a=i;do{if((a.tag&e)===e){var u=a.inst,s=u.destroy;if(s!==void 0){u.destroy=void 0,n=t;var o=l,g=s;try{g()}catch(_){Ae(n,o,_)}}}a=a.next}while(a!==i)}}catch(_){Ae(t,t.return,_)}}function vr(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{co(t,l)}catch(a){Ae(e,e.return,a)}}}function br(e,t,l){l.props=pa(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){Ae(e,t,a)}}function Hn(e,t){try{var l=e.ref;if(l!==null){switch(e.tag){case 26:case 27:case 5:var a=e.stateNode;break;case 30:a=e.stateNode;break;default:a=e.stateNode}typeof l=="function"?e.refCleanup=l(a):l.current=a}}catch(n){Ae(e,t,n)}}function ul(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){Ae(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof l=="function")try{l(null)}catch(n){Ae(e,t,n)}else l.current=null}function Sr(e){var t=e.type,l=e.memoizedProps,a=e.stateNode;try{e:switch(t){case"button":case"input":case"select":case"textarea":l.autoFocus&&a.focus();break e;case"img":l.src?a.src=l.src:l.srcSet&&(a.srcset=l.srcSet)}}catch(n){Ae(e,e.return,n)}}function Zc(e,t,l){try{var a=e.stateNode;Kh(a,e.type,l,t),a[Et]=t}catch(n){Ae(e,e.return,n)}}function xr(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Jl(e.type)||e.tag===4}function Kc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||xr(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Jl(e.type)||e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Jc(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?(l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l).insertBefore(e,t):(t=l.nodeType===9?l.body:l.nodeName==="HTML"?l.ownerDocument.body:l,t.appendChild(e),l=l._reactRootContainer,l!=null||t.onclick!==null||(t.onclick=rl));else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(Jc(e,t,l),e=e.sibling;e!==null;)Jc(e,t,l),e=e.sibling}function Qi(e,t,l){var a=e.tag;if(a===5||a===6)e=e.stateNode,t?l.insertBefore(e,t):l.appendChild(e);else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(Qi(e,t,l),e=e.sibling;e!==null;)Qi(e,t,l),e=e.sibling}function _r(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);xt(t,a,l),t[gt]=e,t[Et]=l}catch(i){Ae(e,e.return,i)}}var xl=!1,ut=!1,$c=!1,jr=typeof WeakSet=="function"?WeakSet:Set,ht=null;function Mh(e,t){if(e=e.containerInfo,ps=ru,e=wf(e),ku(e)){if("selectionStart"in e)var l={start:e.selectionStart,end:e.selectionEnd};else e:{l=(l=e.ownerDocument)&&l.defaultView||window;var a=l.getSelection&&l.getSelection();if(a&&a.rangeCount!==0){l=a.anchorNode;var n=a.anchorOffset,i=a.focusNode;a=a.focusOffset;try{l.nodeType,i.nodeType}catch{l=null;break e}var u=0,s=-1,o=-1,g=0,_=0,E=e,v=null;t:for(;;){for(var S;E!==l||n!==0&&E.nodeType!==3||(s=u+n),E!==i||a!==0&&E.nodeType!==3||(o=u+a),E.nodeType===3&&(u+=E.nodeValue.length),(S=E.firstChild)!==null;)v=E,E=S;for(;;){if(E===e)break t;if(v===l&&++g===n&&(s=u),v===i&&++_===a&&(o=u),(S=E.nextSibling)!==null)break;E=v,v=E.parentNode}E=S}l=s===-1||o===-1?null:{start:s,end:o}}else l=null}l=l||{start:0,end:0}}else l=null;for(gs={focusedElem:e,selectionRange:l},ru=!1,ht=t;ht!==null;)if(t=ht,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ht=e;else for(;ht!==null;){switch(t=ht,i=t.alternate,e=t.flags,t.tag){case 0:if((e&4)!==0&&(e=t.updateQueue,e=e!==null?e.events:null,e!==null))for(l=0;l title"))),xt(i,a,l),i[gt]=e,mt(i),a=i;break e;case"link":var u=Ad("link","href",n).get(a+(l.href||""));if(u){for(var s=0;sOe&&(u=Oe,Oe=W,W=u);var h=Of(s,W),m=Of(s,Oe);if(h&&m&&(S.rangeCount!==1||S.anchorNode!==h.node||S.anchorOffset!==h.offset||S.focusNode!==m.node||S.focusOffset!==m.offset)){var p=E.createRange();p.setStart(h.node,h.offset),S.removeAllRanges(),W>Oe?(S.addRange(p),S.extend(m.node,m.offset)):(p.setEnd(m.node,m.offset),S.addRange(p))}}}}for(E=[],S=s;S=S.parentNode;)S.nodeType===1&&E.push({element:S,left:S.scrollLeft,top:S.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;sl?32:l,x.T=null,l=ls,ls=null;var i=Vl,u=Ml;if(ft=0,Ia=Vl=null,Ml=0,(_e&6)!==0)throw Error(r(331));var s=_e;if(_e|=4,wr(i.current),Cr(i,i.current,u,l),_e=s,Xn(0,!1),dt&&typeof dt.onPostCommitFiberRoot=="function")try{dt.onPostCommitFiberRoot(Bt,i)}catch{}return!0}finally{O.p=n,x.T=a,Ir(e,t)}}function ed(e,t,l){t=Kt(l,t),t=Bc(e.stateNode,t,2),e=Gl(e,t,2),e!==null&&(fn(e,2),cl(e))}function Ae(e,t,l){if(e.tag===3)ed(e,e,l);else for(;t!==null;){if(t.tag===3){ed(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Ql===null||!Ql.has(a))){e=Kt(l,e),l=tr(2),a=Gl(t,l,2),a!==null&&(lr(l,a,t,e),fn(a,2),cl(a));break}}t=t.return}}function us(e,t,l){var a=e.pingCache;if(a===null){a=e.pingCache=new Ah;var n=new Set;a.set(t,n)}else n=a.get(t),n===void 0&&(n=new Set,a.set(t,n));n.has(l)||(Ic=!0,n.add(l),e=wh.bind(null,e,t,l),t.then(e,e))}function wh(e,t,l){var a=e.pingCache;a!==null&&a.delete(t),e.pingedLanes|=e.suspendedLanes&l,e.warmLanes&=~l,Re===e&&(me&l)===l&&(Ie===4||Ie===3&&(me&62914560)===me&&300>ge()-Ki?(_e&2)===0&&Pa(e,0):Pc|=l,Fa===me&&(Fa=0)),cl(e)}function td(e,t){t===0&&(t=Ks()),e=ua(e,t),e!==null&&(fn(e,t),cl(e))}function Bh(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),td(e,l)}function Rh(e,t){var l=0;switch(e.tag){case 31:case 13:var a=e.stateNode,n=e.memoizedState;n!==null&&(l=n.retryLane);break;case 19:a=e.stateNode;break;case 22:a=e.stateNode._retryCache;break;default:throw Error(r(314))}a!==null&&a.delete(t),td(e,l)}function Hh(e,t){return Q(e,t)}var eu=null,tn=null,cs=!1,tu=!1,ss=!1,Kl=0;function cl(e){e!==tn&&e.next===null&&(tn===null?eu=tn=e:tn=tn.next=e),tu=!0,cs||(cs=!0,qh())}function Xn(e,t){if(!ss&&tu){ss=!0;do for(var l=!1,a=eu;a!==null;){if(e!==0){var n=a.pendingLanes;if(n===0)var i=0;else{var u=a.suspendedLanes,s=a.pingedLanes;i=(1<<31-Ee(42|e)+1)-1,i&=n&~(u&~s),i=i&201326741?i&201326741|1:i?i|2:0}i!==0&&(l=!0,id(a,i))}else i=me,i=_t(a,a===Re?i:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(i&3)===0||fl(a,i)||(l=!0,id(a,i));a=a.next}while(l);ss=!1}}function Gh(){ld()}function ld(){tu=cs=!1;var e=0;Kl!==0&&$h()&&(e=Kl);for(var t=ge(),l=null,a=eu;a!==null;){var n=a.next,i=ad(a,t);i===0?(a.next=null,l===null?eu=n:l.next=n,n===null&&(tn=l)):(l=a,(e!==0||(i&3)!==0)&&(tu=!0)),a=n}ft!==0&&ft!==5||Xn(e),Kl!==0&&(Kl=0)}function ad(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,i=e.pendingLanes&-62914561;0s)break;var _=o.transferSize,E=o.initiatorType;_&&md(E)&&(o=o.responseEnd,u+=_*(o"u"?null:document;function Td(e,t,l){var a=ln;if(a&&typeof t=="string"&&t){var n=Vt(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),zd.has(n)||(zd.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),xt(t,"link",e),mt(t),a.head.appendChild(t)))}}function n0(e){El.D(e),Td("dns-prefetch",e,null)}function i0(e,t){El.C(e,t),Td("preconnect",e,t)}function u0(e,t,l){El.L(e,t,l);var a=ln;if(a&&e&&t){var n='link[rel="preload"][as="'+Vt(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Vt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Vt(l.imageSizes)+'"]')):n+='[href="'+Vt(e)+'"]';var i=n;switch(t){case"style":i=an(e);break;case"script":i=nn(e)}Pt.has(i)||(e=U({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Pt.set(i,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(Kn(i))||t==="script"&&a.querySelector(Jn(i))||(t=a.createElement("link"),xt(t,"link",e),mt(t),a.head.appendChild(t)))}}function c0(e,t){El.m(e,t);var l=ln;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+Vt(a)+'"][href="'+Vt(e)+'"]',i=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=nn(e)}if(!Pt.has(i)&&(e=U({rel:"modulepreload",href:e},t),Pt.set(i,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector(Jn(i)))return}a=l.createElement("link"),xt(a,"link",e),mt(a),l.head.appendChild(a)}}}function s0(e,t,l){El.S(e,t,l);var a=ln;if(a&&e){var n=Ta(a).hoistableStyles,i=an(e);t=t||"default";var u=n.get(i);if(!u){var s={loading:0,preload:null};if(u=a.querySelector(Kn(i)))s.loading=5;else{e=U({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Pt.get(i))&&zs(e,l);var o=u=a.createElement("link");mt(o),xt(o,"link",e),o._p=new Promise(function(g,_){o.onload=g,o.onerror=_}),o.addEventListener("load",function(){s.loading|=1}),o.addEventListener("error",function(){s.loading|=2}),s.loading|=4,uu(u,t,a)}u={type:"stylesheet",instance:u,count:1,state:s},n.set(i,u)}}}function f0(e,t){El.X(e,t);var l=ln;if(l&&e){var a=Ta(l).hoistableScripts,n=nn(e),i=a.get(n);i||(i=l.querySelector(Jn(n)),i||(e=U({src:e,async:!0},t),(t=Pt.get(n))&&Ts(e,t),i=l.createElement("script"),mt(i),xt(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function o0(e,t){El.M(e,t);var l=ln;if(l&&e){var a=Ta(l).hoistableScripts,n=nn(e),i=a.get(n);i||(i=l.querySelector(Jn(n)),i||(e=U({src:e,async:!0,type:"module"},t),(t=Pt.get(n))&&Ts(e,t),i=l.createElement("script"),mt(i),xt(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function Md(e,t,l,a){var n=(n=te.current)?iu(n):null;if(!n)throw Error(r(446));switch(e){case"meta":case"title":return null;case"style":return typeof l.precedence=="string"&&typeof l.href=="string"?(t=an(l.href),l=Ta(n).hoistableStyles,a=l.get(t),a||(a={type:"style",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};case"link":if(l.rel==="stylesheet"&&typeof l.href=="string"&&typeof l.precedence=="string"){e=an(l.href);var i=Ta(n).hoistableStyles,u=i.get(e);if(u||(n=n.ownerDocument||n,u={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},i.set(e,u),(i=n.querySelector(Kn(e)))&&!i._p&&(u.instance=i,u.state.loading=5),Pt.has(e)||(l={rel:"preload",as:"style",href:l.href,crossOrigin:l.crossOrigin,integrity:l.integrity,media:l.media,hrefLang:l.hrefLang,referrerPolicy:l.referrerPolicy},Pt.set(e,l),i||r0(n,e,l,u.state))),t&&a===null)throw Error(r(528,""));return u}if(t&&a!==null)throw Error(r(529,""));return null;case"script":return t=l.async,l=l.src,typeof l=="string"&&t&&typeof t!="function"&&typeof t!="symbol"?(t=nn(l),l=Ta(n).hoistableScripts,a=l.get(t),a||(a={type:"script",instance:null,count:0,state:null},l.set(t,a)),a):{type:"void",instance:null,count:0,state:null};default:throw Error(r(444,e))}}function an(e){return'href="'+Vt(e)+'"'}function Kn(e){return'link[rel="stylesheet"]['+e+"]"}function Ed(e){return U({},e,{"data-precedence":e.precedence,precedence:null})}function r0(e,t,l,a){e.querySelector('link[rel="preload"][as="style"]['+t+"]")?a.loading=1:(t=e.createElement("link"),a.preload=t,t.addEventListener("load",function(){return a.loading|=1}),t.addEventListener("error",function(){return a.loading|=2}),xt(t,"link",l),mt(t),e.head.appendChild(t))}function nn(e){return'[src="'+Vt(e)+'"]'}function Jn(e){return"script[async]"+e}function Nd(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Vt(l.href)+'"]');if(a)return t.instance=a,mt(a),a;var n=U({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),mt(a),xt(a,"style",n),uu(a,l.precedence,e),t.instance=a;case"stylesheet":n=an(l.href);var i=e.querySelector(Kn(n));if(i)return t.state.loading|=4,t.instance=i,mt(i),i;a=Ed(l),(n=Pt.get(n))&&zs(a,n),i=(e.ownerDocument||e).createElement("link"),mt(i);var u=i;return u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),xt(i,"link",a),t.state.loading|=4,uu(i,l.precedence,e),t.instance=i;case"script":return i=nn(l.src),(n=e.querySelector(Jn(i)))?(t.instance=n,mt(n),n):(a=l,(n=Pt.get(i))&&(a=U({},l),Ts(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),mt(n),xt(n,"link",a),e.head.appendChild(n),t.instance=n);case"void":return null;default:throw Error(r(443,t.type))}else t.type==="stylesheet"&&(t.state.loading&4)===0&&(a=t.instance,t.state.loading|=4,uu(a,l.precedence,e));return t.instance}function uu(e,t,l){for(var a=l.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),n=a.length?a[a.length-1]:null,i=n,u=0;u title"):null)}function d0(e,t,l){if(l===1||t.itemProp!=null)return!1;switch(e){case"meta":case"title":return!0;case"style":if(typeof t.precedence!="string"||typeof t.href!="string"||t.href==="")break;return!0;case"link":if(typeof t.rel!="string"||typeof t.href!="string"||t.href===""||t.onLoad||t.onError)break;return t.rel==="stylesheet"?(e=t.disabled,typeof t.precedence=="string"&&e==null):!0;case"script":if(t.async&&typeof t.async!="function"&&typeof t.async!="symbol"&&!t.onLoad&&!t.onError&&t.src&&typeof t.src=="string")return!0}return!1}function Cd(e){return!(e.type==="stylesheet"&&(e.state.loading&3)===0)}function m0(e,t,l,a){if(l.type==="stylesheet"&&(typeof a.media!="string"||matchMedia(a.media).matches!==!1)&&(l.state.loading&4)===0){if(l.instance===null){var n=an(a.href),i=t.querySelector(Kn(n));if(i){t=i._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=su.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=i,mt(i);return}i=t.ownerDocument||t,a=Ed(a),(n=Pt.get(n))&&zs(a,n),i=i.createElement("link"),mt(i);var u=i;u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),xt(i,"link",a),l.instance=i}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(l,t),(t=l.state.preload)&&(l.state.loading&3)===0&&(e.count++,l=su.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Ms=0;function h0(e,t){return e.stylesheets&&e.count===0&&ou(e,e.stylesheets),0Ms?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function su(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)ou(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var fu=null;function ou(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,fu=new Map,t.forEach(y0,e),fu=null,su.call(e))}function y0(e,t){if(!(t.state.loading&4)){var l=fu.get(e);if(l)var a=l.get(null);else{l=new Map,fu.set(e,l);for(var n=e.querySelectorAll("link[data-precedence],style[data-precedence]"),i=0;i"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(b){console.error(b)}}return f(),Bs.exports=O0(),Bs.exports}var w0=U0();const B0=sm(w0);const fm=(...f)=>f.filter((b,N,r)=>!!b&&b.trim()!==""&&r.indexOf(b)===N).join(" ").trim();const R0=f=>f.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();const H0=f=>f.replace(/^([A-Z])|[\s-_]+(\w)/g,(b,N,r)=>r?r.toUpperCase():N.toLowerCase());const tm=f=>{const b=H0(f);return b.charAt(0).toUpperCase()+b.slice(1)};var qs={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const G0=f=>{for(const b in f)if(b.startsWith("aria-")||b==="role"||b==="title")return!0;return!1},q0=w.createContext({}),L0=()=>w.useContext(q0),Y0=w.forwardRef(({color:f,size:b,strokeWidth:N,absoluteStrokeWidth:r,className:j="",children:A,iconNode:Y,...G},R)=>{const{size:y=24,strokeWidth:D=2,absoluteStrokeWidth:U=!1,color:V="currentColor",className:ee=""}=L0()??{},k=r??U?Number(N??D)*24/Number(b??y):N??D;return w.createElement("svg",{ref:R,...qs,width:b??y??qs.width,height:b??y??qs.height,stroke:f??V,strokeWidth:k,className:fm("lucide",ee,j),...!A&&!G0(G)&&{"aria-hidden":"true"},...G},[...Y.map(([F,re])=>w.createElement(F,re)),...Array.isArray(A)?A:[A]])});const ke=(f,b)=>{const N=w.forwardRef(({className:r,...j},A)=>w.createElement(Y0,{ref:A,iconNode:b,className:fm(`lucide-${R0(tm(f))}`,`lucide-${f}`,r),...j}));return N.displayName=tm(f),N};const k0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ls=ke("check",k0);const X0=[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]],lm=ke("cloud-download",X0);const Q0=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],V0=ke("copy",Q0);const Z0=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],om=ke("cpu",Z0);const K0=[["path",{d:"M6 2v14a2 2 0 0 0 2 2h14",key:"ron5a4"}],["path",{d:"M18 22V8a2 2 0 0 0-2-2H2",key:"7s9ehn"}]],J0=ke("crop",K0);const $0=[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]],Ys=ke("database",$0);const W0=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],am=ke("download",W0);const F0=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}],["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"m15 13-3 3-3-3",key:"6j2sf0"}]],I0=ke("folder-down",F0);const P0=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],nm=ke("folder-open",P0);const ey=[["path",{d:"M10 16h.01",key:"1bzywj"}],["path",{d:"M2.212 11.577a2 2 0 0 0-.212.896V18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-5.527a2 2 0 0 0-.212-.896L18.55 5.11A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"18tbho"}],["path",{d:"M21.946 12.013H2.054",key:"zqlbp7"}],["path",{d:"M6 16h.01",key:"1pmjb7"}]],bu=ke("hard-drive",ey);const ty=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],ly=ke("image-plus",ty);const ay=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ny=ke("image",ay);const iy=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],uy=ke("info",iy);const cy=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],sy=ke("layers",cy);const fy=[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]],oy=ke("library",fy);const ry=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],dy=ke("moon",ry);const my=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],ta=ke("refresh-cw",my);const hy=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],yy=ke("shield",hy);const py=[["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M12 21v-9",key:"17s77i"}],["path",{d:"M12 8V3",key:"13r4qs"}],["path",{d:"M17 16h4",key:"h1uq16"}],["path",{d:"M19 12V3",key:"o1uvq1"}],["path",{d:"M19 21v-5",key:"qua636"}],["path",{d:"M3 14h4",key:"bcjad9"}],["path",{d:"M5 10V3",key:"cb8scm"}],["path",{d:"M5 21v-7",key:"1w1uti"}]],Vs=ke("sliders-vertical",py);const gy=[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]],vu=ke("sparkles",gy);const vy=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],ks=ke("square",vy);const by=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Sy=ke("sun",by);const xy=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],_y=ke("terminal",xy);const jy=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],ti=ke("trash-2",jy);const zy=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Ty=ke("triangle-alert",zy);function My({activeTab:f,setActiveTab:b,specs:N}){return c.jsxs("div",{className:"sidebar",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"sidebar-logo",children:[c.jsx(yy,{className:"sidebar-logo-icon"}),c.jsx("span",{className:"sidebar-logo-text",children:"Local AI Studio"})]}),c.jsxs("div",{className:"nav-list",children:[c.jsxs("div",{className:`nav-item ${f==="generator"?"active":""}`,onClick:()=>b("generator"),children:[c.jsx(ny,{size:20}),c.jsx("span",{children:"Image Generator"})]}),c.jsxs("div",{className:`nav-item ${f==="models"?"active":""}`,onClick:()=>b("models"),children:[c.jsx(I0,{size:20}),c.jsx("span",{children:"Model Manager"})]}),c.jsxs("div",{className:`nav-item ${f==="constraints"?"active":""}`,onClick:()=>b("constraints"),children:[c.jsx(Vs,{size:20}),c.jsx("span",{children:"Image Constraints"})]})]})]}),c.jsxs("div",{className:"sidebar-footer",children:[c.jsxs("div",{className:"sidebar-specs-header",children:[c.jsx(_y,{size:12}),c.jsx("span",{children:"Host Specifications"})]}),c.jsxs("div",{className:"sidebar-specs-item",title:N.cpu_name,children:["CPU: ",N.cpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",title:N.gpu_name,children:["GPU: ",N.gpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",children:["Memory: ",N.ram_total_gb.toFixed(0)," GB RAM (",N.cpu_cores_physical," Cores)"]}),c.jsxs("div",{className:"sidebar-specs-os",children:["OS: ",N.os_name]})]})]})}const Ey=w.memo(My);function Ny({telemetry:f,serverRunning:b,activeModel:N,onStopServer:r,isStoppingServer:j=!1,theme:A,setTheme:Y}){const G=D=>{const U=Number(D);return Number.isFinite(U)&&U>0?U.toFixed(U>=10?0:1):"--"},R=()=>b?"Server Active":"Local Mode",y=()=>b?"status-indicator busy":"status-indicator offline";return c.jsxs("div",{className:"top-status-bar",children:[c.jsxs("div",{className:"current-model-info",children:[c.jsx("div",{className:y()}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.95rem"},children:R()}),N&&c.jsxs(c.Fragment,{children:[c.jsx("span",{style:{color:"var(--md-sys-color-outline-variant)"},children:"|"}),c.jsx("span",{style:{color:"var(--md-sys-color-primary)",fontWeight:700},children:N})]})]}),c.jsxs("div",{className:"telemetry-group",children:[c.jsx("button",{className:"theme-toggle-btn",onClick:()=>Y(A==="dark"?"light":"dark"),title:`Switch to ${A==="dark"?"light":"dark"} theme`,children:A==="dark"?c.jsx(Sy,{size:18}):c.jsx(dy,{size:18})}),b&&c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:r,disabled:j,title:"Stop local model server",children:[j?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ks,{size:14}),c.jsx("span",{children:j?"Stopping":"Stop Server"})]}),c.jsxs("div",{className:"telemetry-chip",title:"CPU Utilization",children:[c.jsx(om,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-primary)"}}),c.jsxs("span",{children:["CPU: ",Number.isFinite(Number(f.cpu_usage))?f.cpu_usage:"--","%"]})]}),c.jsxs("div",{className:"telemetry-chip",title:"System Memory Usage",children:[c.jsx(bu,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-secondary)"}}),c.jsxs("span",{children:["RAM: ",G(f.ram_used_gb)," / ",G(f.ram_total_gb)," GB"]})]}),f.vram_total_gb>0&&c.jsxs("div",{className:"telemetry-chip",title:`${f.gpu_name} VRAM`,children:[c.jsx(Ys,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-tertiary)"}}),c.jsxs("span",{children:["VRAM: ",G(f.vram_used_gb)," / ",G(f.vram_total_gb)," GB"]})]})]})]})}const Ay=w.memo(Ny),Dy="modulepreload",Cy=function(f){return"/"+f},im={},Oy=function(b,N,r){let j=Promise.resolve();if(N&&N.length>0){let R=function(y){return Promise.all(y.map(D=>Promise.resolve(D).then(U=>({status:"fulfilled",value:U}),U=>({status:"rejected",reason:U}))))};document.getElementsByTagName("link");const Y=document.querySelector("meta[property=csp-nonce]"),G=Y?.nonce||Y?.getAttribute("nonce");j=R(N.map(y=>{if(y=Cy(y),y in im)return;im[y]=!0;const D=y.endsWith(".css"),U=D?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${U}`))return;const V=document.createElement("link");if(V.rel=D?"stylesheet":Dy,D||(V.as="script"),V.crossOrigin="",V.href=y,G&&V.setAttribute("nonce",G),document.head.appendChild(V),D)return new Promise((ee,k)=>{V.addEventListener("load",ee),V.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${y}`)))})}))}function A(Y){const G=new Event("vite:preloadError",{cancelable:!0});if(G.payload=Y,window.dispatchEvent(G),!G.defaultPrevented)throw Y}return j.then(Y=>{for(const G of Y||[])G.status==="rejected"&&A(G.reason);return b().catch(A)})};function o1(f,b=!1){return window.__TAURI_INTERNALS__.transformCallback(f,b)}async function xa(f,b={},N){return window.__TAURI_INTERNALS__.invoke(f,b,N)}const Nl=()=>typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0;let ea=null;const Uy="polish-setup-v1",Sa=()=>typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function li(f){const b=Number(f)||0;if(b<=0)return"0 B";const N=["B","KB","MB","GB","TB"],r=Math.min(N.length-1,Math.floor(Math.log(b)/Math.log(1024)));return`${(b/1024**r).toFixed(r===0?0:1)} ${N[r]}`}function ai(f){return typeof f=="string"?{filename:f,sizeBytes:0,size:"Unknown"}:{filename:f?.filename||f?.name||"",sizeBytes:Number(f?.sizeBytes||0),size:f?.size||(f?.sizeBytes?li(f.sizeBytes):"Unknown")}}async function cn(f,b="The local server returned an invalid response."){const N=await f.text();let r={};try{r=JSON.parse(N||"{}")}catch{const A=N.trim().startsWith("{const ee=y.steps;for(let $=1;$<=ee;$++){if(Y&&Y.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(je=>setTimeout(je,3e3/ee)),A&&A(Math.round($/ee*100))}const k=f.toLowerCase(),F=Math.abs(y.seed)||Math.floor(Math.random()*1e3);let re="#3B82F6",I="#8B5CF6",ne="",ce="Abstract Generation";k.includes("moon")||k.includes("space")||k.includes("astronomy")||k.includes("sky")?(re="#1E293B",I="#0F172A",ce="Luminous Moon in Starry Sky",ne=` @@ -18,7 +18,7 @@ Error generating stack: `+a.message+` - `):X.includes("cat")||X.includes("kitten")||X.includes("feline")?(re="#4F46E5",I="#7C3AED",ce="Stylized Cat Portrait",ne=` + `):k.includes("cat")||k.includes("kitten")||k.includes("feline")?(re="#4F46E5",I="#7C3AED",ce="Stylized Cat Portrait",ne=` @@ -34,7 +34,7 @@ Error generating stack: `+a.message+` - `):X.includes("dog")||X.includes("puppy")||X.includes("canine")?(re="#D97706",I="#B45309",ce="Friendly Dog Portrait",ne=` + `):k.includes("dog")||k.includes("puppy")||k.includes("canine")?(re="#D97706",I="#B45309",ce="Friendly Dog Portrait",ne=` @@ -47,7 +47,7 @@ Error generating stack: `+a.message+` - `):X.includes("city")||X.includes("cyberpunk")||X.includes("tokyo")||X.includes("neon")?(re="#111827",I="#311042",ce="Neon Cyberpunk Skyline",ne=` + `):k.includes("city")||k.includes("cyberpunk")||k.includes("tokyo")||k.includes("neon")?(re="#111827",I="#311042",ce="Neon Cyberpunk Skyline",ne=` @@ -60,7 +60,7 @@ Error generating stack: `+a.message+` - `):X.includes("car")||X.includes("vehicle")||X.includes("supercar")?(re="#DC2626",I="#991B1B",ce="Futuristic Concept Car",ne=` + `):k.includes("car")||k.includes("vehicle")||k.includes("supercar")?(re="#DC2626",I="#991B1B",ce="Futuristic Concept Car",ne=` @@ -104,8 +104,8 @@ Error generating stack: `+a.message+` ${ce} Seed: ${F} • Steps: ${y.steps} • Scale: ${y.cfg_scale} - `;return{image:`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Ge)))}`,seed:y.seed,duration_sec:3}},U=!!y.image,V={prompt:y.prompt,negative_prompt:y.negative_prompt||"",n:1,size:`${y.width}x${y.height}`,response_format:"b64_json",steps:y.steps,cfg_scale:y.cfg_scale,seed:y.seed,sample_method:y.sampler};U&&(V.init_images=[y.image],V.denoising_strength=y.denoising_strength);try{const ee=await fetch(`${R}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:Y,body:JSON.stringify(V)});if(ee.ok){const X=await ee.json(),F=X?.data?.[0]?.b64_json??X?.images?.[0];if(F)return{image:`data:image/png;base64,${F}`,seed:X.data?.[0]?.seed??y.seed,duration_sec:4.5}}else{let X=`Generation failed (HTTP ${ee.status})`;try{const F=await ee.json();(F?.detail||F?.error?.message)&&(X=F.detail||F.error.message)}catch{}throw new Error(X)}}catch(ee){if(ee.name==="AbortError"||ee.message.startsWith("Generation failed"))throw ee;console.warn("Could not reach local server. Falling back to simulation mode.",ee)}return await D()}async function Ky(f,b,N){if(f instanceof File){const G=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Jy(G,b,N),{response:"Model imported successfully"}}if(Nl()){const{listen:G}=await Oy(async()=>{const{listen:y}=await import("./event-Cyr5rmj6.js");return{listen:y}},[]);let R=null;b&&(R=await G("import-progress",y=>{b(y.payload)}));try{return{response:await xa("import_model_file",{sourcePath:f}),unlisten:R}}catch(y){throw R&&R(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const j=40;for(let G=1;G<=j;G++){if(N?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(U=>setTimeout(U,150));const R=G/j*100,y=40+Math.sin(G)*5+Math.random()*2,D=(j-G)*.15;b&&b({filename:r,progress:R,speed_mb_s:y,eta_secs:D,status:"Copying to USB..."})}const A=localStorage.getItem("imported-models"),Y=A?JSON.parse(A):[];return Y.includes(r)||(Y.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(Y))),{response:"Model imported successfully"}}function Jy(f,b,N){return new Promise((r,j)=>{const A=new XMLHttpRequest,Y=Date.now();let G=!1;A.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),A.setRequestHeader("Content-Type","application/octet-stream");const R=()=>{G=!0,A.abort()};N&&(N.aborted?R():N.addEventListener("abort",R,{once:!0})),A.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const D=Math.max(.1,(Date.now()-Y)/1e3),U=y.loaded/D,V=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:U/(1024*1024),eta_secs:V/Math.max(1,U),status:"Copying to models folder..."})},A.onload=()=>{let y={};try{y=JSON.parse(A.responseText||"{}")}catch{}A.status>=200&&A.status<300&&y.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):j(new Error(y.error||`Import failed (HTTP ${A.status})`))},A.onerror=()=>j(new Error("Import failed while uploading the file.")),A.onabort=()=>j(new DOMException(G?"Import cancelled by user.":"Import aborted.","AbortError")),A.send(f)})}async function $y(f){if(Nl())return await xa("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const j=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),A=await j.json();if(!j.ok)throw new Error(A.error||"Failed to delete model file");return A}catch(j){throw console.error("Failed to delete model via local API:",j),j}const N=localStorage.getItem("imported-models");let r=N?JSON.parse(N):[];return r=r.filter(j=>ai(j).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function rm(){const b="http://127.0.0.1:8080";try{return(await fetch(`${b}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Wy(f=30){const b=Nl()||Sa()?f:3;for(let N=0;NsetTimeout(j,500))}return!1}async function Fy(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(b){return console.error("Failed to start model download:",b),{ok:!1,error:b.message}}}async function Iy(){try{return await(await fetch("/api/cancel-download",{method:"POST"})).json()}catch(f){return console.error("Failed to cancel model download:",f),{ok:!1,error:f.message}}}async function um(){try{return await(await fetch("/api/download-progress")).json()}catch(f){return console.error("Failed to get download progress:",f),{active:!1,error:f.message}}}async function Py(){try{return await(await fetch("/api/generation-progress")).json()}catch(f){return console.error("Failed to get generation progress:",f),{active:!1,error:f.message}}}const e1=w.memo(({img:f,idx:b,isSelected:N,onClick:r})=>{const j=A=>{r(b,A)};return c.jsxs("div",{className:`gallery-item ${N?"selected":""}`,onClick:j,title:`Prompt: ${f.prompt} -Seed: ${f.seed}`,children:[c.jsx("img",{src:f.url,className:"gallery-thumb",alt:"Thumbnail",loading:"lazy",decoding:"async"}),N&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ls,{size:14})})]})});function t1({prompt:f,setPrompt:b,negativePrompt:N,setNegativePrompt:r,constraints:j,setConstraints:A,activeModel:Y,generatedImages:G,setGeneratedImages:R,isGenerating:y,setIsGenerating:D,generationProgress:U,setGenerationProgress:V,setActiveTab:ee,inputImage:X,setInputImage:F,showAlert:re=async({message:ne})=>window.alert(ne),showConfirm:I=async({message:ne})=>window.confirm(ne)}){const[ne,ce]=w.useState(null),[Ge,Ze]=w.useState(null),[ke,$]=w.useState(null),[je,ot]=w.useState(!1),[qe,Me]=w.useState(0),[Ke,$e]=w.useState(0),[tt,Je]=w.useState(0),[x,O]=w.useState(""),[K,se]=w.useState(!1),[de,d]=w.useState(!1),[z,B]=w.useState(!1),[H,P]=w.useState(null),[te,le]=w.useState(null),[Ue,ze]=w.useState([]),ct=w.useRef(null),yt=w.useRef(null),wt=w.useRef(null),Al=()=>{yt.current.click()},rt=L=>{const ve=L.target.files[0];if(ve){const we=new FileReader;we.onload=()=>{F(we.result)},we.readAsDataURL(ve)}},al=L=>{L.stopPropagation(),F(null),yt.current&&(yt.current.value="")},sl=async()=>{if(!f.trim())return;le(null),B(!0),P(null);let L=!1;try{const Te=await ba();if(Te&&Te.settings){const xe=Te.settings,Qe=xe.model?xe.model.split(/[\\/]/).pop():null,ye=Y?Y.split(/[\\/]/).pop():null;(Qe!==ye||parseInt(xe.steps)!==parseInt(j.steps)||Math.abs(parseFloat(xe.cfgScale)-parseFloat(j.cfgScale))>.05||xe.sampler!==j.sampler||parseInt(xe.threads)!==parseInt(j.threads)||!!xe.useGpu!=(j.useGpu!==!1)||(xe.backendType||(xe.useGpu===!1?"cpu":"auto"))!==(j.backendType||(j.useGpu===!1?"cpu":"auto")))&&(L=!0)}else L=!0}catch{L=!0}if(L)try{console.log("Settings out of sync, restarting backend..."),await ks(Y,j);let Te=!1,xe=null;for(let Qe=0;Qe<240;Qe++){const ye=await ba();if(ye.loading&&P({progress:ye.loading.progress||0,phase:ye.loading.phase||"Loading model...",speed:ye.loading.speed||"",current:ye.loading.current||0,total:ye.loading.total||0,backendMode:ye.loading.backendMode||ye.settings?.backendMode||"",device:ye.loading.device||ye.settings?.backendDevice||""}),ye.ready){Te=!0;break}if(ye.error){xe=ye.error;break}if(!ye.running&&Qe>3){xe="The backend process terminated immediately on startup.";break}await new Promise(lt=>setTimeout(lt,500))}if(!Te)throw new Error(xe||"Backend server failed to start after applying configuration changes.")}catch(Te){console.error("Failed to restart backend:",Te),le(Te.message||"Failed to sync settings with backend."),B(!1);return}B(!1),P(null),ct.current&&clearInterval(ct.current),D(!0),V(0),Me(0),Je(0),O(""),se(!1),$(null),ce(null);const ve=(j.width>=1024?140:35)*.04,we=j.width>=1024?140:35,pt=(j.backendType||(j.useGpu===!1?"cpu":"auto"))!=="cpu";let Tt=pt?ve:we,Bt=!1,dt=0,Rt=0,Ee=0;$e(Math.round(j.steps*Tt)),ct.current=setInterval(async()=>{Ee++,Me(Ee);try{const Te=await Py();if(Te&&Te.active){const xe=Te.step||0,Qe=Te.steps||j.steps||20,ye=Te.speed||"";Je(xe),O(ye);let lt=0;Qe>0&&(lt=Math.round(xe/Qe*100)),lt=Math.min(99,lt),V(_t=>Math.max(_t,lt));let Be=0;const We=parseFloat(ye);if(!isNaN(We)&&We>0){const _t=Math.max(0,Qe-xe);ye.includes("it/s")?Be=_t/We:ye.includes("s/it")&&(Be=_t*We)}else{const _t=pt?ve:we;Be=Math.max(0,(Qe-xe)*_t)}if(pt&&!Bt){const _t=ye.includes("it/s")&&We<.2,fl=ye.includes("s/it")&&We>5;(_t||fl)&&(Bt=!0,se(!0))}$e(Math.round(Be))}else V(xe=>Math.min(15,xe+1)),$e(xe=>Math.max(1,xe-1))}catch(Te){console.warn("Failed to get generation progress, running simulation fallback:",Te),pt&&!Bt&&Ee>j.steps*ve*1.3&&(Bt=!0,se(!0),Tt=we,dt=Ee,Rt=Math.min(95,Math.round(Ee/(j.steps*ve)*100)));let xe=Math.min(j.steps-1,Math.floor(Ee/Tt)),Qe=j.steps*Tt;if(Ee>=Qe){const Be=Math.ceil(Ee/Math.max(.5,xe));Tt=Math.max(Tt+15,Be+15),Qe=j.steps*Tt,xe=Math.min(j.steps-1,Math.floor(Ee/Tt))}Je(xe);const ye=Math.max(1,Qe-Ee);$e(Math.round(ye));let lt=0;if(Bt){const Be=99-Rt,We=Qe-dt;if(We>0){const _t=Math.min(1,(Ee-dt)/We);if(_t<.85)lt=Math.round(Rt+_t*Be);else{const fl=(Ee-(dt+We*.85))/(Tt*2),Su=1-Math.exp(-fl);lt=Math.min(99,Math.round(Rt+.85*Be+.14*Be*Su))}}else lt=99}else if(EeMath.max(Be,lt))}},1e3);try{wt.current=new AbortController;const Te=await Zy(f,N,j,Y,X,Be=>V(We=>Math.max(We,Be)),wt.current.signal);ct.current&&clearInterval(ct.current),V(100),Je(j.steps),$e(0),O("");const xe={prompt:f,negativePrompt:N,seed:Te.seed,steps:j.steps,cfgScale:j.cfgScale,width:j.width,height:j.height,sampler:j.sampler,model:Y,duration_sec:Te.duration_sec,timestamp:new Date().toLocaleTimeString(),inputImage:!!X};let Qe=null,ye=null;try{if(Qe=await ky(Te.image,xe),ye=Qe.url,!ye)throw new Error("The local server saved the image but did not return a file URL.")}catch(Be){throw console.error("Generated image could not be saved:",Be),new Error(`Image generated but could not be saved to USB: ${Be.message||Be}`)}ce(ye),Ze(Te.seed),$(Te.duration_sec);const lt={...xe,...Qe||{},url:ye};R(Be=>[lt,...Be])}catch(Te){Te.name==="AbortError"?console.log("Generation request was aborted by the user"):(console.error("Generation failed:",Te),le(Te.message||"Generation failed. Please try again.")),ct.current&&clearInterval(ct.current)}finally{D(!1),wt.current=null}},T=async()=>{if(await I({title:"Stop Generation?",message:"The current image generation will be cancelled and the local model server may restart.",confirmLabel:"Stop",danger:!0}))if(ct.current&&clearInterval(ct.current),d(!0),wt.current&&wt.current.abort(),Nl())try{console.log("Cancelling: Stopping server to kill generation threads..."),await Zs(),Y&&(console.log("Cancelling: Restarting server for future generations..."),await ks(Y,j),await Wy()||console.warn("Server failed to restart properly."))}catch(L){console.error("Failed to restart server on cancellation:",L)}finally{d(!1),D(!1),V(0)}else d(!1),D(!1),V(0)},C=async()=>{if(ne)try{if(ne.startsWith("data:image")){const ve=await(await fetch(ne)).blob();await navigator.clipboard.write([new ClipboardItem({[ve.type]:ve})])}else{const L=new Image;L.crossOrigin="anonymous",L.src=ne,L.onload=async()=>{const ve=document.createElement("canvas");ve.width=L.width,ve.height=L.height,ve.getContext("2d").drawImage(L,0,0),ve.toBlob(async pt=>{await navigator.clipboard.write([new ClipboardItem({[pt.type]:pt})])},"image/png")}}ot(!0),setTimeout(()=>ot(!1),2e3)}catch(L){console.error("Failed to copy image:",L)}},q=()=>{if(!ne)return;const L=document.createElement("a");L.href=ne,L.download=`diffusion-${Ge||Date.now()}.png`,document.body.appendChild(L),L.click(),document.body.removeChild(L)},Q=(L,ve=`diffusion-${Date.now()}.png`)=>{if(!L)return;const we=document.createElement("a");we.href=L,we.download=ve,document.body.appendChild(we),we.click(),document.body.removeChild(we)},He=w.useCallback(L=>{b(L.prompt),r(L.negativePrompt),A(ve=>({...ve,steps:L.steps,cfgScale:L.cfgScale,width:L.width,height:L.height,sampler:L.sampler,seed:L.seed})),ce(L.url),Ze(L.seed),$(null)},[b,r,A]),zt=w.useCallback((L,ve)=>{const we=ve.ctrlKey||ve.metaKey||ve.shiftKey;ze(pt=>we?pt.includes(L)?pt.filter(Tt=>Tt!==L):[...pt,L]:[L]),G[L]&&He(G[L])},[G,He]),st=Ue.map(L=>G[L]).filter(Boolean),ge=()=>{ze([])},sn=()=>{st[0]&&He(st[0])},ni=()=>{st.forEach((L,ve)=>{const we=L.seed??Date.now();Q(L.url,`diffusion-${we}-${ve+1}.png`)})},ii=async()=>{if(st.length===0)return;const L=st.length;if(await I({title:"Delete Selected Outputs?",message:`Delete ${L} selected output${L===1?"":"s"} from USB? This removes the image and metadata files.`,confirmLabel:"Delete",danger:!0}))try{await Qy(st);const we=new Set(Ue);R(pt=>pt.filter((Tt,Bt)=>!we.has(Bt))),ze([]),st.some(pt=>pt.url===ne)&&(ce(null),Ze(null),$(null))}catch(we){console.error("Failed to delete selected outputs:",we),re({title:"Delete Failed",message:we.message||String(we),danger:!0})}};return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Generator Dashboard"}),c.jsx("p",{className:"workspace-subtitle",children:"Create high-fidelity images completely locally on your external drive."})]}),c.jsxs("div",{className:"generator-layout",children:[c.jsx("div",{children:c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(vu,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"Generation Workspace"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Positive Prompt"}),c.jsx("textarea",{className:"m3-textarea",value:f,onChange:L=>b(L.target.value),placeholder:"Enter a descriptive prompt (e.g. 'A futuristic city in cyberpunk aesthetic, high details, cinematic lighting')...",disabled:y})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Negative Prompt (Optional)"}),c.jsx("input",{type:"text",className:"m3-input",value:N,onChange:L=>r(L.target.value),placeholder:"Items to avoid (e.g. 'blurry, low quality, deformed hands, texts')...",disabled:y})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Active Image Constraints"}),c.jsxs("div",{className:"chips-container",children:[c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(Vs,{size:14}),c.jsxs("span",{children:["Resolution: ",j.width,"x",j.height]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(ta,{size:14}),c.jsxs("span",{children:["Steps: ",j.steps]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(sy,{size:14}),c.jsxs("span",{children:["CFG: ",j.cfgScale.toFixed(1)]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(vu,{size:14}),c.jsxs("span",{children:["Sampler: ",j.sampler]})]}),c.jsx("div",{className:"status-chip",onClick:()=>ee("constraints"),children:c.jsxs("span",{children:["Seed: ",j.seed===-1?"Random":j.seed]})})]})]}),c.jsxs("div",{className:"image-to-image-section",children:[c.jsx("label",{className:"m3-text-field-label",style:{display:"block",marginBottom:"8px"},children:"Image-to-Image Source (Optional)"}),c.jsxs("div",{className:"image-dropzone",onClick:Al,children:[c.jsx("input",{type:"file",ref:yt,style:{display:"none"},accept:"image/*",onChange:rt,disabled:y}),X?c.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[c.jsx("img",{src:X,className:"dropped-image-preview",alt:"Source"}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{position:"absolute",top:"4px",right:"4px",height:"30px",width:"30px",borderRadius:"50%",padding:0},onClick:al,children:"×"})]}):c.jsxs(c.Fragment,{children:[c.jsx(ly,{size:24,style:{color:"var(--md-sys-color-primary)"}}),c.jsx("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Click or drag image here for Image-to-Image guidance"})]})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"48px",marginTop:"8px"},onClick:sl,disabled:y||!f.trim()||!Y,children:[c.jsx(vu,{size:18}),c.jsx("span",{children:Y?"Generate Local Image":"Select Model to Generate"})]})]})]})}),c.jsxs("div",{className:"m3-card output-panel",children:[c.jsx("div",{className:"output-image-container",children:y||de||z?c.jsx("div",{className:"progress-overlay",children:z?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",padding:"20px"},children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700,textAlign:"center"},children:"Syncing Settings & Initializing..."}),H?c.jsxs("div",{style:{width:"min(360px, 90%)"},children:[c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",fontSize:"0.82rem",fontWeight:700,marginBottom:"6px"},children:[c.jsxs("span",{children:[H.phase,H.speed?` (${H.speed})`:""]}),c.jsx("span",{children:H.total>0?`Loaded ${H.current} / ${H.total} tensors`:`${Math.round(H.progress)}%`})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:0},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${Math.min(100,Math.max(0,H.progress))}%`,transition:"width 0.25s ease"}})}),(H.backendMode||H.device)&&c.jsxs("div",{style:{fontSize:"0.78rem",opacity:.8,textAlign:"center",marginTop:"8px"},children:["Loading on ",H.backendMode||"backend",H.device?` • ${H.device}`:""]})]}):c.jsx("p",{style:{fontSize:"0.85rem",opacity:.8,textAlign:"center",maxWidth:"280px",margin:0},children:"Adjusting inference settings and restarting the local model server."})]}):de?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",padding:"20px"},children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700,textAlign:"center"},children:"Cancelling Generation..."}),c.jsx("p",{style:{fontSize:"0.85rem",opacity:.8,textAlign:"center",maxWidth:"280px",margin:0},children:"Stopping CPU/GPU execution threads and reloading model weights. Please wait a moment."})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700},children:"Generating Locally..."}),K&&c.jsx("div",{style:{fontSize:"0.8rem",color:"var(--md-sys-color-primary)",fontWeight:600,background:"var(--md-sys-color-primary-container)",padding:"4px 12px",borderRadius:"12px",margin:"4px 0 8px 0",animation:"pulse 2s infinite"},children:"⚠️ CPU Fallback Detected (Running Slower)"}),c.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",width:"80%",margin:"8px 0 0 0",fontSize:"0.85rem",opacity:.9},children:[c.jsxs("div",{style:{textAlign:"left"},children:[c.jsx("strong",{children:"Step:"})," ",tt," / ",j.steps," (",j.steps-tt," left)"]}),c.jsxs("div",{style:{textAlign:"right"},children:[c.jsx("strong",{children:"Elapsed:"})," ",qe,"s",x&&` (${x})`]})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:"4px 0 10px 0"},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${U}%`,transition:"width 1s linear"}})}),c.jsxs("div",{style:{fontSize:"0.85rem",opacity:.8,display:"flex",gap:"8px",alignItems:"center"},children:[c.jsxs("span",{children:["Progress: ",U,"%"]}),c.jsx("span",{children:"•"}),c.jsxs("span",{children:["Est. remaining: ",Ke,"s"]})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{marginTop:"16px",height:"36px",padding:"0 24px"},onClick:T,children:"Stop Generating"})]})}):ne?c.jsx("img",{src:ne,className:"output-image",alt:"Generated Output"}):te?c.jsxs("div",{style:{textAlign:"center",padding:"24px",color:"var(--md-sys-color-error)",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[c.jsx("div",{style:{background:"rgba(239, 68, 68, 0.1)",padding:"16px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center"},children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),c.jsx("h3",{style:{margin:0,fontSize:"1.2rem",fontWeight:"bold"},children:"Generation Failed"}),c.jsx("p",{style:{margin:0,fontSize:"0.95rem",opacity:.9,maxWidth:"320px",lineHeight:"1.4"},children:te}),c.jsxs("div",{style:{marginTop:"8px",fontSize:"0.85rem",opacity:.8,color:"var(--md-sys-color-on-surface-variant)"},children:["Hint: Try lowering the resolution in the ",c.jsx("strong",{children:"Image Constraints"})," settings (e.g., to 512x512)."]})]}):c.jsxs("div",{style:{textAlign:"center"},children:[c.jsx(vu,{className:"output-placeholder-icon"}),c.jsxs("p",{className:"output-placeholder-text",children:["Your generated image will appear here.",c.jsx("br",{}),"Enter a prompt on the left and click Generate."]})]})}),ne&&!y&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{width:"100%",display:"flex",justifyContent:"space-between",marginTop:"12px",fontSize:"0.8rem",color:"var(--md-sys-color-outline)"},children:[c.jsxs("span",{children:["Seed: ",Ge]}),ke&&c.jsxs("span",{children:["Inference Time: ",ke.toFixed(1),"s"]})]}),c.jsxs("div",{className:"image-actions",children:[c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:C,children:[je?c.jsx(Ls,{size:16}):c.jsx(V0,{size:16}),c.jsx("span",{children:je?"Copied":"Copy"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:q,children:[c.jsx(am,{size:16}),c.jsx("span",{children:"Save to USB"})]})]})]})]})]}),c.jsxs("div",{className:"gallery-section",children:[c.jsxs("div",{className:"gallery-header",children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:0},children:"Recent Outputs Gallery"}),st.length>0&&c.jsxs("div",{className:"gallery-selection-actions",children:[c.jsxs("span",{className:"gallery-selection-count",children:[st.length," selected"]}),c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:sn,children:[c.jsx(Ls,{size:14}),c.jsx("span",{children:"Use"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:ni,children:[c.jsx(am,{size:14}),c.jsx("span",{children:"Download"})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ii,children:[c.jsx(ti,{size:14}),c.jsx("span",{children:"Delete"})]}),c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:ge,children:"Clear"})]})]}),G.length===0?c.jsx("div",{className:"m3-card gallery-empty",children:"No images generated in this session yet. Everything will be saved directly on your external drive."}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"gallery-hint",children:"Click to select one image. Ctrl-click or Shift-click to select multiple."}),c.jsx("div",{className:"gallery-grid",children:G.map((L,ve)=>c.jsx(e1,{img:L,idx:ve,isSelected:Ue.includes(ve),onClick:zt},L.image||ve))})]})]})]})}const l1=w.memo(t1),a1=[{group:"SDXL - Best Quality",items:[{name:"Juggernaut XL v9 Lightning",filename:"Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors",format:"Safetensors",approxSize:"6.6 GB",resolution:"1024x1024",notes:"Photorealistic SDXL model tuned for 4-8 step Lightning generation.",url:"https://huggingface.co/RunDiffusion/Juggernaut-XL-Lightning/resolve/main/Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors"},{name:"DreamShaper XL Lightning",filename:"DreamShaperXL_Lightning.safetensors",format:"Safetensors",approxSize:"6.6 GB",resolution:"1024x1024",notes:"All-around SDXL model for fantasy art, renders, illustration, and stylized images.",url:"https://huggingface.co/Lykon/dreamshaper-xl-lightning/resolve/main/DreamShaperXL_Lightning.safetensors"},{name:"SDXL Base 1.0 Q4_0 GGUF",filename:"stable-diffusion-xl-base-1.0-Q4_0.gguf",format:"GGUF",approxSize:"3.8 GB",resolution:"1024x1024",notes:"Quantized SDXL base model for lower VRAM or CPU-friendly generation.",url:"https://huggingface.co/hum-ma/SDXL-models-GGUF/resolve/7e15380138e7069ca3aaef5bf0401c3406e3a593/stable-diffusion-xl-base-1.0-Q4_0.gguf"}]},{group:"SD 1.5 - Ultra Fast / Low VRAM",items:[{name:"DreamShaper 8",filename:"DreamShaper_8_pruned.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"General-purpose SD 1.5 model for illustration, anime, and semi-realistic portraits.",url:"https://huggingface.co/Lykon/DreamShaper/resolve/main/DreamShaper_8_pruned.safetensors"},{name:"CyberRealistic V8",filename:"CyberRealistic_V8_FP16.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"High-fidelity realism and photorealism in the SD 1.5 ecosystem.",url:"https://huggingface.co/cyberdelia/CyberRealistic/resolve/main/CyberRealistic_V8_FP16.safetensors"},{name:"ReV Animated v1.2.2",filename:"rev-animated-v1-2-2.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"Semi-realistic, 2.5D, anime, fantasy, and stylized digital art.",url:"https://huggingface.co/danbrown/RevAnimated-v1-2-2/resolve/main/rev-animated-v1-2-2.safetensors"}]}];function n1({activeModel:f,setActiveModel:b,serverRunning:N,setServerRunning:r,constraints:j,showAlert:A=async({message:G})=>window.alert(G),showConfirm:Y=async({message:G})=>window.confirm(G)}){const[G,R]=w.useState([]),[y,D]=w.useState(null),[U,V]=w.useState(0),[ee,X]=w.useState(""),[F,re]=w.useState(null),[I,ne]=w.useState(null),[ce,Ge]=w.useState(null),[Ze,ke]=w.useState({filename:"",speed:"0.0",eta:0,status:""}),[$,je]=w.useState(""),[ot,qe]=w.useState(null),[Me,Ke]=w.useState(!1),[$e,tt]=w.useState({progress:0,phase:""}),[Je,x]=w.useState(null),[O,K]=w.useState({backendMode:"",backendBinary:"",backendDevice:""}),se=G.map(T=>ai(T).filename),de=F!==null||Me;w.useEffect(()=>{B(),d()},[]),w.useEffect(()=>{if(!N&&!F){K({backendMode:"",backendBinary:"",backendDevice:""});return}let T=!1;const C=async()=>{try{const Q=await ba();if(T)return;K({backendMode:Q.settings?.backendMode||Q.loading?.backendMode||"",backendBinary:Q.settings?.backendBinary||Q.loading?.backendBinary||"",backendDevice:Q.settings?.backendDevice||Q.loading?.device||""})}catch{}};C();const q=setInterval(C,2e3);return()=>{T=!0,clearInterval(q)}},[N,F]);const d=async()=>{try{const T=await um();T.active&&T.filename&&z(T.filename)}catch(T){console.error("Check active download failed:",T)}},z=T=>{D(T);const C=setInterval(async()=>{try{const q=await um();q.active?(V(q.progress===-1?0:q.progress),X(`${q.speed} • ETA ${q.eta}s`)):(clearInterval(C),D(null),q.error?String(q.error).toLowerCase().includes("cancelled")||A({title:"Download Failed",message:q.error,danger:!0}):B())}catch(q){console.error("Polling error:",q)}},1e3)},B=async()=>{try{const T=await Yy();R(T.map(ai).filter(C=>C.filename))}catch(T){console.error(T)}},H=async(T,C)=>{if(y||se.includes(C)&&!await Y({title:"Overwrite Model?",message:`"${C}" is already downloaded. Do you want to download and overwrite it?`,confirmLabel:"Overwrite"}))return;const q=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,Q=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!q&&!Q){A({title:"Server Required",message:"Model download requires the local image generator server.",danger:!0});return}try{const He=await Fy(T);He.ok?z(C):A({title:"Download Failed",message:He.error||"Unknown error",danger:!0})}catch(He){A({title:"Download Error",message:He.message,danger:!0})}},P=async T=>{if(T.preventDefault(),!$.trim())return;let C="model.gguf";try{const q=new URL($.trim());if(q.protocol!=="http:"&&q.protocol!=="https:")throw new Error("URL protocol must be http or https");if(C=q.pathname.split("/").pop()||"",!C)throw new Error("Could not extract filename from URL");const Q=C.toLowerCase();if(!Q.endsWith(".gguf")&&!Q.endsWith(".safetensors")&&!Q.endsWith(".ckpt"))throw new Error("URL must point to a .gguf, .safetensors, or .ckpt weights file")}catch(q){A({title:"Invalid URL",message:q.message,danger:!0});return}await H($.trim(),C),je("")},te=T=>{H(T.url,T.filename)},le=async()=>{await Iy(),D(null),V(0),X(""),await B()},Ue=async T=>{if(f&&f!==T&&N){x(T);return}await ze(T)},ze=async T=>{const C=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,q=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!C&&!q){const Q=await rm(),He=`.\\backend\\win\\vulkan\\sd-vulkan.exe --listen-port 8080 --model .\\models\\${T} --threads 8`;Q?await Y({title:"Web Browser Mode",message:`To load "${T}" on the active GPU server, restart your terminal backend with: + `;return{image:`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Ge)))}`,seed:y.seed,duration_sec:3}},U=!!y.image,V={prompt:y.prompt,negative_prompt:y.negative_prompt||"",n:1,size:`${y.width}x${y.height}`,response_format:"b64_json",steps:y.steps,cfg_scale:y.cfg_scale,seed:y.seed,sample_method:y.sampler};U&&(V.init_images=[y.image],V.denoising_strength=y.denoising_strength);try{const ee=await fetch(`${R}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:Y,body:JSON.stringify(V)});if(ee.ok){const k=await ee.json(),F=k?.data?.[0]?.b64_json??k?.images?.[0];if(F)return{image:`data:image/png;base64,${F}`,seed:k.data?.[0]?.seed??y.seed,duration_sec:4.5}}else{let k=`Generation failed (HTTP ${ee.status})`;try{const F=await ee.json();(F?.detail||F?.error?.message)&&(k=F.detail||F.error.message)}catch{}throw new Error(k)}}catch(ee){if(ee.name==="AbortError"||ee.message.startsWith("Generation failed"))throw ee;console.warn("Could not reach local server. Falling back to simulation mode.",ee)}return await D()}async function Ky(f,b,N){if(f instanceof File){const G=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Jy(G,b,N),{response:"Model imported successfully"}}if(Nl()){const{listen:G}=await Oy(async()=>{const{listen:y}=await import("./event-DJ2yZWXo.js");return{listen:y}},[]);let R=null;b&&(R=await G("import-progress",y=>{b(y.payload)}));try{return{response:await xa("import_model_file",{sourcePath:f}),unlisten:R}}catch(y){throw R&&R(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const j=40;for(let G=1;G<=j;G++){if(N?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(U=>setTimeout(U,150));const R=G/j*100,y=40+Math.sin(G)*5+Math.random()*2,D=(j-G)*.15;b&&b({filename:r,progress:R,speed_mb_s:y,eta_secs:D,status:"Copying to USB..."})}const A=localStorage.getItem("imported-models"),Y=A?JSON.parse(A):[];return Y.includes(r)||(Y.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(Y))),{response:"Model imported successfully"}}function Jy(f,b,N){return new Promise((r,j)=>{const A=new XMLHttpRequest,Y=Date.now();let G=!1;A.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),A.setRequestHeader("Content-Type","application/octet-stream");const R=()=>{G=!0,A.abort()};N&&(N.aborted?R():N.addEventListener("abort",R,{once:!0})),A.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const D=Math.max(.1,(Date.now()-Y)/1e3),U=y.loaded/D,V=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:U/(1024*1024),eta_secs:V/Math.max(1,U),status:"Copying to models folder..."})},A.onload=()=>{let y={};try{y=JSON.parse(A.responseText||"{}")}catch{}A.status>=200&&A.status<300&&y.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):j(new Error(y.error||`Import failed (HTTP ${A.status})`))},A.onerror=()=>j(new Error("Import failed while uploading the file.")),A.onabort=()=>j(new DOMException(G?"Import cancelled by user.":"Import aborted.","AbortError")),A.send(f)})}async function $y(f){if(Nl())return await xa("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const j=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),A=await j.json();if(!j.ok)throw new Error(A.error||"Failed to delete model file");return A}catch(j){throw console.error("Failed to delete model via local API:",j),j}const N=localStorage.getItem("imported-models");let r=N?JSON.parse(N):[];return r=r.filter(j=>ai(j).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function rm(){const b="http://127.0.0.1:8080";try{return(await fetch(`${b}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Wy(f=30){const b=Nl()||Sa()?f:3;for(let N=0;NsetTimeout(j,500))}return!1}async function Fy(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(b){return console.error("Failed to start model download:",b),{ok:!1,error:b.message}}}async function Iy(){try{return await(await fetch("/api/cancel-download",{method:"POST"})).json()}catch(f){return console.error("Failed to cancel model download:",f),{ok:!1,error:f.message}}}async function um(){try{return await(await fetch("/api/download-progress")).json()}catch(f){return console.error("Failed to get download progress:",f),{active:!1,error:f.message}}}async function Py(){try{return await(await fetch("/api/generation-progress")).json()}catch(f){return console.error("Failed to get generation progress:",f),{active:!1,error:f.message}}}const e1=w.memo(({img:f,idx:b,isSelected:N,onClick:r})=>{const j=A=>{r(b,A)};return c.jsxs("div",{className:`gallery-item ${N?"selected":""}`,onClick:j,title:`Prompt: ${f.prompt} +Seed: ${f.seed}`,children:[c.jsx("img",{src:f.url,className:"gallery-thumb",alt:"Thumbnail",loading:"lazy",decoding:"async"}),N&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ls,{size:14})})]})});function t1({prompt:f,setPrompt:b,negativePrompt:N,setNegativePrompt:r,constraints:j,setConstraints:A,activeModel:Y,generatedImages:G,setGeneratedImages:R,isGenerating:y,setIsGenerating:D,generationProgress:U,setGenerationProgress:V,setActiveTab:ee,inputImage:k,setInputImage:F,showAlert:re=async({message:ne})=>window.alert(ne),showConfirm:I=async({message:ne})=>window.confirm(ne)}){const[ne,ce]=w.useState(null),[Ge,Ze]=w.useState(null),[Xe,$]=w.useState(null),[je,ot]=w.useState(!1),[qe,Me]=w.useState(0),[Ke,$e]=w.useState(0),[tt,Je]=w.useState(0),[x,O]=w.useState(""),[K,se]=w.useState(!1),[de,d]=w.useState(!1),[z,B]=w.useState(!1),[H,P]=w.useState(null),[te,le]=w.useState(null),[Ue,ze]=w.useState([]),ct=w.useRef(null),yt=w.useRef(null),wt=w.useRef(null),Al=()=>{yt.current.click()},rt=L=>{const ve=L.target.files[0];if(ve){const we=new FileReader;we.onload=()=>{F(we.result)},we.readAsDataURL(ve)}},al=L=>{L.stopPropagation(),F(null),yt.current&&(yt.current.value="")},sl=async()=>{if(!f.trim())return;le(null),B(!0),P(null);let L=!1;try{const Te=await ba();if(Te&&Te.settings){const xe=Te.settings,Qe=xe.model?xe.model.split(/[\\/]/).pop():null,ye=Y?Y.split(/[\\/]/).pop():null;(Qe!==ye||parseInt(xe.steps)!==parseInt(j.steps)||Math.abs(parseFloat(xe.cfgScale)-parseFloat(j.cfgScale))>.05||xe.sampler!==j.sampler||parseInt(xe.threads)!==parseInt(j.threads)||!!xe.useGpu!=(j.useGpu!==!1)||(xe.backendType||(xe.useGpu===!1?"cpu":"auto"))!==(j.backendType||(j.useGpu===!1?"cpu":"auto")))&&(L=!0)}else L=!0}catch{L=!0}if(L)try{console.log("Settings out of sync, restarting backend..."),await Xs(Y,j);let Te=!1,xe=null;for(let Qe=0;Qe<240;Qe++){const ye=await ba();if(ye.loading&&P({progress:ye.loading.progress||0,phase:ye.loading.phase||"Loading model...",speed:ye.loading.speed||"",current:ye.loading.current||0,total:ye.loading.total||0,backendMode:ye.loading.backendMode||ye.settings?.backendMode||"",device:ye.loading.device||ye.settings?.backendDevice||""}),ye.ready){Te=!0;break}if(ye.error){xe=ye.error;break}if(!ye.running&&Qe>3){xe="The backend process terminated immediately on startup.";break}await new Promise(lt=>setTimeout(lt,500))}if(!Te)throw new Error(xe||"Backend server failed to start after applying configuration changes.")}catch(Te){console.error("Failed to restart backend:",Te),le(Te.message||"Failed to sync settings with backend."),B(!1);return}B(!1),P(null),ct.current&&clearInterval(ct.current),D(!0),V(0),Me(0),Je(0),O(""),se(!1),$(null),ce(null);const ve=(j.width>=1024?140:35)*.04,we=j.width>=1024?140:35,pt=(j.backendType||(j.useGpu===!1?"cpu":"auto"))!=="cpu";let Tt=pt?ve:we,Bt=!1,dt=0,Rt=0,Ee=0;$e(Math.round(j.steps*Tt)),ct.current=setInterval(async()=>{Ee++,Me(Ee);try{const Te=await Py();if(Te&&Te.active){const xe=Te.step||0,Qe=Te.steps||j.steps||20,ye=Te.speed||"";Je(xe),O(ye);let lt=0;Qe>0&&(lt=Math.round(xe/Qe*100)),lt=Math.min(99,lt),V(_t=>Math.max(_t,lt));let Be=0;const We=parseFloat(ye);if(!isNaN(We)&&We>0){const _t=Math.max(0,Qe-xe);ye.includes("it/s")?Be=_t/We:ye.includes("s/it")&&(Be=_t*We)}else{const _t=pt?ve:we;Be=Math.max(0,(Qe-xe)*_t)}if(pt&&!Bt){const _t=ye.includes("it/s")&&We<.2,fl=ye.includes("s/it")&&We>5;(_t||fl)&&(Bt=!0,se(!0))}$e(Math.round(Be))}else V(xe=>Math.min(15,xe+1)),$e(xe=>Math.max(1,xe-1))}catch(Te){console.warn("Failed to get generation progress, running simulation fallback:",Te),pt&&!Bt&&Ee>j.steps*ve*1.3&&(Bt=!0,se(!0),Tt=we,dt=Ee,Rt=Math.min(95,Math.round(Ee/(j.steps*ve)*100)));let xe=Math.min(j.steps-1,Math.floor(Ee/Tt)),Qe=j.steps*Tt;if(Ee>=Qe){const Be=Math.ceil(Ee/Math.max(.5,xe));Tt=Math.max(Tt+15,Be+15),Qe=j.steps*Tt,xe=Math.min(j.steps-1,Math.floor(Ee/Tt))}Je(xe);const ye=Math.max(1,Qe-Ee);$e(Math.round(ye));let lt=0;if(Bt){const Be=99-Rt,We=Qe-dt;if(We>0){const _t=Math.min(1,(Ee-dt)/We);if(_t<.85)lt=Math.round(Rt+_t*Be);else{const fl=(Ee-(dt+We*.85))/(Tt*2),Su=1-Math.exp(-fl);lt=Math.min(99,Math.round(Rt+.85*Be+.14*Be*Su))}}else lt=99}else if(EeMath.max(Be,lt))}},1e3);try{wt.current=new AbortController;const Te=await Zy(f,N,j,Y,k,Be=>V(We=>Math.max(We,Be)),wt.current.signal);ct.current&&clearInterval(ct.current),V(100),Je(j.steps),$e(0),O("");const xe={prompt:f,negativePrompt:N,seed:Te.seed,steps:j.steps,cfgScale:j.cfgScale,width:j.width,height:j.height,sampler:j.sampler,model:Y,duration_sec:Te.duration_sec,timestamp:new Date().toLocaleTimeString(),inputImage:!!k};let Qe=null,ye=null;try{if(Qe=await Xy(Te.image,xe),ye=Qe.url,!ye)throw new Error("The local server saved the image but did not return a file URL.")}catch(Be){throw console.error("Generated image could not be saved:",Be),new Error(`Image generated but could not be saved to USB: ${Be.message||Be}`)}ce(ye),Ze(Te.seed),$(Te.duration_sec);const lt={...xe,...Qe||{},url:ye};R(Be=>[lt,...Be])}catch(Te){Te.name==="AbortError"?console.log("Generation request was aborted by the user"):(console.error("Generation failed:",Te),le(Te.message||"Generation failed. Please try again.")),ct.current&&clearInterval(ct.current)}finally{D(!1),wt.current=null}},T=async()=>{if(await I({title:"Stop Generation?",message:"The current image generation will be cancelled and the local model server may restart.",confirmLabel:"Stop",danger:!0}))if(ct.current&&clearInterval(ct.current),d(!0),wt.current&&wt.current.abort(),Nl())try{console.log("Cancelling: Stopping server to kill generation threads..."),await Zs(),Y&&(console.log("Cancelling: Restarting server for future generations..."),await Xs(Y,j),await Wy()||console.warn("Server failed to restart properly."))}catch(L){console.error("Failed to restart server on cancellation:",L)}finally{d(!1),D(!1),V(0)}else d(!1),D(!1),V(0)},C=async()=>{if(ne)try{if(ne.startsWith("data:image")){const ve=await(await fetch(ne)).blob();await navigator.clipboard.write([new ClipboardItem({[ve.type]:ve})])}else{const L=new Image;L.crossOrigin="anonymous",L.src=ne,L.onload=async()=>{const ve=document.createElement("canvas");ve.width=L.width,ve.height=L.height,ve.getContext("2d").drawImage(L,0,0),ve.toBlob(async pt=>{await navigator.clipboard.write([new ClipboardItem({[pt.type]:pt})])},"image/png")}}ot(!0),setTimeout(()=>ot(!1),2e3)}catch(L){console.error("Failed to copy image:",L)}},q=()=>{if(!ne)return;const L=document.createElement("a");L.href=ne,L.download=`diffusion-${Ge||Date.now()}.png`,document.body.appendChild(L),L.click(),document.body.removeChild(L)},Q=(L,ve=`diffusion-${Date.now()}.png`)=>{if(!L)return;const we=document.createElement("a");we.href=L,we.download=ve,document.body.appendChild(we),we.click(),document.body.removeChild(we)},He=w.useCallback(L=>{b(L.prompt),r(L.negativePrompt),A(ve=>({...ve,steps:L.steps,cfgScale:L.cfgScale,width:L.width,height:L.height,sampler:L.sampler,seed:L.seed})),ce(L.url),Ze(L.seed),$(null)},[b,r,A]),zt=w.useCallback((L,ve)=>{const we=ve.ctrlKey||ve.metaKey||ve.shiftKey;ze(pt=>we?pt.includes(L)?pt.filter(Tt=>Tt!==L):[...pt,L]:[L]),G[L]&&He(G[L])},[G,He]),st=Ue.map(L=>G[L]).filter(Boolean),ge=()=>{ze([])},sn=()=>{st[0]&&He(st[0])},ni=()=>{st.forEach((L,ve)=>{const we=L.seed??Date.now();Q(L.url,`diffusion-${we}-${ve+1}.png`)})},ii=async()=>{if(st.length===0)return;const L=st.length;if(await I({title:"Delete Selected Outputs?",message:`Delete ${L} selected output${L===1?"":"s"} from USB? This removes the image and metadata files.`,confirmLabel:"Delete",danger:!0}))try{await Qy(st);const we=new Set(Ue);R(pt=>pt.filter((Tt,Bt)=>!we.has(Bt))),ze([]),st.some(pt=>pt.url===ne)&&(ce(null),Ze(null),$(null))}catch(we){console.error("Failed to delete selected outputs:",we),re({title:"Delete Failed",message:we.message||String(we),danger:!0})}};return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Generator Dashboard"}),c.jsx("p",{className:"workspace-subtitle",children:"Create high-fidelity images completely locally on your external drive."})]}),c.jsxs("div",{className:"generator-layout",children:[c.jsx("div",{children:c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(vu,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"Generation Workspace"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Positive Prompt"}),c.jsx("textarea",{className:"m3-textarea",value:f,onChange:L=>b(L.target.value),placeholder:"Enter a descriptive prompt (e.g. 'A futuristic city in cyberpunk aesthetic, high details, cinematic lighting')...",disabled:y})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Negative Prompt (Optional)"}),c.jsx("input",{type:"text",className:"m3-input",value:N,onChange:L=>r(L.target.value),placeholder:"Items to avoid (e.g. 'blurry, low quality, deformed hands, texts')...",disabled:y})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Active Image Constraints"}),c.jsxs("div",{className:"chips-container",children:[c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(Vs,{size:14}),c.jsxs("span",{children:["Resolution: ",j.width,"x",j.height]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(ta,{size:14}),c.jsxs("span",{children:["Steps: ",j.steps]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(sy,{size:14}),c.jsxs("span",{children:["CFG: ",j.cfgScale.toFixed(1)]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(vu,{size:14}),c.jsxs("span",{children:["Sampler: ",j.sampler]})]}),c.jsx("div",{className:"status-chip",onClick:()=>ee("constraints"),children:c.jsxs("span",{children:["Seed: ",j.seed===-1?"Random":j.seed]})})]})]}),c.jsxs("div",{className:"image-to-image-section",children:[c.jsx("label",{className:"m3-text-field-label",style:{display:"block",marginBottom:"8px"},children:"Image-to-Image Source (Optional)"}),c.jsxs("div",{className:"image-dropzone",onClick:Al,children:[c.jsx("input",{type:"file",ref:yt,style:{display:"none"},accept:"image/*",onChange:rt,disabled:y}),k?c.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[c.jsx("img",{src:k,className:"dropped-image-preview",alt:"Source"}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{position:"absolute",top:"4px",right:"4px",height:"30px",width:"30px",borderRadius:"50%",padding:0},onClick:al,children:"×"})]}):c.jsxs(c.Fragment,{children:[c.jsx(ly,{size:24,style:{color:"var(--md-sys-color-primary)"}}),c.jsx("span",{style:{fontSize:"0.85rem",fontWeight:500},children:"Click or drag image here for Image-to-Image guidance"})]})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"48px",marginTop:"8px"},onClick:sl,disabled:y||!f.trim()||!Y,children:[c.jsx(vu,{size:18}),c.jsx("span",{children:Y?"Generate Local Image":"Select Model to Generate"})]})]})]})}),c.jsxs("div",{className:"m3-card output-panel",children:[c.jsx("div",{className:"output-image-container",children:y||de||z?c.jsx("div",{className:"progress-overlay",children:z?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",padding:"20px"},children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700,textAlign:"center"},children:"Syncing Settings & Initializing..."}),H?c.jsxs("div",{style:{width:"min(360px, 90%)"},children:[c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:"12px",fontSize:"0.82rem",fontWeight:700,marginBottom:"6px"},children:[c.jsxs("span",{children:[H.phase,H.speed?` (${H.speed})`:""]}),c.jsx("span",{children:H.total>0?`Loaded ${H.current} / ${H.total} tensors`:`${Math.round(H.progress)}%`})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:0},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${Math.min(100,Math.max(0,H.progress))}%`,transition:"width 0.25s ease"}})}),(H.backendMode||H.device)&&c.jsxs("div",{style:{fontSize:"0.78rem",opacity:.8,textAlign:"center",marginTop:"8px"},children:["Loading on ",H.backendMode||"backend",H.device?` • ${H.device}`:""]})]}):c.jsx("p",{style:{fontSize:"0.85rem",opacity:.8,textAlign:"center",maxWidth:"280px",margin:0},children:"Adjusting inference settings and restarting the local model server."})]}):de?c.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"16px",padding:"20px"},children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700,textAlign:"center"},children:"Cancelling Generation..."}),c.jsx("p",{style:{fontSize:"0.85rem",opacity:.8,textAlign:"center",maxWidth:"280px",margin:0},children:"Stopping CPU/GPU execution threads and reloading model weights. Please wait a moment."})]}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"progress-spinner"}),c.jsx("div",{className:"progress-text",style:{fontSize:"1.1rem",fontWeight:700},children:"Generating Locally..."}),K&&c.jsx("div",{style:{fontSize:"0.8rem",color:"var(--md-sys-color-primary)",fontWeight:600,background:"var(--md-sys-color-primary-container)",padding:"4px 12px",borderRadius:"12px",margin:"4px 0 8px 0",animation:"pulse 2s infinite"},children:"⚠️ CPU Fallback Detected (Running Slower)"}),c.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px",width:"80%",margin:"8px 0 0 0",fontSize:"0.85rem",opacity:.9},children:[c.jsxs("div",{style:{textAlign:"left"},children:[c.jsx("strong",{children:"Step:"})," ",tt," / ",j.steps," (",j.steps-tt," left)"]}),c.jsxs("div",{style:{textAlign:"right"},children:[c.jsx("strong",{children:"Elapsed:"})," ",qe,"s",x&&` (${x})`]})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:"4px 0 10px 0"},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${U}%`,transition:"width 1s linear"}})}),c.jsxs("div",{style:{fontSize:"0.85rem",opacity:.8,display:"flex",gap:"8px",alignItems:"center"},children:[c.jsxs("span",{children:["Progress: ",U,"%"]}),c.jsx("span",{children:"•"}),c.jsxs("span",{children:["Est. remaining: ",Ke,"s"]})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{marginTop:"16px",height:"36px",padding:"0 24px"},onClick:T,children:"Stop Generating"})]})}):ne?c.jsx("img",{src:ne,className:"output-image",alt:"Generated Output"}):te?c.jsxs("div",{style:{textAlign:"center",padding:"24px",color:"var(--md-sys-color-error)",display:"flex",flexDirection:"column",alignItems:"center",gap:"16px"},children:[c.jsx("div",{style:{background:"rgba(239, 68, 68, 0.1)",padding:"16px",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center"},children:c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"48",height:"48",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",children:c.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})}),c.jsx("h3",{style:{margin:0,fontSize:"1.2rem",fontWeight:"bold"},children:"Generation Failed"}),c.jsx("p",{style:{margin:0,fontSize:"0.95rem",opacity:.9,maxWidth:"320px",lineHeight:"1.4"},children:te}),c.jsxs("div",{style:{marginTop:"8px",fontSize:"0.85rem",opacity:.8,color:"var(--md-sys-color-on-surface-variant)"},children:["Hint: Try lowering the resolution in the ",c.jsx("strong",{children:"Image Constraints"})," settings (e.g., to 512x512)."]})]}):c.jsxs("div",{style:{textAlign:"center"},children:[c.jsx(vu,{className:"output-placeholder-icon"}),c.jsxs("p",{className:"output-placeholder-text",children:["Your generated image will appear here.",c.jsx("br",{}),"Enter a prompt on the left and click Generate."]})]})}),ne&&!y&&c.jsxs(c.Fragment,{children:[c.jsxs("div",{style:{width:"100%",display:"flex",justifyContent:"space-between",marginTop:"12px",fontSize:"0.8rem",color:"var(--md-sys-color-outline)"},children:[c.jsxs("span",{children:["Seed: ",Ge]}),Xe&&c.jsxs("span",{children:["Inference Time: ",Xe.toFixed(1),"s"]})]}),c.jsxs("div",{className:"image-actions",children:[c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:C,children:[je?c.jsx(Ls,{size:16}):c.jsx(V0,{size:16}),c.jsx("span",{children:je?"Copied":"Copy"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:q,children:[c.jsx(am,{size:16}),c.jsx("span",{children:"Save to USB"})]})]})]})]})]}),c.jsxs("div",{className:"gallery-section",children:[c.jsxs("div",{className:"gallery-header",children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:0},children:"Recent Outputs Gallery"}),st.length>0&&c.jsxs("div",{className:"gallery-selection-actions",children:[c.jsxs("span",{className:"gallery-selection-count",children:[st.length," selected"]}),c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:sn,children:[c.jsx(Ls,{size:14}),c.jsx("span",{children:"Use"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:ni,children:[c.jsx(am,{size:14}),c.jsx("span",{children:"Download"})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ii,children:[c.jsx(ti,{size:14}),c.jsx("span",{children:"Delete"})]}),c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:ge,children:"Clear"})]})]}),G.length===0?c.jsx("div",{className:"m3-card gallery-empty",children:"No images generated in this session yet. Everything will be saved directly on your external drive."}):c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"gallery-hint",children:"Click to select one image. Ctrl-click or Shift-click to select multiple."}),c.jsx("div",{className:"gallery-grid",children:G.map((L,ve)=>c.jsx(e1,{img:L,idx:ve,isSelected:Ue.includes(ve),onClick:zt},L.image||ve))})]})]})]})}const l1=w.memo(t1),a1=[{group:"SDXL - Best Quality",items:[{name:"Juggernaut XL v9 Lightning",filename:"Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors",format:"Safetensors",approxSize:"6.6 GB",resolution:"1024x1024",notes:"Photorealistic SDXL model tuned for 4-8 step Lightning generation.",url:"https://huggingface.co/RunDiffusion/Juggernaut-XL-Lightning/resolve/main/Juggernaut_RunDiffusionPhoto2_Lightning_4Steps.safetensors"},{name:"DreamShaper XL Lightning",filename:"DreamShaperXL_Lightning.safetensors",format:"Safetensors",approxSize:"6.6 GB",resolution:"1024x1024",notes:"All-around SDXL model for fantasy art, renders, illustration, and stylized images.",url:"https://huggingface.co/Lykon/dreamshaper-xl-lightning/resolve/main/DreamShaperXL_Lightning.safetensors"},{name:"SDXL Base 1.0 Q4_0 GGUF",filename:"stable-diffusion-xl-base-1.0-Q4_0.gguf",format:"GGUF",approxSize:"3.8 GB",resolution:"1024x1024",notes:"Quantized SDXL base model for lower VRAM or CPU-friendly generation.",url:"https://huggingface.co/hum-ma/SDXL-models-GGUF/resolve/7e15380138e7069ca3aaef5bf0401c3406e3a593/stable-diffusion-xl-base-1.0-Q4_0.gguf"}]},{group:"SD 1.5 - Ultra Fast / Low VRAM",items:[{name:"DreamShaper 8",filename:"DreamShaper_8_pruned.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"General-purpose SD 1.5 model for illustration, anime, and semi-realistic portraits.",url:"https://huggingface.co/Lykon/DreamShaper/resolve/main/DreamShaper_8_pruned.safetensors"},{name:"CyberRealistic V8",filename:"CyberRealistic_V8_FP16.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"High-fidelity realism and photorealism in the SD 1.5 ecosystem.",url:"https://huggingface.co/cyberdelia/CyberRealistic/resolve/main/CyberRealistic_V8_FP16.safetensors"},{name:"ReV Animated v1.2.2",filename:"rev-animated-v1-2-2.safetensors",format:"Safetensors",approxSize:"2.1 GB",resolution:"512x512",notes:"Semi-realistic, 2.5D, anime, fantasy, and stylized digital art.",url:"https://huggingface.co/danbrown/RevAnimated-v1-2-2/resolve/main/rev-animated-v1-2-2.safetensors"}]}];function n1({activeModel:f,setActiveModel:b,serverRunning:N,setServerRunning:r,constraints:j,showAlert:A=async({message:G})=>window.alert(G),showConfirm:Y=async({message:G})=>window.confirm(G)}){const[G,R]=w.useState([]),[y,D]=w.useState(null),[U,V]=w.useState(0),[ee,k]=w.useState(""),[F,re]=w.useState(null),[I,ne]=w.useState(null),[ce,Ge]=w.useState(null),[Ze,Xe]=w.useState({filename:"",speed:"0.0",eta:0,status:""}),[$,je]=w.useState(""),[ot,qe]=w.useState(null),[Me,Ke]=w.useState(!1),[$e,tt]=w.useState({progress:0,phase:""}),[Je,x]=w.useState(null),[O,K]=w.useState({backendMode:"",backendBinary:"",backendDevice:""}),se=G.map(T=>ai(T).filename),de=F!==null||Me;w.useEffect(()=>{B(),d()},[]),w.useEffect(()=>{if(!N&&!F){K({backendMode:"",backendBinary:"",backendDevice:""});return}let T=!1;const C=async()=>{try{const Q=await ba();if(T)return;K({backendMode:Q.settings?.backendMode||Q.loading?.backendMode||"",backendBinary:Q.settings?.backendBinary||Q.loading?.backendBinary||"",backendDevice:Q.settings?.backendDevice||Q.loading?.device||""})}catch{}};C();const q=setInterval(C,2e3);return()=>{T=!0,clearInterval(q)}},[N,F]);const d=async()=>{try{const T=await um();T.active&&T.filename&&z(T.filename)}catch(T){console.error("Check active download failed:",T)}},z=T=>{D(T);const C=setInterval(async()=>{try{const q=await um();q.active?(V(q.progress===-1?0:q.progress),k(`${q.speed} • ETA ${q.eta}s`)):(clearInterval(C),D(null),q.error?String(q.error).toLowerCase().includes("cancelled")||A({title:"Download Failed",message:q.error,danger:!0}):B())}catch(q){console.error("Polling error:",q)}},1e3)},B=async()=>{try{const T=await Yy();R(T.map(ai).filter(C=>C.filename))}catch(T){console.error(T)}},H=async(T,C)=>{if(y||se.includes(C)&&!await Y({title:"Overwrite Model?",message:`"${C}" is already downloaded. Do you want to download and overwrite it?`,confirmLabel:"Overwrite"}))return;const q=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,Q=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!q&&!Q){A({title:"Server Required",message:"Model download requires the local image generator server.",danger:!0});return}try{const He=await Fy(T);He.ok?z(C):A({title:"Download Failed",message:He.error||"Unknown error",danger:!0})}catch(He){A({title:"Download Error",message:He.message,danger:!0})}},P=async T=>{if(T.preventDefault(),!$.trim())return;let C="model.gguf";try{const q=new URL($.trim());if(q.protocol!=="http:"&&q.protocol!=="https:")throw new Error("URL protocol must be http or https");if(C=q.pathname.split("/").pop()||"",!C)throw new Error("Could not extract filename from URL");const Q=C.toLowerCase();if(!Q.endsWith(".gguf")&&!Q.endsWith(".safetensors")&&!Q.endsWith(".ckpt"))throw new Error("URL must point to a .gguf, .safetensors, or .ckpt weights file")}catch(q){A({title:"Invalid URL",message:q.message,danger:!0});return}await H($.trim(),C),je("")},te=T=>{H(T.url,T.filename)},le=async()=>{await Iy(),D(null),V(0),k(""),await B()},Ue=async T=>{if(f&&f!==T&&N){x(T);return}await ze(T)},ze=async T=>{const C=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,q=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!C&&!q){const Q=await rm(),He=`.\\backend\\win\\vulkan\\sd-vulkan.exe --listen-port 8080 --model .\\models\\${T} --threads 8`;Q?await Y({title:"Web Browser Mode",message:`To load "${T}" on the active GPU server, restart your terminal backend with: ${He} @@ -115,6 +115,6 @@ To run locally, start: ${He} -Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(T),r(!1));return}re(T),ne({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:T,backendMode:"",backendBinary:"",device:""});try{const Q=await ks(T,j);console.log(Q);let He=!1,zt=null;for(let st=0;st<240;st++){const ge=await ba();if(ge.loading&&ne({progress:ge.loading.progress||0,phase:ge.loading.phase||"Loading model...",speed:ge.loading.speed||"",current:ge.loading.current||0,total:ge.loading.total||0,model:ge.loading.model||T,backendMode:ge.loading.backendMode||ge.settings?.backendMode||"",backendBinary:ge.loading.backendBinary||ge.settings?.backendBinary||"",device:ge.loading.device||ge.settings?.backendDevice||""}),ge.ready){He=!0;break}if(ge.error){zt=ge.error;break}if(!ge.running&&st>3){zt="The backend process terminated immediately on startup.";break}await new Promise(sn=>setTimeout(sn,500))}if(He)ne(st=>({...st||{},progress:100,phase:"Model ready",speed:"",current:st?.current||0,total:st?.total||0,model:T})),b(T),r(!0);else throw new Error(zt||"Model server failed to respond on port 8080.")}catch(Q){console.error("Failed to load model:",Q),A({title:"Model Load Failed",message:Q.message||String(Q),danger:!0})}finally{setTimeout(()=>ne(null),800),re(null)}},ct=async()=>{const T=Je;x(null),await yt(),T&&await ze(T)},yt=async()=>{if(Me)return;Ke(!0),tt({progress:10,phase:"Stopping backend process..."});const T=setInterval(async()=>{try{const C=await ba();C.unloading?.active?tt({progress:C.unloading.progress||50,phase:C.unloading.phase||"Unloading model..."}):tt(q=>({progress:Math.min(95,q.progress+10),phase:q.phase||"Unloading model..."}))}catch{}},300);try{await Zs(),tt({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(C){console.error(C),A({title:"Unload Failed",message:C.message||String(C),danger:!0})}finally{clearInterval(T),setTimeout(()=>{Ke(!1),tt({progress:0,phase:""})},500)}},wt=async T=>{if(await Y({title:"Delete Model?",message:`Delete "${T}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await $y(T),await B(),f===T&&await yt()}catch(C){console.error("Failed to delete model:",C),A({title:"Delete Failed",message:C.message||String(C),danger:!0})}},Al=async(T,C)=>{const q=new AbortController;qe(q),Ge(0),ke({filename:C,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Ky(T,Q=>{Ge(Math.round(Q.progress)),ke({filename:Q.filename,speed:Q.speed_mb_s.toFixed(1),eta:Math.round(Q.eta_secs),status:Q.status})},q.signal),await B()}catch(Q){console.error("Import failed:",Q),Q.name!=="AbortError"&&A({title:"Import Failed",message:Q.message||String(Q),danger:!0})}finally{Ge(null),qe(null)}},rt=()=>{ot&&ot.abort()},al=T=>{const C=T.target.files[0];C&&Al(C,C.name),T.target.value=""},sl=!!y;return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Model Manager"}),c.jsx("p",{className:"workspace-subtitle",children:"Manage local files and download recommended weights directly to your local models folder."})]}),f&&c.jsx("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",background:"var(--md-sys-color-primary-container)",color:"var(--md-sys-color-on-primary-container)"},children:c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{children:[c.jsxs("h4",{style:{fontWeight:700},children:["Active Model: ",f]}),c.jsx("p",{style:{fontSize:"0.85rem",marginTop:"2px",opacity:.9},children:"The local C++ stable-diffusion server is running. Real-time telemetry is displaying performance status in the top bar."}),(O.backendMode||O.backendDevice||O.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[O.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loaded on ",O.backendMode]})]}),O.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendDevice})}),O.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:yt,disabled:Me||F!==null,children:[Me?c.jsx(ta,{className:"progress-spinner",size:16}):c.jsx(ti,{size:16}),c.jsx("span",{children:Me?"Unloading":"Unload Server"})]})]})}),Me&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-error)",marginTop:"16px"},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"8px"},children:"Unloading Model"}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{children:$e.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round($e.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,$e.progress))}%`,transition:"width 0.25s ease"}})})]})]}),I&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-secondary)",marginTop:"16px"},children:[c.jsxs("h4",{style:{fontWeight:700,marginBottom:"8px"},children:["Loading Model: ",I.model||F]}),(I.backendMode||I.backendBinary||I.device)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"10px"},children:[I.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loading on ",I.backendMode]})]}),I.device&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:I.device})}),I.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:I.backendBinary})})]}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{children:[I.phase,I.speed?` (${I.speed})`:""]}),c.jsx("span",{children:I.total>0?`Loaded ${I.current} / ${I.total} tensors`:`${Math.round(I.progress)}%`})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,I.progress))}%`,transition:"width 0.25s ease"}})})]})]}),c.jsxs("div",{className:"m3-card",style:{marginTop:"24px"},children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(Ys,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"Local Models (",G.length,")"]}),G.length===0?c.jsx("p",{style:{fontSize:"0.9rem",color:"var(--md-sys-color-outline)",textAlign:"center",padding:"16px 0"},children:"No models detected in app/models/. Download from the library below or import a file."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:G.map(T=>{const C=T.filename,q=f===C;return c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",background:q?"var(--md-sys-color-primary-container)":"var(--md-sys-color-surface-variant)",color:q?"var(--md-sys-color-on-primary-container)":"var(--md-sys-color-on-surface-variant)",borderRadius:"var(--md-shape-corner-medium)",border:"1px solid var(--md-sys-color-outline-variant)"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[c.jsx("span",{style:{fontWeight:600,fontSize:"0.95rem"},children:C}),c.jsxs("span",{style:{fontSize:"0.75rem",opacity:.8},children:["Local Weights File • ",T.size||li(T.sizeBytes)]})]}),c.jsx("div",{style:{display:"flex",gap:"8px"},children:q?c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"36px",padding:"0 16px"},onClick:yt,disabled:Me,children:[Me?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ti,{size:14}),c.jsx("span",{children:Me?"Unloading":"Unload"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"36px",padding:"0 16px"},onClick:()=>Ue(C),disabled:de,children:[F===C?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(Ys,{size:14}),c.jsx("span",{children:F===C?"Loading":"Load"})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{height:"36px",width:"36px",padding:0,minWidth:"36px"},onClick:()=>wt(C),disabled:de,title:"Delete from models folder",children:c.jsx(ti,{size:14})})]})})]},C)})})]}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(oy,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Model Library"]})}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:a1.map(T=>c.jsxs("div",{className:"m3-card",style:{margin:0},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"12px"},children:T.group}),c.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"12px"},children:T.items.map(C=>{const q=se.includes(C.filename),Q=y===C.filename;return c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",padding:"14px",background:"var(--md-sys-color-surface-variant)",border:"1px solid var(--md-sys-color-outline-variant)",borderRadius:"var(--md-shape-corner-medium)"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[c.jsx("span",{style:{fontWeight:700},children:C.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)"},children:[C.format," • approx. ",C.approxSize," • ",C.resolution]})]}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--md-sys-color-on-surface-variant)",lineHeight:1.35,margin:0},children:C.notes}),Q&&c.jsxs("div",{className:"model-progress-section",style:{marginTop:"2px"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"8px"},children:[c.jsx("span",{className:"loading-dot"}),"Downloading"]}),c.jsx("span",{children:U>0?`${U}%`:"Preparing"})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,U))}%`,transition:"width 0.2s ease"}})}),ee&&c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"4px"},children:ee})]}),c.jsxs("button",{className:q?"m3-btn m3-btn-tonal":"m3-btn m3-btn-filled",style:{height:"36px",marginTop:"auto"},onClick:()=>te(C),disabled:q||y!==null,children:[q?c.jsx(bu,{size:14}):Q?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(lm,{size:14}),c.jsx("span",{children:q?"Downloaded":Q?"Downloading":"Download"})]})]},C.filename)})})]},T.group))}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(nm,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Local Model Import"]})}),ce!==null&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",marginTop:"24px"},children:[c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px"},children:[c.jsxs("h4",{style:{fontWeight:600},children:["Copying Model to local folder: ",Ze.filename]}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:rt,children:[c.jsx(Xs,{size:14}),c.jsx("span",{children:"Stop Import"})]})]}),c.jsxs("div",{className:"model-progress-section",style:{margin:"12px 0 6px 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{children:[Ze.status," (",Ze.speed," MB/s)"]}),c.jsxs("span",{children:[ce,"% (",Ze.eta,"s remaining)"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${ce}%`,transition:"width 0.15s ease"}})})]})]}),c.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"16px",marginTop:"16px"},children:[c.jsxs("label",{className:"import-box",style:{margin:0,height:"100%",justifyContent:"center"},children:[c.jsx("input",{type:"file",style:{display:"none"},accept:".gguf,.safetensors,.ckpt",onChange:al,disabled:ce!==null}),c.jsx(nm,{className:"import-icon"}),c.jsx("span",{style:{fontWeight:600},children:"Choose weights file"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",textAlign:"center"},children:"Select `.gguf`, `.safetensors` or `.ckpt` weights."})]}),c.jsxs("div",{className:"m3-card",style:{display:"flex",flexDirection:"column",justifyContent:"center",margin:0,padding:"20px"},children:[c.jsxs("h4",{style:{fontWeight:600,marginBottom:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[c.jsx(lm,{size:16}),"Download Model from URL"]}),c.jsx("p",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginBottom:"12px"},children:"Download any GGUF or Safetensors model from Hugging Face or other sites directly to your models folder."}),sl?c.jsxs("div",{className:"model-progress-section",style:{marginTop:"0px"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{style:{fontSize:"0.75rem",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"200px"},title:y,children:y}),c.jsxs("span",{children:[U,"%"]})]}),c.jsx("div",{className:"model-progress-bar",style:{margin:"4px 0"},children:c.jsx("div",{className:"model-progress-fill",style:{width:`${U}%`,transition:"width 0.15s ease"}})}),c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"2px"},children:ee}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px",marginTop:"10px"},onClick:le,children:[c.jsx(Xs,{size:14}),c.jsx("span",{children:"Stop Download"})]})]}):c.jsxs("form",{onSubmit:P,style:{display:"flex",gap:"8px"},children:[c.jsx("input",{type:"text",className:"m3-input",style:{flex:1,height:"40px"},placeholder:"e.g. https://huggingface.co/...",value:$,onChange:T=>je(T.target.value),disabled:y!==null}),c.jsx("button",{type:"submit",className:"m3-btn m3-btn-filled",style:{height:"40px"},disabled:y!==null,children:"Download"})]})]})]}),Je&&c.jsx("div",{style:{position:"fixed",inset:0,zIndex:50,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},children:c.jsxs("div",{className:"m3-card",style:{maxWidth:"460px",width:"100%",margin:0,border:"1px solid var(--md-sys-color-outline-variant)"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[c.jsx(Ty,{size:22,style:{color:"var(--md-sys-color-error)"}}),c.jsx("h3",{style:{fontSize:"1.05rem",fontWeight:700},children:"Unload Current Model?"})]}),c.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--md-sys-color-on-surface-variant)",lineHeight:1.45,marginBottom:"16px"},children:['"',f,'" is already loaded. Unload it before loading "',Je,'".']}),c.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>x(null),disabled:Me,children:"Cancel"}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:yt,disabled:Me,children:[c.jsx(ti,{size:14}),c.jsx("span",{children:"Unload Only"})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",onClick:ct,disabled:Me,children:[Me?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ta,{size:14}),c.jsx("span",{children:"Unload and Load"})]})]})]})})]})}const i1=w.memo(n1),cm=[{id:"1:1",label:"1:1 Square",width:512,height:512,sdxl_width:1024,sdxl_height:1024,desc:"Social posts & avatars"},{id:"4:3",label:"4:3 Photo",width:640,height:480,sdxl_width:1152,sdxl_height:864,desc:"Classic photo look"},{id:"16:9",label:"16:9 Landscape",width:768,height:432,sdxl_width:1216,sdxl_height:684,desc:"Widescreen landscape"},{id:"9:16",label:"9:16 Portrait",width:432,height:768,sdxl_width:684,sdxl_height:1216,desc:"Tall phone screen"}],u1=f=>{if(!f)return!0;const b=f.toLowerCase();return!(b.includes("flux")||b.includes("schnell")||b.includes("sdxl")||b.includes("lightning")||b.includes("turbo")||b.includes("sd3"))};function c1({constraints:f,setConstraints:b,activeModel:N,specs:r,backendOptions:j}){const A=N?u1(N):!1,Y=j?.options?.length?j.options:[{id:"cpu",label:"CPU",available:!0}],G=(D,U)=>{b(V=>({...V,[D]:U}))},R=(D,U)=>{const V=U==="sdxl"&&!A,ee=cm.find(X=>X.id===D);if(ee){let X=V?ee.sdxl_width:ee.width,F=V?ee.sdxl_height:ee.height;A&&(X>F?(F=Math.round(F*512/X),X=512):(X=Math.round(X*512/F),F=512),X=Math.round(X/64)*64,F=Math.round(F/64)*64),G("width",X),G("height",F)}},y=D=>{b(U=>({...U,backendType:D,useGpu:D!=="cpu"}))};return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Image Constraints"}),c.jsx("p",{className:"workspace-subtitle",children:"Configure size, quality, and performance controls for image generation."})]}),c.jsxs("div",{className:"generator-layout",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(J0,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"1. Picture Size & Shape"]}),A&&c.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.1)",border:"1px solid rgb(251, 191, 36)",color:"var(--md-sys-color-on-surface)",padding:"12px",borderRadius:"8px",marginBottom:"16px",fontSize:"0.85rem",display:"flex",gap:"8px",alignItems:"flex-start"},children:[c.jsx(uy,{size:16,style:{color:"rgb(251, 191, 36)",flexShrink:0,marginTop:"2px"}}),c.jsxs("div",{children:[c.jsx("strong",{children:"Low-VRAM Protection Active:"})," Capped at 512x512 for the loaded SD 1.x model (",c.jsx("code",{children:N}),"). Generating at larger sizes (like 1024x1024) is disabled to prevent out-of-memory crashes on your ",r&&r.gpu_name&&!r.gpu_name.includes("Loading")?r.gpu_name:"graphics processor","."]})]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"AI Generation Engine Optimization"}),c.jsxs("div",{className:"m3-segmented-button",children:[A?c.jsx("div",{className:"m3-segment-item disabled",style:{opacity:.5,cursor:"not-allowed",textDecoration:"line-through",backgroundColor:"var(--md-sys-color-surface-variant)"},title:"High Quality Mode is disabled for SD 1.x models.",children:"High Quality Mode (1024px)"}):c.jsx("div",{className:`m3-segment-item ${f.width>=1024?"active":""}`,onClick:()=>{G("width",1024),G("height",1024)},children:"High Quality Mode (1024px)"}),c.jsx("div",{className:`m3-segment-item ${f.width<1024||A?"active":""}`,onClick:()=>{G("width",512),G("height",512)},children:"Standard Speed Mode (512px)"})]}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"4px"},children:A?"*Standard Speed Mode (512px) is forced for SD 1.5 / custom models to ensure stable local generations.":"*Use High Quality (1024px) for Flux or SDXL models. Use Standard (512px) for SD 1.5."})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Select Shape (Aspect Ratio)"}),c.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:cm.map(D=>{const U=Math.abs(f.width/f.height-D.width/D.height)<.1;return c.jsxs("button",{className:`m3-btn m3-btn-outlined aspect-ratio-btn ${U?"active":""}`,style:{height:"86px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"8px",borderRadius:"var(--md-shape-corner-medium)",borderColor:"var(--md-sys-color-outline-variant)"},onClick:()=>R(D.id,A?"sd15":f.width>=1024?"sdxl":"sd15"),children:[c.jsx("div",{className:`aspect-ratio-preview ratio-${D.id.replace(":","-")}`}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem",marginTop:"2px"},children:D.label}),c.jsx("span",{style:{fontSize:"0.68rem",opacity:.7},children:A?`Max: ${D.id==="1:1"?"512x512":D.id==="4:3"?"512x384":D.id==="16:9"?"512x288":"288x512"}`:D.desc})]},D.id)})})]})]})]}),c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(Vs,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"2. Quality, Speed & Logic"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-slider-group",children:[c.jsxs("div",{className:"m3-slider-header",children:[c.jsx("span",{className:"m3-slider-label",children:"Detail Steps (Inference speed)"}),c.jsxs("span",{className:"m3-slider-value",children:[f.steps," steps"]})]}),c.jsx("input",{type:"range",className:"m3-slider",value:f.steps,onChange:D=>G("steps",parseInt(D.target.value)),min:"1",max:"60"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",lineHeight:"1.3"},children:"The number of times the AI cleans up the image. More steps = sharper details, but takes longer."})]}),c.jsxs("div",{className:"m3-slider-group",style:{marginTop:"8px"},children:[c.jsxs("div",{className:"m3-slider-header",children:[c.jsx("span",{className:"m3-slider-label",children:"Prompt Strictness (Instruction obedience)"}),c.jsx("span",{className:"m3-slider-value",children:f.cfgScale.toFixed(1)})]}),c.jsx("input",{type:"range",className:"m3-slider",value:f.cfgScale,onChange:D=>G("cfgScale",parseFloat(D.target.value)),min:"1",max:"15",step:"0.5"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",lineHeight:"1.3"},children:"How closely the AI follows your text prompt. Lower = more creative. Higher = more strict."})]}),c.jsxs("div",{className:"m3-text-field",style:{marginTop:"8px"},children:[c.jsx("label",{className:"m3-text-field-label",children:"Image Blueprint (DNA Seed)"}),c.jsxs("div",{style:{display:"flex",gap:"8px"},children:[c.jsx("input",{type:"number",className:"m3-input",value:f.seed,onChange:D=>G("seed",parseInt(D.target.value)||-1),placeholder:"-1 for a brand new image...",style:{flex:1,height:"40px"}}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:()=>G("seed",-1),style:{height:"40px"},children:"Random (-1)"})]})]})]})]})]}),c.jsx("div",{children:c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(om,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"3. System Settings"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Generation Backend"}),c.jsx("div",{className:"m3-segmented-button",children:Y.map(D=>c.jsx("div",{className:`m3-segment-item ${f.backendType===D.id||!f.backendType&&D.id==="cpu"?"active":""}`,onClick:()=>y(D.id),title:D.id==="cuda"?"CUDA appears only when an NVIDIA CUDA backend is available.":void 0,children:D.label},D.id))}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"4px",lineHeight:1.35},children:"CPU is slow but safest. Vulkan works on supported GPUs. CUDA is shown only when NVIDIA CUDA support is available."}),j?.unavailable?.length>0&&c.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"4px"},children:j.unavailable.map(D=>c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-error)",lineHeight:1.35},children:[D.label," unavailable: ",D.reason]},D.id))})]}),c.jsxs("div",{className:"m3-text-field",style:{marginTop:"20px"},children:[c.jsx("label",{className:"m3-text-field-label",children:"Memory Optimization (GPU VRAM)"}),c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"14px",marginTop:"10px"},children:[c.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",fontSize:"0.85rem"},children:[c.jsx("input",{type:"checkbox",checked:f.vaeTiling!==!1,onChange:D=>G("vaeTiling",D.target.checked),style:{width:"16px",height:"16px",marginTop:"3px",accentColor:"var(--md-sys-color-primary)",cursor:"pointer"}}),c.jsxs("div",{children:[c.jsx("strong",{style:{color:"var(--md-sys-color-on-surface)"},children:"Enable VAE Tiling"}),c.jsx("div",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"2px",lineHeight:1.35},children:"Processes VAE decoding in smaller tiles. Drastically reduces VRAM usage (from 2GB+ down to ~100MB) with no speed loss. Highly recommended for GPUs with 4GB-6GB VRAM."})]})]}),c.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",fontSize:"0.85rem"},children:[c.jsx("input",{type:"checkbox",checked:f.vaeOnCpu===!0,onChange:D=>G("vaeOnCpu",D.target.checked),style:{width:"16px",height:"16px",marginTop:"3px",accentColor:"var(--md-sys-color-primary)",cursor:"pointer"}}),c.jsxs("div",{children:[c.jsx("strong",{style:{color:"var(--md-sys-color-on-surface)"},children:"Run VAE on CPU"}),c.jsx("div",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"2px",lineHeight:1.35},children:"Offloads the heavy VAE decoder computation from GPU VRAM to system memory (RAM). Saves ~2GB of VRAM, but makes the final decoding stage slightly slower."})]})]})]})]})]})]})})]})]})}const s1=w.memo(c1);function f1(){const f=w.useRef(null),[b,N]=w.useState(null),r=w.useCallback(T=>{const C=f.current;f.current=null,N(null),C&&C(T)},[]),j=w.useCallback(({title:T="Confirm Action",message:C,confirmLabel:q="OK",cancelLabel:Q="Cancel",danger:He=!1})=>new Promise(zt=>{f.current=zt,N({type:"confirm",title:T,message:C,confirmLabel:q,cancelLabel:Q,danger:He})}),[]),A=w.useCallback(({title:T="Notice",message:C,confirmLabel:q="OK",danger:Q=!1})=>new Promise(He=>{f.current=He,N({type:"alert",title:T,message:C,confirmLabel:q,danger:Q})}),[]),[Y,G]=w.useState(()=>{const T=localStorage.getItem("theme");return T||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")});w.useEffect(()=>{document.documentElement.setAttribute("data-theme",Y),localStorage.setItem("theme",Y)},[Y]);const[R,y]=w.useState("generator"),[D,U]=w.useState(""),[V,ee]=w.useState(""),[X,F]=w.useState(null),[re,I]=w.useState(null),[ne,ce]=w.useState(!1),[Ge,Ze]=w.useState(!1),[ke,$]=w.useState({options:[{id:"cpu",label:"CPU",available:!0}],cudaAvailable:!1,vulkanAvailable:!1,defaultBackendType:"cpu"}),[je,ot]=w.useState(null),[qe,Me]=w.useState([]),[Ke,$e]=w.useState(!1),[tt,Je]=w.useState(!1),[x,O]=w.useState([]),[K,se]=w.useState(!1),[de,d]=w.useState(0),[z,B]=w.useState({os_name:"Loading Specs...",cpu_name:"Loading Specs...",cpu_cores_physical:4,cpu_cores_logical:8,ram_total_gb:0,gpu_name:"Loading Specs..."}),[H,P]=w.useState({cpu_usage:0,ram_used_gb:0,ram_total_gb:0,gpu_name:"Detecting...",vram_used_gb:0,vram_total_gb:0}),[te,le]=w.useState({width:1024,height:1024,steps:4,cfgScale:1,sampler:"euler_a",seed:-1,denoisingStrength:.7,useGpu:!0,useTaesd:!0,useFlashAttn:!0,useTiling:!1,vaeTiling:!0,vaeOnCpu:!1,threads:4,backendType:"auto"});w.useEffect(()=>{async function T(){try{const C=await Gy(),q=await Ly();$(q),B(C),le(Q=>({...Q,threads:C.cpu_cores_physical||4,backendType:Q.backendType==="auto"?q.defaultBackendType||"cpu":Q.backendType,useGpu:(Q.backendType==="auto"?q.defaultBackendType:Q.backendType)!=="cpu"}))}catch(C){console.error("Error fetching hardware specs:",C)}}T()},[]);const Ue=w.useCallback(async()=>{$e(!0);try{const[T,C]=await Promise.all([wy(),Ry().catch(()=>[])]);ot(T),Me(C)}finally{$e(!1)}},[]);w.useEffect(()=>{Ue()},[Ue]);const ze=w.useCallback(async()=>{try{const T=await By();await navigator.clipboard.writeText(JSON.stringify(T,null,2)),Je(!0),setTimeout(()=>Je(!1),1800)}catch(T){A({title:"Diagnostics Failed",message:T.message||String(T),danger:!0})}},[A]),ct=w.useCallback(async()=>{if(qe.length===0)return;const T=qe.reduce((q,Q)=>q+Number(Q.sizeBytes||0),0);if(await j({title:"Clean Safe Files?",message:`Delete ${qe.length} temporary/cache item${qe.length===1?"":"s"} and free about ${li(T)}? +Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(T),r(!1));return}re(T),ne({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:T,backendMode:"",backendBinary:"",device:""});try{const Q=await Xs(T,j);console.log(Q);let He=!1,zt=null;for(let st=0;st<240;st++){const ge=await ba();if(ge.loading&&ne({progress:ge.loading.progress||0,phase:ge.loading.phase||"Loading model...",speed:ge.loading.speed||"",current:ge.loading.current||0,total:ge.loading.total||0,model:ge.loading.model||T,backendMode:ge.loading.backendMode||ge.settings?.backendMode||"",backendBinary:ge.loading.backendBinary||ge.settings?.backendBinary||"",device:ge.loading.device||ge.settings?.backendDevice||""}),ge.ready){He=!0;break}if(ge.error){zt=ge.error;break}if(!ge.running&&st>3){zt="The backend process terminated immediately on startup.";break}await new Promise(sn=>setTimeout(sn,500))}if(He)ne(st=>({...st||{},progress:100,phase:"Model ready",speed:"",current:st?.current||0,total:st?.total||0,model:T})),b(T),r(!0);else throw new Error(zt||"Model server failed to respond on port 8080.")}catch(Q){console.error("Failed to load model:",Q),A({title:"Model Load Failed",message:Q.message||String(Q),danger:!0})}finally{setTimeout(()=>ne(null),800),re(null)}},ct=async()=>{const T=Je;x(null),await yt(),T&&await ze(T)},yt=async()=>{if(Me)return;Ke(!0),tt({progress:10,phase:"Stopping backend process..."});const T=setInterval(async()=>{try{const C=await ba();C.unloading?.active?tt({progress:C.unloading.progress||50,phase:C.unloading.phase||"Unloading model..."}):tt(q=>({progress:Math.min(95,q.progress+10),phase:q.phase||"Unloading model..."}))}catch{}},300);try{await Zs(),tt({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(C){console.error(C),A({title:"Unload Failed",message:C.message||String(C),danger:!0})}finally{clearInterval(T),setTimeout(()=>{Ke(!1),tt({progress:0,phase:""})},500)}},wt=async T=>{if(await Y({title:"Delete Model?",message:`Delete "${T}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await $y(T),await B(),f===T&&await yt()}catch(C){console.error("Failed to delete model:",C),A({title:"Delete Failed",message:C.message||String(C),danger:!0})}},Al=async(T,C)=>{const q=new AbortController;qe(q),Ge(0),Xe({filename:C,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Ky(T,Q=>{Ge(Math.round(Q.progress)),Xe({filename:Q.filename,speed:Q.speed_mb_s.toFixed(1),eta:Math.round(Q.eta_secs),status:Q.status})},q.signal),await B()}catch(Q){console.error("Import failed:",Q),Q.name!=="AbortError"&&A({title:"Import Failed",message:Q.message||String(Q),danger:!0})}finally{Ge(null),qe(null)}},rt=()=>{ot&&ot.abort()},al=T=>{const C=T.target.files[0];C&&Al(C,C.name),T.target.value=""},sl=!!y;return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Model Manager"}),c.jsx("p",{className:"workspace-subtitle",children:"Manage local files and download recommended weights directly to your local models folder."})]}),f&&c.jsx("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",background:"var(--md-sys-color-primary-container)",color:"var(--md-sys-color-on-primary-container)"},children:c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[c.jsxs("div",{children:[c.jsxs("h4",{style:{fontWeight:700},children:["Active Model: ",f]}),c.jsx("p",{style:{fontSize:"0.85rem",marginTop:"2px",opacity:.9},children:"The local C++ stable-diffusion server is running. Real-time telemetry is displaying performance status in the top bar."}),(O.backendMode||O.backendDevice||O.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[O.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loaded on ",O.backendMode]})]}),O.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendDevice})}),O.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:O.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:yt,disabled:Me||F!==null,children:[Me?c.jsx(ta,{className:"progress-spinner",size:16}):c.jsx(ti,{size:16}),c.jsx("span",{children:Me?"Unloading":"Unload Server"})]})]})}),Me&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-error)",marginTop:"16px"},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"8px"},children:"Unloading Model"}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{children:$e.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round($e.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,$e.progress))}%`,transition:"width 0.25s ease"}})})]})]}),I&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-secondary)",marginTop:"16px"},children:[c.jsxs("h4",{style:{fontWeight:700,marginBottom:"8px"},children:["Loading Model: ",I.model||F]}),(I.backendMode||I.backendBinary||I.device)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"10px"},children:[I.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(bu,{size:14}),c.jsxs("span",{children:["Loading on ",I.backendMode]})]}),I.device&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:I.device})}),I.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:I.backendBinary})})]}),c.jsxs("div",{className:"model-progress-section",style:{margin:"8px 0 0 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{children:[I.phase,I.speed?` (${I.speed})`:""]}),c.jsx("span",{children:I.total>0?`Loaded ${I.current} / ${I.total} tensors`:`${Math.round(I.progress)}%`})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,I.progress))}%`,transition:"width 0.25s ease"}})})]})]}),c.jsxs("div",{className:"m3-card",style:{marginTop:"24px"},children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(Ys,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"Local Models (",G.length,")"]}),G.length===0?c.jsx("p",{style:{fontSize:"0.9rem",color:"var(--md-sys-color-outline)",textAlign:"center",padding:"16px 0"},children:"No models detected in app/models/. Download from the library below or import a file."}):c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:G.map(T=>{const C=T.filename,q=f===C;return c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",background:q?"var(--md-sys-color-primary-container)":"var(--md-sys-color-surface-variant)",color:q?"var(--md-sys-color-on-primary-container)":"var(--md-sys-color-on-surface-variant)",borderRadius:"var(--md-shape-corner-medium)",border:"1px solid var(--md-sys-color-outline-variant)"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[c.jsx("span",{style:{fontWeight:600,fontSize:"0.95rem"},children:C}),c.jsxs("span",{style:{fontSize:"0.75rem",opacity:.8},children:["Local Weights File • ",T.size||li(T.sizeBytes)]})]}),c.jsx("div",{style:{display:"flex",gap:"8px"},children:q?c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"36px",padding:"0 16px"},onClick:yt,disabled:Me,children:[Me?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ti,{size:14}),c.jsx("span",{children:Me?"Unloading":"Unload"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"36px",padding:"0 16px"},onClick:()=>Ue(C),disabled:de,children:[F===C?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(Ys,{size:14}),c.jsx("span",{children:F===C?"Loading":"Load"})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{height:"36px",width:"36px",padding:0,minWidth:"36px"},onClick:()=>wt(C),disabled:de,title:"Delete from models folder",children:c.jsx(ti,{size:14})})]})})]},C)})})]}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(oy,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Model Library"]})}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:a1.map(T=>c.jsxs("div",{className:"m3-card",style:{margin:0},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"12px"},children:T.group}),c.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"12px"},children:T.items.map(C=>{const q=se.includes(C.filename),Q=y===C.filename;return c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"10px",padding:"14px",background:"var(--md-sys-color-surface-variant)",border:"1px solid var(--md-sys-color-outline-variant)",borderRadius:"var(--md-shape-corner-medium)"},children:[c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"4px"},children:[c.jsx("span",{style:{fontWeight:700},children:C.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)"},children:[C.format," • approx. ",C.approxSize," • ",C.resolution]})]}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--md-sys-color-on-surface-variant)",lineHeight:1.35,margin:0},children:C.notes}),Q&&c.jsxs("div",{className:"model-progress-section",style:{marginTop:"2px"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"8px"},children:[c.jsx("span",{className:"loading-dot"}),"Downloading"]}),c.jsx("span",{children:U>0?`${U}%`:"Preparing"})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,U))}%`,transition:"width 0.2s ease"}})}),ee&&c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"4px"},children:ee})]}),c.jsxs("button",{className:q?"m3-btn m3-btn-tonal":"m3-btn m3-btn-filled",style:{height:"36px",marginTop:"auto"},onClick:()=>te(C),disabled:q||y!==null,children:[q?c.jsx(bu,{size:14}):Q?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(lm,{size:14}),c.jsx("span",{children:q?"Downloaded":Q?"Downloading":"Download"})]})]},C.filename)})})]},T.group))}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(nm,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Local Model Import"]})}),ce!==null&&c.jsxs("div",{className:"m3-card",style:{borderLeft:"4px solid var(--md-sys-color-primary)",marginTop:"24px"},children:[c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px"},children:[c.jsxs("h4",{style:{fontWeight:600},children:["Copying Model to local folder: ",Ze.filename]}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:rt,children:[c.jsx(ks,{size:14}),c.jsx("span",{children:"Stop Import"})]})]}),c.jsxs("div",{className:"model-progress-section",style:{margin:"12px 0 6px 0"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsxs("span",{children:[Ze.status," (",Ze.speed," MB/s)"]}),c.jsxs("span",{children:[ce,"% (",Ze.eta,"s remaining)"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${ce}%`,transition:"width 0.15s ease"}})})]})]}),c.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(300px, 1fr))",gap:"16px",marginTop:"16px"},children:[c.jsxs("label",{className:"import-box",style:{margin:0,height:"100%",justifyContent:"center"},children:[c.jsx("input",{type:"file",style:{display:"none"},accept:".gguf,.safetensors,.ckpt",onChange:al,disabled:ce!==null}),c.jsx(nm,{className:"import-icon"}),c.jsx("span",{style:{fontWeight:600},children:"Choose weights file"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",textAlign:"center"},children:"Select `.gguf`, `.safetensors` or `.ckpt` weights."})]}),c.jsxs("div",{className:"m3-card",style:{display:"flex",flexDirection:"column",justifyContent:"center",margin:0,padding:"20px"},children:[c.jsxs("h4",{style:{fontWeight:600,marginBottom:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[c.jsx(lm,{size:16}),"Download Model from URL"]}),c.jsx("p",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginBottom:"12px"},children:"Download any GGUF or Safetensors model from Hugging Face or other sites directly to your models folder."}),sl?c.jsxs("div",{className:"model-progress-section",style:{marginTop:"0px"},children:[c.jsxs("div",{className:"model-progress-label",children:[c.jsx("span",{style:{fontSize:"0.75rem",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"200px"},title:y,children:y}),c.jsxs("span",{children:[U,"%"]})]}),c.jsx("div",{className:"model-progress-bar",style:{margin:"4px 0"},children:c.jsx("div",{className:"model-progress-fill",style:{width:`${U}%`,transition:"width 0.15s ease"}})}),c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"2px"},children:ee}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px",marginTop:"10px"},onClick:le,children:[c.jsx(ks,{size:14}),c.jsx("span",{children:"Stop Download"})]})]}):c.jsxs("form",{onSubmit:P,style:{display:"flex",gap:"8px"},children:[c.jsx("input",{type:"text",className:"m3-input",style:{flex:1,height:"40px"},placeholder:"e.g. https://huggingface.co/...",value:$,onChange:T=>je(T.target.value),disabled:y!==null}),c.jsx("button",{type:"submit",className:"m3-btn m3-btn-filled",style:{height:"40px"},disabled:y!==null,children:"Download"})]})]})]}),Je&&c.jsx("div",{style:{position:"fixed",inset:0,zIndex:50,background:"rgba(0,0,0,0.55)",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px"},children:c.jsxs("div",{className:"m3-card",style:{maxWidth:"460px",width:"100%",margin:0,border:"1px solid var(--md-sys-color-outline-variant)"},children:[c.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"10px",marginBottom:"10px"},children:[c.jsx(Ty,{size:22,style:{color:"var(--md-sys-color-error)"}}),c.jsx("h3",{style:{fontSize:"1.05rem",fontWeight:700},children:"Unload Current Model?"})]}),c.jsxs("p",{style:{fontSize:"0.9rem",color:"var(--md-sys-color-on-surface-variant)",lineHeight:1.45,marginBottom:"16px"},children:['"',f,'" is already loaded. Unload it before loading "',Je,'".']}),c.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>x(null),disabled:Me,children:"Cancel"}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:yt,disabled:Me,children:[c.jsx(ti,{size:14}),c.jsx("span",{children:"Unload Only"})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",onClick:ct,disabled:Me,children:[Me?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ta,{size:14}),c.jsx("span",{children:"Unload and Load"})]})]})]})})]})}const i1=w.memo(n1),cm=[{id:"1:1",label:"1:1 Square",width:512,height:512,sdxl_width:1024,sdxl_height:1024,desc:"Social posts & avatars"},{id:"4:3",label:"4:3 Photo",width:640,height:480,sdxl_width:1152,sdxl_height:864,desc:"Classic photo look"},{id:"16:9",label:"16:9 Landscape",width:768,height:432,sdxl_width:1216,sdxl_height:684,desc:"Widescreen landscape"},{id:"9:16",label:"9:16 Portrait",width:432,height:768,sdxl_width:684,sdxl_height:1216,desc:"Tall phone screen"}],u1=f=>{if(!f)return!0;const b=f.toLowerCase();return!(b.includes("flux")||b.includes("schnell")||b.includes("sdxl")||b.includes("lightning")||b.includes("turbo")||b.includes("sd3"))};function c1({constraints:f,setConstraints:b,activeModel:N,specs:r,backendOptions:j}){const A=N?u1(N):!1,Y=j?.options?.length?j.options:[{id:"cpu",label:"CPU",available:!0}],G=(D,U)=>{b(V=>({...V,[D]:U}))},R=(D,U)=>{const V=U==="sdxl"&&!A,ee=cm.find(k=>k.id===D);if(ee){let k=V?ee.sdxl_width:ee.width,F=V?ee.sdxl_height:ee.height;A&&(k>F?(F=Math.round(F*512/k),k=512):(k=Math.round(k*512/F),F=512),k=Math.round(k/64)*64,F=Math.round(F/64)*64),G("width",k),G("height",F)}},y=D=>{b(U=>({...U,backendType:D,useGpu:D!=="cpu"}))};return c.jsxs("div",{className:"workspace-area",children:[c.jsxs("div",{className:"workspace-title-section",children:[c.jsx("h2",{className:"workspace-title",children:"Image Constraints"}),c.jsx("p",{className:"workspace-subtitle",children:"Configure size, quality, and performance controls for image generation."})]}),c.jsxs("div",{className:"generator-layout",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(J0,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"1. Picture Size & Shape"]}),A&&c.jsxs("div",{style:{background:"rgba(251, 191, 36, 0.1)",border:"1px solid rgb(251, 191, 36)",color:"var(--md-sys-color-on-surface)",padding:"12px",borderRadius:"8px",marginBottom:"16px",fontSize:"0.85rem",display:"flex",gap:"8px",alignItems:"flex-start"},children:[c.jsx(uy,{size:16,style:{color:"rgb(251, 191, 36)",flexShrink:0,marginTop:"2px"}}),c.jsxs("div",{children:[c.jsx("strong",{children:"Low-VRAM Protection Active:"})," Capped at 512x512 for the loaded SD 1.x model (",c.jsx("code",{children:N}),"). Generating at larger sizes (like 1024x1024) is disabled to prevent out-of-memory crashes on your ",r&&r.gpu_name&&!r.gpu_name.includes("Loading")?r.gpu_name:"graphics processor","."]})]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"AI Generation Engine Optimization"}),c.jsxs("div",{className:"m3-segmented-button",children:[A?c.jsx("div",{className:"m3-segment-item disabled",style:{opacity:.5,cursor:"not-allowed",textDecoration:"line-through",backgroundColor:"var(--md-sys-color-surface-variant)"},title:"High Quality Mode is disabled for SD 1.x models.",children:"High Quality Mode (1024px)"}):c.jsx("div",{className:`m3-segment-item ${f.width>=1024?"active":""}`,onClick:()=>{G("width",1024),G("height",1024)},children:"High Quality Mode (1024px)"}),c.jsx("div",{className:`m3-segment-item ${f.width<1024||A?"active":""}`,onClick:()=>{G("width",512),G("height",512)},children:"Standard Speed Mode (512px)"})]}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"4px"},children:A?"*Standard Speed Mode (512px) is forced for SD 1.5 / custom models to ensure stable local generations.":"*Use High Quality (1024px) for Flux or SDXL models. Use Standard (512px) for SD 1.5."})]}),c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Select Shape (Aspect Ratio)"}),c.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px"},children:cm.map(D=>{const U=Math.abs(f.width/f.height-D.width/D.height)<.1;return c.jsxs("button",{className:`m3-btn m3-btn-outlined aspect-ratio-btn ${U?"active":""}`,style:{height:"86px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"8px",borderRadius:"var(--md-shape-corner-medium)",borderColor:"var(--md-sys-color-outline-variant)"},onClick:()=>R(D.id,A?"sd15":f.width>=1024?"sdxl":"sd15"),children:[c.jsx("div",{className:`aspect-ratio-preview ratio-${D.id.replace(":","-")}`}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem",marginTop:"2px"},children:D.label}),c.jsx("span",{style:{fontSize:"0.68rem",opacity:.7},children:A?`Max: ${D.id==="1:1"?"512x512":D.id==="4:3"?"512x384":D.id==="16:9"?"512x288":"288x512"}`:D.desc})]},D.id)})})]})]})]}),c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(Vs,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"2. Quality, Speed & Logic"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-slider-group",children:[c.jsxs("div",{className:"m3-slider-header",children:[c.jsx("span",{className:"m3-slider-label",children:"Detail Steps (Inference speed)"}),c.jsxs("span",{className:"m3-slider-value",children:[f.steps," steps"]})]}),c.jsx("input",{type:"range",className:"m3-slider",value:f.steps,onChange:D=>G("steps",parseInt(D.target.value)),min:"1",max:"60"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",lineHeight:"1.3"},children:"The number of times the AI cleans up the image. More steps = sharper details, but takes longer."})]}),c.jsxs("div",{className:"m3-slider-group",style:{marginTop:"8px"},children:[c.jsxs("div",{className:"m3-slider-header",children:[c.jsx("span",{className:"m3-slider-label",children:"Prompt Strictness (Instruction obedience)"}),c.jsx("span",{className:"m3-slider-value",children:f.cfgScale.toFixed(1)})]}),c.jsx("input",{type:"range",className:"m3-slider",value:f.cfgScale,onChange:D=>G("cfgScale",parseFloat(D.target.value)),min:"1",max:"15",step:"0.5"}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",lineHeight:"1.3"},children:"How closely the AI follows your text prompt. Lower = more creative. Higher = more strict."})]}),c.jsxs("div",{className:"m3-text-field",style:{marginTop:"8px"},children:[c.jsx("label",{className:"m3-text-field-label",children:"Image Blueprint (DNA Seed)"}),c.jsxs("div",{style:{display:"flex",gap:"8px"},children:[c.jsx("input",{type:"number",className:"m3-input",value:f.seed,onChange:D=>G("seed",parseInt(D.target.value)||-1),placeholder:"-1 for a brand new image...",style:{flex:1,height:"40px"}}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:()=>G("seed",-1),style:{height:"40px"},children:"Random (-1)"})]})]})]})]})]}),c.jsx("div",{children:c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(om,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"3. System Settings"]}),c.jsxs("div",{className:"m3-field-group",children:[c.jsxs("div",{className:"m3-text-field",children:[c.jsx("label",{className:"m3-text-field-label",children:"Generation Backend"}),c.jsx("div",{className:"m3-segmented-button",children:Y.map(D=>c.jsx("div",{className:`m3-segment-item ${f.backendType===D.id||!f.backendType&&D.id==="cpu"?"active":""}`,onClick:()=>y(D.id),title:D.id==="cuda"?"CUDA appears only when an NVIDIA CUDA backend is available.":void 0,children:D.label},D.id))}),c.jsx("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"4px",lineHeight:1.35},children:"CPU is slow but safest. Vulkan works on supported GPUs. CUDA is shown only when NVIDIA CUDA support is available."}),f.backendType==="cuda"&&r?.gpu_name&&String(r.gpu_name).toLowerCase().includes("gtx")&&c.jsxs("div",{style:{marginTop:"12px",padding:"10px 14px",background:"rgba(239, 68, 68, 0.08)",border:"1px dashed rgb(239, 68, 68)",borderRadius:"8px",fontSize:"0.75rem",color:"var(--md-sys-color-on-surface)",lineHeight:"1.45"},children:[c.jsx("strong",{children:"Performance Alert:"})," Your graphics card (",c.jsx("code",{children:r.gpu_name}),") is a GTX-series GPU which lacks hardware ",c.jsx("strong",{children:"Tensor Cores"}),". Running in CUDA mode will be up to 3x slower. We strongly recommend switching to ",c.jsx("strong",{children:"Vulkan GPU"})," for optimal generation speed."]}),j?.unavailable?.length>0&&c.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"4px"},children:j.unavailable.map(D=>c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-error)",lineHeight:1.35},children:[D.label," unavailable: ",D.reason]},D.id))})]}),c.jsxs("div",{className:"m3-text-field",style:{marginTop:"20px"},children:[c.jsx("label",{className:"m3-text-field-label",children:"Memory Optimization (GPU VRAM)"}),c.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"14px",marginTop:"10px"},children:[c.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",fontSize:"0.85rem"},children:[c.jsx("input",{type:"checkbox",checked:f.vaeTiling!==!1,onChange:D=>G("vaeTiling",D.target.checked),style:{width:"16px",height:"16px",marginTop:"3px",accentColor:"var(--md-sys-color-primary)",cursor:"pointer"}}),c.jsxs("div",{children:[c.jsx("strong",{style:{color:"var(--md-sys-color-on-surface)"},children:"Enable VAE Tiling"}),c.jsx("div",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"2px",lineHeight:1.35},children:"Processes VAE decoding in smaller tiles. Drastically reduces VRAM usage (from 2GB+ down to ~100MB) with no speed loss. Highly recommended for GPUs with 4GB-6GB VRAM."})]})]}),c.jsxs("label",{style:{display:"flex",alignItems:"flex-start",gap:"10px",cursor:"pointer",fontSize:"0.85rem"},children:[c.jsx("input",{type:"checkbox",checked:f.vaeOnCpu===!0,onChange:D=>G("vaeOnCpu",D.target.checked),style:{width:"16px",height:"16px",marginTop:"3px",accentColor:"var(--md-sys-color-primary)",cursor:"pointer"}}),c.jsxs("div",{children:[c.jsx("strong",{style:{color:"var(--md-sys-color-on-surface)"},children:"Run VAE on CPU"}),c.jsx("div",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)",marginTop:"2px",lineHeight:1.35},children:"Offloads the heavy VAE decoder computation from GPU VRAM to system memory (RAM). Saves ~2GB of VRAM, but makes the final decoding stage slightly slower."})]})]})]})]})]})]})})]})]})}const s1=w.memo(c1);function f1(){const f=w.useRef(null),[b,N]=w.useState(null),r=w.useCallback(T=>{const C=f.current;f.current=null,N(null),C&&C(T)},[]),j=w.useCallback(({title:T="Confirm Action",message:C,confirmLabel:q="OK",cancelLabel:Q="Cancel",danger:He=!1})=>new Promise(zt=>{f.current=zt,N({type:"confirm",title:T,message:C,confirmLabel:q,cancelLabel:Q,danger:He})}),[]),A=w.useCallback(({title:T="Notice",message:C,confirmLabel:q="OK",danger:Q=!1})=>new Promise(He=>{f.current=He,N({type:"alert",title:T,message:C,confirmLabel:q,danger:Q})}),[]),[Y,G]=w.useState(()=>{const T=localStorage.getItem("theme");return T||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")});w.useEffect(()=>{document.documentElement.setAttribute("data-theme",Y),localStorage.setItem("theme",Y)},[Y]);const[R,y]=w.useState("generator"),[D,U]=w.useState(""),[V,ee]=w.useState(""),[k,F]=w.useState(null),[re,I]=w.useState(null),[ne,ce]=w.useState(!1),[Ge,Ze]=w.useState(!1),[Xe,$]=w.useState({options:[{id:"cpu",label:"CPU",available:!0}],cudaAvailable:!1,vulkanAvailable:!1,defaultBackendType:"cpu"}),[je,ot]=w.useState(null),[qe,Me]=w.useState([]),[Ke,$e]=w.useState(!1),[tt,Je]=w.useState(!1),[x,O]=w.useState([]),[K,se]=w.useState(!1),[de,d]=w.useState(0),[z,B]=w.useState({os_name:"Loading Specs...",cpu_name:"Loading Specs...",cpu_cores_physical:4,cpu_cores_logical:8,ram_total_gb:0,gpu_name:"Loading Specs..."}),[H,P]=w.useState({cpu_usage:0,ram_used_gb:0,ram_total_gb:0,gpu_name:"Detecting...",vram_used_gb:0,vram_total_gb:0}),[te,le]=w.useState({width:1024,height:1024,steps:4,cfgScale:1,sampler:"euler_a",seed:-1,denoisingStrength:.7,useGpu:!0,useTaesd:!0,useFlashAttn:!0,useTiling:!1,vaeTiling:!0,vaeOnCpu:!1,threads:4,backendType:"auto"});w.useEffect(()=>{async function T(){try{const C=await Gy(),q=await Ly();$(q),B(C),le(Q=>({...Q,threads:C.cpu_cores_physical||4,backendType:Q.backendType==="auto"?q.defaultBackendType||"cpu":Q.backendType,useGpu:(Q.backendType==="auto"?q.defaultBackendType:Q.backendType)!=="cpu"}))}catch(C){console.error("Error fetching hardware specs:",C)}}T()},[]);const Ue=w.useCallback(async()=>{$e(!0);try{const[T,C]=await Promise.all([wy(),Ry().catch(()=>[])]);ot(T),Me(C)}finally{$e(!1)}},[]);w.useEffect(()=>{Ue()},[Ue]);const ze=w.useCallback(async()=>{try{const T=await By();await navigator.clipboard.writeText(JSON.stringify(T,null,2)),Je(!0),setTimeout(()=>Je(!1),1800)}catch(T){A({title:"Diagnostics Failed",message:T.message||String(T),danger:!0})}},[A]),ct=w.useCallback(async()=>{if(qe.length===0)return;const T=qe.reduce((q,Q)=>q+Number(Q.sizeBytes||0),0);if(await j({title:"Clean Safe Files?",message:`Delete ${qe.length} temporary/cache item${qe.length===1?"":"s"} and free about ${li(T)}? -Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){$e(!0);try{await Hy(qe.map(q=>q.id)),await Ue()}catch(q){A({title:"Cleanup Failed",message:q.message||String(q),danger:!0})}finally{$e(!1)}}},[qe,Ue,A,j]);w.useEffect(()=>{async function T(){const C=await Xy();O(C)}T()},[]),w.useEffect(()=>{re?localStorage.setItem("active-model",re):localStorage.removeItem("active-model")},[re]),w.useEffect(()=>{let T=null;async function C(){const q=await ba();if(!!q.ready){T&&clearInterval(T);const He=localStorage.getItem("active-model");if(He)I(He),ce(!0);else{try{if(q&&q.settings&&q.settings.model){const zt=q.settings.model.split(/[\\/]/).pop();I(zt)}}catch{}ce(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const zt=localStorage.getItem("active-model");zt&&(I(zt),ce(!1))}}return C(),T=setInterval(C,2e3),()=>{T&&clearInterval(T)}},[]),w.useEffect(()=>{async function T(){try{const q=await qy();P(Q=>Q.cpu_usage===q.cpu_usage&&Q.ram_used_gb===q.ram_used_gb&&Q.ram_total_gb===q.ram_total_gb&&Q.gpu_name===q.gpu_name&&Q.vram_used_gb===q.vram_used_gb&&Q.vram_total_gb===q.vram_total_gb?Q:q)}catch{}}T();const C=setInterval(T,1500);return()=>clearInterval(C)},[]),w.useEffect(()=>{if(re){const T=re.toLowerCase();T.includes("flux")||T.includes("schnell")?le(C=>({...C,steps:4,cfgScale:1,width:1024,height:1024})):T.includes("lightning")||T.includes("turbo")?le(C=>({...C,steps:4,cfgScale:1.5,width:1024,height:1024})):T.includes("sd15")?le(C=>({...C,steps:25,cfgScale:7,width:512,height:512})):T.includes("sd35")?le(C=>({...C,steps:20,cfgScale:4.5,width:1024,height:1024})):le(C=>({...C,steps:20,cfgScale:7,width:512,height:512}))}},[re]);const yt=w.useMemo(()=>{switch(R){case"generator":return c.jsx(l1,{prompt:D,setPrompt:U,negativePrompt:V,setNegativePrompt:ee,constraints:te,setConstraints:le,activeModel:re,generatedImages:x,setGeneratedImages:O,isGenerating:K,setIsGenerating:se,generationProgress:de,setGenerationProgress:d,setActiveTab:y,inputImage:X,setInputImage:F,showAlert:A,showConfirm:j});case"models":return c.jsx(i1,{activeModel:re,setActiveModel:I,serverRunning:ne,setServerRunning:ce,constraints:te,showAlert:A,showConfirm:j});case"constraints":return c.jsx(s1,{constraints:te,setConstraints:le,activeModel:re,specs:z,backendOptions:ke});default:return null}},[R,D,V,te,re,x,K,de,X,ne,z,ke,A,j]),wt=w.useMemo(()=>c.jsx(Ey,{activeTab:R,setActiveTab:y,specs:z}),[R,z]),Al=w.useCallback(async()=>{if(!(!ne||Ge)){Ze(!0);try{await Zs(),ce(!1),I(null)}catch(T){console.error("Failed to stop server:",T),A({title:"Stop Server Failed",message:T.message||String(T),danger:!0})}finally{Ze(!1)}}},[ne,Ge,A]),rt=[...je?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...je?.issues||[]],al=qe.reduce((T,C)=>T+Number(C.sizeBytes||0),0),sl=!!(je&&(rt.length>0||qe.length>0));return c.jsxs("div",{className:"app-container",children:[wt,c.jsxs("div",{className:"main-content",children:[c.jsx(Ay,{telemetry:H,serverRunning:ne,activeModel:re,onStopServer:Al,isStoppingServer:Ge,theme:Y,setTheme:G}),sl&&c.jsxs("div",{className:`m3-card readiness-card ${je?.stale||rt.length>0?"readiness-card-warning":""}`,children:[c.jsxs("div",{className:"readiness-header",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:"4px"},children:je?.stale?"Restart Required":rt.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:je?.stale?`Running server build: ${je.build||"unknown"}`:rt.length>0?"Local AI Image Generator found setup items that may need attention.":`${qe.length} temporary item${qe.length===1?"":"s"} can be cleaned (${li(al)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:Ue,disabled:Ke,children:Ke?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:ze,children:tt?"Copied":"Copy Diagnostics"}),qe.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ct,disabled:Ke,children:["Clean ",li(al)]})]})]}),rt.length>0&&c.jsx("div",{className:"readiness-issues",children:rt.slice(0,4).map(T=>c.jsx("span",{children:T},T))}),qe.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:qe.slice(0,3).map(T=>c.jsxs("span",{title:T.path,children:[T.name," · ",T.size," · ",T.reason]},T.id))})]}),yt]}),b&&c.jsx("div",{className:"app-dialog-backdrop",role:"presentation",children:c.jsxs("div",{className:"app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"app-dialog-title",children:[c.jsx("h3",{id:"app-dialog-title",className:"app-dialog-title",children:b.title}),c.jsx("p",{className:"app-dialog-message",children:b.message}),c.jsxs("div",{className:"app-dialog-actions",children:[b.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:b.cancelLabel}),c.jsx("button",{className:`m3-btn ${b.danger?"m3-btn-error":"m3-btn-filled"}`,onClick:()=>r(!0),children:b.confirmLabel})]})]})})]})}B0.createRoot(document.getElementById("root")).render(c.jsx(E0.StrictMode,{children:c.jsx(f1,{})}));export{xa as i,o1 as t}; +Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){$e(!0);try{await Hy(qe.map(q=>q.id)),await Ue()}catch(q){A({title:"Cleanup Failed",message:q.message||String(q),danger:!0})}finally{$e(!1)}}},[qe,Ue,A,j]);w.useEffect(()=>{async function T(){const C=await ky();O(C)}T()},[]),w.useEffect(()=>{re?localStorage.setItem("active-model",re):localStorage.removeItem("active-model")},[re]),w.useEffect(()=>{let T=null;async function C(){const q=await ba();if(!!q.ready){T&&clearInterval(T);const He=localStorage.getItem("active-model");if(He)I(He),ce(!0);else{try{if(q&&q.settings&&q.settings.model){const zt=q.settings.model.split(/[\\/]/).pop();I(zt)}}catch{}ce(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const zt=localStorage.getItem("active-model");zt&&(I(zt),ce(!1))}}return C(),T=setInterval(C,2e3),()=>{T&&clearInterval(T)}},[]),w.useEffect(()=>{async function T(){try{const q=await qy();P(Q=>Q.cpu_usage===q.cpu_usage&&Q.ram_used_gb===q.ram_used_gb&&Q.ram_total_gb===q.ram_total_gb&&Q.gpu_name===q.gpu_name&&Q.vram_used_gb===q.vram_used_gb&&Q.vram_total_gb===q.vram_total_gb?Q:q)}catch{}}T();const C=setInterval(T,1500);return()=>clearInterval(C)},[]),w.useEffect(()=>{if(re){const T=re.toLowerCase();T.includes("flux")||T.includes("schnell")?le(C=>({...C,steps:4,cfgScale:1,width:1024,height:1024})):T.includes("lightning")||T.includes("turbo")?le(C=>({...C,steps:4,cfgScale:1.5,width:1024,height:1024})):T.includes("sd15")?le(C=>({...C,steps:25,cfgScale:7,width:512,height:512})):T.includes("sd35")?le(C=>({...C,steps:20,cfgScale:4.5,width:1024,height:1024})):le(C=>({...C,steps:20,cfgScale:7,width:512,height:512}))}},[re]);const yt=w.useMemo(()=>{switch(R){case"generator":return c.jsx(l1,{prompt:D,setPrompt:U,negativePrompt:V,setNegativePrompt:ee,constraints:te,setConstraints:le,activeModel:re,generatedImages:x,setGeneratedImages:O,isGenerating:K,setIsGenerating:se,generationProgress:de,setGenerationProgress:d,setActiveTab:y,inputImage:k,setInputImage:F,showAlert:A,showConfirm:j});case"models":return c.jsx(i1,{activeModel:re,setActiveModel:I,serverRunning:ne,setServerRunning:ce,constraints:te,showAlert:A,showConfirm:j});case"constraints":return c.jsx(s1,{constraints:te,setConstraints:le,activeModel:re,specs:z,backendOptions:Xe});default:return null}},[R,D,V,te,re,x,K,de,k,ne,z,Xe,A,j]),wt=w.useMemo(()=>c.jsx(Ey,{activeTab:R,setActiveTab:y,specs:z}),[R,z]),Al=w.useCallback(async()=>{if(!(!ne||Ge)){Ze(!0);try{await Zs(),ce(!1),I(null)}catch(T){console.error("Failed to stop server:",T),A({title:"Stop Server Failed",message:T.message||String(T),danger:!0})}finally{Ze(!1)}}},[ne,Ge,A]),rt=[...je?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...je?.issues||[]],al=qe.reduce((T,C)=>T+Number(C.sizeBytes||0),0),sl=!!(je&&(rt.length>0||qe.length>0));return c.jsxs("div",{className:"app-container",children:[wt,c.jsxs("div",{className:"main-content",children:[c.jsx(Ay,{telemetry:H,serverRunning:ne,activeModel:re,onStopServer:Al,isStoppingServer:Ge,theme:Y,setTheme:G}),sl&&c.jsxs("div",{className:`m3-card readiness-card ${je?.stale||rt.length>0?"readiness-card-warning":""}`,children:[c.jsxs("div",{className:"readiness-header",children:[c.jsxs("div",{children:[c.jsx("h3",{className:"m3-card-title",style:{marginBottom:"4px"},children:je?.stale?"Restart Required":rt.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:je?.stale?`Running server build: ${je.build||"unknown"}`:rt.length>0?"Local AI Image Generator found setup items that may need attention.":`${qe.length} temporary item${qe.length===1?"":"s"} can be cleaned (${li(al)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:Ue,disabled:Ke,children:Ke?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:ze,children:tt?"Copied":"Copy Diagnostics"}),qe.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ct,disabled:Ke,children:["Clean ",li(al)]})]})]}),rt.length>0&&c.jsx("div",{className:"readiness-issues",children:rt.slice(0,4).map(T=>c.jsx("span",{children:T},T))}),qe.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:qe.slice(0,3).map(T=>c.jsxs("span",{title:T.path,children:[T.name," · ",T.size," · ",T.reason]},T.id))})]}),yt]}),b&&c.jsx("div",{className:"app-dialog-backdrop",role:"presentation",children:c.jsxs("div",{className:"app-dialog",role:"dialog","aria-modal":"true","aria-labelledby":"app-dialog-title",children:[c.jsx("h3",{id:"app-dialog-title",className:"app-dialog-title",children:b.title}),c.jsx("p",{className:"app-dialog-message",children:b.message}),c.jsxs("div",{className:"app-dialog-actions",children:[b.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:b.cancelLabel}),c.jsx("button",{className:`m3-btn ${b.danger?"m3-btn-error":"m3-btn-filled"}`,onClick:()=>r(!0),children:b.confirmLabel})]})]})})]})}B0.createRoot(document.getElementById("root")).render(c.jsx(E0.StrictMode,{children:c.jsx(f1,{})}));export{xa as i,o1 as t}; diff --git a/app/dist/index.html b/app/dist/index.html index c363715..b07261e 100644 --- a/app/dist/index.html +++ b/app/dist/index.html @@ -8,7 +8,7 @@ Local AI Image Generator - + diff --git a/app/frontend/src/components/ImageConstraints.jsx b/app/frontend/src/components/ImageConstraints.jsx index 2417593..53ffb90 100644 --- a/app/frontend/src/components/ImageConstraints.jsx +++ b/app/frontend/src/components/ImageConstraints.jsx @@ -281,6 +281,20 @@ function ImageConstraints({ constraints, setConstraints, activeModel, specs, bac CPU is slow but safest. Vulkan works on supported GPUs. CUDA is shown only when NVIDIA CUDA support is available. + {constraints.backendType === "cuda" && specs?.gpu_name && String(specs.gpu_name).toLowerCase().includes("gtx") && ( +
+ Performance Alert: Your graphics card ({specs.gpu_name}) is a GTX-series GPU which lacks hardware Tensor Cores. Running in CUDA mode will be up to 3x slower. We strongly recommend switching to Vulkan GPU for optimal generation speed. +
+ )} {backendOptions?.unavailable?.length > 0 && (
{backendOptions.unavailable.map((backend) => ( diff --git a/scripts/serve.cjs b/scripts/serve.cjs index be61d33..9bcdd7c 100644 --- a/scripts/serve.cjs +++ b/scripts/serve.cjs @@ -513,12 +513,25 @@ function getBackendOptions() { if (cudaInstalled && !cudaAvailable) { unavailable.push({ id: "cuda", label: "CUDA GPU", reason: "Installed, but CUDA backend validation failed." }); } + let defaultBackend = "cpu"; + if (cudaAvailable) { + const gpuName = String(getGpuInfo().name).toLowerCase(); + const isGtxCard = gpuName.includes("gtx"); + if (isGtxCard && vulkanAvailable) { + defaultBackend = "vulkan"; // Default to Vulkan for GTX cards because of lack of Tensor Cores + } else { + defaultBackend = "cuda"; + } + } else if (vulkanAvailable) { + defaultBackend = "vulkan"; + } + cachedBackendOptions = { options, unavailable, cudaAvailable, vulkanAvailable, - defaultBackendType: cudaAvailable ? "cuda" : vulkanAvailable ? "vulkan" : "cpu", + defaultBackendType: defaultBackend, }; return cachedBackendOptions; }