diff --git a/app/dist/assets/event-CvjXGmc1.js b/app/dist/assets/event-DUWu82QQ.js similarity index 94% rename from app/dist/assets/event-CvjXGmc1.js rename to app/dist/assets/event-DUWu82QQ.js index 52e5a03..cb45fbb 100644 --- a/app/dist/assets/event-CvjXGmc1.js +++ b/app/dist/assets/event-DUWu82QQ.js @@ -1 +1 @@ -import{i as D,t as i}from"./index-BOI9YDBQ.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-CBtRYlFE.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-BOI9YDBQ.js b/app/dist/assets/index-BOI9YDBQ.js deleted file mode 100644 index afa7024..0000000 --- a/app/dist/assets/index-BOI9YDBQ.js +++ /dev/null @@ -1,121 +0,0 @@ -(function(){const b=document.createElement("link").relList;if(b&&b.supports&&b.supports("modulepreload"))return;for(const _ of document.querySelectorAll('link[rel="modulepreload"]'))r(_);new MutationObserver(_=>{for(const D of _)if(D.type==="childList")for(const Y of D.addedNodes)Y.tagName==="LINK"&&Y.rel==="modulepreload"&&r(Y)}).observe(document,{childList:!0,subtree:!0});function A(_){const D={};return _.integrity&&(D.integrity=_.integrity),_.referrerPolicy&&(D.referrerPolicy=_.referrerPolicy),_.crossOrigin==="use-credentials"?D.credentials="include":_.crossOrigin==="anonymous"?D.credentials="omit":D.credentials="same-origin",D}function r(_){if(_.ep)return;_.ep=!0;const D=A(_);fetch(_.href,D)}})();function sm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var ws={exports:{}},ti={};var Vd;function z0(){if(Vd)return ti;Vd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.fragment");function A(r,_,D){var Y=null;if(D!==void 0&&(Y=""+D),_.key!==void 0&&(Y=""+_.key),"key"in _){D={};for(var G in _)G!=="key"&&(D[G]=_[G])}else D=_;return _=D.ref,{$$typeof:f,type:r,key:Y,ref:_!==void 0?_:null,props:D}}return ti.Fragment=b,ti.jsx=A,ti.jsxs=A,ti}var Zd;function T0(){return Zd||(Zd=1,ws.exports=z0()),ws.exports}var c=T0(),Bs={exports:{}},le={};var Kd;function M0(){if(Kd)return le;Kd=1;var f=Symbol.for("react.transitional.element"),b=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),_=Symbol.for("react.profiler"),D=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"),E=Symbol.for("react.lazy"),w=Symbol.for("react.activity"),Z=Symbol.iterator;function ce(d){return d===null||typeof d!="object"?null:(d=Z&&d[Z]||d["@@iterator"],typeof d=="function"?d:null)}var $={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,se={};function F(d,z,B){this.props=d,this.context=z,this.refs=se,this.updater=B||$}F.prototype.isReactComponent={},F.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")},F.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function ae(){}ae.prototype=F.prototype;function ue(d,z,B){this.props=d,this.context=z,this.refs=se,this.updater=B||$}var je=ue.prototype=new ae;je.constructor=ue,k(je,F.prototype),je.isPureReactComponent=!0;var Qe=Array.isArray;function Ve(){}var P={H:null,A:null,T:null,S:null},Te=Object.prototype.hasOwnProperty;function Fe(d,z,B){var H=B.ref;return{$$typeof:f,type:d,key:z,ref:H!==void 0?H:null,props:B}}function we(d,z){return Fe(d.type,z,d.props)}function Me(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Je(d){var z={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(B){return z[B]})}var We=/\/+/g;function nt(d,z){return typeof d=="object"&&d!==null&&d.key!=null?Je(""+d.key):z.toString(36)}function $e(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Ve,Ve):(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,I){var ee=typeof d;(ee==="undefined"||ee==="boolean")&&(d=null);var te=!1;if(d===null)te=!0;else switch(ee){case"bigint":case"string":case"number":te=!0;break;case"object":switch(d.$$typeof){case f:case b:te=!0;break;case E:return te=d._init,x(te(d._payload),z,B,H,I)}}if(te)return I=I(d),te=H===""?"."+nt(d,0):H,Qe(I)?(B="",te!=null&&(B=te.replace(We,"$&/")+"/"),x(I,z,B,"",function(Ut){return Ut})):I!=null&&(Me(I)&&(I=we(I,B+(I.key==null||d&&d.key===I.key?"":(""+I.key).replace(We,"$&/")+"/")+te)),z.push(I)),1;te=0;var qe=H===""?".":H+":";if(Qe(d))for(var Ee=0;Ee>>1,de=x[fe];if(0<_(de,O))x[fe]=O,x[K]=de,K=fe;else break e}}function A(x){return x.length===0?null:x[0]}function r(x){if(x.length===0)return null;var O=x[0],K=x.pop();if(K!==O){x[0]=K;e:for(var fe=0,de=x.length,d=de>>>1;fe_(B,K))H_(I,B)?(x[fe]=I,x[H]=K,fe=H):(x[fe]=B,x[z]=K,fe=z);else if(H_(I,K))x[fe]=I,x[H]=K,fe=H;else break e}}return O}function _(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 D=performance;f.unstable_now=function(){return D.now()}}else{var Y=Date,G=Y.now();f.unstable_now=function(){return Y.now()-G}}var R=[],y=[],E=1,w=null,Z=3,ce=!1,$=!1,k=!1,se=!1,F=typeof setTimeout=="function"?setTimeout:null,ae=typeof clearTimeout=="function"?clearTimeout:null,ue=typeof setImmediate<"u"?setImmediate:null;function je(x){for(var O=A(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=A(y)}}function Qe(x){if(k=!1,je(x),!$)if(A(R)!==null)$=!0,Ve||(Ve=!0,Je());else{var O=A(y);O!==null&&$e(Qe,O.startTime-x)}}var Ve=!1,P=-1,Te=5,Fe=-1;function we(){return se?!0:!(f.unstable_now()-Fex&&we());){var fe=w.callback;if(typeof fe=="function"){w.callback=null,Z=w.priorityLevel;var de=fe(w.expirationTime<=x);if(x=f.unstable_now(),typeof de=="function"){w.callback=de,je(x),O=!0;break t}w===A(R)&&r(R),je(x)}else r(R);w=A(R)}if(w!==null)O=!0;else{var d=A(y);d!==null&&$e(Qe,d.startTime-x),O=!1}}break e}finally{w=null,Z=K,ce=!1}O=void 0}}finally{O?Je():Ve=!1}}}var Je;if(typeof ue=="function")Je=function(){ue(Me)};else if(typeof MessageChannel<"u"){var We=new MessageChannel,nt=We.port2;We.port1.onmessage=Me,Je=function(){nt.postMessage(null)}}else Je=function(){F(Me,0)};function $e(x,O){P=F(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||125fe?(x.sortIndex=K,b(y,x),A(R)===null&&x===A(y)&&(k?(ae(P),P=-1):k=!0,$e(Qe,K-fe))):(x.sortIndex=de,b(R,x),$||ce||($=!0,Ve||(Ve=!0,Je()))),x},f.unstable_shouldYield=we,f.unstable_wrapCallback=function(x){var O=Z;return function(){var K=Z;Z=O;try{return x.apply(this,arguments)}finally{Z=K}}}})(Gs)),Gs}var Fd;function A0(){return Fd||(Fd=1,Hs.exports=N0()),Hs.exports}var qs={exports:{}},jt={};var Wd;function D0(){if(Wd)return jt;Wd=1;var f=Vs();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(),qs.exports=D0(),qs.exports}var Pd;function O0(){if(Pd)return li;Pd=1;var f=A0(),b=Vs(),A=C0();function r(e){var t="https://react.dev/errors/"+e;if(1de||(e.current=fe[de],fe[de]=null,de--)}function B(e,t){de++,fe[de]=e.current,e.current=t}var H=d(null),I=d(null),ee=d(null),te=d(null);function qe(e,t){switch(B(ee,t),B(I,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 Ee(){z(H),z(I),z(ee)}function Ut(e){e.memoizedState!==null&&B(te,e);var t=H.current,l=yd(t,e.type);t!==l&&(B(I,e),B(H,l))}function xt(e){I.current===e&&(z(H),z(I)),te.current===e&&(z(te),Wn._currentValue=K)}var ht,el;function Ie(e){if(ht===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);ht=t&&t[1]||"",el=-1)":-1n||o[a]!==g[n]){var j=` -`+o[a].replace(" at new "," at ");return e.displayName&&j.includes("")&&(j=j.replace("",e.displayName)),j}while(1<=a&&0<=n);break}}}finally{il=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ie(l):""}function T(e,t){switch(e.tag){case 26:case 27:case 5:return Ie(e.type);case 16:return Ie("Lazy");case 13:return e.child!==t&&t!==null?Ie("Suspense Fallback"):Ie("Suspense");case 19:return Ie("SuspenseList");case 0:case 15:return ol(e.type,!1);case 11:return ol(e.type.render,!1);case 1:return ol(e.type,!0);case 31:return Ie("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,Ze=f.unstable_cancelCallback,zt=f.unstable_shouldYield,wt=f.unstable_requestPaint,ge=f.unstable_now,Bt=f.unstable_getCurrentPriorityLevel,ui=f.unstable_ImmediatePriority,ci=f.unstable_UserBlockingPriority,_a=f.unstable_NormalPriority,_u=f.unstable_LowPriority,L=f.unstable_IdlePriority,be=f.log,Ge=f.unstable_setDisableYieldValue,tt=null,Be=null;function _t(e){if(typeof be=="function"&&Ge(e),Be&&typeof Be.setStrictMode=="function")try{Be.setStrictMode(tt,e)}catch{}}var rt=Math.clz32?Math.clz32:Se,ja=Math.log,yt=Math.LN2;function Se(e){return e>>>=0,e===0?32:31-(ja(e)/yt|0)|0}var me=256,Re=262144,ve=4194304;function Le(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 De(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=Le(a):(u&=s,u!==0?n=Le(u):l||(l=s&~e,l!==0&&(n=Le(l))))):(s=a&~i,s!==0?n=Le(s):u!==0?n=Le(u):l||(l=a&~e,l!==0&&(n=Le(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 ft(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Rt(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 tl(){var e=ve;return ve<<=1,(ve&62914560)===0&&(ve=4194304),e}function on(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function rn(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 Nu(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?Au(e,u,Qt(t)):l!=null?Au(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)){Eu(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),Eu(e)}function Au(e,t,l){t==="number"&&oi(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Aa(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"),wu=!1;if(ml)try{var yn={};Object.defineProperty(yn,"passive",{get:function(){wu=!0}}),window.addEventListener("test",yn,yn),window.removeEventListener("test",yn,yn)}catch{wu=!1}var Cl=null,Bu=null,di=null;function hf(){if(di)return di;var e,t=Bu,l=t.length,a,n="value"in Cl?Cl.value:Cl.textContent,i=n.length;for(e=0;e=vn),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 Ua=!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(Ua)return e==="compositionend"||!Lu&&_f(e,t)?(e=hf(),di=Bu=Cl=null,Ua=!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=oi(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=oi(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=ml&&"documentMode"in document&&11>=document.documentMode,wa=null,Qu=null,_n=null,Vu=!1;function Bf(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Vu||wa==null||wa!==oi(a)||(a=wa,"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}),_n&&xn(_n,a)||(_n=a,a=iu(Qu,"onSelect"),0>=u,n-=u,ul=1<<32-rt(t)+n|l<ie?(ye=V,V=null):ye=V.sibling;var _e=v(h,V,p[ie],M);if(_e===null){V===null&&(V=ye);break}e&&V&&_e.alternate===null&&t(h,V),m=i(_e,m,ie),xe===null?J=_e:xe.sibling=_e,xe=_e,V=ye}if(ie===p.length)return l(h,V),pe&&yl(h,ie),J;if(V===null){for(;ieie?(ye=V,V=null):ye=V.sibling;var Pl=v(h,V,_e.value,M);if(Pl===null){V===null&&(V=ye);break}e&&V&&Pl.alternate===null&&t(h,V),m=i(Pl,m,ie),xe===null?J=Pl:xe.sibling=Pl,xe=Pl,V=ye}if(_e.done)return l(h,V),pe&&yl(h,ie),J;if(V===null){for(;!_e.done;ie++,_e=p.next())_e=N(h,_e.value,M),_e!==null&&(m=i(_e,m,ie),xe===null?J=_e:xe.sibling=_e,xe=_e);return pe&&yl(h,ie),J}for(V=a(V);!_e.done;ie++,_e=p.next())_e=S(V,h,ie,_e.value,M),_e!==null&&(e&&_e.alternate!==null&&V.delete(_e.key===null?ie:_e.key),m=i(_e,m,ie),xe===null?J=_e:xe.sibling=_e,xe=_e);return e&&V.forEach(function(j0){return t(h,j0)}),pe&&yl(h,ie),J}function Ue(h,m,p,M){if(typeof p=="object"&&p!==null&&p.type===k&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case ce:e:{for(var J=p.key;m!==null;){if(m.key===J){if(J=p.type,J===k){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===Te&&da(J)===m.type){l(h,m.sibling),M=n(m,p.props),Nn(M,p),M.return=h,h=M;break e}l(h,m);break}else t(h,m);m=m.sibling}p.type===k?(M=ca(p.props.children,h.mode,M,p.key),M.return=h,h=M):(M=_i(p.type,p.key,p.props,null,h.mode,M),Nn(M,p),M.return=h,h=M)}return u(h);case $: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=Iu(p,h.mode,M),M.return=h,h=M}return u(h);case Te:return p=da(p),Ue(h,m,p,M)}if($e(p))return X(h,m,p,M);if(Je(p)){if(J=Je(p),typeof J!="function")throw Error(r(150));return p=J.call(p),W(h,m,p,M)}if(typeof p.then=="function")return Ue(h,m,Ai(p),M);if(p.$$typeof===ue)return Ue(h,m,Ti(h,p),M);Di(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{En=0;var J=Ue(h,m,p,M);return Va=null,J}catch(V){if(V===Qa||V===Ei)throw V;var xe=Gt(29,V,null,h.mode);return xe.lanes=M,xe.return=h,xe}}}var ha=no(!0),io=no(!1),Rl=!1;function oc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function rc(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,(ze&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=xi(e),Xf(e,null,l),t}return Si(e,a,t,l),xi(e)}function An(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 dc(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 mc=!1;function Dn(){if(mc){var e=ka;if(e!==null)throw e}}function Cn(e,t,l,a){mc=!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 j=e.alternate;j!==null&&(j=j.updateQueue,s=j.lastBaseUpdate,s!==u&&(s===null?j.firstBaseUpdate=g:s.next=g,j.lastBaseUpdate=o))}if(i!==null){var N=n.baseState;u=0,j=g=o=null,s=i;do{var v=s.lane&-536870913,S=v!==s.lane;if(S?(he&v)===v:(a&v)===v){v!==0&&v===Xa&&(mc=!0),j!==null&&(j=j.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var X=e,W=s;v=t;var Ue=l;switch(W.tag){case 1:if(X=W.payload,typeof X=="function"){N=X.call(Ue,N,v);break e}N=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=W.payload,v=typeof X=="function"?X.call(Ue,N,v):X,v==null)break e;N=w({},N,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},j===null?(g=j=S,o=N):j=j.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);j===null&&(o=N),n.baseState=o,n.firstBaseUpdate=g,n.lastBaseUpdate=j,i===null&&(n.shared.lanes=0),kl|=u,e.lanes=u,e.memoizedState=N}}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,Oc(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 j=dh(o,a);wn(e,t,j,kt(e))}else wn(e,t,a,kt(e))}catch(N){wn(e,t,{then:function(){},status:"rejected",reason:N},kt())}finally{O.p=i,u!==null&&s.types!==null&&(u.types=s.types),x.T=u}}function vh(){}function Dc(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:bl,lastRenderedState:K},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:bl,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),wn(e,t.next.queue,{},kt())}function Cc(){return vt(Wn)}function Xo(){return at().memoizedState}function ko(){return at().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&&(Ot(a,t,l),An(a,t,l)),t={cache:uc()},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},Li(e)?Vo(t,l):(l=$u(e,t,l,a),l!==null&&(Ot(l,e,a),Zo(l,t,a)))}function Qo(e,t,l){var a=kt();wn(e,t,l,a)}function wn(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Li(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 Si(e,t,n,0),He===null&&bi(),!1}catch{}if(l=$u(e,t,n,a),l!==null)return Ot(l,e,a),Zo(l,t,a),!0}return!1}function Oc(e,t,l,a){if(a={lane:2,revertLane:os(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Li(e)){if(t)throw Error(r(479))}else t=$u(e,l,a,2),t!==null&&Ot(t,e,2)}function Li(e){var t=e.alternate;return e===ne||t!==null&&t===ne}function Vo(e,t){Ka=Ui=!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 Bn={readContext:vt,use:Ri,useCallback:Pe,useContext:Pe,useEffect:Pe,useImperativeHandle:Pe,useLayoutEffect:Pe,useInsertionEffect:Pe,useMemo:Pe,useReducer:Pe,useRef:Pe,useState:Pe,useDebugValue:Pe,useDeferredValue:Pe,useTransition:Pe,useSyncExternalStore:Pe,useId:Pe,useHostTransitionStatus:Pe,useFormState:Pe,useActionState:Pe,useOptimistic:Pe,useMemoCache:Pe,useCacheRefresh:Pe};Bn.useEffectEvent=Pe;var Ko={readContext:vt,use:Ri,useCallback:function(e,t){return Tt().memoizedState=[e,t===void 0?null:t],e},useContext:vt,useEffect:Do,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Gi(4194308,4,wo.bind(null,t,e),l)},useLayoutEffect:function(e,t){return Gi(4194308,4,e,t)},useInsertionEffect:function(e,t){Gi(4,2,e,t)},useMemo:function(e,t){var l=Tt();t=t===void 0?null:t;var a=e();if(ya){_t(!0);try{e()}finally{_t(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=Tt();if(l!==void 0){var n=l(t);if(ya){_t(!0);try{l(t)}finally{_t(!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,ne,e),[a.memoizedState,e]},useRef:function(e){var t=Tt();return e={current:e},t.memoizedState=e},useState:function(e){e=Tc(e);var t=e.queue,l=Qo.bind(null,ne,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Nc,useDeferredValue:function(e,t){var l=Tt();return Ac(l,e,t)},useTransition:function(){var e=Tc(!1);return e=qo.bind(null,ne,e.queue,!0,!1),Tt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=ne,n=Tt();if(pe){if(l===void 0)throw Error(r(407));l=l()}else{if(l=t(),He===null)throw Error(r(349));(he&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,$a(9,{destroy:void 0},yo.bind(null,a,i,l,t),null),l},useId:function(){var e=Tt(),t=He.identifierPrefix;if(pe){var l=cl,a=ul;l=(a&~(1<<32-rt(a)-1)).toString(32)+l,t="_"+t+"R_"+l,l=wi++,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[pt]=t,i[Mt]=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(St(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&&xl(t)}}return Xe(t),Zc(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,l),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==a&&xl(t);else{if(typeof a!="string"&&t.stateNode===null)throw Error(r(166));if(e=ee.current,La(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=gt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[pt]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||dd(e.nodeValue,l)),e||wl(t,!0)}else e=uu(e).createTextNode(a),e[pt]=t,t.stateNode=e}return Xe(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=La(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[pt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xe(t),e=!1}else l=lc(),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 Xe(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=La(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[pt]=t}else sa(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;Xe(t),n=!1}else n=lc(),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),Vi(t,t.updateQueue),Xe(t),null);case 4:return Ee(),e===null&&hs(t.stateNode.containerInfo),Xe(t),null;case 10:return gl(t.type),Xe(t),null;case 19:if(z(lt),a=t.memoizedState,a===null)return Xe(t),null;if(n=(t.flags&128)!==0,i=a.rendering,i===null)if(n)Hn(a,!1);else{if(et!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=Oi(e),i!==null){for(t.flags|=128,Hn(a,!1),e=i.updateQueue,t.updateQueue=e,Vi(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)kf(l,e),l=l.sibling;return B(lt,lt.current&1|2),pe&&yl(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&ge()>Fi&&(t.flags|=128,n=!0,Hn(a,!1),t.lanes=4194304)}else{if(!n)if(e=Oi(i),e!==null){if(t.flags|=128,n=!0,e=e.updateQueue,t.updateQueue=e,Vi(t,e),Hn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!pe)return Xe(t),null}else 2*ge()-a.renderingStartTime>Fi&&l!==536870912&&(t.flags|=128,n=!0,Hn(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=lt.current,B(lt,n?l&1|2:l&1),pe&&yl(t,a.treeForkCount),e):(Xe(t),null);case 22:case 23:return Lt(t),yc(),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&&(Xe(t),t.subtreeFlags&6&&(t.flags|=8192)):Xe(t),l=t.updateQueue,l!==null&&Vi(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),gl(it),Xe(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Th(e,t){switch(ec(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return gl(it),Ee(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return xt(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(lt),null;case 4:return Ee(),null;case 10:return gl(t.type),null;case 22:case 23:return Lt(t),yc(),e!==null&&z(ra),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return gl(it),null;case 25:return null;default:return null}}function gr(e,t){switch(ec(t),t.tag){case 3:gl(it),Ee();break;case 26:case 27:case 5:xt(t);break;case 4:Ee();break;case 31:t.memoizedState!==null&&Lt(t);break;case 13:Lt(t);break;case 19:z(lt);break;case 10:gl(t.type);break;case 22:case 23:Lt(t),yc(),e!==null&&z(ra);break;case 24:gl(it)}}function Gn(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(j){Ae(n,o,j)}}}a=a.next}while(a!==i)}}catch(j){Ae(t,t.return,j)}}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 qn(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 sl(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 Kc(e,t,l){try{var a=e.stateNode;Kh(a,e.type,l,t),a[Mt]=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 Jc(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 $c(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=dl));else if(a!==4&&(a===27&&Jl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for($c(e,t,l),e=e.sibling;e!==null;)$c(e,t,l),e=e.sibling}function Zi(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(Zi(e,t,l),e=e.sibling;e!==null;)Zi(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]);St(t,a,l),t[pt]=e,t[Mt]=l}catch(i){Ae(e,e.return,i)}}var _l=!1,st=!1,Fc=!1,jr=typeof WeakSet=="function"?WeakSet:Set,mt=null;function Mh(e,t){if(e=e.containerInfo,gs=mu,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,j=0,N=e,v=null;t:for(;;){for(var S;N!==l||n!==0&&N.nodeType!==3||(s=u+n),N!==i||a!==0&&N.nodeType!==3||(o=u+a),N.nodeType===3&&(u+=N.nodeValue.length),(S=N.firstChild)!==null;)v=N,N=S;for(;;){if(N===e)break t;if(v===l&&++g===n&&(s=u),v===i&&++j===a&&(o=u),(S=N.nextSibling)!==null)break;N=v,v=N.parentNode}N=S}l=s===-1||o===-1?null:{start:s,end:o}}else l=null}l=l||{start:0,end:0}}else l=null;for(vs={focusedElem:e,selectionRange:l},mu=!1,mt=t;mt!==null;)if(t=mt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,mt=e;else for(;mt!==null;){switch(t=mt,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"))),St(i,a,l),i[pt]=e,dt(i),a=i;break e;case"link":var u=Ad("link","href",n).get(a+(l.href||""));if(u){for(var s=0;sUe&&(u=Ue,Ue=W,W=u);var h=Of(s,W),m=Of(s,Ue);if(h&&m&&(S.rangeCount!==1||S.anchorNode!==h.node||S.anchorOffset!==h.offset||S.focusNode!==m.node||S.focusOffset!==m.offset)){var p=N.createRange();p.setStart(h.node,h.offset),S.removeAllRanges(),W>Ue?(S.addRange(p),S.extend(m.node,m.offset)):(p.setEnd(m.node,m.offset),S.addRange(p))}}}}for(N=[],S=s;S=S.parentNode;)S.nodeType===1&&N.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=as,as=null;var i=Vl,u=El;if(ot=0,en=Vl=null,El=0,(ze&6)!==0)throw Error(r(331));var s=ze;if(ze|=4,wr(i.current),Cr(i,i.current,u,l),ze=s,Vn(0,!1),Be&&typeof Be.onPostCommitFiberRoot=="function")try{Be.onPostCommitFiberRoot(tt,i)}catch{}return!0}finally{O.p=n,x.T=a,Ir(e,t)}}function ed(e,t,l){t=Kt(l,t),t=Rc(e.stateNode,t,2),e=Gl(e,t,2),e!==null&&(rn(e,2),fl(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),rn(a,2),fl(a));break}}t=t.return}}function cs(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)||(Pc=!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,He===e&&(he&l)===l&&(et===4||et===3&&(he&62914560)===he&&300>ge()-$i?(ze&2)===0&&tn(e,0):es|=l,Pa===he&&(Pa=0)),fl(e)}function td(e,t){t===0&&(t=tl()),e=ua(e,t),e!==null&&(rn(e,t),fl(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 lu=null,an=null,ss=!1,au=!1,fs=!1,Kl=0;function fl(e){e!==an&&e.next===null&&(an===null?lu=an=e:an=an.next=e),au=!0,ss||(ss=!0,qh())}function Vn(e,t){if(!fs&&au){fs=!0;do for(var l=!1,a=lu;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-rt(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=he,i=De(a,a===He?i:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(i&3)===0||ft(a,i)||(l=!0,id(a,i));a=a.next}while(l);fs=!1}}function Gh(){ld()}function ld(){au=ss=!1;var e=0;Kl!==0&&$h()&&(e=Kl);for(var t=ge(),l=null,a=lu;a!==null;){var n=a.next,i=ad(a,t);i===0?(a.next=null,l===null?lu=n:l.next=n,n===null&&(an=l)):(l=a,(e!==0||(i&3)!==0)&&(au=!0)),a=n}ot!==0&&ot!==5||Vn(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 j=o.transferSize,N=o.initiatorType;j&&md(N)&&(o=o.responseEnd,u+=j*(o"u"?null:document;function Td(e,t,l){var a=nn;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"),St(t,"link",e),dt(t),a.head.appendChild(t)))}}function n0(e){Nl.D(e),Td("dns-prefetch",e,null)}function i0(e,t){Nl.C(e,t),Td("preconnect",e,t)}function u0(e,t,l){Nl.L(e,t,l);var a=nn;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=un(e);break;case"script":i=cn(e)}Pt.has(i)||(e=w({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($n(i))||t==="script"&&a.querySelector(Fn(i))||(t=a.createElement("link"),St(t,"link",e),dt(t),a.head.appendChild(t)))}}function c0(e,t){Nl.m(e,t);var l=nn;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=cn(e)}if(!Pt.has(i)&&(e=w({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(Fn(i)))return}a=l.createElement("link"),St(a,"link",e),dt(a),l.head.appendChild(a)}}}function s0(e,t,l){Nl.S(e,t,l);var a=nn;if(a&&e){var n=Ea(a).hoistableStyles,i=un(e);t=t||"default";var u=n.get(i);if(!u){var s={loading:0,preload:null};if(u=a.querySelector($n(i)))s.loading=5;else{e=w({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Pt.get(i))&&Ts(e,l);var o=u=a.createElement("link");dt(o),St(o,"link",e),o._p=new Promise(function(g,j){o.onload=g,o.onerror=j}),o.addEventListener("load",function(){s.loading|=1}),o.addEventListener("error",function(){s.loading|=2}),s.loading|=4,su(u,t,a)}u={type:"stylesheet",instance:u,count:1,state:s},n.set(i,u)}}}function f0(e,t){Nl.X(e,t);var l=nn;if(l&&e){var a=Ea(l).hoistableScripts,n=cn(e),i=a.get(n);i||(i=l.querySelector(Fn(n)),i||(e=w({src:e,async:!0},t),(t=Pt.get(n))&&Ms(e,t),i=l.createElement("script"),dt(i),St(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function o0(e,t){Nl.M(e,t);var l=nn;if(l&&e){var a=Ea(l).hoistableScripts,n=cn(e),i=a.get(n);i||(i=l.querySelector(Fn(n)),i||(e=w({src:e,async:!0,type:"module"},t),(t=Pt.get(n))&&Ms(e,t),i=l.createElement("script"),dt(i),St(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=ee.current)?cu(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=un(l.href),l=Ea(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=un(l.href);var i=Ea(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($n(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=cn(l),l=Ea(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 un(e){return'href="'+Vt(e)+'"'}function $n(e){return'link[rel="stylesheet"]['+e+"]"}function Ed(e){return w({},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}),St(t,"link",l),dt(t),e.head.appendChild(t))}function cn(e){return'[src="'+Vt(e)+'"]'}function Fn(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,dt(a),a;var n=w({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),dt(a),St(a,"style",n),su(a,l.precedence,e),t.instance=a;case"stylesheet":n=un(l.href);var i=e.querySelector($n(n));if(i)return t.state.loading|=4,t.instance=i,dt(i),i;a=Ed(l),(n=Pt.get(n))&&Ts(a,n),i=(e.ownerDocument||e).createElement("link"),dt(i);var u=i;return u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),St(i,"link",a),t.state.loading|=4,su(i,l.precedence,e),t.instance=i;case"script":return i=cn(l.src),(n=e.querySelector(Fn(i)))?(t.instance=n,dt(n),n):(a=l,(n=Pt.get(i))&&(a=w({},l),Ms(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),dt(n),St(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,su(a,l.precedence,e));return t.instance}function su(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=un(a.href),i=t.querySelector($n(n));if(i){t=i._p,t!==null&&typeof t=="object"&&typeof t.then=="function"&&(e.count++,e=ou.bind(e),t.then(e,e)),l.state.loading|=4,l.instance=i,dt(i);return}i=t.ownerDocument||t,a=Ed(a),(n=Pt.get(n))&&Ts(a,n),i=i.createElement("link"),dt(i);var u=i;u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),St(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=ou.bind(e),t.addEventListener("load",l),t.addEventListener("error",l))}}var Es=0;function h0(e,t){return e.stylesheets&&e.count===0&&du(e,e.stylesheets),0Es?50:800)+t);return e.unsuspend=l,function(){e.unsuspend=null,clearTimeout(a),clearTimeout(n)}}:null}function ou(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)du(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var ru=null;function du(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,ru=new Map,t.forEach(y0,e),ru=null,ou.call(e))}function y0(e,t){if(!(t.state.loading&4)){var l=ru.get(e);if(l)var a=l.get(null);else{l=new Map,ru.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(),Rs.exports=O0(),Rs.exports}var w0=U0();const B0=sm(w0);const fm=(...f)=>f.filter((b,A,r)=>!!b&&b.trim()!==""&&r.indexOf(b)===A).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,A,r)=>r?r.toUpperCase():A.toLowerCase());const tm=f=>{const b=H0(f);return b.charAt(0).toUpperCase()+b.slice(1)};var Ls={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=U.createContext({}),L0=()=>U.useContext(q0),Y0=U.forwardRef(({color:f,size:b,strokeWidth:A,absoluteStrokeWidth:r,className:_="",children:D,iconNode:Y,...G},R)=>{const{size:y=24,strokeWidth:E=2,absoluteStrokeWidth:w=!1,color:Z="currentColor",className:ce=""}=L0()??{},$=r??w?Number(A??E)*24/Number(b??y):A??E;return U.createElement("svg",{ref:R,...Ls,width:b??y??Ls.width,height:b??y??Ls.height,stroke:f??Z,strokeWidth:$,className:fm("lucide",ce,_),...!D&&!G0(G)&&{"aria-hidden":"true"},...G},[...Y.map(([k,se])=>U.createElement(k,se)),...Array.isArray(D)?D:[D]])});const ke=(f,b)=>{const A=U.forwardRef(({className:r,..._},D)=>U.createElement(Y0,{ref:D,iconNode:b,className:fm(`lucide-${R0(tm(f))}`,`lucide-${f}`,r),..._}));return A.displayName=tm(f),A};const X0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ys=ke("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=ke("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=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"}]],Xs=ke("database",$0);const F0=[["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",F0);const W0=[["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",W0);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"}]],xu=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"}]],Zs=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"}]],Su=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"}]],ai=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:A}){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(Zs,{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:A.cpu_name,children:["CPU: ",A.cpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",title:A.gpu_name,children:["GPU: ",A.gpu_name]}),c.jsxs("div",{className:"sidebar-specs-item",children:["Memory: ",A.ram_total_gb.toFixed(0)," GB RAM (",A.cpu_cores_physical," Cores)"]}),c.jsxs("div",{className:"sidebar-specs-os",children:["OS: ",A.os_name]})]})]})}const Ey=U.memo(My);function Ny({telemetry:f,serverRunning:b,activeModel:A,onStopServer:r,isStoppingServer:_=!1,theme:D,setTheme:Y}){const G=E=>{const w=Number(E);return Number.isFinite(w)&&w>0?w.toFixed(w>=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()}),A&&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:A})]})]}),c.jsxs("div",{className:"telemetry-group",children:[c.jsx("button",{className:"theme-toggle-btn",onClick:()=>Y(D==="dark"?"light":"dark"),title:`Switch to ${D==="dark"?"light":"dark"} theme`,children:D==="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:_,title:"Stop local model server",children:[_?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ks,{size:14}),c.jsx("span",{children:_?"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(xu,{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(Xs,{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=U.memo(Ny),Dy="modulepreload",Cy=function(f){return"/"+f},im={},Oy=function(b,A,r){let _=Promise.resolve();if(A&&A.length>0){let R=function(y){return Promise.all(y.map(E=>Promise.resolve(E).then(w=>({status:"fulfilled",value:w}),w=>({status:"rejected",reason:w}))))};document.getElementsByTagName("link");const Y=document.querySelector("meta[property=csp-nonce]"),G=Y?.nonce||Y?.getAttribute("nonce");_=R(A.map(y=>{if(y=Cy(y),y in im)return;im[y]=!0;const E=y.endsWith(".css"),w=E?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${w}`))return;const Z=document.createElement("link");if(Z.rel=E?"stylesheet":Dy,E||(Z.as="script"),Z.crossOrigin="",Z.href=y,G&&Z.setAttribute("nonce",G),document.head.appendChild(Z),E)return new Promise((ce,$)=>{Z.addEventListener("load",ce),Z.addEventListener("error",()=>$(new Error(`Unable to preload CSS for ${y}`)))})}))}function D(Y){const G=new Event("vite:preloadError",{cancelable:!0});if(G.payload=Y,window.dispatchEvent(G),!G.defaultPrevented)throw Y}return _.then(Y=>{for(const G of Y||[])G.status==="rejected"&&D(G.reason);return b().catch(D)})};function o1(f,b=!1){return window.__TAURI_INTERNALS__.transformCallback(f,b)}async function xa(f,b={},A){return window.__TAURI_INTERNALS__.invoke(f,b,A)}const Al=()=>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 ni(f){const b=Number(f)||0;if(b<=0)return"0 B";const A=["B","KB","MB","GB","TB"],r=Math.min(A.length-1,Math.floor(Math.log(b)/Math.log(1024)));return`${(b/1024**r).toFixed(r===0?0:1)} ${A[r]}`}function ii(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?ni(f.sizeBytes):"Unknown")}}async function fn(f,b="The local server returned an invalid response."){const A=await f.text();let r={};try{r=JSON.parse(A||"{}")}catch{const D=A.trim().startsWith("{const $=E.steps;for(let Fe=1;Fe<=$;Fe++){if(Y&&Y.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(we=>setTimeout(we,3e3/$)),D&&D(Math.round(Fe/$*100))}const k=f.toLowerCase(),se=Math.abs(E.seed)||Math.floor(Math.random()*1e3);let F="#3B82F6",ae="#8B5CF6",ue="",je="Abstract Generation";k.includes("moon")||k.includes("space")||k.includes("astronomy")||k.includes("sky")?(F="#1E293B",ae="#0F172A",je="Luminous Moon in Starry Sky",ue=` - - - - - - - - - - - - `):k.includes("cat")||k.includes("kitten")||k.includes("feline")?(F="#4F46E5",ae="#7C3AED",je="Stylized Cat Portrait",ue=` - - - - - - - - - - - - - - - - `):k.includes("dog")||k.includes("puppy")||k.includes("canine")?(F="#D97706",ae="#B45309",je="Friendly Dog Portrait",ue=` - - - - - - - - - - - - - `):k.includes("city")||k.includes("cyberpunk")||k.includes("tokyo")||k.includes("neon")?(F="#111827",ae="#311042",je="Neon Cyberpunk Skyline",ue=` - - - - - - - - - - - - - `):k.includes("car")||k.includes("vehicle")||k.includes("supercar")?(F="#DC2626",ae="#991B1B",je="Futuristic Concept Car",ue=` - - - - - - - - - - - - - `):(F="#06B6D4",ae="#0891B2",je="Abstract Creative Concept",ue=` - - - - `);const Qe=` - - - - - - - - - - - - - - - - - ${ue} - - - - - - - ${je} - Seed: ${se} • Steps: ${E.steps} • Scale: ${E.cfg_scale} - - `,P=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Qe)))}`,Te=parseFloat(((Date.now()-G)/1e3).toFixed(1));return{image:P,seed:E.seed,duration_sec:Te}},Z=!!E.image,ce={prompt:E.prompt,negative_prompt:E.negative_prompt||"",n:1,size:`${E.width}x${E.height}`,response_format:"b64_json",steps:E.steps,cfg_scale:E.cfg_scale,seed:E.seed,sample_method:E.sampler};Z&&(ce.init_images=[E.image],ce.denoising_strength=E.denoising_strength);try{const $=await fetch(`${y}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:Y,body:JSON.stringify(ce)});if($.ok){const k=await $.json(),se=k?.data?.[0]?.b64_json??k?.images?.[0];if(se){const F=parseFloat(((Date.now()-G)/1e3).toFixed(1));return{image:`data:image/png;base64,${se}`,seed:k.data?.[0]?.seed??E.seed,duration_sec:F}}}else{let k=`Generation failed (HTTP ${$.status})`;try{const se=await $.json();(se?.detail||se?.error?.message)&&(k=se.detail||se.error.message)}catch{}throw new Error(k)}}catch($){if($.name==="AbortError"||$.message.startsWith("Generation failed"))throw $;console.warn("Could not reach local server. Falling back to simulation mode.",$)}return await w()}async function Ky(f,b,A){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,A),{response:"Model imported successfully"}}if(Al()){const{listen:G}=await Oy(async()=>{const{listen:y}=await import("./event-CvjXGmc1.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 _=40;for(let G=1;G<=_;G++){if(A?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(w=>setTimeout(w,150));const R=G/_*100,y=40+Math.sin(G)*5+Math.random()*2,E=(_-G)*.15;b&&b({filename:r,progress:R,speed_mb_s:y,eta_secs:E,status:"Copying to USB..."})}const D=localStorage.getItem("imported-models"),Y=D?JSON.parse(D):[];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,A){return new Promise((r,_)=>{const D=new XMLHttpRequest,Y=Date.now();let G=!1;D.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),D.setRequestHeader("Content-Type","application/octet-stream");const R=()=>{G=!0,D.abort()};A&&(A.aborted?R():A.addEventListener("abort",R,{once:!0})),D.upload.onprogress=y=>{if(!y.lengthComputable||!b)return;const E=Math.max(.1,(Date.now()-Y)/1e3),w=y.loaded/E,Z=Math.max(0,y.total-y.loaded);b({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:w/(1024*1024),eta_secs:Z/Math.max(1,w),status:"Copying to models folder..."})},D.onload=()=>{let y={};try{y=JSON.parse(D.responseText||"{}")}catch{}D.status>=200&&D.status<300&&y.ok!==!1?(b&&b({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):_(new Error(y.error||`Import failed (HTTP ${D.status})`))},D.onerror=()=>_(new Error("Import failed while uploading the file.")),D.onabort=()=>_(new DOMException(G?"Import cancelled by user.":"Import aborted.","AbortError")),D.send(f)})}async function $y(f){if(Al())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 _=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),D=await _.json();if(!_.ok)throw new Error(D.error||"Failed to delete model file");return D}catch(_){throw console.error("Failed to delete model via local API:",_),_}const A=localStorage.getItem("imported-models");let r=A?JSON.parse(A):[];return r=r.filter(_=>ii(_).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 Fy(f=30){const b=Al()||Sa()?f:3;for(let A=0;AsetTimeout(_,500))}return!1}async function Wy(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=U.memo(({img:f,idx:b,isSelected:A,onClick:r})=>{const _=D=>{r(b,D)};return c.jsxs("div",{className:`gallery-item ${A?"selected":""}`,onClick:_,title:`Prompt: ${f.prompt} -Seed: ${f.seed}${f.duration_sec?` -Time: ${f.duration_sec.toFixed(1)}s`:""}`,children:[c.jsx("img",{src:f.url,className:"gallery-thumb",alt:"Thumbnail",loading:"lazy",decoding:"async"}),A&&c.jsx("div",{className:"gallery-select-badge",children:c.jsx(Ys,{size:14})})]})});function t1({prompt:f,setPrompt:b,negativePrompt:A,setNegativePrompt:r,constraints:_,setConstraints:D,activeModel:Y,generatedImages:G,setGeneratedImages:R,isGenerating:y,setIsGenerating:E,generationProgress:w,setGenerationProgress:Z,setActiveTab:ce,inputImage:$,setInputImage:k,showAlert:se=async({message:ae})=>window.alert(ae),showConfirm:F=async({message:ae})=>window.confirm(ae)}){const[ae,ue]=U.useState(null),[je,Qe]=U.useState(null),[Ve,P]=U.useState(null),[Te,Fe]=U.useState(!1),[we,Me]=U.useState(0),[Je,We]=U.useState(0),[nt,$e]=U.useState(0),[x,O]=U.useState(""),[K,fe]=U.useState(!1),[de,d]=U.useState(!1),[z,B]=U.useState(!1),[H,I]=U.useState(null),[ee,te]=U.useState(null),[qe,Ee]=U.useState(!1),[Ut,xt]=U.useState([]),ht=U.useRef(null),el=U.useRef(null),Ie=U.useRef(null),il=()=>{el.current.click()},ol=L=>{const be=L.target.files[0];if(be){const Ge=new FileReader;Ge.onload=()=>{k(Ge.result)},Ge.readAsDataURL(be)}},T=L=>{L.stopPropagation(),k(null),el.current&&(el.current.value="")},C=async()=>{if(!f.trim())return;te(null),B(!0),I(null);let L=!1;try{const Se=await ba();if(Se&&Se.settings){const me=Se.settings,Re=me.model?me.model.split(/[\\/]/).pop():null,ve=Y?Y.split(/[\\/]/).pop():null;(Re!==ve||parseInt(me.steps)!==parseInt(_.steps)||Math.abs(parseFloat(me.cfgScale)-parseFloat(_.cfgScale))>.05||me.sampler!==_.sampler||parseInt(me.threads)!==parseInt(_.threads)||!!me.useGpu!=(_.useGpu!==!1)||(me.backendType||(me.useGpu===!1?"cpu":"auto"))!==(_.backendType||(_.useGpu===!1?"cpu":"auto")))&&(L=!0)}else L=!0}catch{L=!0}if(L)try{console.log("Settings out of sync, restarting backend..."),await Qs(Y,_);let Se=!1,me=null;for(let Re=0;Re<240;Re++){const ve=await ba();if(ve.loading&&I({progress:ve.loading.progress||0,phase:ve.loading.phase||"Loading model...",speed:ve.loading.speed||"",current:ve.loading.current||0,total:ve.loading.total||0,backendMode:ve.loading.backendMode||ve.settings?.backendMode||"",device:ve.loading.device||ve.settings?.backendDevice||""}),ve.ready){Se=!0;break}if(ve.error){me=ve.error;break}if(!ve.running&&Re>3){me="The backend process terminated immediately on startup.";break}await new Promise(Le=>setTimeout(Le,500))}if(!Se)throw new Error(me||"Backend server failed to start after applying configuration changes.")}catch(Se){console.error("Failed to restart backend:",Se),te(Se.message||"Failed to sync settings with backend."),B(!1);return}B(!1),I(null),ht.current&&clearInterval(ht.current),E(!0),Z(0),Me(0),$e(0),O(""),fe(!1),Ee(!1),P(null),ue(null);const be=(_.width>=1024?140:35)*.04,Ge=_.width>=1024?140:35,tt=(_.backendType||(_.useGpu===!1?"cpu":"auto"))!=="cpu";let Be=tt?be:Ge,_t=!1,rt=0,ja=0,yt=0;We(Math.round(_.steps*Be)),ht.current=setInterval(async()=>{yt++,Me(yt);try{const Se=await Py();if(Se&&Se.active){const me=Se.decoding||!1;Ee(me);const Re=me?Se.steps||_.steps||20:Se.step||0,ve=Se.steps||_.steps||20,Le=me?"":Se.speed||"";$e(Re),O(me?"decoding":Le);let De=0;me?De=99:ve>0&&(De=Math.round(Re/ve*100)),De=Math.min(99,De),Z(Rt=>Math.max(Rt,De));let ft=0;if(me)ft=3;else{const Rt=parseFloat(Le);if(!isNaN(Rt)&&Rt>0){const tl=Math.max(0,ve-Re);Le.includes("it/s")?ft=tl/Rt:Le.includes("s/it")&&(ft=tl*Rt)}else{const tl=tt?be:Ge;ft=Math.max(0,(ve-Re)*tl)}}if(tt&&!_t){const Rt=Le.includes("it/s")&&numericSpeed<.2,tl=Le.includes("s/it")&&numericSpeed>5;(Rt||tl)&&(_t=!0,fe(!0))}We(Math.round(ft))}else Z(me=>Math.min(15,me+1)),We(me=>Math.max(1,me-1))}catch(Se){console.warn("Failed to get generation progress, running simulation fallback:",Se),tt&&!_t&&yt>_.steps*be*1.3&&(_t=!0,fe(!0),Be=Ge,rt=yt,ja=Math.min(95,Math.round(yt/(_.steps*be)*100)));let me=Math.min(_.steps-1,Math.floor(yt/Be)),Re=_.steps*Be;if(yt>=Re){const De=Math.ceil(yt/Math.max(.5,me));Be=Math.max(Be+15,De+15),Re=_.steps*Be,me=Math.min(_.steps-1,Math.floor(yt/Be))}$e(me);const ve=Math.max(1,Re-yt);We(Math.round(ve));let Le=0;if(_t){const De=99-ja,ft=Re-rt;if(ft>0){const Rt=Math.min(1,(yt-rt)/ft);if(Rt<.85)Le=Math.round(ja+Rt*De);else{const tl=(yt-(rt+ft*.85))/(Be*2),on=1-Math.exp(-tl);Le=Math.min(99,Math.round(ja+.85*De+.14*De*on))}}else Le=99}else if(ytMath.max(De,Le))}},1e3);try{Ie.current=new AbortController;const Se=await Zy(f,A,_,Y,$,De=>Z(ft=>Math.max(ft,De)),Ie.current.signal);ht.current&&clearInterval(ht.current),Z(100),$e(_.steps),We(0),O("");const me={prompt:f,negativePrompt:A,seed:Se.seed,steps:_.steps,cfgScale:_.cfgScale,width:_.width,height:_.height,sampler:_.sampler,model:Y,duration_sec:Se.duration_sec,timestamp:new Date().toLocaleTimeString(),inputImage:!!$};let Re=null,ve=null;try{if(Re=await ky(Se.image,me),ve=Re.url,!ve)throw new Error("The local server saved the image but did not return a file URL.")}catch(De){throw console.error("Generated image could not be saved:",De),new Error(`Image generated but could not be saved to USB: ${De.message||De}`)}ue(ve),Qe(Se.seed),P(Se.duration_sec);const Le={...me,...Re||{},url:ve};R(De=>[Le,...De])}catch(Se){Se.name==="AbortError"?console.log("Generation request was aborted by the user"):(console.error("Generation failed:",Se),te(Se.message||"Generation failed. Please try again.")),ht.current&&clearInterval(ht.current)}finally{E(!1),Ie.current=null}},q=async()=>{if(await F({title:"Stop Generation?",message:"The current image generation will be cancelled and the local model server may restart.",confirmLabel:"Stop",danger:!0}))if(ht.current&&clearInterval(ht.current),d(!0),Ie.current&&Ie.current.abort(),Al())try{console.log("Cancelling: Stopping server to kill generation threads..."),await Ks(),Y&&(console.log("Cancelling: Restarting server for future generations..."),await Qs(Y,_),await Fy()||console.warn("Server failed to restart properly."))}catch(L){console.error("Failed to restart server on cancellation:",L)}finally{d(!1),E(!1),Z(0)}else d(!1),E(!1),Z(0)},Q=async()=>{if(ae)try{if(ae.startsWith("data:image")){const be=await(await fetch(ae)).blob();await navigator.clipboard.write([new ClipboardItem({[be.type]:be})])}else{const L=new Image;L.crossOrigin="anonymous",L.src=ae,L.onload=async()=>{const be=document.createElement("canvas");be.width=L.width,be.height=L.height,be.getContext("2d").drawImage(L,0,0),be.toBlob(async tt=>{await navigator.clipboard.write([new ClipboardItem({[tt.type]:tt})])},"image/png")}}Fe(!0),setTimeout(()=>Fe(!1),2e3)}catch(L){console.error("Failed to copy image:",L)}},Ze=()=>{if(!ae)return;const L=document.createElement("a");L.href=ae,L.download=`diffusion-${je||Date.now()}.png`,document.body.appendChild(L),L.click(),document.body.removeChild(L)},zt=(L,be=`diffusion-${Date.now()}.png`)=>{if(!L)return;const Ge=document.createElement("a");Ge.href=L,Ge.download=be,document.body.appendChild(Ge),Ge.click(),document.body.removeChild(Ge)},wt=U.useCallback(L=>{b(L.prompt),r(L.negativePrompt),D(be=>({...be,steps:L.steps,cfgScale:L.cfgScale,width:L.width,height:L.height,sampler:L.sampler,seed:L.seed})),ue(L.url),Qe(L.seed),P(L.duration_sec??L.durationSec??null)},[b,r,D]),ge=U.useCallback((L,be)=>{const Ge=be.ctrlKey||be.metaKey||be.shiftKey;xt(tt=>Ge?tt.includes(L)?tt.filter(Be=>Be!==L):[...tt,L]:[L]),G[L]&&wt(G[L])},[G,wt]),Bt=Ut.map(L=>G[L]).filter(Boolean),ui=()=>{xt([])},ci=()=>{Bt[0]&&wt(Bt[0])},_a=()=>{Bt.forEach((L,be)=>{const Ge=L.seed??Date.now();zt(L.url,`diffusion-${Ge}-${be+1}.png`)})},_u=async()=>{if(Bt.length===0)return;const L=Bt.length;if(await F({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(Bt);const Ge=new Set(Ut);R(tt=>tt.filter((Be,_t)=>!Ge.has(_t))),xt([]),Bt.some(tt=>tt.url===ae)&&(ue(null),Qe(null),P(null))}catch(Ge){console.error("Failed to delete selected outputs:",Ge),se({title:"Delete Failed",message:Ge.message||String(Ge),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(Su,{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:A,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:()=>ce("constraints"),children:[c.jsx(Zs,{size:14}),c.jsxs("span",{children:["Resolution: ",_.width,"x",_.height]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ce("constraints"),children:[c.jsx(ta,{size:14}),c.jsxs("span",{children:["Steps: ",_.steps]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ce("constraints"),children:[c.jsx(sy,{size:14}),c.jsxs("span",{children:["CFG: ",_.cfgScale.toFixed(1)]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ce("constraints"),children:[c.jsx(Su,{size:14}),c.jsxs("span",{children:["Sampler: ",_.sampler]})]}),c.jsx("div",{className:"status-chip",onClick:()=>ce("constraints"),children:c.jsxs("span",{children:["Seed: ",_.seed===-1?"Random":_.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:il,children:[c.jsx("input",{type:"file",ref:el,style:{display:"none"},accept:"image/*",onChange:ol,disabled:y}),$?c.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[c.jsx("img",{src:$,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:T,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:C,disabled:y||!f.trim()||!Y,children:[c.jsx(Su,{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:qe?"Decoding Latents...":"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:"})," ",nt," / ",_.steps," (",Math.max(0,_.steps-nt)," left)"]}),c.jsxs("div",{style:{textAlign:"right"},children:[c.jsx("strong",{children:"Elapsed:"})," ",we,"s",x&&` (${x==="decoding"?"decoding":x})`]})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:"4px 0 10px 0"},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${w}%`,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: ",w,"%"]}),c.jsx("span",{children:"•"}),c.jsxs("span",{children:["Est. remaining: ",Je,"s"]})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{marginTop:"16px",height:"36px",padding:"0 24px"},onClick:q,children:"Stop Generating"})]})}):ae?c.jsx("img",{src:ae,className:"output-image",alt:"Generated Output"}):ee?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:ee}),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(Su,{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."]})]})}),ae&&!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: ",je]}),Ve&&c.jsxs("span",{children:["Inference Time: ",Ve.toFixed(1),"s"]})]}),c.jsxs("div",{className:"image-actions",children:[c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:Q,children:[Te?c.jsx(Ys,{size:16}):c.jsx(V0,{size:16}),c.jsx("span",{children:Te?"Copied":"Copy"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:Ze,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"}),Bt.length>0&&c.jsxs("div",{className:"gallery-selection-actions",children:[c.jsxs("span",{className:"gallery-selection-count",children:[Bt.length," selected"]}),c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:ci,children:[c.jsx(Ys,{size:14}),c.jsx("span",{children:"Use"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:_a,children:[c.jsx(am,{size:14}),c.jsx("span",{children:"Download"})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:_u,children:[c.jsx(ai,{size:14}),c.jsx("span",{children:"Delete"})]}),c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:ui,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,be)=>c.jsx(e1,{img:L,idx:be,isSelected:Ut.includes(be),onClick:ge},L.image||be))})]})]})]})}const l1=U.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:A,setServerRunning:r,constraints:_,showAlert:D=async({message:G})=>window.alert(G),showConfirm:Y=async({message:G})=>window.confirm(G)}){const[G,R]=U.useState([]),[y,E]=U.useState(null),[w,Z]=U.useState(0),[ce,$]=U.useState(""),[k,se]=U.useState(null),[F,ae]=U.useState(null),[ue,je]=U.useState(null),[Qe,Ve]=U.useState({filename:"",speed:"0.0",eta:0,status:""}),[P,Te]=U.useState(""),[Fe,we]=U.useState(null),[Me,Je]=U.useState(!1),[We,nt]=U.useState({progress:0,phase:""}),[$e,x]=U.useState(null),[O,K]=U.useState({backendMode:"",backendBinary:"",backendDevice:""}),fe=G.map(T=>ii(T).filename),de=k!==null||Me;U.useEffect(()=>{B(),d()},[]),U.useEffect(()=>{if(!A&&!k){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)}},[A,k]);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=>{E(T);const C=setInterval(async()=>{try{const q=await um();q.active?(Z(q.progress===-1?0:q.progress),$(`${q.speed} • ETA ${q.eta}s`)):(clearInterval(C),E(null),q.error?String(q.error).toLowerCase().includes("cancelled")||D({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(ii).filter(C=>C.filename))}catch(T){console.error(T)}},H=async(T,C)=>{if(y||fe.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){D({title:"Server Required",message:"Model download requires the local image generator server.",danger:!0});return}try{const Ze=await Wy(T);Ze.ok?z(C):D({title:"Download Failed",message:Ze.error||"Unknown error",danger:!0})}catch(Ze){D({title:"Download Error",message:Ze.message,danger:!0})}},I=async T=>{if(T.preventDefault(),!P.trim())return;let C="model.gguf";try{const q=new URL(P.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){D({title:"Invalid URL",message:q.message,danger:!0});return}await H(P.trim(),C),Te("")},ee=T=>{H(T.url,T.filename)},te=async()=>{await Iy(),E(null),Z(0),$(""),await B()},qe=async T=>{if(f&&f!==T&&A){x(T);return}await Ee(T)},Ee=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(),Ze=`.\\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: - -${Ze} - -Update the UI status anyway?`,confirmLabel:"Update UI"})&&(b(T),r(!0)):await Y({title:"Backend Not Running",message:`C++ backend server is not running on port 8080. - -To run locally, start: - -${Ze} - -Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(b(T),r(!1));return}se(T),ae({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:T,backendMode:"",backendBinary:"",device:""});try{const Q=await Qs(T,_);console.log(Q);let Ze=!1,zt=null;for(let wt=0;wt<240;wt++){const ge=await ba();if(ge.loading&&ae({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){Ze=!0;break}if(ge.error){zt=ge.error;break}if(!ge.running&&wt>3){zt="The backend process terminated immediately on startup.";break}await new Promise(Bt=>setTimeout(Bt,500))}if(Ze)ae(wt=>({...wt||{},progress:100,phase:"Model ready",speed:"",current:wt?.current||0,total:wt?.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),D({title:"Model Load Failed",message:Q.message||String(Q),danger:!0})}finally{setTimeout(()=>ae(null),800),se(null)}},Ut=async()=>{const T=$e;x(null),await xt(),T&&await Ee(T)},xt=async()=>{if(Me)return;Je(!0),nt({progress:10,phase:"Stopping backend process..."});const T=setInterval(async()=>{try{const C=await ba();C.unloading?.active?nt({progress:C.unloading.progress||50,phase:C.unloading.phase||"Unloading model..."}):nt(q=>({progress:Math.min(95,q.progress+10),phase:q.phase||"Unloading model..."}))}catch{}},300);try{await Ks(),nt({progress:100,phase:"Model unloaded"}),b(null),x(null),r(!1)}catch(C){console.error(C),D({title:"Unload Failed",message:C.message||String(C),danger:!0})}finally{clearInterval(T),setTimeout(()=>{Je(!1),nt({progress:0,phase:""})},500)}},ht=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 xt()}catch(C){console.error("Failed to delete model:",C),D({title:"Delete Failed",message:C.message||String(C),danger:!0})}},el=async(T,C)=>{const q=new AbortController;we(q),je(0),Ve({filename:C,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Ky(T,Q=>{je(Math.round(Q.progress)),Ve({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"&&D({title:"Import Failed",message:Q.message||String(Q),danger:!0})}finally{je(null),we(null)}},Ie=()=>{Fe&&Fe.abort()},il=T=>{const C=T.target.files[0];C&&el(C,C.name),T.target.value=""},ol=!!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(xu,{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:xt,disabled:Me||k!==null,children:[Me?c.jsx(ta,{className:"progress-spinner",size:16}):c.jsx(ai,{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:We.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(We.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,We.progress))}%`,transition:"width 0.25s ease"}})})]})]}),F&&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: ",F.model||k]}),(F.backendMode||F.backendBinary||F.device)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"10px"},children:[F.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(xu,{size:14}),c.jsxs("span",{children:["Loading on ",F.backendMode]})]}),F.device&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:F.device})}),F.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:F.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:[F.phase,F.speed?` (${F.speed})`:""]}),c.jsx("span",{children:F.total>0?`Loaded ${F.current} / ${F.total} tensors`:`${Math.round(F.progress)}%`})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,F.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(Xs,{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||ni(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:xt,disabled:Me,children:[Me?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(ai,{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:()=>qe(C),disabled:de,children:[k===C?c.jsx(ta,{className:"progress-spinner",size:14}):c.jsx(Xs,{size:14}),c.jsx("span",{children:k===C?"Loading":"Load"})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{height:"36px",width:"36px",padding:0,minWidth:"36px"},onClick:()=>ht(C),disabled:de,title:"Delete from models folder",children:c.jsx(ai,{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=fe.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:w>0?`${w}%`:"Preparing"})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,w))}%`,transition:"width 0.2s ease"}})}),ce&&c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"4px"},children:ce})]}),c.jsxs("button",{className:q?"m3-btn m3-btn-tonal":"m3-btn m3-btn-filled",style:{height:"36px",marginTop:"auto"},onClick:()=>ee(C),disabled:q||y!==null,children:[q?c.jsx(xu,{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"]})}),ue!==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: ",Qe.filename]}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:Ie,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:[Qe.status," (",Qe.speed," MB/s)"]}),c.jsxs("span",{children:[ue,"% (",Qe.eta,"s remaining)"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${ue}%`,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:il,disabled:ue!==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."}),ol?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:[w,"%"]})]}),c.jsx("div",{className:"model-progress-bar",style:{margin:"4px 0"},children:c.jsx("div",{className:"model-progress-fill",style:{width:`${w}%`,transition:"width 0.15s ease"}})}),c.jsx("div",{style:{fontSize:"0.7rem",color:"var(--md-sys-color-outline)",marginTop:"2px"},children:ce}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px",marginTop:"10px"},onClick:te,children:[c.jsx(ks,{size:14}),c.jsx("span",{children:"Stop Download"})]})]}):c.jsxs("form",{onSubmit:I,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:P,onChange:T=>Te(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"})]})]})]}),$e&&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 "',$e,'".']}),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:xt,disabled:Me,children:[c.jsx(ai,{size:14}),c.jsx("span",{children:"Unload Only"})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",onClick:Ut,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=U.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:A,specs:r,backendOptions:_}){const D=A?u1(A):!1,Y=_?.options?.length?_.options:[{id:"cpu",label:"CPU",available:!0}],G=(E,w)=>{b(Z=>({...Z,[E]:w}))},R=(E,w)=>{const Z=w==="sdxl"&&!D,ce=cm.find($=>$.id===E);if(ce){let $=Z?ce.sdxl_width:ce.width,k=Z?ce.sdxl_height:ce.height;D&&($>k?(k=Math.round(k*512/$),$=512):($=Math.round($*512/k),k=512),$=Math.round($/64)*64,k=Math.round(k/64)*64),G("width",$),G("height",k)}},y=E=>{b(w=>({...w,backendType:E,useGpu:E!=="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"]}),D&&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:A}),"). 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:[D?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||D?"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:D?"*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(E=>{const w=Math.abs(f.width/f.height-E.width/E.height)<.1;return c.jsxs("button",{className:`m3-btn m3-btn-outlined aspect-ratio-btn ${w?"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(E.id,D?"sd15":f.width>=1024?"sdxl":"sd15"),children:[c.jsx("div",{className:`aspect-ratio-preview ratio-${E.id.replace(":","-")}`}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem",marginTop:"2px"},children:E.label}),c.jsx("span",{style:{fontSize:"0.68rem",opacity:.7},children:D?`Max: ${E.id==="1:1"?"512x512":E.id==="4:3"?"512x384":E.id==="16:9"?"512x288":"288x512"}`:E.desc})]},E.id)})})]})]})]}),c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(Zs,{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:E=>G("steps",parseInt(E.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:E=>G("cfgScale",parseFloat(E.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:E=>G("seed",parseInt(E.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(E=>c.jsx("div",{className:`m3-segment-item ${f.backendType===E.id||!f.backendType&&E.id==="cpu"?"active":""}`,onClick:()=>y(E.id),title:E.id==="cuda"?"CUDA appears only when an NVIDIA CUDA backend is available.":void 0,children:E.label},E.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."]}),_?.unavailable?.length>0&&c.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"4px"},children:_.unavailable.map(E=>c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-error)",lineHeight:1.35},children:[E.label," unavailable: ",E.reason]},E.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:E=>G("vaeTiling",E.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:E=>G("vaeOnCpu",E.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=U.memo(c1);function f1(){const f=U.useRef(null),[b,A]=U.useState(null),r=U.useCallback(T=>{const C=f.current;f.current=null,A(null),C&&C(T)},[]),_=U.useCallback(({title:T="Confirm Action",message:C,confirmLabel:q="OK",cancelLabel:Q="Cancel",danger:Ze=!1})=>new Promise(zt=>{f.current=zt,A({type:"confirm",title:T,message:C,confirmLabel:q,cancelLabel:Q,danger:Ze})}),[]),D=U.useCallback(({title:T="Notice",message:C,confirmLabel:q="OK",danger:Q=!1})=>new Promise(Ze=>{f.current=Ze,A({type:"alert",title:T,message:C,confirmLabel:q,danger:Q})}),[]),[Y,G]=U.useState(()=>{const T=localStorage.getItem("theme");return T||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")});U.useEffect(()=>{document.documentElement.setAttribute("data-theme",Y),localStorage.setItem("theme",Y)},[Y]);const[R,y]=U.useState("generator"),[E,w]=U.useState(""),[Z,ce]=U.useState(""),[$,k]=U.useState(null),[se,F]=U.useState(null),[ae,ue]=U.useState(!1),[je,Qe]=U.useState(!1),[Ve,P]=U.useState({options:[{id:"cpu",label:"CPU",available:!0}],cudaAvailable:!1,vulkanAvailable:!1,defaultBackendType:"cpu"}),[Te,Fe]=U.useState(null),[we,Me]=U.useState([]),[Je,We]=U.useState(!1),[nt,$e]=U.useState(!1),[x,O]=U.useState([]),[K,fe]=U.useState(!1),[de,d]=U.useState(0),[z,B]=U.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,I]=U.useState({cpu_usage:0,ram_used_gb:0,ram_total_gb:0,gpu_name:"Detecting...",vram_used_gb:0,vram_total_gb:0}),[ee,te]=U.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"});U.useEffect(()=>{async function T(){try{const C=await Gy(),q=await Ly();P(q),B(C),te(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 qe=U.useCallback(async()=>{We(!0);try{const[T,C]=await Promise.all([wy(),Ry().catch(()=>[])]);Fe(T),Me(C)}finally{We(!1)}},[]);U.useEffect(()=>{qe()},[qe]);const Ee=U.useCallback(async()=>{try{const T=await By();await navigator.clipboard.writeText(JSON.stringify(T,null,2)),$e(!0),setTimeout(()=>$e(!1),1800)}catch(T){D({title:"Diagnostics Failed",message:T.message||String(T),danger:!0})}},[D]),Ut=U.useCallback(async()=>{if(we.length===0)return;const T=we.reduce((q,Q)=>q+Number(Q.sizeBytes||0),0);if(await _({title:"Clean Safe Files?",message:`Delete ${we.length} temporary/cache item${we.length===1?"":"s"} and free about ${ni(T)}? - -Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){We(!0);try{await Hy(we.map(q=>q.id)),await qe()}catch(q){D({title:"Cleanup Failed",message:q.message||String(q),danger:!0})}finally{We(!1)}}},[we,qe,D,_]);U.useEffect(()=>{async function T(){const C=await Xy();O(C)}T()},[]),U.useEffect(()=>{se?localStorage.setItem("active-model",se):localStorage.removeItem("active-model")},[se]),U.useEffect(()=>{let T=null;async function C(){const q=await ba();if(!!q.ready){T&&clearInterval(T);const Ze=localStorage.getItem("active-model");if(Ze)F(Ze),ue(!0);else{try{if(q&&q.settings&&q.settings.model){const zt=q.settings.model.split(/[\\/]/).pop();F(zt)}}catch{}ue(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const zt=localStorage.getItem("active-model");zt&&(F(zt),ue(!1))}}return C(),T=setInterval(C,2e3),()=>{T&&clearInterval(T)}},[]),U.useEffect(()=>{async function T(){try{const q=await qy();I(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)},[]),U.useEffect(()=>{if(se){const T=se.toLowerCase();T.includes("flux")||T.includes("schnell")?te(C=>({...C,steps:4,cfgScale:1,width:1024,height:1024})):T.includes("lightning")||T.includes("turbo")?te(C=>({...C,steps:4,cfgScale:1.5,width:1024,height:1024})):T.includes("sd15")?te(C=>({...C,steps:25,cfgScale:7,width:512,height:512})):T.includes("sd35")?te(C=>({...C,steps:20,cfgScale:4.5,width:1024,height:1024})):te(C=>({...C,steps:20,cfgScale:7,width:512,height:512}))}},[se]);const xt=U.useMemo(()=>{switch(R){case"generator":return c.jsx(l1,{prompt:E,setPrompt:w,negativePrompt:Z,setNegativePrompt:ce,constraints:ee,setConstraints:te,activeModel:se,generatedImages:x,setGeneratedImages:O,isGenerating:K,setIsGenerating:fe,generationProgress:de,setGenerationProgress:d,setActiveTab:y,inputImage:$,setInputImage:k,showAlert:D,showConfirm:_});case"models":return c.jsx(i1,{activeModel:se,setActiveModel:F,serverRunning:ae,setServerRunning:ue,constraints:ee,showAlert:D,showConfirm:_});case"constraints":return c.jsx(s1,{constraints:ee,setConstraints:te,activeModel:se,specs:z,backendOptions:Ve});default:return null}},[R,E,Z,ee,se,x,K,de,$,ae,z,Ve,D,_]),ht=U.useMemo(()=>c.jsx(Ey,{activeTab:R,setActiveTab:y,specs:z}),[R,z]),el=U.useCallback(async()=>{if(!(!ae||je)){Qe(!0);try{await Ks(),ue(!1),F(null)}catch(T){console.error("Failed to stop server:",T),D({title:"Stop Server Failed",message:T.message||String(T),danger:!0})}finally{Qe(!1)}}},[ae,je,D]),Ie=[...Te?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Te?.issues||[]],il=we.reduce((T,C)=>T+Number(C.sizeBytes||0),0),ol=!!(Te&&(Ie.length>0||we.length>0));return c.jsxs("div",{className:"app-container",children:[ht,c.jsxs("div",{className:"main-content",children:[c.jsx(Ay,{telemetry:H,serverRunning:ae,activeModel:se,onStopServer:el,isStoppingServer:je,theme:Y,setTheme:G}),ol&&c.jsxs("div",{className:`m3-card readiness-card ${Te?.stale||Ie.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:Te?.stale?"Restart Required":Ie.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Te?.stale?`Running server build: ${Te.build||"unknown"}`:Ie.length>0?"Local AI Image Generator found setup items that may need attention.":`${we.length} temporary item${we.length===1?"":"s"} can be cleaned (${ni(il)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:qe,disabled:Je,children:Je?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:Ee,children:nt?"Copied":"Copy Diagnostics"}),we.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Ut,disabled:Je,children:["Clean ",ni(il)]})]})]}),Ie.length>0&&c.jsx("div",{className:"readiness-issues",children:Ie.slice(0,4).map(T=>c.jsx("span",{children:T},T))}),we.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:we.slice(0,3).map(T=>c.jsxs("span",{title:T.path,children:[T.name," · ",T.size," · ",T.reason]},T.id))})]}),xt]}),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/assets/index-CBtRYlFE.js b/app/dist/assets/index-CBtRYlFE.js new file mode 100644 index 0000000..74ecbc6 --- /dev/null +++ b/app/dist/assets/index-CBtRYlFE.js @@ -0,0 +1,121 @@ +(function(){const S=document.createElement("link").relList;if(S&&S.supports&&S.supports("modulepreload"))return;for(const z of document.querySelectorAll('link[rel="modulepreload"]'))r(z);new MutationObserver(z=>{for(const A of z)if(A.type==="childList")for(const L of A.addedNodes)L.tagName==="LINK"&&L.rel==="modulepreload"&&r(L)}).observe(document,{childList:!0,subtree:!0});function N(z){const A={};return z.integrity&&(A.integrity=z.integrity),z.referrerPolicy&&(A.referrerPolicy=z.referrerPolicy),z.crossOrigin==="use-credentials"?A.credentials="include":z.crossOrigin==="anonymous"?A.credentials="omit":A.credentials="same-origin",A}function r(z){if(z.ep)return;z.ep=!0;const A=N(z);fetch(z.href,A)}})();function cm(f){return f&&f.__esModule&&Object.prototype.hasOwnProperty.call(f,"default")?f.default:f}var Os={exports:{}},ei={};var kd;function z0(){if(kd)return ei;kd=1;var f=Symbol.for("react.transitional.element"),S=Symbol.for("react.fragment");function N(r,z,A){var L=null;if(A!==void 0&&(L=""+A),z.key!==void 0&&(L=""+z.key),"key"in z){A={};for(var H in z)H!=="key"&&(A[H]=z[H])}else A=z;return z=A.ref,{$$typeof:f,type:r,key:L,ref:z!==void 0?z:null,props:A}}return ei.Fragment=S,ei.jsx=N,ei.jsxs=N,ei}var Zd;function T0(){return Zd||(Zd=1,Os.exports=z0()),Os.exports}var c=T0(),Us={exports:{}},ie={};var Vd;function M0(){if(Vd)return ie;Vd=1;var f=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),N=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),A=Symbol.for("react.consumer"),L=Symbol.for("react.context"),H=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),y=Symbol.for("react.memo"),E=Symbol.for("react.lazy"),O=Symbol.for("react.activity"),Z=Symbol.iterator;function ee(d){return d===null||typeof d!="object"?null:(d=Z&&d[Z]||d["@@iterator"],typeof d=="function"?d:null)}var q={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},W=Object.assign,ne={};function F(d,_,w){this.props=d,this.context=_,this.refs=ne,this.updater=w||q}F.prototype.isReactComponent={},F.prototype.setState=function(d,_){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,_,"setState")},F.prototype.forceUpdate=function(d){this.updater.enqueueForceUpdate(this,d,"forceUpdate")};function Oe(){}Oe.prototype=F.prototype;function ye(d,_,w){this.props=d,this.context=_,this.refs=ne,this.updater=w||q}var Le=ye.prototype=new Oe;Le.constructor=ye,W(Le,F.prototype),Le.isPureReactComponent=!0;var ke=Array.isArray;function Me(){}var te={H:null,A:null,T:null,S:null},de=Object.prototype.hasOwnProperty;function et(d,_,w){var G=w.ref;return{$$typeof:f,type:d,key:_,ref:G!==void 0?G:null,props:w}}function jt(d,_){return et(d.type,_,d.props)}function pe(d){return typeof d=="object"&&d!==null&&d.$$typeof===f}function Ke(d){var _={"=":"=0",":":"=2"};return"$"+d.replace(/[=:]/g,function(w){return _[w]})}var ut=/\/+/g;function Je(d,_){return typeof d=="object"&&d!==null&&d.key!=null?Ke(""+d.key):_.toString(36)}function Ye(d){switch(d.status){case"fulfilled":return d.value;case"rejected":throw d.reason;default:switch(typeof d.status=="string"?d.then(Me,Me):(d.status="pending",d.then(function(_){d.status==="pending"&&(d.status="fulfilled",d.value=_)},function(_){d.status==="pending"&&(d.status="rejected",d.reason=_)})),d.status){case"fulfilled":return d.value;case"rejected":throw d.reason}}throw d}function x(d,_,w,G,J){var le=typeof d;(le==="undefined"||le==="boolean")&&(d=null);var re=!1;if(d===null)re=!0;else switch(le){case"bigint":case"string":case"number":re=!0;break;case"object":switch(d.$$typeof){case f:case S:re=!0;break;case E:return re=d._init,x(re(d._payload),_,w,G,J)}}if(re)return J=J(d),re=G===""?"."+Je(d,0):G,ke(J)?(w="",re!=null&&(w=re.replace(ut,"$&/")+"/"),x(J,_,w,"",function(ct){return ct})):J!=null&&(pe(J)&&(J=jt(J,w+(J.key==null||d&&d.key===J.key?"":(""+J.key).replace(ut,"$&/")+"/")+re)),_.push(J)),1;re=0;var Ze=G===""?".":G+":";if(ke(d))for(var Ee=0;Ee>>1,oe=x[ge];if(0>>1;gez(w,K))Gz(J,w)?(x[ge]=J,x[G]=K,ge=G):(x[ge]=w,x[_]=K,ge=_);else if(Gz(J,K))x[ge]=J,x[G]=K,ge=G;else break e}}return C}function z(x,C){var K=x.sortIndex-C.sortIndex;return K!==0?K:x.id-C.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 L=Date,H=L.now();f.unstable_now=function(){return L.now()-H}}var B=[],y=[],E=1,O=null,Z=3,ee=!1,q=!1,W=!1,ne=!1,F=typeof setTimeout=="function"?setTimeout:null,Oe=typeof clearTimeout=="function"?clearTimeout:null,ye=typeof setImmediate<"u"?setImmediate:null;function Le(x){for(var C=N(y);C!==null;){if(C.callback===null)r(y);else if(C.startTime<=x)r(y),C.sortIndex=C.expirationTime,S(B,C);else break;C=N(y)}}function ke(x){if(W=!1,Le(x),!q)if(N(B)!==null)q=!0,Me||(Me=!0,Ke());else{var C=N(y);C!==null&&Ye(ke,C.startTime-x)}}var Me=!1,te=-1,de=5,et=-1;function jt(){return ne?!0:!(f.unstable_now()-etx&&jt());){var ge=O.callback;if(typeof ge=="function"){O.callback=null,Z=O.priorityLevel;var oe=ge(O.expirationTime<=x);if(x=f.unstable_now(),typeof oe=="function"){O.callback=oe,Le(x),C=!0;break t}O===N(B)&&r(B),Le(x)}else r(B);O=N(B)}if(O!==null)C=!0;else{var d=N(y);d!==null&&Ye(ke,d.startTime-x),C=!1}}break e}finally{O=null,Z=K,ee=!1}C=void 0}}finally{C?Ke():Me=!1}}}var Ke;if(typeof ye=="function")Ke=function(){ye(pe)};else if(typeof MessageChannel<"u"){var ut=new MessageChannel,Je=ut.port2;ut.port1.onmessage=pe,Ke=function(){Je.postMessage(null)}}else Ke=function(){F(pe,0)};function Ye(x,C){te=F(function(){x(f.unstable_now())},C)}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||125ge?(x.sortIndex=K,S(y,x),N(B)===null&&x===N(y)&&(W?(Oe(te),te=-1):W=!0,Ye(ke,K-ge))):(x.sortIndex=oe,S(B,x),q||ee||(q=!0,Me||(Me=!0,Ke()))),x},f.unstable_shouldYield=jt,f.unstable_wrapCallback=function(x){var C=Z;return function(){var K=Z;Z=C;try{return x.apply(this,arguments)}finally{Z=K}}}})(Rs)),Rs}var $d;function A0(){return $d||($d=1,Bs.exports=N0()),Bs.exports}var Hs={exports:{}},_t={};var Wd;function D0(){if(Wd)return _t;Wd=1;var f=Qs();function S(B){var y="https://react.dev/errors/"+B;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(f)}catch(S){console.error(S)}}return f(),Hs.exports=D0(),Hs.exports}var Id;function O0(){if(Id)return ti;Id=1;var f=A0(),S=Qs(),N=C0();function r(e){var t="https://react.dev/errors/"+e;if(1oe||(e.current=ge[oe],ge[oe]=null,oe--)}function w(e,t){oe++,ge[oe]=e.current,e.current=t}var G=d(null),J=d(null),le=d(null),re=d(null);function Ze(e,t){switch(w(le,t),w(J,e),w(G,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?md(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=md(t),e=hd(t,e);else switch(e){case"svg":e=1;break;case"math":e=2;break;default:e=0}}_(G),w(G,e)}function Ee(){_(G),_(J),_(le)}function ct(e){e.memoizedState!==null&&w(re,e);var t=G.current,l=hd(t,e.type);t!==l&&(w(J,e),w(G,l))}function ot(e){J.current===e&&(_(G),_(J)),re.current===e&&(_(re),Wn._currentValue=K)}var ht,cl;function Ut(e){if(ht===void 0)try{throw Error()}catch(l){var t=l.stack.trim().match(/\n( *(at )?)/);ht=t&&t[1]||"",cl=-1)":-1n||o[a]!==g[n]){var j=` +`+o[a].replace(" at new "," at ");return e.displayName&&j.includes("")&&(j=j.replace("",e.displayName)),j}while(1<=a&&0<=n);break}}}finally{k=!1,Error.prepareStackTrace=l}return(l=e?e.displayName||e.name:"")?Ut(l):""}function D(e,t){switch(e.tag){case 26:case 27:case 5:return Ut(e.type);case 16:return Ut("Lazy");case 13:return e.child!==t&&t!==null?Ut("Suspense Fallback"):Ut("Suspense");case 19:return Ut("SuspenseList");case 0:case 15:return ce(e.type,!1);case 11:return ce(e.type.render,!1);case 1:return ce(e.type,!0);case 31:return Ut("Activity");default:return""}}function R(e){try{var t="",l=null;do t+=D(e,l),l=e,e=e.return;while(e);return t}catch(a){return` +Error generating stack: `+a.message+` +`+a.stack}}var I=Object.prototype.hasOwnProperty,V=f.unstable_scheduleCallback,bt=f.unstable_cancelCallback,ea=f.unstable_shouldYield,It=f.unstable_requestPaint,_e=f.unstable_now,Y=f.unstable_getCurrentPriorityLevel,Ne=f.unstable_ImmediatePriority,Ve=f.unstable_UserBlockingPriority,tt=f.unstable_NormalPriority,zt=f.unstable_LowPriority,ll=f.unstable_IdlePriority,xa=f.log,_a=f.unstable_setDisableYieldValue,Fe=null,ae=null;function se(e){if(typeof xa=="function"&&_a(e),ae&&typeof ae.setStrictMode=="function")try{ae.setStrictMode(Fe,e)}catch{}}var ve=Math.clz32?Math.clz32:He,Ae=Math.log,st=Math.LN2;function He(e){return e>>>=0,e===0?32:31-(Ae(e)/st|0)|0}var rt=256,xt=262144,wt=4194304;function sl(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 ii(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=sl(a):(u&=s,u!==0?n=sl(u):l||(l=s&~e,l!==0&&(n=sl(l))))):(s=a&~i,s!==0?n=sl(s):u!==0?n=sl(u):l||(l=a&~e,l!==0&&(n=sl(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 fn(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function rm(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 Vs(){var e=wt;return wt<<=1,(wt&62914560)===0&&(wt=4194304),e}function bu(e){for(var t=[],l=0;31>l;l++)t.push(e);return t}function on(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 Qt(e){return e.replace(vm,function(t){return"\\"+t.charCodeAt(0).toString(16)+" "})}function Mu(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=""+Xt(t)):e.value!==""+Xt(t)&&(e.value=""+Xt(t)):u!=="submit"&&u!=="reset"||e.removeAttribute("value"),t!=null?Eu(e,u,Xt(t)):l!=null?Eu(e,u,Xt(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=""+Xt(s):e.removeAttribute("name")}function uf(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)){Tu(e);return}l=l!=null?""+Xt(l):"",t=t!=null?""+Xt(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),Tu(e)}function Eu(e,t,l){t==="number"&&si(e.ownerDocument)===e||e.defaultValue===""+l||(e.defaultValue=""+l)}function Na(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"),Ou=!1;if(rl)try{var hn={};Object.defineProperty(hn,"passive",{get:function(){Ou=!0}}),window.addEventListener("test",hn,hn),window.removeEventListener("test",hn,hn)}catch{Ou=!1}var Nl=null,Uu=null,oi=null;function mf(){if(oi)return oi;var e,t=Uu,l=t.length,a,n="value"in Nl?Nl.value:Nl.textContent,i=n.length;for(e=0;e=gn),Sf=" ",bf=!1;function xf(e,t){switch(e){case"keyup":return Vm.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function _f(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Oa=!1;function Jm(e,t){switch(e){case"compositionend":return _f(t);case"keypress":return t.which!==32?null:(bf=!0,Sf);case"textInput":return e=t.data,e===Sf&&bf?null:e;default:return null}}function $m(e,t){if(Oa)return e==="compositionend"||!Gu&&xf(e,t)?(e=mf(),oi=Uu=Nl=null,Oa=!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=Df(l)}}function Of(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Of(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Uf(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 Yu(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=rl&&"documentMode"in document&&11>=document.documentMode,Ua=null,Xu=null,xn=null,Qu=!1;function wf(e,t,l){var a=l.window===l?l.document:l.nodeType===9?l:l.ownerDocument;Qu||Ua==null||Ua!==si(a)||(a=Ua,"selectionStart"in a&&Yu(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}),xn&&bn(xn,a)||(xn=a,a=au(Xu,"onSelect"),0>=u,n-=u,al=1<<32-ve(t)+n|l<fe?(be=Q,Q=null):be=Q.sibling;var ze=v(h,Q,p[fe],T);if(ze===null){Q===null&&(Q=be);break}e&&Q&&ze.alternate===null&&t(h,Q),m=i(ze,m,fe),je===null?$=ze:je.sibling=ze,je=ze,Q=be}if(fe===p.length)return l(h,Q),xe&&ml(h,fe),$;if(Q===null){for(;fefe?(be=Q,Q=null):be=Q.sibling;var Wl=v(h,Q,ze.value,T);if(Wl===null){Q===null&&(Q=be);break}e&&Q&&Wl.alternate===null&&t(h,Q),m=i(Wl,m,fe),je===null?$=Wl:je.sibling=Wl,je=Wl,Q=be}if(ze.done)return l(h,Q),xe&&ml(h,fe),$;if(Q===null){for(;!ze.done;fe++,ze=p.next())ze=M(h,ze.value,T),ze!==null&&(m=i(ze,m,fe),je===null?$=ze:je.sibling=ze,je=ze);return xe&&ml(h,fe),$}for(Q=a(Q);!ze.done;fe++,ze=p.next())ze=b(Q,h,fe,ze.value,T),ze!==null&&(e&&ze.alternate!==null&&Q.delete(ze.key===null?fe:ze.key),m=i(ze,m,fe),je===null?$=ze:je.sibling=ze,je=ze);return e&&Q.forEach(function(j0){return t(h,j0)}),xe&&ml(h,fe),$}function Be(h,m,p,T){if(typeof p=="object"&&p!==null&&p.type===W&&p.key===null&&(p=p.props.children),typeof p=="object"&&p!==null){switch(p.$$typeof){case ee:e:{for(var $=p.key;m!==null;){if(m.key===$){if($=p.type,$===W){if(m.tag===7){l(h,m.sibling),T=n(m,p.props.children),T.return=h,h=T;break e}}else if(m.elementType===$||typeof $=="object"&&$!==null&&$.$$typeof===de&&ra($)===m.type){l(h,m.sibling),T=n(m,p.props),En(T,p),T.return=h,h=T;break e}l(h,m);break}else t(h,m);m=m.sibling}p.type===W?(T=ua(p.props.children,h.mode,T,p.key),T.return=h,h=T):(T=bi(p.type,p.key,p.props,null,h.mode,T),En(T,p),T.return=h,h=T)}return u(h);case q:e:{for($=p.key;m!==null;){if(m.key===$)if(m.tag===4&&m.stateNode.containerInfo===p.containerInfo&&m.stateNode.implementation===p.implementation){l(h,m.sibling),T=n(m,p.children||[]),T.return=h,h=T;break e}else{l(h,m);break}else t(h,m);m=m.sibling}T=Wu(p,h.mode,T),T.return=h,h=T}return u(h);case de:return p=ra(p),Be(h,m,p,T)}if(Ye(p))return X(h,m,p,T);if(Ke(p)){if($=Ke(p),typeof $!="function")throw Error(r(150));return p=$.call(p),P(h,m,p,T)}if(typeof p.then=="function")return Be(h,m,Ei(p),T);if(p.$$typeof===ye)return Be(h,m,ji(h,p),T);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),T=n(m,p),T.return=h,h=T):(l(h,m),T=$u(p,h.mode,T),T.return=h,h=T),u(h)):l(h,m)}return function(h,m,p,T){try{Mn=0;var $=Be(h,m,p,T);return ka=null,$}catch(Q){if(Q===Qa||Q===Ti)throw Q;var je=Rt(29,Q,null,h.mode);return je.lanes=T,je.return=h,je}}}var ma=ao(!0),no=ao(!1),Ul=!1;function sc(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function fc(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 wl(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Bl(e,t,l){var a=e.updateQueue;if(a===null)return null;if(a=a.shared,(Te&2)!==0){var n=a.pending;return n===null?t.next=t:(t.next=n.next,n.next=t),a.pending=t,t=Si(e),Yf(e,null,l),t}return vi(e,a,t,l),Si(e)}function Nn(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,Js(e,l)}}function oc(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 rc=!1;function An(){if(rc){var e=Xa;if(e!==null)throw e}}function Dn(e,t,l,a){rc=!1;var n=e.updateQueue;Ul=!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 j=e.alternate;j!==null&&(j=j.updateQueue,s=j.lastBaseUpdate,s!==u&&(s===null?j.firstBaseUpdate=g:s.next=g,j.lastBaseUpdate=o))}if(i!==null){var M=n.baseState;u=0,j=g=o=null,s=i;do{var v=s.lane&-536870913,b=v!==s.lane;if(b?(Se&v)===v:(a&v)===v){v!==0&&v===Ya&&(rc=!0),j!==null&&(j=j.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});e:{var X=e,P=s;v=t;var Be=l;switch(P.tag){case 1:if(X=P.payload,typeof X=="function"){M=X.call(Be,M,v);break e}M=X;break e;case 3:X.flags=X.flags&-65537|128;case 0:if(X=P.payload,v=typeof X=="function"?X.call(Be,M,v):X,v==null)break e;M=O({},M,v);break e;case 2:Ul=!0}}v=s.callback,v!==null&&(e.flags|=64,b&&(e.flags|=8192),b=n.callbacks,b===null?n.callbacks=[v]:b.push(v))}else b={lane:v,tag:s.tag,payload:s.payload,callback:s.callback,next:null},j===null?(g=j=b,o=M):j=j.next=b,u|=v;if(s=s.next,s===null){if(s=n.shared.pending,s===null)break;b=s,s=b.next,b.next=null,n.lastBaseUpdate=b,n.shared.pending=null}}while(!0);j===null&&(o=M),n.baseState=o,n.firstBaseUpdate=g,n.lastBaseUpdate=j,i===null&&(n.shared.lanes=0),Ll|=u,e.lanes=u,e.memoizedState=M}}function io(e,t){if(typeof e!="function")throw Error(r(191,e));e.call(t)}function uo(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,Dc(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 j=dh(o,a);Un(e,t,j,Yt(e))}else Un(e,t,a,Yt(e))}catch(M){Un(e,t,{then:function(){},status:"rejected",reason:M},Yt())}finally{C.p=i,u!==null&&s.types!==null&&(u.types=s.types),x.T=u}}function vh(){}function Nc(e,t,l,a){if(e.tag!==5)throw Error(r(476));var n=qo(e).queue;Go(e,n,t,K,l===null?vh:function(){return Lo(e),l(a)})}function qo(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:gl,lastRenderedState:K},next:null};var l={};return t.next={memoizedState:l,baseState:l,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:gl,lastRenderedState:l},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Lo(e){var t=qo(e);t.next===null&&(t=e.alternate.memoizedState),Un(e,t.next.queue,{},Yt())}function Ac(){return gt(Wn)}function Yo(){return Pe().memoizedState}function Xo(){return Pe().memoizedState}function Sh(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var l=Yt();e=wl(l);var a=Bl(t,e,l);a!==null&&(Ot(a,t,l),Nn(a,t,l)),t={cache:nc()},e.payload=t;return}t=t.return}}function bh(e,t,l){var a=Yt();l={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null},Gi(e)?ko(t,l):(l=Ku(e,t,l,a),l!==null&&(Ot(l,e,a),Zo(l,t,a)))}function Qo(e,t,l){var a=Yt();Un(e,t,l,a)}function Un(e,t,l,a){var n={lane:a,revertLane:0,gesture:null,action:l,hasEagerState:!1,eagerState:null,next:null};if(Gi(e))ko(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,Bt(s,u))return vi(e,t,n,0),Re===null&&gi(),!1}catch{}if(l=Ku(e,t,n,a),l!==null)return Ot(l,e,a),Zo(l,t,a),!0}return!1}function Dc(e,t,l,a){if(a={lane:2,revertLane:ss(),gesture:null,action:a,hasEagerState:!1,eagerState:null,next:null},Gi(e)){if(t)throw Error(r(479))}else t=Ku(e,l,a,2),t!==null&&Ot(t,e,2)}function Gi(e){var t=e.alternate;return e===ue||t!==null&&t===ue}function ko(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,Js(e,l)}}var wn={readContext:gt,use:wi,useCallback:$e,useContext:$e,useEffect:$e,useImperativeHandle:$e,useLayoutEffect:$e,useInsertionEffect:$e,useMemo:$e,useReducer:$e,useRef:$e,useState:$e,useDebugValue:$e,useDeferredValue:$e,useTransition:$e,useSyncExternalStore:$e,useId:$e,useHostTransitionStatus:$e,useFormState:$e,useActionState:$e,useOptimistic:$e,useMemoCache:$e,useCacheRefresh:$e};wn.useEffectEvent=$e;var Vo={readContext:gt,use:wi,useCallback:function(e,t){return Tt().memoizedState=[e,t===void 0?null:t],e},useContext:gt,useEffect:Ao,useImperativeHandle:function(e,t,l){l=l!=null?l.concat([e]):null,Ri(4194308,4,Uo.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=Tt();t=t===void 0?null:t;var a=e();if(ha){se(!0);try{e()}finally{se(!1)}}return l.memoizedState=[a,t],a},useReducer:function(e,t,l){var a=Tt();if(l!==void 0){var n=l(t);if(ha){se(!0);try{l(t)}finally{se(!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=bh.bind(null,ue,e),[a.memoizedState,e]},useRef:function(e){var t=Tt();return e={current:e},t.memoizedState=e},useState:function(e){e=jc(e);var t=e.queue,l=Qo.bind(null,ue,t);return t.dispatch=l,[e.memoizedState,l]},useDebugValue:Mc,useDeferredValue:function(e,t){var l=Tt();return Ec(l,e,t)},useTransition:function(){var e=jc(!1);return e=Go.bind(null,ue,e.queue,!0,!1),Tt().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,l){var a=ue,n=Tt();if(xe){if(l===void 0)throw Error(r(407));l=l()}else{if(l=t(),Re===null)throw Error(r(349));(Se&127)!==0||mo(a,t,l)}n.memoizedState=l;var i={value:l,getSnapshot:t};return n.queue=i,Ao(yo.bind(null,a,i,e),[e]),a.flags|=2048,Ja(9,{destroy:void 0},ho.bind(null,a,i,l,t),null),l},useId:function(){var e=Tt(),t=Re.identifierPrefix;if(xe){var l=nl,a=al;l=(a&~(1<<32-ve(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[yt]=t,i[Mt]=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(St(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 qe(t),kc(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=le.current,qa(t)){if(e=t.stateNode,l=t.memoizedProps,a=null,n=pt,n!==null)switch(n.tag){case 27:case 5:a=n.memoizedProps}e[yt]=t,e=!!(e.nodeValue===l||a!==null&&a.suppressHydrationWarning===!0||rd(e.nodeValue,l)),e||Cl(t,!0)}else e=nu(e).createTextNode(a),e[yt]=t,t.stateNode=e}return qe(t),null;case 31:if(l=t.memoizedState,e===null||e.memoizedState!==null){if(a=qa(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[yt]=t}else ca(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;qe(t),e=!1}else l=ec(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=l),e=!0;if(!e)return t.flags&256?(Gt(t),t):(Gt(t),null);if((t.flags&128)!==0)throw Error(r(558))}return qe(t),null;case 13:if(a=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(n=qa(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[yt]=t}else ca(),(t.flags&128)===0&&(t.memoizedState=null),t.flags|=4;qe(t),n=!1}else n=ec(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),n=!0;if(!n)return t.flags&256?(Gt(t),t):(Gt(t),null)}return Gt(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),Qi(t,t.updateQueue),qe(t),null);case 4:return Ee(),e===null&&ds(t.stateNode.containerInfo),qe(t),null;case 10:return yl(t.type),qe(t),null;case 19:if(_(Ie),a=t.memoizedState,a===null)return qe(t),null;if(n=(t.flags&128)!==0,i=a.rendering,i===null)if(n)Rn(a,!1);else{if(We!==0||e!==null&&(e.flags&128)!==0)for(e=t.child;e!==null;){if(i=Di(e),i!==null){for(t.flags|=128,Rn(a,!1),e=i.updateQueue,t.updateQueue=e,Qi(t,e),t.subtreeFlags=0,e=l,l=t.child;l!==null;)Xf(l,e),l=l.sibling;return w(Ie,Ie.current&1|2),xe&&ml(t,a.treeForkCount),t.child}e=e.sibling}a.tail!==null&&_e()>Ji&&(t.flags|=128,n=!0,Rn(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,Qi(t,e),Rn(a,!0),a.tail===null&&a.tailMode==="hidden"&&!i.alternate&&!xe)return qe(t),null}else 2*_e()-a.renderingStartTime>Ji&&l!==536870912&&(t.flags|=128,n=!0,Rn(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=_e(),e.sibling=null,l=Ie.current,w(Ie,n?l&1|2:l&1),xe&&ml(t,a.treeForkCount),e):(qe(t),null);case 22:case 23:return Gt(t),mc(),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&&(qe(t),t.subtreeFlags&6&&(t.flags|=8192)):qe(t),l=t.updateQueue,l!==null&&Qi(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&&_(oa),null;case 24:return l=null,e!==null&&(l=e.memoizedState.cache),t.memoizedState.cache!==l&&(t.flags|=2048),yl(lt),qe(t),null;case 25:return null;case 30:return null}throw Error(r(156,t.tag))}function Th(e,t){switch(Iu(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return yl(lt),Ee(),e=t.flags,(e&65536)!==0&&(e&128)===0?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return ot(t),null;case 31:if(t.memoizedState!==null){if(Gt(t),t.alternate===null)throw Error(r(340));ca()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Gt(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(r(340));ca()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return _(Ie),null;case 4:return Ee(),null;case 10:return yl(t.type),null;case 22:case 23:return Gt(t),mc(),e!==null&&_(oa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return yl(lt),null;case 25:return null;default:return null}}function pr(e,t){switch(Iu(t),t.tag){case 3:yl(lt),Ee();break;case 26:case 27:case 5:ot(t);break;case 4:Ee();break;case 31:t.memoizedState!==null&&Gt(t);break;case 13:Gt(t);break;case 19:_(Ie);break;case 10:yl(t.type);break;case 22:case 23:Gt(t),mc(),e!==null&&_(oa);break;case 24:yl(lt)}}function Hn(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){Ce(t,t.return,s)}}function Gl(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(j){Ce(n,o,j)}}}a=a.next}while(a!==i)}}catch(j){Ce(t,t.return,j)}}function gr(e){var t=e.updateQueue;if(t!==null){var l=e.stateNode;try{uo(t,l)}catch(a){Ce(e,e.return,a)}}}function vr(e,t,l){l.props=ya(e.type,e.memoizedProps),l.state=e.memoizedState;try{l.componentWillUnmount()}catch(a){Ce(e,t,a)}}function Gn(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){Ce(e,t,n)}}function il(e,t){var l=e.ref,a=e.refCleanup;if(l!==null)if(typeof a=="function")try{a()}catch(n){Ce(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){Ce(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){Ce(e,e.return,n)}}function Zc(e,t,l){try{var a=e.stateNode;Kh(a,e.type,l,t),a[Mt]=t}catch(n){Ce(e,e.return,n)}}function br(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zl(e.type)||e.tag===4}function Vc(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||br(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&&Zl(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 Kc(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=ol));else if(a!==4&&(a===27&&Zl(e.type)&&(l=e.stateNode,t=null),e=e.child,e!==null))for(Kc(e,t,l),e=e.sibling;e!==null;)Kc(e,t,l),e=e.sibling}function ki(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&&Zl(e.type)&&(l=e.stateNode),e=e.child,e!==null))for(ki(e,t,l),e=e.sibling;e!==null;)ki(e,t,l),e=e.sibling}function xr(e){var t=e.stateNode,l=e.memoizedProps;try{for(var a=e.type,n=t.attributes;n.length;)t.removeAttributeNode(n[0]);St(t,a,l),t[yt]=e,t[Mt]=l}catch(i){Ce(e,e.return,i)}}var bl=!1,it=!1,Jc=!1,_r=typeof WeakSet=="function"?WeakSet:Set,mt=null;function Mh(e,t){if(e=e.containerInfo,ys=ru,e=Uf(e),Yu(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,j=0,M=e,v=null;t:for(;;){for(var b;M!==l||n!==0&&M.nodeType!==3||(s=u+n),M!==i||a!==0&&M.nodeType!==3||(o=u+a),M.nodeType===3&&(u+=M.nodeValue.length),(b=M.firstChild)!==null;)v=M,M=b;for(;;){if(M===e)break t;if(v===l&&++g===n&&(s=u),v===i&&++j===a&&(o=u),(b=M.nextSibling)!==null)break;M=v,v=M.parentNode}M=b}l=s===-1||o===-1?null:{start:s,end:o}}else l=null}l=l||{start:0,end:0}}else l=null;for(ps={focusedElem:e,selectionRange:l},ru=!1,mt=t;mt!==null;)if(t=mt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,mt=e;else for(;mt!==null;){switch(t=mt,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"))),St(i,a,l),i[yt]=e,dt(i),a=i;break e;case"link":var u=Nd("link","href",n).get(a+(l.href||""));if(u){for(var s=0;sBe&&(u=Be,Be=P,P=u);var h=Cf(s,P),m=Cf(s,Be);if(h&&m&&(b.rangeCount!==1||b.anchorNode!==h.node||b.anchorOffset!==h.offset||b.focusNode!==m.node||b.focusOffset!==m.offset)){var p=M.createRange();p.setStart(h.node,h.offset),b.removeAllRanges(),P>Be?(b.addRange(p),b.extend(m.node,m.offset)):(p.setEnd(m.node,m.offset),b.addRange(p))}}}}for(M=[],b=s;b=b.parentNode;)b.nodeType===1&&M.push({element:b,left:b.scrollLeft,top:b.scrollTop});for(typeof s.focus=="function"&&s.focus(),s=0;sl?32:l,x.T=null,l=ts,ts=null;var i=Xl,u=Tl;if(ft=0,Pa=Xl=null,Tl=0,(Te&6)!==0)throw Error(r(331));var s=Te;if(Te|=4,Ur(i.current),Dr(i,i.current,u,l),Te=s,kn(0,!1),ae&&typeof ae.onPostCommitFiberRoot=="function")try{ae.onPostCommitFiberRoot(Fe,i)}catch{}return!0}finally{C.p=n,x.T=a,Fr(e,t)}}function Pr(e,t,l){t=Zt(l,t),t=wc(e.stateNode,t,2),e=Bl(e,t,2),e!==null&&(on(e,2),ul(e))}function Ce(e,t,l){if(e.tag===3)Pr(e,e,l);else for(;t!==null;){if(t.tag===3){Pr(t,e,l);break}else if(t.tag===1){var a=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof a.componentDidCatch=="function"&&(Yl===null||!Yl.has(a))){e=Zt(l,e),l=er(2),a=Bl(t,l,2),a!==null&&(tr(l,a,t,e),on(a,2),ul(a));break}}t=t.return}}function is(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)||(Fc=!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&&(Se&l)===l&&(We===4||We===3&&(Se&62914560)===Se&&300>_e()-Ki?(Te&2)===0&&en(e,0):Ic|=l,Ia===Se&&(Ia=0)),ul(e)}function ed(e,t){t===0&&(t=Vs()),e=ia(e,t),e!==null&&(on(e,t),ul(e))}function Bh(e){var t=e.memoizedState,l=0;t!==null&&(l=t.retryLane),ed(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),ed(e,l)}function Hh(e,t){return V(e,t)}var eu=null,ln=null,us=!1,tu=!1,cs=!1,kl=0;function ul(e){e!==ln&&e.next===null&&(ln===null?eu=ln=e:ln=ln.next=e),tu=!0,us||(us=!0,qh())}function kn(e,t){if(!cs&&tu){cs=!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-ve(42|e)+1)-1,i&=n&~(u&~s),i=i&201326741?i&201326741|1:i?i|2:0}i!==0&&(l=!0,nd(a,i))}else i=Se,i=ii(a,a===Re?i:0,a.cancelPendingCommit!==null||a.timeoutHandle!==-1),(i&3)===0||fn(a,i)||(l=!0,nd(a,i));a=a.next}while(l);cs=!1}}function Gh(){td()}function td(){tu=us=!1;var e=0;kl!==0&&$h()&&(e=kl);for(var t=_e(),l=null,a=eu;a!==null;){var n=a.next,i=ld(a,t);i===0?(a.next=null,l===null?eu=n:l.next=n,n===null&&(ln=l)):(l=a,(e!==0||(i&3)!==0)&&(tu=!0)),a=n}ft!==0&&ft!==5||kn(e),kl!==0&&(kl=0)}function ld(e,t){for(var l=e.suspendedLanes,a=e.pingedLanes,n=e.expirationTimes,i=e.pendingLanes&-62914561;0s)break;var j=o.transferSize,M=o.initiatorType;j&&dd(M)&&(o=o.responseEnd,u+=j*(o"u"?null:document;function zd(e,t,l){var a=an;if(a&&typeof t=="string"&&t){var n=Qt(t);n='link[rel="'+e+'"][href="'+n+'"]',typeof l=="string"&&(n+='[crossorigin="'+l+'"]'),jd.has(n)||(jd.add(n),e={rel:e,crossOrigin:l,href:t},a.querySelector(n)===null&&(t=a.createElement("link"),St(t,"link",e),dt(t),a.head.appendChild(t)))}}function n0(e){Ml.D(e),zd("dns-prefetch",e,null)}function i0(e,t){Ml.C(e,t),zd("preconnect",e,t)}function u0(e,t,l){Ml.L(e,t,l);var a=an;if(a&&e&&t){var n='link[rel="preload"][as="'+Qt(t)+'"]';t==="image"&&l&&l.imageSrcSet?(n+='[imagesrcset="'+Qt(l.imageSrcSet)+'"]',typeof l.imageSizes=="string"&&(n+='[imagesizes="'+Qt(l.imageSizes)+'"]')):n+='[href="'+Qt(e)+'"]';var i=n;switch(t){case"style":i=nn(e);break;case"script":i=un(e)}Ft.has(i)||(e=O({rel:"preload",href:t==="image"&&l&&l.imageSrcSet?void 0:e,as:t},l),Ft.set(i,e),a.querySelector(n)!==null||t==="style"&&a.querySelector(Jn(i))||t==="script"&&a.querySelector($n(i))||(t=a.createElement("link"),St(t,"link",e),dt(t),a.head.appendChild(t)))}}function c0(e,t){Ml.m(e,t);var l=an;if(l&&e){var a=t&&typeof t.as=="string"?t.as:"script",n='link[rel="modulepreload"][as="'+Qt(a)+'"][href="'+Qt(e)+'"]',i=n;switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":i=un(e)}if(!Ft.has(i)&&(e=O({rel:"modulepreload",href:e},t),Ft.set(i,e),l.querySelector(n)===null)){switch(a){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(l.querySelector($n(i)))return}a=l.createElement("link"),St(a,"link",e),dt(a),l.head.appendChild(a)}}}function s0(e,t,l){Ml.S(e,t,l);var a=an;if(a&&e){var n=Ma(a).hoistableStyles,i=nn(e);t=t||"default";var u=n.get(i);if(!u){var s={loading:0,preload:null};if(u=a.querySelector(Jn(i)))s.loading=5;else{e=O({rel:"stylesheet",href:e,"data-precedence":t},l),(l=Ft.get(i))&&js(e,l);var o=u=a.createElement("link");dt(o),St(o,"link",e),o._p=new Promise(function(g,j){o.onload=g,o.onerror=j}),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){Ml.X(e,t);var l=an;if(l&&e){var a=Ma(l).hoistableScripts,n=un(e),i=a.get(n);i||(i=l.querySelector($n(n)),i||(e=O({src:e,async:!0},t),(t=Ft.get(n))&&zs(e,t),i=l.createElement("script"),dt(i),St(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function o0(e,t){Ml.M(e,t);var l=an;if(l&&e){var a=Ma(l).hoistableScripts,n=un(e),i=a.get(n);i||(i=l.querySelector($n(n)),i||(e=O({src:e,async:!0,type:"module"},t),(t=Ft.get(n))&&zs(e,t),i=l.createElement("script"),dt(i),St(i,"link",e),l.head.appendChild(i)),i={type:"script",instance:i,count:1,state:null},a.set(n,i))}}function Td(e,t,l,a){var n=(n=le.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=nn(l.href),l=Ma(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=nn(l.href);var i=Ma(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(Jn(e)))&&!i._p&&(u.instance=i,u.state.loading=5),Ft.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},Ft.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=un(l),l=Ma(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 nn(e){return'href="'+Qt(e)+'"'}function Jn(e){return'link[rel="stylesheet"]['+e+"]"}function Md(e){return O({},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}),St(t,"link",l),dt(t),e.head.appendChild(t))}function un(e){return'[src="'+Qt(e)+'"]'}function $n(e){return"script[async]"+e}function Ed(e,t,l){if(t.count++,t.instance===null)switch(t.type){case"style":var a=e.querySelector('style[data-href~="'+Qt(l.href)+'"]');if(a)return t.instance=a,dt(a),a;var n=O({},l,{"data-href":l.href,"data-precedence":l.precedence,href:null,precedence:null});return a=(e.ownerDocument||e).createElement("style"),dt(a),St(a,"style",n),uu(a,l.precedence,e),t.instance=a;case"stylesheet":n=nn(l.href);var i=e.querySelector(Jn(n));if(i)return t.state.loading|=4,t.instance=i,dt(i),i;a=Md(l),(n=Ft.get(n))&&js(a,n),i=(e.ownerDocument||e).createElement("link"),dt(i);var u=i;return u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),St(i,"link",a),t.state.loading|=4,uu(i,l.precedence,e),t.instance=i;case"script":return i=un(l.src),(n=e.querySelector($n(i)))?(t.instance=n,dt(n),n):(a=l,(n=Ft.get(i))&&(a=O({},l),zs(a,n)),e=e.ownerDocument||e,n=e.createElement("script"),dt(n),St(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 Dd(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=nn(a.href),i=t.querySelector(Jn(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,dt(i);return}i=t.ownerDocument||t,a=Md(a),(n=Ft.get(n))&&js(a,n),i=i.createElement("link"),dt(i);var u=i;u._p=new Promise(function(s,o){u.onload=s,u.onerror=o}),St(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 Ts=0;function h0(e,t){return e.stylesheets&&e.count===0&&ou(e,e.stylesheets),0Ts?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(S){console.error(S)}}return f(),ws.exports=O0(),ws.exports}var w0=U0();const B0=cm(w0);const sm=(...f)=>f.filter((S,N,r)=>!!S&&S.trim()!==""&&r.indexOf(S)===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,(S,N,r)=>r?r.toUpperCase():N.toLowerCase());const em=f=>{const S=H0(f);return S.charAt(0).toUpperCase()+S.slice(1)};var Gs={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 S in f)if(S.startsWith("aria-")||S==="role"||S==="title")return!0;return!1},q0=U.createContext({}),L0=()=>U.useContext(q0),Y0=U.forwardRef(({color:f,size:S,strokeWidth:N,absoluteStrokeWidth:r,className:z="",children:A,iconNode:L,...H},B)=>{const{size:y=24,strokeWidth:E=2,absoluteStrokeWidth:O=!1,color:Z="currentColor",className:ee=""}=L0()??{},q=r??O?Number(N??E)*24/Number(S??y):N??E;return U.createElement("svg",{ref:B,...Gs,width:S??y??Gs.width,height:S??y??Gs.height,stroke:f??Z,strokeWidth:q,className:sm("lucide",ee,z),...!A&&!G0(H)&&{"aria-hidden":"true"},...H},[...L.map(([W,ne])=>U.createElement(W,ne)),...Array.isArray(A)?A:[A]])});const Qe=(f,S)=>{const N=U.forwardRef(({className:r,...z},A)=>U.createElement(Y0,{ref:A,iconNode:S,className:sm(`lucide-${R0(em(f))}`,`lucide-${f}`,r),...z}));return N.displayName=em(f),N};const X0=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],qs=Qe("check",X0);const Q0=[["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"}]],tm=Qe("cloud-download",Q0);const k0=[["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"}]],Z0=Qe("copy",k0);const V0=[["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"}]],fm=Qe("cpu",V0);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=Qe("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"}]],Ls=Qe("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"}]],lm=Qe("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=Qe("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"}]],am=Qe("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"}]],Su=Qe("hard-drive",ey);const ty=[["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"}]],ly=Qe("image",ty);const ay=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],ny=Qe("info",ay);const iy=[["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"}]],uy=Qe("layers",iy);const cy=[["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"}]],sy=Qe("library",cy);const fy=[["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"}]],oy=Qe("moon",fy);const ry=[["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"}]],Il=Qe("refresh-cw",ry);const dy=[["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"}]],my=Qe("shield",dy);const hy=[["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"}]],ks=Qe("sliders-vertical",hy);const yy=[["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=Qe("sparkles",yy);const py=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Ys=Qe("square",py);const gy=[["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"}]],vy=Qe("sun",gy);const Sy=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],by=Qe("terminal",Sy);const xy=[["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"}]],li=Qe("trash-2",xy);const _y=[["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"}]],jy=Qe("triangle-alert",_y);function zy({activeTab:f,setActiveTab:S,specs:N}){return c.jsxs("div",{className:"sidebar",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"sidebar-logo",children:[c.jsx(my,{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:()=>S("generator"),children:[c.jsx(ly,{size:20}),c.jsx("span",{children:"Image Generator"})]}),c.jsxs("div",{className:`nav-item ${f==="models"?"active":""}`,onClick:()=>S("models"),children:[c.jsx(I0,{size:20}),c.jsx("span",{children:"Model Manager"})]}),c.jsxs("div",{className:`nav-item ${f==="constraints"?"active":""}`,onClick:()=>S("constraints"),children:[c.jsx(ks,{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(by,{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 Ty=U.memo(zy);function My({telemetry:f,serverRunning:S,activeModel:N,onStopServer:r,isStoppingServer:z=!1,theme:A,setTheme:L}){const H=E=>{const O=Number(E);return Number.isFinite(O)&&O>0?O.toFixed(O>=10?0:1):"--"},B=()=>S?"Server Active":"Local Mode",y=()=>S?"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:B()}),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:()=>L(A==="dark"?"light":"dark"),title:`Switch to ${A==="dark"?"light":"dark"} theme`,children:A==="dark"?c.jsx(vy,{size:18}):c.jsx(oy,{size:18})}),S&&c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:r,disabled:z,title:"Stop local model server",children:[z?c.jsx(Il,{className:"progress-spinner",size:14}):c.jsx(Ys,{size:14}),c.jsx("span",{children:z?"Stopping":"Stop Server"})]}),c.jsxs("div",{className:"telemetry-chip",title:"CPU Utilization",children:[c.jsx(fm,{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(Su,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-secondary)"}}),c.jsxs("span",{children:["RAM: ",H(f.ram_used_gb)," / ",H(f.ram_total_gb)," GB"]})]}),f.vram_total_gb>0&&c.jsxs("div",{className:"telemetry-chip",title:`${f.gpu_name} VRAM`,children:[c.jsx(Ls,{className:"telemetry-chip-icon",style:{color:"var(--md-sys-color-tertiary)"}}),c.jsxs("span",{children:["VRAM: ",H(f.vram_used_gb)," / ",H(f.vram_total_gb)," GB"]})]})]})]})}const Ey=U.memo(My),Ny="modulepreload",Ay=function(f){return"/"+f},nm={},Dy=function(S,N,r){let z=Promise.resolve();if(N&&N.length>0){let B=function(y){return Promise.all(y.map(E=>Promise.resolve(E).then(O=>({status:"fulfilled",value:O}),O=>({status:"rejected",reason:O}))))};document.getElementsByTagName("link");const L=document.querySelector("meta[property=csp-nonce]"),H=L?.nonce||L?.getAttribute("nonce");z=B(N.map(y=>{if(y=Ay(y),y in nm)return;nm[y]=!0;const E=y.endsWith(".css"),O=E?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${y}"]${O}`))return;const Z=document.createElement("link");if(Z.rel=E?"stylesheet":Ny,E||(Z.as="script"),Z.crossOrigin="",Z.href=y,H&&Z.setAttribute("nonce",H),document.head.appendChild(Z),E)return new Promise((ee,q)=>{Z.addEventListener("load",ee),Z.addEventListener("error",()=>q(new Error(`Unable to preload CSS for ${y}`)))})}))}function A(L){const H=new Event("vite:preloadError",{cancelable:!0});if(H.payload=L,window.dispatchEvent(H),!H.defaultPrevented)throw L}return z.then(L=>{for(const H of L||[])H.status==="rejected"&&A(H.reason);return S().catch(A)})};function s1(f,S=!1){return window.__TAURI_INTERNALS__.transformCallback(f,S)}async function ba(f,S={},N){return window.__TAURI_INTERNALS__.invoke(f,S,N)}const Pl=()=>typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0;let Fl=null;const Cy="polish-setup-v1",Sa=()=>typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");function ai(f){const S=Number(f)||0;if(S<=0)return"0 B";const N=["B","KB","MB","GB","TB"],r=Math.min(N.length-1,Math.floor(Math.log(S)/Math.log(1024)));return`${(S/1024**r).toFixed(r===0?0:1)} ${N[r]}`}function ni(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?ai(f.sizeBytes):"Unknown")}}async function sn(f,S="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=E.steps;for(let de=1;de<=ee;de++){if(L&&L.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(et=>setTimeout(et,3e3/ee)),A&&A(Math.round(de/ee*100))}const q=f.toLowerCase(),W=Math.abs(E.seed)||Math.floor(Math.random()*1e3);let ne="#3B82F6",F="#8B5CF6",Oe="",ye="Abstract Generation";q.includes("moon")||q.includes("space")||q.includes("astronomy")||q.includes("sky")?(ne="#1E293B",F="#0F172A",ye="Luminous Moon in Starry Sky",Oe=` + + + + + + + + + + + + `):q.includes("cat")||q.includes("kitten")||q.includes("feline")?(ne="#4F46E5",F="#7C3AED",ye="Stylized Cat Portrait",Oe=` + + + + + + + + + + + + + + + + `):q.includes("dog")||q.includes("puppy")||q.includes("canine")?(ne="#D97706",F="#B45309",ye="Friendly Dog Portrait",Oe=` + + + + + + + + + + + + + `):q.includes("city")||q.includes("cyberpunk")||q.includes("tokyo")||q.includes("neon")?(ne="#111827",F="#311042",ye="Neon Cyberpunk Skyline",Oe=` + + + + + + + + + + + + + `):q.includes("car")||q.includes("vehicle")||q.includes("supercar")?(ne="#DC2626",F="#991B1B",ye="Futuristic Concept Car",Oe=` + + + + + + + + + + + + + `):(ne="#06B6D4",F="#0891B2",ye="Abstract Creative Concept",Oe=` + + + + `);const Le=` + + + + + + + + + + + + + + + + + ${Oe} + + + + + + + ${ye} + Seed: ${W} • Steps: ${E.steps} • Scale: ${E.cfg_scale} + + `,Me=`data:image/svg+xml;base64,${btoa(unescape(encodeURIComponent(Le)))}`,te=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:Me,seed:E.seed,duration_sec:te}},Z={prompt:E.prompt,negative_prompt:E.negative_prompt||"",n:1,size:`${E.width}x${E.height}`,response_format:"b64_json",steps:E.steps,cfg_scale:E.cfg_scale,seed:E.seed,sample_method:E.sampler};try{const ee=await fetch(`${y}/v1/images/generations`,{method:"POST",headers:{"Content-Type":"application/json"},signal:L,body:JSON.stringify(Z)});if(ee.ok){const q=await ee.json(),W=q?.data?.[0]?.b64_json??q?.images?.[0];if(W){const ne=parseFloat(((Date.now()-H)/1e3).toFixed(1));return{image:`data:image/png;base64,${W}`,seed:q.data?.[0]?.seed??E.seed,duration_sec:ne}}}else{let q=`Generation failed (HTTP ${ee.status})`;try{const W=await ee.json();(W?.detail||W?.error?.message)&&(q=W.detail||W.error.message)}catch{}throw new Error(q)}}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 O()}async function Zy(f,S,N){if(f instanceof File){const H=f;if(!Sa())throw new Error("File import requires the local image generator server.");return await Vy(H,S,N),{response:"Model imported successfully"}}if(Pl()){const{listen:H}=await Dy(async()=>{const{listen:y}=await import("./event-DUWu82QQ.js");return{listen:y}},[]);let B=null;S&&(B=await H("import-progress",y=>{S(y.payload)}));try{return{response:await ba("import_model_file",{sourcePath:f}),unlisten:B}}catch(y){throw B&&B(),y}}const r=f.split(/[\\/]/).pop()||"imported_model.gguf";console.log(`Web Mode: Simulating copying ${r} to USB models folder`);const z=40;for(let H=1;H<=z;H++){if(N?.aborted)throw new DOMException("The user aborted a request.","AbortError");await new Promise(O=>setTimeout(O,150));const B=H/z*100,y=40+Math.sin(H)*5+Math.random()*2,E=(z-H)*.15;S&&S({filename:r,progress:B,speed_mb_s:y,eta_secs:E,status:"Copying to USB..."})}const A=localStorage.getItem("imported-models"),L=A?JSON.parse(A):[];return L.includes(r)||(L.push({filename:r,sizeBytes:0,size:"Unknown"}),localStorage.setItem("imported-models",JSON.stringify(L))),{response:"Model imported successfully"}}function Vy(f,S,N){return new Promise((r,z)=>{const A=new XMLHttpRequest,L=Date.now();let H=!1;A.open("POST",`/api/import-model?filename=${encodeURIComponent(f.name)}`),A.setRequestHeader("Content-Type","application/octet-stream");const B=()=>{H=!0,A.abort()};N&&(N.aborted?B():N.addEventListener("abort",B,{once:!0})),A.upload.onprogress=y=>{if(!y.lengthComputable||!S)return;const E=Math.max(.1,(Date.now()-L)/1e3),O=y.loaded/E,Z=Math.max(0,y.total-y.loaded);S({filename:f.name,progress:y.loaded/y.total*100,speed_mb_s:O/(1024*1024),eta_secs:Z/Math.max(1,O),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?(S&&S({filename:f.name,progress:100,speed_mb_s:0,eta_secs:0,status:"Import complete"}),r(y)):z(new Error(y.error||`Import failed (HTTP ${A.status})`))},A.onerror=()=>z(new Error("Import failed while uploading the file.")),A.onabort=()=>z(new DOMException(H?"Import cancelled by user.":"Import aborted.","AbortError")),A.send(f)})}async function Ky(f){if(Pl())return await ba("delete_model_file",{filename:f});if(typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"))try{const z=await fetch("/api/delete-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({filename:f})}),A=await z.json();if(!z.ok)throw new Error(A.error||"Failed to delete model file");return A}catch(z){throw console.error("Failed to delete model via local API:",z),z}const N=localStorage.getItem("imported-models");let r=N?JSON.parse(N):[];return r=r.filter(z=>ni(z).filename!==f),localStorage.setItem("imported-models",JSON.stringify(r)),`Simulated deletion of ${f} from browser session`}async function om(){const S="http://127.0.0.1:8080";try{return(await fetch(`${S}/v1/models`,{method:"GET"})).ok}catch{return!1}}async function Jy(f=30){const S=Pl()||Sa()?f:3;for(let N=0;NsetTimeout(z,500))}return!1}async function $y(f){try{return await(await fetch("/api/download-model",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:f})})).json()}catch(S){return console.error("Failed to start model download:",S),{ok:!1,error:S.message}}}async function Wy(){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 im(){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 Fy(){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 Iy=U.memo(({img:f,idx:S,isSelected:N,onClick:r})=>{const z=A=>{r(S,A)};return c.jsxs("div",{className:`gallery-item ${N?"selected":""}`,onClick:z,title:`Prompt: ${f.prompt} +Seed: ${f.seed}${f.duration_sec?` +Time: ${f.duration_sec.toFixed(1)}s`:""}`,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(qs,{size:14})})]})});function Py({prompt:f,setPrompt:S,negativePrompt:N,setNegativePrompt:r,constraints:z,setConstraints:A,activeModel:L,generatedImages:H,setGeneratedImages:B,isGenerating:y,setIsGenerating:E,generationProgress:O,setGenerationProgress:Z,setActiveTab:ee,showAlert:q=async({message:ne})=>window.alert(ne),showConfirm:W=async({message:ne})=>window.confirm(ne)}){const[ne,F]=U.useState(null),[Oe,ye]=U.useState(null),[Le,ke]=U.useState(null),[Me,te]=U.useState(!1),[de,et]=U.useState(0),[jt,pe]=U.useState(0),[Ke,ut]=U.useState(0),[Je,Ye]=U.useState(""),[x,C]=U.useState(!1),[K,ge]=U.useState(!1),[oe,d]=U.useState(!1),[_,w]=U.useState(null),[G,J]=U.useState(null),[le,re]=U.useState(!1),[Ze,Ee]=U.useState([]),ct=U.useRef(null),ot=U.useRef(null),ht=U.useRef(!1),cl=async()=>{if(!f.trim())return;J(null),d(!0),w(null);let Y=!1;try{const ae=await va();if(ae&&ae.settings){const se=ae.settings,ve=se.model?se.model.split(/[\\/]/).pop():null,Ae=L?L.split(/[\\/]/).pop():null;(ve!==Ae||parseInt(se.steps)!==parseInt(z.steps)||Math.abs(parseFloat(se.cfgScale)-parseFloat(z.cfgScale))>.05||se.sampler!==z.sampler||parseInt(se.threads)!==parseInt(z.threads)||!!se.useGpu!=(z.useGpu!==!1)||(se.backendType||(se.useGpu===!1?"cpu":"auto"))!==(z.backendType||(z.useGpu===!1?"cpu":"auto")))&&(Y=!0)}else Y=!0}catch{Y=!0}if(Y)try{console.log("Settings out of sync, restarting backend..."),await Xs(L,z);let ae=!1,se=null;for(let ve=0;ve<240;ve++){const Ae=await va();if(Ae.loading&&w({progress:Ae.loading.progress||0,phase:Ae.loading.phase||"Loading model...",speed:Ae.loading.speed||"",current:Ae.loading.current||0,total:Ae.loading.total||0,backendMode:Ae.loading.backendMode||Ae.settings?.backendMode||"",device:Ae.loading.device||Ae.settings?.backendDevice||""}),Ae.ready){ae=!0;break}if(Ae.error){se=Ae.error;break}if(!Ae.running&&ve>3){se="The backend process terminated immediately on startup.";break}await new Promise(st=>setTimeout(st,500))}if(!ae)throw new Error(se||"Backend server failed to start after applying configuration changes.")}catch(ae){console.error("Failed to restart backend:",ae),J(ae.message||"Failed to sync settings with backend."),d(!1);return}d(!1),w(null),ct.current&&clearInterval(ct.current),E(!0),Z(0),et(0),ut(0),Ye(""),ht.current=!1,C(!1),re(!1),ke(null),F(null);const Ne=(z.width>=1024?140:35)*.04,Ve=z.width>=1024?140:35,tt=(z.backendType||(z.useGpu===!1?"cpu":"auto"))!=="cpu";let zt=tt?Ne:Ve,ll=!1,xa=0,_a=0,Fe=0;pe(Math.round(z.steps*zt)),ct.current=setInterval(async()=>{Fe++,et(Fe);try{const ae=await Fy();if(ae&&ae.active){const se=ae.decoding||!1;re(se);const ve=se?ae.steps||z.steps||20:ae.step||0,Ae=ae.steps||z.steps||20,st=se?"":ae.speed||"";(se||ae.steps>0)&&(ht.current=!0,ut(ve)),Ye(se?"decoding":st);let He=0;se?He=99:Ae>0&&(He=Math.round(ve/Ae*100)),He=Math.min(99,He),se||ae.steps>0?Z(He):Z(xt=>Math.max(xt,He));let rt=0;if(se)rt=3;else{const xt=parseFloat(st);if(!isNaN(xt)&&xt>0){const wt=Math.max(0,Ae-ve);st.includes("it/s")?rt=wt/xt:st.includes("s/it")&&(rt=wt*xt)}else{const wt=tt?Ne:Ve;rt=Math.max(0,(Ae-ve)*wt)}}if(tt&&!ll){const xt=st.includes("it/s")&&numericSpeed<.2,wt=st.includes("s/it")&&numericSpeed>5;(xt||wt)&&(ll=!0,C(!0))}pe(Math.round(rt))}else Z(se=>Math.min(15,se+1)),pe(se=>Math.max(1,se-1))}catch(ae){console.warn("Failed to get generation progress, running simulation fallback:",ae),tt&&!ll&&Fe>z.steps*Ne*1.3&&(ll=!0,C(!0),zt=Ve,xa=Fe,_a=Math.min(95,Math.round(Fe/(z.steps*Ne)*100)));let se=Math.min(z.steps-1,Math.floor(Fe/zt)),ve=z.steps*zt;if(Fe>=ve){const He=Math.ceil(Fe/Math.max(.5,se));zt=Math.max(zt+15,He+15),ve=z.steps*zt,se=Math.min(z.steps-1,Math.floor(Fe/zt))}const Ae=Math.max(1,ve-Fe);pe(Math.round(Ae));let st=0;if(ll){const He=99-_a,rt=ve-xa;if(rt>0){const xt=Math.min(1,(Fe-xa)/rt);if(xt<.85)st=Math.round(_a+xt*He);else{const wt=(Fe-(xa+rt*.85))/(zt*2),sl=1-Math.exp(-wt);st=Math.min(99,Math.round(_a+.85*He+.14*He*sl))}}else st=99}else if(FeMath.max(He,st))}},1e3);try{ot.current=new AbortController;const ae=await ky(f,N,z,L,null,He=>Z(rt=>Math.max(rt,He)),ot.current.signal);ct.current&&clearInterval(ct.current),Z(100),ut(z.steps),pe(0),Ye("");const se={prompt:f,negativePrompt:N,seed:ae.seed,steps:z.steps,cfgScale:z.cfgScale,width:z.width,height:z.height,sampler:z.sampler,model:L,duration_sec:ae.duration_sec,timestamp:new Date().toLocaleTimeString()};let ve=null,Ae=null;try{if(ve=await Yy(ae.image,se),Ae=ve.url,!Ae)throw new Error("The local server saved the image but did not return a file URL.")}catch(He){throw console.error("Generated image could not be saved:",He),new Error(`Image generated but could not be saved to USB: ${He.message||He}`)}F(Ae),ye(ae.seed),ke(ae.duration_sec);const st={...se,...ve||{},url:Ae};B(He=>[st,...He])}catch(ae){ae.name==="AbortError"?console.log("Generation request was aborted by the user"):(console.error("Generation failed:",ae),J(ae.message||"Generation failed. Please try again.")),ct.current&&clearInterval(ct.current)}finally{E(!1),ot.current=null}},Ut=async()=>{if(await W({title:"Stop Generation?",message:"The current image generation will be cancelled and the local model server may restart.",confirmLabel:"Stop",danger:!0})){ct.current&&clearInterval(ct.current),ge(!0),ot.current&&ot.current.abort();try{console.log("Cancelling: Stopping server to kill generation threads..."),await Zs(),ut(0),Ye(""),re(!1),ht.current=!1,L&&(console.log("Cancelling: Restarting server for future generations..."),await Xs(L,z),await Jy()||console.warn("Server failed to restart properly."))}catch(Y){console.error("Failed to restart server on cancellation:",Y)}finally{ge(!1),E(!1),Z(0),pe(0)}}},k=async()=>{if(ne)try{if(ne.startsWith("data:image")){const Ne=await(await fetch(ne)).blob();await navigator.clipboard.write([new ClipboardItem({[Ne.type]:Ne})])}else{const Y=new Image;Y.crossOrigin="anonymous",Y.src=ne,Y.onload=async()=>{const Ne=document.createElement("canvas");Ne.width=Y.width,Ne.height=Y.height,Ne.getContext("2d").drawImage(Y,0,0),Ne.toBlob(async tt=>{await navigator.clipboard.write([new ClipboardItem({[tt.type]:tt})])},"image/png")}}te(!0),setTimeout(()=>te(!1),2e3)}catch(Y){console.error("Failed to copy image:",Y)}},ce=()=>{if(!ne)return;const Y=document.createElement("a");Y.href=ne,Y.download=`diffusion-${Oe||Date.now()}.png`,document.body.appendChild(Y),Y.click(),document.body.removeChild(Y)},D=(Y,Ne=`diffusion-${Date.now()}.png`)=>{if(!Y)return;const Ve=document.createElement("a");Ve.href=Y,Ve.download=Ne,document.body.appendChild(Ve),Ve.click(),document.body.removeChild(Ve)},R=U.useCallback(Y=>{S(Y.prompt),r(Y.negativePrompt),A(Ne=>({...Ne,steps:Y.steps,cfgScale:Y.cfgScale,width:Y.width,height:Y.height,sampler:Y.sampler,seed:Y.seed})),F(Y.url),ye(Y.seed),ke(Y.duration_sec??Y.durationSec??null)},[S,r,A]),I=U.useCallback((Y,Ne)=>{const Ve=Ne.ctrlKey||Ne.metaKey||Ne.shiftKey;Ee(tt=>Ve?tt.includes(Y)?tt.filter(zt=>zt!==Y):[...tt,Y]:[Y]),H[Y]&&R(H[Y])},[H,R]),V=Ze.map(Y=>H[Y]).filter(Boolean),bt=()=>{Ee([])},ea=()=>{V[0]&&R(V[0])},It=()=>{V.forEach((Y,Ne)=>{const Ve=Y.seed??Date.now();D(Y.url,`diffusion-${Ve}-${Ne+1}.png`)})},_e=async()=>{if(V.length===0)return;const Y=V.length;if(await W({title:"Delete Selected Outputs?",message:`Delete ${Y} selected output${Y===1?"":"s"} from USB? This removes the image and metadata files.`,confirmLabel:"Delete",danger:!0}))try{await Xy(V);const Ve=new Set(Ze);B(tt=>tt.filter((zt,ll)=>!Ve.has(ll))),Ee([]),V.some(tt=>tt.url===ne)&&(F(null),ye(null),ke(null))}catch(Ve){console.error("Failed to delete selected outputs:",Ve),q({title:"Delete Failed",message:Ve.message||String(Ve),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:Y=>S(Y.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:Y=>r(Y.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(ks,{size:14}),c.jsxs("span",{children:["Resolution: ",z.width,"x",z.height]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(Il,{size:14}),c.jsxs("span",{children:["Steps: ",z.steps]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(uy,{size:14}),c.jsxs("span",{children:["CFG: ",z.cfgScale.toFixed(1)]})]}),c.jsxs("div",{className:"status-chip",onClick:()=>ee("constraints"),children:[c.jsx(vu,{size:14}),c.jsxs("span",{children:["Sampler: ",z.sampler]})]}),c.jsx("div",{className:"status-chip",onClick:()=>ee("constraints"),children:c.jsxs("span",{children:["Seed: ",z.seed===-1?"Random":z.seed]})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"48px",marginTop:"8px"},onClick:cl,disabled:y||!f.trim()||!L,children:[c.jsx(vu,{size:18}),c.jsx("span",{children:L?"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||K||oe?c.jsx("div",{className:"progress-overlay",children:oe?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..."}),_?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:[_.phase,_.speed?` (${_.speed})`:""]}),c.jsx("span",{children:_.total>0?`Loaded ${_.current} / ${_.total} tensors`:`${Math.round(_.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,_.progress))}%`,transition:"width 0.25s ease"}})}),(_.backendMode||_.device)&&c.jsxs("div",{style:{fontSize:"0.78rem",opacity:.8,textAlign:"center",marginTop:"8px"},children:["Loading on ",_.backendMode||"backend",_.device?` • ${_.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."})]}):K?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:le?"Decoding Latents...":"Generating Locally..."}),x&&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:"})," ",Ke," / ",z.steps," (",Math.max(0,z.steps-Ke)," left)"]}),c.jsxs("div",{style:{textAlign:"right"},children:[c.jsx("strong",{children:"Elapsed:"})," ",de,"s",Je&&` (${Je==="decoding"?"decoding":Je})`]})]}),c.jsx("div",{className:"progress-bar-container",style:{margin:"4px 0 10px 0"},children:c.jsx("div",{className:"progress-bar-fill",style:{width:`${O}%`,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: ",O,"%"]}),c.jsx("span",{children:"•"}),c.jsxs("span",{children:["Est. remaining: ",jt,"s"]})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{marginTop:"16px",height:"36px",padding:"0 24px"},onClick:Ut,children:"Stop Generating"})]})}):ne?c.jsx("img",{src:ne,className:"output-image",alt:"Generated Output"}):G?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:G}),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: ",Oe]}),Le&&c.jsxs("span",{children:["Inference Time: ",Le.toFixed(1),"s"]})]}),c.jsxs("div",{className:"image-actions",children:[c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:k,children:[Me?c.jsx(qs,{size:16}):c.jsx(Z0,{size:16}),c.jsx("span",{children:Me?"Copied":"Copy"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:ce,children:[c.jsx(lm,{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"}),V.length>0&&c.jsxs("div",{className:"gallery-selection-actions",children:[c.jsxs("span",{className:"gallery-selection-count",children:[V.length," selected"]}),c.jsxs("button",{className:"m3-btn m3-btn-tonal",onClick:ea,children:[c.jsx(qs,{size:14}),c.jsx("span",{children:"Use"})]}),c.jsxs("button",{className:"m3-btn m3-btn-outlined",onClick:It,children:[c.jsx(lm,{size:14}),c.jsx("span",{children:"Download"})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:_e,children:[c.jsx(li,{size:14}),c.jsx("span",{children:"Delete"})]}),c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:bt,children:"Clear"})]})]}),H.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:H.map((Y,Ne)=>c.jsx(Iy,{img:Y,idx:Ne,isSelected:Ze.includes(Ne),onClick:I},Y.image||Ne))})]})]})]})}const e1=U.memo(Py),t1=[{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 l1({activeModel:f,setActiveModel:S,serverRunning:N,setServerRunning:r,constraints:z,showAlert:A=async({message:H})=>window.alert(H),showConfirm:L=async({message:H})=>window.confirm(H)}){const[H,B]=U.useState([]),[y,E]=U.useState(null),[O,Z]=U.useState(0),[ee,q]=U.useState(""),[W,ne]=U.useState(null),[F,Oe]=U.useState(null),[ye,Le]=U.useState(null),[ke,Me]=U.useState({filename:"",speed:"0.0",eta:0,status:""}),[te,de]=U.useState(""),[et,jt]=U.useState(null),[pe,Ke]=U.useState(!1),[ut,Je]=U.useState({progress:0,phase:""}),[Ye,x]=U.useState(null),[C,K]=U.useState({backendMode:"",backendBinary:"",backendDevice:""}),ge=H.map(D=>ni(D).filename),oe=W!==null||pe;U.useEffect(()=>{w(),d()},[]),U.useEffect(()=>{if(!N&&!W){K({backendMode:"",backendBinary:"",backendDevice:""});return}let D=!1;const R=async()=>{try{const V=await va();if(D)return;K({backendMode:V.settings?.backendMode||V.loading?.backendMode||"",backendBinary:V.settings?.backendBinary||V.loading?.backendBinary||"",backendDevice:V.settings?.backendDevice||V.loading?.device||""})}catch{}};R();const I=setInterval(R,2e3);return()=>{D=!0,clearInterval(I)}},[N,W]);const d=async()=>{try{const D=await im();D.active&&D.filename&&_(D.filename)}catch(D){console.error("Check active download failed:",D)}},_=D=>{E(D);const R=setInterval(async()=>{try{const I=await im();I.active?(Z(I.progress===-1?0:I.progress),q(`${I.speed} • ETA ${I.eta}s`)):(clearInterval(R),E(null),I.error?String(I.error).toLowerCase().includes("cancelled")||A({title:"Download Failed",message:I.error,danger:!0}):w())}catch(I){console.error("Polling error:",I)}},1e3)},w=async()=>{try{const D=await qy();B(D.map(ni).filter(R=>R.filename))}catch(D){console.error(D)}},G=async(D,R)=>{if(y||ge.includes(R)&&!await L({title:"Overwrite Model?",message:`"${R}" is already downloaded. Do you want to download and overwrite it?`,confirmLabel:"Overwrite"}))return;const I=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,V=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!I&&!V){A({title:"Server Required",message:"Model download requires the local image generator server.",danger:!0});return}try{const bt=await $y(D);bt.ok?_(R):A({title:"Download Failed",message:bt.error||"Unknown error",danger:!0})}catch(bt){A({title:"Download Error",message:bt.message,danger:!0})}},J=async D=>{if(D.preventDefault(),!te.trim())return;let R="model.gguf";try{const I=new URL(te.trim());if(I.protocol!=="http:"&&I.protocol!=="https:")throw new Error("URL protocol must be http or https");if(R=I.pathname.split("/").pop()||"",!R)throw new Error("Could not extract filename from URL");const V=R.toLowerCase();if(!V.endsWith(".gguf")&&!V.endsWith(".safetensors")&&!V.endsWith(".ckpt"))throw new Error("URL must point to a .gguf, .safetensors, or .ckpt weights file")}catch(I){A({title:"Invalid URL",message:I.message,danger:!0});return}await G(te.trim(),R),de("")},le=D=>{G(D.url,D.filename)},re=async()=>{await Wy(),E(null),Z(0),q(""),await w()},Ze=async D=>{if(f&&f!==D&&N){x(D);return}await Ee(D)},Ee=async D=>{const R=typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0,I=typeof window<"u"&&(window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1");if(!R&&!I){const V=await om(),bt=`.\\backend\\win\\vulkan\\sd-vulkan.exe --listen-port 8080 --model .\\models\\${D} --threads 8`;V?await L({title:"Web Browser Mode",message:`To load "${D}" on the active GPU server, restart your terminal backend with: + +${bt} + +Update the UI status anyway?`,confirmLabel:"Update UI"})&&(S(D),r(!0)):await L({title:"Backend Not Running",message:`C++ backend server is not running on port 8080. + +To run locally, start: + +${bt} + +Proceed in Simulation Mode instead?`,confirmLabel:"Proceed"})&&(S(D),r(!1));return}ne(D),Oe({progress:0,phase:"Starting backend...",speed:"",current:0,total:0,model:D,backendMode:"",backendBinary:"",device:""});try{const V=await Xs(D,z);console.log(V);let bt=!1,ea=null;for(let It=0;It<240;It++){const _e=await va();if(_e.loading&&Oe({progress:_e.loading.progress||0,phase:_e.loading.phase||"Loading model...",speed:_e.loading.speed||"",current:_e.loading.current||0,total:_e.loading.total||0,model:_e.loading.model||D,backendMode:_e.loading.backendMode||_e.settings?.backendMode||"",backendBinary:_e.loading.backendBinary||_e.settings?.backendBinary||"",device:_e.loading.device||_e.settings?.backendDevice||""}),_e.ready){bt=!0;break}if(_e.error){ea=_e.error;break}if(!_e.running&&It>3){ea="The backend process terminated immediately on startup.";break}await new Promise(Y=>setTimeout(Y,500))}if(bt)Oe(It=>({...It||{},progress:100,phase:"Model ready",speed:"",current:It?.current||0,total:It?.total||0,model:D})),S(D),r(!0);else throw new Error(ea||"Model server failed to respond on port 8080.")}catch(V){console.error("Failed to load model:",V),A({title:"Model Load Failed",message:V.message||String(V),danger:!0})}finally{setTimeout(()=>Oe(null),800),ne(null)}},ct=async()=>{const D=Ye;x(null),await ot(),D&&await Ee(D)},ot=async()=>{if(pe)return;Ke(!0),Je({progress:10,phase:"Stopping backend process..."});const D=setInterval(async()=>{try{const R=await va();R.unloading?.active?Je({progress:R.unloading.progress||50,phase:R.unloading.phase||"Unloading model..."}):Je(I=>({progress:Math.min(95,I.progress+10),phase:I.phase||"Unloading model..."}))}catch{}},300);try{await Zs(),Je({progress:100,phase:"Model unloaded"}),S(null),x(null),r(!1)}catch(R){console.error(R),A({title:"Unload Failed",message:R.message||String(R),danger:!0})}finally{clearInterval(D),setTimeout(()=>{Ke(!1),Je({progress:0,phase:""})},500)}},ht=async D=>{if(await L({title:"Delete Model?",message:`Delete "${D}" from your drive?`,confirmLabel:"Delete",danger:!0}))try{await Ky(D),await w(),f===D&&await ot()}catch(R){console.error("Failed to delete model:",R),A({title:"Delete Failed",message:R.message||String(R),danger:!0})}},cl=async(D,R)=>{const I=new AbortController;jt(I),Le(0),Me({filename:R,speed:"0.0",eta:0,status:"Initiating file copy..."});try{await Zy(D,V=>{Le(Math.round(V.progress)),Me({filename:V.filename,speed:V.speed_mb_s.toFixed(1),eta:Math.round(V.eta_secs),status:V.status})},I.signal),await w()}catch(V){console.error("Import failed:",V),V.name!=="AbortError"&&A({title:"Import Failed",message:V.message||String(V),danger:!0})}finally{Le(null),jt(null)}},Ut=()=>{et&&et.abort()},k=D=>{const R=D.target.files[0];R&&cl(R,R.name),D.target.value=""},ce=!!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."}),(C.backendMode||C.backendDevice||C.backendBinary)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginTop:"10px"},children:[C.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(Su,{size:14}),c.jsxs("span",{children:["Loaded on ",C.backendMode]})]}),C.backendDevice&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendDevice})}),C.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:C.backendBinary})})]})]}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ot,disabled:pe||W!==null,children:[pe?c.jsx(Il,{className:"progress-spinner",size:16}):c.jsx(li,{size:16}),c.jsx("span",{children:pe?"Unloading":"Unload Server"})]})]})}),pe&&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:ut.phase||"Unloading model..."}),c.jsxs("span",{children:[Math.round(ut.progress),"%"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,ut.progress))}%`,transition:"width 0.25s ease"}})})]})]}),F&&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: ",F.model||W]}),(F.backendMode||F.backendBinary||F.device)&&c.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"10px"},children:[F.backendMode&&c.jsxs("span",{className:"status-chip",style:{cursor:"default"},children:[c.jsx(Su,{size:14}),c.jsxs("span",{children:["Loading on ",F.backendMode]})]}),F.device&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:F.device})}),F.backendBinary&&c.jsx("span",{className:"status-chip",style:{cursor:"default"},children:c.jsx("span",{children:F.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:[F.phase,F.speed?` (${F.speed})`:""]}),c.jsx("span",{children:F.total>0?`Loaded ${F.current} / ${F.total} tensors`:`${Math.round(F.progress)}%`})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,F.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(Ls,{size:18,style:{color:"var(--md-sys-color-primary)"}}),"Local Models (",H.length,")"]}),H.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:H.map(D=>{const R=D.filename,I=f===R;return c.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"12px 16px",background:I?"var(--md-sys-color-primary-container)":"var(--md-sys-color-surface-variant)",color:I?"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:R}),c.jsxs("span",{style:{fontSize:"0.75rem",opacity:.8},children:["Local Weights File • ",D.size||ai(D.sizeBytes)]})]}),c.jsx("div",{style:{display:"flex",gap:"8px"},children:I?c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"36px",padding:"0 16px"},onClick:ot,disabled:pe,children:[pe?c.jsx(Il,{className:"progress-spinner",size:14}):c.jsx(li,{size:14}),c.jsx("span",{children:pe?"Unloading":"Unload"})]}):c.jsxs(c.Fragment,{children:[c.jsxs("button",{className:"m3-btn m3-btn-filled",style:{height:"36px",padding:"0 16px"},onClick:()=>Ze(R),disabled:oe,children:[W===R?c.jsx(Il,{className:"progress-spinner",size:14}):c.jsx(Ls,{size:14}),c.jsx("span",{children:W===R?"Loading":"Load"})]}),c.jsx("button",{className:"m3-btn m3-btn-error",style:{height:"36px",width:"36px",padding:0,minWidth:"36px"},onClick:()=>ht(R),disabled:oe,title:"Delete from models folder",children:c.jsx(li,{size:14})})]})})]},R)})})]}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(sy,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Model Library"]})}),c.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:t1.map(D=>c.jsxs("div",{className:"m3-card",style:{margin:0},children:[c.jsx("h4",{style:{fontWeight:700,marginBottom:"12px"},children:D.group}),c.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(280px, 1fr))",gap:"12px"},children:D.items.map(R=>{const I=ge.includes(R.filename),V=y===R.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:R.name}),c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-outline)"},children:[R.format," • approx. ",R.approxSize," • ",R.resolution]})]}),c.jsx("p",{style:{fontSize:"0.78rem",color:"var(--md-sys-color-on-surface-variant)",lineHeight:1.35,margin:0},children:R.notes}),V&&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:O>0?`${O}%`:"Preparing"})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${Math.min(100,Math.max(0,O))}%`,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:I?"m3-btn m3-btn-tonal":"m3-btn m3-btn-filled",style:{height:"36px",marginTop:"auto"},onClick:()=>le(R),disabled:I||y!==null,children:[I?c.jsx(Su,{size:14}):V?c.jsx(Il,{className:"progress-spinner",size:14}):c.jsx(tm,{size:14}),c.jsx("span",{children:I?"Downloaded":V?"Downloading":"Download"})]})]},R.filename)})})]},D.group))}),c.jsx("div",{className:"workspace-title-section",style:{marginTop:"32px",marginBottom:"16px"},children:c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(am,{size:20,style:{color:"var(--md-sys-color-primary)"}}),"Local Model Import"]})}),ye!==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: ",ke.filename]}),c.jsxs("button",{className:"m3-btn m3-btn-error",style:{height:"34px",padding:"0 14px"},onClick:Ut,children:[c.jsx(Ys,{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:[ke.status," (",ke.speed," MB/s)"]}),c.jsxs("span",{children:[ye,"% (",ke.eta,"s remaining)"]})]}),c.jsx("div",{className:"model-progress-bar",children:c.jsx("div",{className:"model-progress-fill",style:{width:`${ye}%`,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:k,disabled:ye!==null}),c.jsx(am,{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(tm,{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."}),ce?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:[O,"%"]})]}),c.jsx("div",{className:"model-progress-bar",style:{margin:"4px 0"},children:c.jsx("div",{className:"model-progress-fill",style:{width:`${O}%`,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:re,children:[c.jsx(Ys,{size:14}),c.jsx("span",{children:"Stop Download"})]})]}):c.jsxs("form",{onSubmit:J,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:te,onChange:D=>de(D.target.value),disabled:y!==null}),c.jsx("button",{type:"submit",className:"m3-btn m3-btn-filled",style:{height:"40px"},disabled:y!==null,children:"Download"})]})]})]}),Ye&&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(jy,{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 "',Ye,'".']}),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:pe,children:"Cancel"}),c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:ot,disabled:pe,children:[c.jsx(li,{size:14}),c.jsx("span",{children:"Unload Only"})]}),c.jsxs("button",{className:"m3-btn m3-btn-filled",onClick:ct,disabled:pe,children:[pe?c.jsx(Il,{className:"progress-spinner",size:14}):c.jsx(Il,{size:14}),c.jsx("span",{children:"Unload and Load"})]})]})]})})]})}const a1=U.memo(l1),um=[{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"}],n1=f=>{if(!f)return!0;const S=f.toLowerCase();return!(S.includes("flux")||S.includes("schnell")||S.includes("sdxl")||S.includes("lightning")||S.includes("turbo")||S.includes("sd3"))};function i1({constraints:f,setConstraints:S,activeModel:N,specs:r,backendOptions:z}){const A=N?n1(N):!1,L=z?.options?.length?z.options:[{id:"cpu",label:"CPU",available:!0}],H=(E,O)=>{S(Z=>({...Z,[E]:O}))},B=(E,O)=>{const Z=O==="sdxl"&&!A,ee=um.find(q=>q.id===E);if(ee){let q=Z?ee.sdxl_width:ee.width,W=Z?ee.sdxl_height:ee.height;A&&(q>W?(W=Math.round(W*512/q),q=512):(q=Math.round(q*512/W),W=512),q=Math.round(q/64)*64,W=Math.round(W/64)*64),H("width",q),H("height",W)}},y=E=>{S(O=>({...O,backendType:E,useGpu:E!=="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(ny,{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:()=>{H("width",1024),H("height",1024)},children:"High Quality Mode (1024px)"}),c.jsx("div",{className:`m3-segment-item ${f.width<1024||A?"active":""}`,onClick:()=>{H("width",512),H("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:um.map(E=>{const O=Math.abs(f.width/f.height-E.width/E.height)<.1;return c.jsxs("button",{className:`m3-btn m3-btn-outlined aspect-ratio-btn ${O?"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:()=>B(E.id,A?"sd15":f.width>=1024?"sdxl":"sd15"),children:[c.jsx("div",{className:`aspect-ratio-preview ratio-${E.id.replace(":","-")}`}),c.jsx("span",{style:{fontWeight:600,fontSize:"0.85rem",marginTop:"2px"},children:E.label}),c.jsx("span",{style:{fontSize:"0.68rem",opacity:.7},children:A?`Max: ${E.id==="1:1"?"512x512":E.id==="4:3"?"512x384":E.id==="16:9"?"512x288":"288x512"}`:E.desc})]},E.id)})})]})]})]}),c.jsxs("div",{className:"m3-card",children:[c.jsxs("h3",{className:"m3-card-title",children:[c.jsx(ks,{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:E=>H("steps",parseInt(E.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:E=>H("cfgScale",parseFloat(E.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:E=>H("seed",parseInt(E.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:()=>H("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(fm,{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:L.map(E=>c.jsx("div",{className:`m3-segment-item ${f.backendType===E.id||!f.backendType&&E.id==="cpu"?"active":""}`,onClick:()=>y(E.id),title:E.id==="cuda"?"CUDA appears only when an NVIDIA CUDA backend is available.":void 0,children:E.label},E.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."]}),z?.unavailable?.length>0&&c.jsx("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"4px"},children:z.unavailable.map(E=>c.jsxs("span",{style:{fontSize:"0.75rem",color:"var(--md-sys-color-error)",lineHeight:1.35},children:[E.label," unavailable: ",E.reason]},E.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:E=>H("vaeTiling",E.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:E=>H("vaeOnCpu",E.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 u1=U.memo(i1);function c1(){const f=U.useRef(null),[S,N]=U.useState(null),r=U.useCallback(k=>{const ce=f.current;f.current=null,N(null),ce&&ce(k)},[]),z=U.useCallback(({title:k="Confirm Action",message:ce,confirmLabel:D="OK",cancelLabel:R="Cancel",danger:I=!1})=>new Promise(V=>{f.current=V,N({type:"confirm",title:k,message:ce,confirmLabel:D,cancelLabel:R,danger:I})}),[]),A=U.useCallback(({title:k="Notice",message:ce,confirmLabel:D="OK",danger:R=!1})=>new Promise(I=>{f.current=I,N({type:"alert",title:k,message:ce,confirmLabel:D,danger:R})}),[]),[L,H]=U.useState(()=>{const k=localStorage.getItem("theme");return k||(window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")});U.useEffect(()=>{document.documentElement.setAttribute("data-theme",L),localStorage.setItem("theme",L)},[L]);const[B,y]=U.useState("generator"),[E,O]=U.useState(""),[Z,ee]=U.useState(""),[q,W]=U.useState(null),[ne,F]=U.useState(!1),[Oe,ye]=U.useState(!1),[Le,ke]=U.useState({options:[{id:"cpu",label:"CPU",available:!0}],cudaAvailable:!1,vulkanAvailable:!1,defaultBackendType:"cpu"}),[Me,te]=U.useState(null),[de,et]=U.useState([]),[jt,pe]=U.useState(!1),[Ke,ut]=U.useState(!1),[Je,Ye]=U.useState([]),[x,C]=U.useState(!1),[K,ge]=U.useState(0),[oe,d]=U.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..."}),[_,w]=U.useState({cpu_usage:0,ram_used_gb:0,ram_total_gb:0,gpu_name:"Detecting...",vram_used_gb:0,vram_total_gb:0}),[G,J]=U.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"});U.useEffect(()=>{async function k(){try{const ce=await Ry(),D=await Gy();ke(D),d(ce),J(R=>({...R,threads:ce.cpu_cores_physical||4,backendType:R.backendType==="auto"?D.defaultBackendType||"cpu":R.backendType,useGpu:(R.backendType==="auto"?D.defaultBackendType:R.backendType)!=="cpu"}))}catch(ce){console.error("Error fetching hardware specs:",ce)}}k()},[]);const le=U.useCallback(async()=>{pe(!0);try{const[k,ce]=await Promise.all([Oy(),wy().catch(()=>[])]);te(k),et(ce)}finally{pe(!1)}},[]);U.useEffect(()=>{le()},[le]);const re=U.useCallback(async()=>{try{const k=await Uy();await navigator.clipboard.writeText(JSON.stringify(k,null,2)),ut(!0),setTimeout(()=>ut(!1),1800)}catch(k){A({title:"Diagnostics Failed",message:k.message||String(k),danger:!0})}},[A]),Ze=U.useCallback(async()=>{if(de.length===0)return;const k=de.reduce((D,R)=>D+Number(R.sizeBytes||0),0);if(await z({title:"Clean Safe Files?",message:`Delete ${de.length} temporary/cache item${de.length===1?"":"s"} and free about ${ai(k)}? + +Models and generated outputs are not included.`,confirmLabel:"Clean",danger:!0})){pe(!0);try{await By(de.map(D=>D.id)),await le()}catch(D){A({title:"Cleanup Failed",message:D.message||String(D),danger:!0})}finally{pe(!1)}}},[de,le,A,z]);U.useEffect(()=>{async function k(){const ce=await Ly();Ye(ce)}k()},[]),U.useEffect(()=>{q?localStorage.setItem("active-model",q):localStorage.removeItem("active-model")},[q]),U.useEffect(()=>{let k=null;async function ce(){const D=await va();if(!!D.ready){k&&clearInterval(k);const I=localStorage.getItem("active-model");if(I)W(I),F(!0);else{try{if(D&&D.settings&&D.settings.model){const V=D.settings.model.split(/[\\/]/).pop();W(V)}}catch{}F(!0)}}else if(!(typeof window<"u"&&window.__TAURI_INTERNALS__!==void 0)){const V=localStorage.getItem("active-model");V&&(W(V),F(!1))}}return ce(),k=setInterval(ce,2e3),()=>{k&&clearInterval(k)}},[]),U.useEffect(()=>{async function k(){try{const D=await Hy();w(R=>R.cpu_usage===D.cpu_usage&&R.ram_used_gb===D.ram_used_gb&&R.ram_total_gb===D.ram_total_gb&&R.gpu_name===D.gpu_name&&R.vram_used_gb===D.vram_used_gb&&R.vram_total_gb===D.vram_total_gb?R:D)}catch{}}k();const ce=setInterval(k,1500);return()=>clearInterval(ce)},[]),U.useEffect(()=>{if(q){const k=q.toLowerCase();k.includes("flux")||k.includes("schnell")?J(ce=>({...ce,steps:4,cfgScale:1,width:1024,height:1024})):k.includes("lightning")||k.includes("turbo")?J(ce=>({...ce,steps:4,cfgScale:1.5,width:1024,height:1024})):k.includes("sd15")?J(ce=>({...ce,steps:25,cfgScale:7,width:512,height:512})):k.includes("sd35")?J(ce=>({...ce,steps:20,cfgScale:4.5,width:1024,height:1024})):J(ce=>({...ce,steps:20,cfgScale:7,width:512,height:512}))}},[q]);const Ee=U.useMemo(()=>{switch(B){case"generator":return c.jsx(e1,{prompt:E,setPrompt:O,negativePrompt:Z,setNegativePrompt:ee,constraints:G,setConstraints:J,activeModel:q,generatedImages:Je,setGeneratedImages:Ye,isGenerating:x,setIsGenerating:C,generationProgress:K,setGenerationProgress:ge,setActiveTab:y,showAlert:A,showConfirm:z});case"models":return c.jsx(a1,{activeModel:q,setActiveModel:W,serverRunning:ne,setServerRunning:F,constraints:G,showAlert:A,showConfirm:z});case"constraints":return c.jsx(u1,{constraints:G,setConstraints:J,activeModel:q,specs:oe,backendOptions:Le});default:return null}},[B,E,Z,G,q,Je,x,K,ne,oe,Le,A,z]),ct=U.useMemo(()=>c.jsx(Ty,{activeTab:B,setActiveTab:y,specs:oe}),[B,oe]),ot=U.useCallback(async()=>{if(!(!ne||Oe)){ye(!0);try{await Zs(),F(!1),W(null)}catch(k){console.error("Failed to stop server:",k),A({title:"Stop Server Failed",message:k.message||String(k),danger:!0})}finally{ye(!1)}}},[ne,Oe,A]),ht=[...Me?.stale?["Restart Local AI Image Generator so the local server loads the latest API."]:[],...Me?.issues||[]],cl=de.reduce((k,ce)=>k+Number(ce.sizeBytes||0),0),Ut=!!(Me&&(ht.length>0||de.length>0));return c.jsxs("div",{className:"app-container",children:[ct,c.jsxs("div",{className:"main-content",children:[c.jsx(Ey,{telemetry:_,serverRunning:ne,activeModel:q,onStopServer:ot,isStoppingServer:Oe,theme:L,setTheme:H}),Ut&&c.jsxs("div",{className:`m3-card readiness-card ${Me?.stale||ht.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:Me?.stale?"Restart Required":ht.length>0?"System Readiness":"Safe Cleanup Available"}),c.jsx("p",{className:"m3-card-subtitle",style:{margin:0},children:Me?.stale?`Running server build: ${Me.build||"unknown"}`:ht.length>0?"Local AI Image Generator found setup items that may need attention.":`${de.length} temporary item${de.length===1?"":"s"} can be cleaned (${ai(cl)}).`})]}),c.jsxs("div",{className:"readiness-actions",children:[c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:le,disabled:jt,children:jt?"Checking":"Refresh"}),c.jsx("button",{className:"m3-btn m3-btn-tonal",onClick:re,children:Ke?"Copied":"Copy Diagnostics"}),de.length>0&&c.jsxs("button",{className:"m3-btn m3-btn-error",onClick:Ze,disabled:jt,children:["Clean ",ai(cl)]})]})]}),ht.length>0&&c.jsx("div",{className:"readiness-issues",children:ht.slice(0,4).map(k=>c.jsx("span",{children:k},k))}),de.length>0&&c.jsx("div",{className:"readiness-cleanup-list",children:de.slice(0,3).map(k=>c.jsxs("span",{title:k.path,children:[k.name," · ",k.size," · ",k.reason]},k.id))})]}),Ee]}),S&&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:S.title}),c.jsx("p",{className:"app-dialog-message",children:S.message}),c.jsxs("div",{className:"app-dialog-actions",children:[S.type==="confirm"&&c.jsx("button",{className:"m3-btn m3-btn-outlined",onClick:()=>r(!1),children:S.cancelLabel}),c.jsx("button",{className:`m3-btn ${S.danger?"m3-btn-error":"m3-btn-filled"}`,onClick:()=>r(!0),children:S.confirmLabel})]})]})})]})}B0.createRoot(document.getElementById("root")).render(c.jsx(E0.StrictMode,{children:c.jsx(c1,{})}));export{ba as i,s1 as t}; diff --git a/app/dist/assets/index-BVK0F0Ah.css b/app/dist/assets/index-DW6G7wc2.css similarity index 63% rename from app/dist/assets/index-BVK0F0Ah.css rename to app/dist/assets/index-DW6G7wc2.css index 976f5a1..d6e6769 100644 --- a/app/dist/assets/index-BVK0F0Ah.css +++ b/app/dist/assets/index-DW6G7wc2.css @@ -1 +1 @@ -:root{font-family:Outfit,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--md-shape-corner-small: 8px;--md-shape-corner-medium: 12px;--md-shape-corner-large: 16px;--md-shape-corner-extra-large: 22px;--md-shape-corner-full: 9999px;--md-transition-duration: .25s;--md-transition-easing: cubic-bezier(.4, 0, .2, 1);--md-sys-color-primary: #4f46e5;--md-sys-color-on-primary: #ffffff;--md-sys-color-primary-container: rgba(79, 70, 229, .06);--md-sys-color-on-primary-container: #4338ca;--md-sys-color-secondary: #0ea5e9;--md-sys-color-on-secondary: #ffffff;--md-sys-color-secondary-container: rgba(14, 165, 233, .06);--md-sys-color-on-secondary-container: #0369a1;--md-sys-color-tertiary: #d946ef;--md-sys-color-on-tertiary: #ffffff;--md-sys-color-background: #f8fafc;--md-sys-color-on-background: #0f172a;--md-sys-color-surface: rgba(255, 255, 255, .75);--md-sys-color-on-surface: #0f172a;--md-sys-color-surface-variant: rgba(241, 245, 249, .8);--md-sys-color-on-surface-variant: #475569;--md-sys-color-outline: #64748b;--md-sys-color-outline-variant: #94a3b8;--border-color: rgba(15, 23, 42, .08);--border-color-muted: rgba(15, 23, 42, .05);--md-sys-color-error: #ef4444;--md-sys-color-on-error: #ffffff;--md-sys-color-success: #10b981;--md-sys-color-on-success: #ffffff;--md-sys-color-card-border: rgba(15, 23, 42, .06);--glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, .04);--glass-blur: blur(16px)}html[data-theme=dark]{--md-sys-color-primary: #6366f1;--md-sys-color-on-primary: #ffffff;--md-sys-color-primary-container: rgba(99, 102, 241, .12);--md-sys-color-on-primary-container: #c7d2fe;--md-sys-color-secondary: #38bdf8;--md-sys-color-on-secondary: #0f172a;--md-sys-color-secondary-container: rgba(56, 189, 248, .08);--md-sys-color-on-secondary-container: #bae6fd;--md-sys-color-tertiary: #f472b6;--md-sys-color-on-tertiary: #0f172a;--md-sys-color-background: #090a0f;--md-sys-color-on-background: #f4f4f5;--md-sys-color-surface: rgba(18, 20, 29, .65);--md-sys-color-on-surface: #f4f4f5;--md-sys-color-surface-variant: rgba(26, 29, 41, .55);--md-sys-color-on-surface-variant: #a1a1aa;--md-sys-color-outline: #a1a1aa;--md-sys-color-outline-variant: #71717a;--border-color: rgba(255, 255, 255, .09);--border-color-muted: rgba(255, 255, 255, .05);--md-sys-color-error: #f87171;--md-sys-color-on-error: #ffffff;--md-sys-color-success: #34d399;--md-sys-color-on-success: #090a0f;--md-sys-color-card-border: rgba(255, 255, 255, .04);--glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, .3);--glass-blur: blur(16px)}*{box-sizing:border-box;margin:0;padding:0}body{background-color:var(--md-sys-color-background);background-image:radial-gradient(at 0% 0%,var(--md-sys-color-primary-container) 0px,transparent 50%),radial-gradient(at 100% 0%,var(--md-sys-color-secondary-container) 0px,transparent 40%);color:var(--md-sys-color-on-background);overflow:hidden;height:100vh;width:100vw;font-size:16px;transition:background-color var(--md-transition-duration) ease}.app-container{display:flex;flex-direction:row;height:100vh;width:100vw;overflow:hidden}.sidebar{width:280px;background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border-right:1px solid var(--border-color);display:flex;flex-direction:column;padding:28px 18px;justify-content:space-between;box-shadow:var(--glass-shadow);z-index:11;transition:all var(--md-transition-duration) var(--md-transition-easing)}.sidebar-logo{display:flex;align-items:center;gap:12px;padding:0 12px 28px}.sidebar-logo-icon{color:var(--md-sys-color-primary);width:26px;height:26px;filter:drop-shadow(0 2px 8px rgba(99,102,241,.3))}.sidebar-logo-text{font-size:1.15rem;font-weight:700;letter-spacing:-.02em;color:var(--md-sys-color-on-background)}.nav-list{display:flex;flex-direction:column;gap:6px;margin-bottom:auto}.nav-item{display:flex;align-items:center;gap:12px;padding:10px 16px;height:48px;border-radius:var(--md-shape-corner-medium);color:var(--md-sys-color-on-surface-variant);font-size:.9rem;font-weight:500;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing);-webkit-user-select:none;user-select:none;text-decoration:none;position:relative}.nav-item:hover{background-color:var(--md-sys-color-surface-variant);color:var(--md-sys-color-primary);transform:translate(2px)}.nav-item.active{background-color:var(--md-sys-color-primary-container);color:var(--md-sys-color-primary);font-weight:600}.nav-item.active:before{content:"";position:absolute;left:0;top:14px;bottom:14px;width:4px;background-color:var(--md-sys-color-primary);border-radius:0 4px 4px 0}.sidebar-footer{padding:18px 12px 0;border-top:1px solid var(--border-color);font-size:.78rem;color:var(--md-sys-color-on-surface-variant);display:flex;flex-direction:column;gap:6px;opacity:.95}.main-content{flex:1;display:flex;flex-direction:column;background-color:transparent;overflow:hidden}.top-status-bar{height:64px;background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border-bottom:1px solid var(--border-color);display:flex;align-items:center;justify-content:space-between;padding:0 24px;z-index:10;box-shadow:var(--glass-shadow)}.current-model-info{display:flex;align-items:center;gap:10px;font-size:.88rem}.status-indicator{width:8px;height:8px;border-radius:50%;background-color:var(--md-sys-color-success);box-shadow:0 0 8px var(--md-sys-color-success)}.status-indicator.busy{background-color:var(--md-sys-color-primary);box-shadow:0 0 8px var(--md-sys-color-primary);animation:pulse 1.8s infinite}.status-indicator.offline{background-color:var(--md-sys-color-on-surface-variant);box-shadow:none;opacity:.6}.telemetry-group{display:flex;align-items:center;gap:8px}.telemetry-chip{display:flex;align-items:center;gap:6px;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:6px 12px;font-size:.8rem;font-weight:500;color:var(--md-sys-color-on-surface-variant);transition:all var(--md-transition-duration)}.telemetry-chip-icon{width:14px;height:14px}.readiness-card{margin:0 0 18px;border-left:4px solid var(--md-sys-color-primary)}.readiness-card-warning{border-left-color:var(--md-sys-color-error)}.readiness-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.readiness-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.readiness-actions .m3-btn{height:34px;padding:0 14px}.readiness-issues,.readiness-cleanup-list{display:flex;flex-direction:column;gap:6px;margin-top:12px;font-size:.82rem;color:var(--md-sys-color-on-surface-variant)}.readiness-issues span{color:var(--md-sys-color-error)}.theme-toggle-btn{background:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);color:var(--md-sys-color-on-surface-variant);cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:var(--md-shape-corner-medium);transition:all var(--md-transition-duration) var(--md-transition-easing);margin-right:6px}.theme-toggle-btn:hover{color:var(--md-sys-color-primary);border-color:var(--md-sys-color-primary);background-color:var(--md-sys-color-primary-container);transform:scale(1.05)}.workspace-area{flex:1;overflow-y:auto;padding:28px}.workspace-title-section{margin-bottom:24px}.workspace-title{font-size:1.6rem;font-weight:700;color:var(--md-sys-color-on-background);letter-spacing:-.02em}.workspace-subtitle{font-size:.9rem;color:var(--md-sys-color-on-surface-variant);margin-top:4px;opacity:.8}.m3-card{background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border:1px solid var(--md-sys-color-card-border);border-radius:var(--md-shape-corner-large);padding:24px;margin-bottom:24px;box-shadow:var(--glass-shadow);transition:all var(--md-transition-duration) var(--md-transition-easing)}.m3-card:hover{border-color:#6366f126}.m3-card-title{font-size:1.05rem;font-weight:600;margin-bottom:20px;color:var(--md-sys-color-on-surface);display:flex;align-items:center;gap:8px}.m3-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:38px;padding:0 20px;border-radius:var(--md-shape-corner-medium);font-size:.88rem;font-weight:550;font-family:inherit;border:none;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing);-webkit-user-select:none;user-select:none;line-height:1;white-space:nowrap}.m3-btn svg{flex:0 0 auto}.m3-btn .progress-spinner{width:14px;height:14px;border-width:2px;border-color:currentColor;border-right-color:transparent;border-bottom-color:transparent}.m3-btn:disabled{opacity:.45;cursor:not-allowed}.m3-btn-filled{background:linear-gradient(135deg,var(--md-sys-color-primary),#8b5cf6);color:var(--md-sys-color-on-primary);box-shadow:0 4px 12px #6366f133}.m3-btn-filled:hover:not(:disabled){box-shadow:0 6px 20px #6366f159;transform:translateY(-1px);filter:brightness(1.04)}.m3-btn-tonal{background-color:var(--md-sys-color-primary-container);color:var(--md-sys-color-on-primary-container)}.m3-btn-tonal:hover:not(:disabled){background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);transform:translateY(-1px)}.m3-btn-outlined{background-color:transparent;border:1px solid var(--border-color);color:var(--md-sys-color-on-surface)}.m3-btn-outlined:hover:not(:disabled){background-color:var(--md-sys-color-surface-variant);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.m3-btn-error{background-color:#f43f5e14;border:1px solid rgba(244,63,94,.18);color:#e11d48;box-shadow:0 2px 8px #f43f5e0d}.m3-btn-error:hover:not(:disabled){background-color:#f43f5e26;border-color:#f43f5e4d;transform:translateY(-1px)}html[data-theme=dark] .m3-btn-error{background-color:#fb718517;border:1px solid rgba(251,113,133,.22);color:#fda4af;box-shadow:0 2px 8px #fb71850a}html[data-theme=dark] .m3-btn-error:hover:not(:disabled){background-color:#fb718529;border-color:#fb718559}.m3-field-group{display:flex;flex-direction:column;gap:18px}.m3-text-field{display:flex;flex-direction:column;gap:6px}.m3-text-field-label{font-size:.82rem;font-weight:600;letter-spacing:.01em;color:var(--md-sys-color-on-surface-variant)}.m3-input,.m3-textarea{width:100%;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:10px 14px;font-family:inherit;font-size:.92rem;color:var(--md-sys-color-on-surface);transition:all var(--md-transition-duration) var(--md-transition-easing);outline:none}.m3-input{height:42px}.m3-textarea{min-height:90px;resize:vertical}.m3-input:focus,.m3-textarea:focus{border-color:var(--md-sys-color-primary);background-color:var(--md-sys-color-surface);box-shadow:0 0 0 3px #6366f11f}.m3-slider-group{display:flex;flex-direction:column;gap:4px}.m3-slider-header{display:flex;justify-content:space-between;align-items:center}.m3-slider-label{font-size:.82rem;font-weight:600;color:var(--md-sys-color-on-surface-variant)}.m3-slider-value{font-size:.78rem;font-weight:700;color:var(--md-sys-color-primary);background-color:var(--md-sys-color-primary-container);padding:2px 8px;border-radius:var(--md-shape-corner-full)}.m3-slider{-webkit-appearance:none;appearance:none;width:100%;height:4px;border-radius:var(--md-shape-corner-full);background:var(--border-color);outline:none;margin:12px 0;transition:background .25s}.m3-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background:var(--md-sys-color-primary);border:2px solid var(--md-sys-color-surface);box-shadow:0 0 8px #6366f159;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing)}.m3-slider::-webkit-slider-thumb:hover{transform:scale(1.25);box-shadow:0 0 12px #6366f199}.m3-switch-row{display:flex;justify-content:space-between;align-items:center;padding:8px 0}.m3-switch-info{display:flex;flex-direction:column;gap:2px}.m3-switch-title{font-size:.9rem;font-weight:600;color:var(--md-sys-color-on-surface)}.m3-switch-description{font-size:.78rem;color:var(--md-sys-color-on-surface-variant);opacity:.8}.m3-switch{position:relative;display:inline-block;width:46px;height:26px}.m3-switch input{opacity:0;width:0;height:0}.m3-switch-slider{position:absolute;cursor:pointer;inset:0;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:26px;transition:.25s}.m3-switch-slider:before{position:absolute;content:"";height:18px;width:18px;left:3px;bottom:3px;background-color:var(--md-sys-color-on-surface-variant);border-radius:50%;transition:.25s}.m3-switch input:checked+.m3-switch-slider{background-color:var(--md-sys-color-primary);border-color:var(--md-sys-color-primary)}.m3-switch input:checked+.m3-switch-slider:before{transform:translate(20px);background-color:var(--md-sys-color-on-primary)}.m3-segmented-button{display:flex;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:3px;overflow:hidden;width:100%}.m3-segment-item{flex:1;text-align:center;padding:8px 0;font-size:.82rem;font-weight:600;cursor:pointer;background-color:transparent;color:var(--md-sys-color-on-surface-variant);transition:all var(--md-transition-duration) var(--md-transition-easing);border-radius:calc(var(--md-shape-corner-medium) - 2px);-webkit-user-select:none;user-select:none;border:none}.m3-segment-item:hover:not(.active):not(.disabled){color:var(--md-sys-color-on-surface);background-color:#00000008}html[data-theme=dark] .m3-segment-item:hover:not(.active):not(.disabled){background-color:#ffffff0a}.m3-segment-item.active{background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);box-shadow:0 2px 8px #6366f133}.m3-segment-item.disabled{opacity:.45;cursor:not-allowed;text-decoration:line-through}.generator-layout{display:grid;grid-template-columns:1fr;gap:24px}@media(min-width:1000px){.generator-layout{grid-template-columns:1.15fr .85fr}}.chips-container{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.status-chip{display:inline-flex;align-items:center;gap:6px;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);color:var(--md-sys-color-on-surface-variant);padding:5px 12px;border-radius:var(--md-shape-corner-full);font-size:.78rem;font-weight:550;cursor:pointer;transition:all var(--md-transition-duration)}.status-chip:hover{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.prompt-actions{display:flex;justify-content:space-between;align-items:center;margin-top:16px}.image-to-image-section{margin-top:12px;border-top:1px solid var(--border-color);padding-top:16px}.image-dropzone{border:2.5px dashed var(--border-color);border-radius:var(--md-shape-corner-large);padding:24px;text-align:center;cursor:pointer;background-color:var(--md-sys-color-surface-variant);color:var(--md-sys-color-on-surface-variant);transition:all var(--md-transition-duration);position:relative;overflow:hidden;min-height:120px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px}.image-dropzone:hover{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.dropped-image-preview{max-width:100%;max-height:160px;border-radius:var(--md-shape-corner-medium);object-fit:contain;box-shadow:var(--glass-shadow)}.aspect-ratio-btn{position:relative;transition:all var(--md-transition-duration) var(--md-transition-easing)}.aspect-ratio-btn.active{background-color:var(--md-sys-color-primary-container)!important;border-color:var(--md-sys-color-primary)!important;color:var(--md-sys-color-primary)!important;box-shadow:0 0 0 2px #6366f126}.aspect-ratio-preview{border:1.5px solid currentColor;border-radius:2px;opacity:.6;background-color:transparent;transition:all .2s ease;margin-bottom:6px}.aspect-ratio-btn:hover .aspect-ratio-preview,.aspect-ratio-btn.active .aspect-ratio-preview{opacity:1;background-color:#6366f10f}.ratio-1-1{width:16px;height:16px}.ratio-4-3{width:20px;height:15px}.ratio-16-9{width:24px;height:13.5px}.ratio-9-16{width:13.5px;height:24px}.output-panel{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:380px}.output-image-container{width:100%;aspect-ratio:1;background-color:var(--md-sys-color-surface-variant);border-radius:var(--md-shape-corner-large);border:1px solid var(--border-color);display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative;box-shadow:inset 0 2px 8px #0000000d}.output-image{width:100%;height:100%;object-fit:contain;transition:transform .3s}.output-image:hover{transform:scale(1.015)}.progress-overlay{position:absolute;inset:0;background-color:#090a0fd9;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;color:#fff;gap:14px;padding:24px;z-index:5}.progress-spinner{width:44px;height:44px;border:3px solid rgba(255,255,255,.15);border-top-color:var(--md-sys-color-primary);border-radius:50%;animation:spin .9s cubic-bezier(.5,.1,.4,.9) infinite;box-shadow:0 0 12px #6366f133}.loading-dot{width:8px;height:8px;border-radius:50%;background:var(--md-sys-color-primary);opacity:.9;animation:pulse 1.2s ease-in-out infinite;box-shadow:0 0 8px var(--md-sys-color-primary)}.progress-text{font-size:1.05rem;font-weight:700;letter-spacing:-.01em}.progress-bar-container{width:80%;height:5px;background-color:#ffffff1f;border-radius:var(--md-shape-corner-full);overflow:hidden;margin:4px 0}.progress-bar-fill{height:100%;background:linear-gradient(90deg,var(--md-sys-color-primary),#d946ef);width:0%;transition:width .4s cubic-bezier(.1,.8,.25,1);box-shadow:0 0 8px #6366f166}.output-placeholder-icon{width:48px;height:48px;color:var(--md-sys-color-on-surface-variant);opacity:.5;filter:drop-shadow(0 2px 10px rgba(0,0,0,.05))}.output-placeholder-text{font-size:.88rem;color:var(--md-sys-color-on-surface-variant);margin-top:12px;text-align:center;line-height:1.5;opacity:.8}.image-actions{display:flex;gap:10px;margin-top:16px;width:100%}.image-actions button{flex:1}.models-grid{display:grid;grid-template-columns:1fr;gap:20px}@media(min-width:800px){.models-grid{grid-template-columns:1fr 1fr}}.model-card{display:flex;flex-direction:column;justify-content:space-between;border:1px solid var(--border-color-muted)}.model-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px}.model-name{font-size:1.05rem;font-weight:600}.model-badge{font-size:.72rem;font-weight:700;padding:3px 8px;border-radius:var(--md-shape-corner-full)}.model-badge-gguf{background-color:#f59e0b26;color:#d97706}.model-badge-safetensors{background-color:#0ea5e926;color:#0284c7}.model-description{font-size:.82rem;color:var(--md-sys-color-on-surface-variant);margin-bottom:16px;line-height:1.45;opacity:.9}.model-status-info{margin-top:auto;padding-top:12px;border-top:1px solid var(--border-color-muted);display:flex;align-items:center;justify-content:space-between}.model-size{font-size:.8rem;font-weight:550;color:var(--md-sys-color-on-surface-variant)}.model-progress-section{width:100%;margin-top:12px}.model-progress-label{display:flex;justify-content:space-between;font-size:.78rem;font-weight:600;margin-bottom:4px}.model-progress-bar{width:100%;height:6px;background-color:var(--border-color-muted);border-radius:var(--md-shape-corner-full);overflow:hidden}.model-progress-fill{height:100%;background:linear-gradient(90deg,var(--md-sys-color-primary),var(--md-sys-color-secondary));width:0%;transition:width .25s ease}.import-box{border:2px dashed var(--border-color);border-radius:var(--md-shape-corner-large);padding:32px;text-align:center;cursor:pointer;transition:all var(--md-transition-duration);background-color:var(--md-sys-color-surface);color:var(--md-sys-color-on-surface-variant);display:flex;flex-direction:column;align-items:center;gap:10px}.import-box:hover{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.import-icon{width:40px;height:40px;color:var(--md-sys-color-primary);filter:drop-shadow(0 2px 6px rgba(99,102,241,.15))}.gallery-section{margin-top:36px}.gallery-header{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.gallery-selection-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.gallery-selection-actions .m3-btn{height:34px;padding:0 14px}.gallery-selection-count{font-size:.82rem;font-weight:700;color:var(--md-sys-color-primary);padding:7px 10px;border-radius:var(--md-shape-corner-full);background:var(--md-sys-color-primary-container)}.gallery-hint{margin-top:8px;font-size:.78rem;color:var(--md-sys-color-outline)}.gallery-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:12px;margin-top:16px}.gallery-item{aspect-ratio:1;border-radius:var(--md-shape-corner-medium);overflow:hidden;border:1px solid var(--border-color-muted);cursor:pointer;position:relative;contain:layout paint style;transition:border-color var(--md-transition-duration),box-shadow var(--md-transition-duration),transform var(--md-transition-duration)}.gallery-item.selected{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 3px #4f46e540}.gallery-thumb{width:100%;height:100%;object-fit:cover;transition:transform var(--md-transition-duration) var(--md-transition-easing)}.gallery-item:hover .gallery-thumb{transform:scale(1.05)}.gallery-select-badge{position:absolute;top:8px;right:8px;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;color:var(--md-sys-color-on-primary);background:var(--md-sys-color-primary);box-shadow:0 2px 8px #00000047}.app-dialog-backdrop{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:24px;background:#080c18a3;-webkit-backdrop-filter:blur(4px) saturate(.86);backdrop-filter:blur(4px) saturate(.86)}.app-dialog{width:min(460px,100%);background:color-mix(in srgb,var(--md-sys-color-surface) 96%,white 4%);color:var(--md-sys-color-on-surface);border:1px solid color-mix(in srgb,var(--md-sys-color-outline) 55%,transparent);border-radius:var(--md-shape-corner-large);box-shadow:0 22px 60px #0000006b,0 0 0 1px #ffffff14 inset;padding:24px}.app-dialog-title{font-size:1.15rem;font-weight:800;margin:0 0 10px}.app-dialog-message{font-size:.92rem;line-height:1.45;color:var(--md-sys-color-on-surface-variant);margin:0;white-space:pre-wrap}.app-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:22px;flex-wrap:wrap}.gallery-empty{text-align:center;padding:36px;color:var(--md-sys-color-on-surface-variant);font-size:.85rem;opacity:.8}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(1.06)}}.sidebar-specs-header{display:flex;align-items:center;gap:6px;margin-bottom:6px;font-weight:600;color:var(--md-sys-color-on-background)}.sidebar-specs-item{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;opacity:.85;margin-bottom:2px;color:var(--md-sys-color-on-background)}.sidebar-specs-os{color:var(--md-sys-color-primary);font-weight:600;margin-top:4px} +:root{font-family:Outfit,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica,Arial,sans-serif;font-synthesis:none;text-rendering:optimizeLegibility;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;--md-shape-corner-small: 8px;--md-shape-corner-medium: 12px;--md-shape-corner-large: 16px;--md-shape-corner-extra-large: 22px;--md-shape-corner-full: 9999px;--md-transition-duration: .25s;--md-transition-easing: cubic-bezier(.4, 0, .2, 1);--md-sys-color-primary: #4f46e5;--md-sys-color-on-primary: #ffffff;--md-sys-color-primary-container: rgba(79, 70, 229, .06);--md-sys-color-on-primary-container: #4338ca;--md-sys-color-secondary: #0ea5e9;--md-sys-color-on-secondary: #ffffff;--md-sys-color-secondary-container: rgba(14, 165, 233, .06);--md-sys-color-on-secondary-container: #0369a1;--md-sys-color-tertiary: #d946ef;--md-sys-color-on-tertiary: #ffffff;--md-sys-color-background: #f8fafc;--md-sys-color-on-background: #0f172a;--md-sys-color-surface: rgba(255, 255, 255, .75);--md-sys-color-on-surface: #0f172a;--md-sys-color-surface-variant: rgba(241, 245, 249, .8);--md-sys-color-on-surface-variant: #475569;--md-sys-color-outline: #64748b;--md-sys-color-outline-variant: #94a3b8;--border-color: rgba(15, 23, 42, .08);--border-color-muted: rgba(15, 23, 42, .05);--md-sys-color-error: #ef4444;--md-sys-color-on-error: #ffffff;--md-sys-color-success: #10b981;--md-sys-color-on-success: #ffffff;--md-sys-color-card-border: rgba(15, 23, 42, .06);--glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, .04);--glass-blur: blur(16px)}html[data-theme=dark]{--md-sys-color-primary: #6366f1;--md-sys-color-on-primary: #ffffff;--md-sys-color-primary-container: rgba(99, 102, 241, .12);--md-sys-color-on-primary-container: #c7d2fe;--md-sys-color-secondary: #38bdf8;--md-sys-color-on-secondary: #0f172a;--md-sys-color-secondary-container: rgba(56, 189, 248, .08);--md-sys-color-on-secondary-container: #bae6fd;--md-sys-color-tertiary: #f472b6;--md-sys-color-on-tertiary: #0f172a;--md-sys-color-background: #090a0f;--md-sys-color-on-background: #f4f4f5;--md-sys-color-surface: rgba(18, 20, 29, .65);--md-sys-color-on-surface: #f4f4f5;--md-sys-color-surface-variant: rgba(26, 29, 41, .55);--md-sys-color-on-surface-variant: #a1a1aa;--md-sys-color-outline: #a1a1aa;--md-sys-color-outline-variant: #71717a;--border-color: rgba(255, 255, 255, .09);--border-color-muted: rgba(255, 255, 255, .05);--md-sys-color-error: #f87171;--md-sys-color-on-error: #ffffff;--md-sys-color-success: #34d399;--md-sys-color-on-success: #090a0f;--md-sys-color-card-border: rgba(255, 255, 255, .04);--glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, .3);--glass-blur: blur(16px)}*{box-sizing:border-box;margin:0;padding:0}body{background-color:var(--md-sys-color-background);background-image:radial-gradient(at 0% 0%,var(--md-sys-color-primary-container) 0px,transparent 50%),radial-gradient(at 100% 0%,var(--md-sys-color-secondary-container) 0px,transparent 40%);color:var(--md-sys-color-on-background);overflow:hidden;height:100vh;width:100vw;font-size:16px;transition:background-color var(--md-transition-duration) ease}.app-container{display:flex;flex-direction:row;height:100vh;width:100vw;overflow:hidden}.sidebar{width:280px;background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border-right:1px solid var(--border-color);display:flex;flex-direction:column;padding:28px 18px;justify-content:space-between;box-shadow:var(--glass-shadow);z-index:11;transition:all var(--md-transition-duration) var(--md-transition-easing)}.sidebar-logo{display:flex;align-items:center;gap:12px;padding:0 12px 28px}.sidebar-logo-icon{color:var(--md-sys-color-primary);width:26px;height:26px;filter:drop-shadow(0 2px 8px rgba(99,102,241,.3))}.sidebar-logo-text{font-size:1.15rem;font-weight:700;letter-spacing:-.02em;color:var(--md-sys-color-on-background)}.nav-list{display:flex;flex-direction:column;gap:6px;margin-bottom:auto}.nav-item{display:flex;align-items:center;gap:12px;padding:10px 16px;height:48px;border-radius:var(--md-shape-corner-medium);color:var(--md-sys-color-on-surface-variant);font-size:.9rem;font-weight:500;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing);-webkit-user-select:none;user-select:none;text-decoration:none;position:relative}.nav-item:hover{background-color:var(--md-sys-color-surface-variant);color:var(--md-sys-color-primary);transform:translate(2px)}.nav-item.active{background-color:var(--md-sys-color-primary-container);color:var(--md-sys-color-primary);font-weight:600}.nav-item.active:before{content:"";position:absolute;left:0;top:14px;bottom:14px;width:4px;background-color:var(--md-sys-color-primary);border-radius:0 4px 4px 0}.sidebar-footer{padding:18px 12px 0;border-top:1px solid var(--border-color);font-size:.78rem;color:var(--md-sys-color-on-surface-variant);display:flex;flex-direction:column;gap:6px;opacity:.95}.main-content{flex:1;display:flex;flex-direction:column;background-color:transparent;overflow:hidden}.top-status-bar{height:64px;background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border-bottom:1px solid var(--border-color);display:flex;align-items:center;justify-content:space-between;padding:0 24px;z-index:10;box-shadow:var(--glass-shadow)}.current-model-info{display:flex;align-items:center;gap:10px;font-size:.88rem}.status-indicator{width:8px;height:8px;border-radius:50%;background-color:var(--md-sys-color-success);box-shadow:0 0 8px var(--md-sys-color-success)}.status-indicator.busy{background-color:var(--md-sys-color-primary);box-shadow:0 0 8px var(--md-sys-color-primary);animation:pulse 1.8s infinite}.status-indicator.offline{background-color:var(--md-sys-color-on-surface-variant);box-shadow:none;opacity:.6}.telemetry-group{display:flex;align-items:center;gap:8px}.telemetry-chip{display:flex;align-items:center;gap:6px;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:6px 12px;font-size:.8rem;font-weight:500;color:var(--md-sys-color-on-surface-variant);transition:all var(--md-transition-duration)}.telemetry-chip-icon{width:14px;height:14px}.readiness-card{margin:0 0 18px;border-left:4px solid var(--md-sys-color-primary)}.readiness-card-warning{border-left-color:var(--md-sys-color-error)}.readiness-header{display:flex;align-items:flex-start;justify-content:space-between;gap:14px}.readiness-actions{display:flex;align-items:center;justify-content:flex-end;gap:8px;flex-wrap:wrap}.readiness-actions .m3-btn{height:34px;padding:0 14px}.readiness-issues,.readiness-cleanup-list{display:flex;flex-direction:column;gap:6px;margin-top:12px;font-size:.82rem;color:var(--md-sys-color-on-surface-variant)}.readiness-issues span{color:var(--md-sys-color-error)}.theme-toggle-btn{background:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);color:var(--md-sys-color-on-surface-variant);cursor:pointer;display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:var(--md-shape-corner-medium);transition:all var(--md-transition-duration) var(--md-transition-easing);margin-right:6px}.theme-toggle-btn:hover{color:var(--md-sys-color-primary);border-color:var(--md-sys-color-primary);background-color:var(--md-sys-color-primary-container);transform:scale(1.05)}.workspace-area{flex:1;overflow-y:auto;padding:28px}.workspace-title-section{margin-bottom:24px}.workspace-title{font-size:1.6rem;font-weight:700;color:var(--md-sys-color-on-background);letter-spacing:-.02em}.workspace-subtitle{font-size:.9rem;color:var(--md-sys-color-on-surface-variant);margin-top:4px;opacity:.8}.m3-card{background-color:var(--md-sys-color-surface);backdrop-filter:var(--glass-blur);-webkit-backdrop-filter:var(--glass-blur);border:1px solid var(--md-sys-color-card-border);border-radius:var(--md-shape-corner-large);padding:24px;margin-bottom:24px;box-shadow:var(--glass-shadow);transition:all var(--md-transition-duration) var(--md-transition-easing)}.m3-card:hover{border-color:#6366f126}.m3-card-title{font-size:1.05rem;font-weight:600;margin-bottom:20px;color:var(--md-sys-color-on-surface);display:flex;align-items:center;gap:8px}.m3-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;height:38px;padding:0 20px;border-radius:var(--md-shape-corner-medium);font-size:.88rem;font-weight:550;font-family:inherit;border:none;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing);-webkit-user-select:none;user-select:none;line-height:1;white-space:nowrap}.m3-btn svg{flex:0 0 auto}.m3-btn .progress-spinner{width:14px;height:14px;border-width:2px;border-color:currentColor;border-right-color:transparent;border-bottom-color:transparent}.m3-btn:disabled{opacity:.45;cursor:not-allowed}.m3-btn-filled{background:linear-gradient(135deg,var(--md-sys-color-primary),#8b5cf6);color:var(--md-sys-color-on-primary);box-shadow:0 4px 12px #6366f133}.m3-btn-filled:hover:not(:disabled){box-shadow:0 6px 20px #6366f159;transform:translateY(-1px);filter:brightness(1.04)}.m3-btn-tonal{background-color:var(--md-sys-color-primary-container);color:var(--md-sys-color-on-primary-container)}.m3-btn-tonal:hover:not(:disabled){background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);transform:translateY(-1px)}.m3-btn-outlined{background-color:transparent;border:1px solid var(--border-color);color:var(--md-sys-color-on-surface)}.m3-btn-outlined:hover:not(:disabled){background-color:var(--md-sys-color-surface-variant);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.m3-btn-error{background-color:#f43f5e14;border:1px solid rgba(244,63,94,.18);color:#e11d48;box-shadow:0 2px 8px #f43f5e0d}.m3-btn-error:hover:not(:disabled){background-color:#f43f5e26;border-color:#f43f5e4d;transform:translateY(-1px)}html[data-theme=dark] .m3-btn-error{background-color:#fb718517;border:1px solid rgba(251,113,133,.22);color:#fda4af;box-shadow:0 2px 8px #fb71850a}html[data-theme=dark] .m3-btn-error:hover:not(:disabled){background-color:#fb718529;border-color:#fb718559}.m3-field-group{display:flex;flex-direction:column;gap:18px}.m3-text-field{display:flex;flex-direction:column;gap:6px}.m3-text-field-label{font-size:.82rem;font-weight:600;letter-spacing:.01em;color:var(--md-sys-color-on-surface-variant)}.m3-input,.m3-textarea{width:100%;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:10px 14px;font-family:inherit;font-size:.92rem;color:var(--md-sys-color-on-surface);transition:all var(--md-transition-duration) var(--md-transition-easing);outline:none}.m3-input{height:42px}.m3-textarea{min-height:90px;resize:vertical}.m3-input:focus,.m3-textarea:focus{border-color:var(--md-sys-color-primary);background-color:var(--md-sys-color-surface);box-shadow:0 0 0 3px #6366f11f}.m3-slider-group{display:flex;flex-direction:column;gap:4px}.m3-slider-header{display:flex;justify-content:space-between;align-items:center}.m3-slider-label{font-size:.82rem;font-weight:600;color:var(--md-sys-color-on-surface-variant)}.m3-slider-value{font-size:.78rem;font-weight:700;color:var(--md-sys-color-primary);background-color:var(--md-sys-color-primary-container);padding:2px 8px;border-radius:var(--md-shape-corner-full)}.m3-slider{-webkit-appearance:none;appearance:none;width:100%;height:4px;border-radius:var(--md-shape-corner-full);background:var(--border-color);outline:none;margin:12px 0;transition:background .25s}.m3-slider::-webkit-slider-thumb{-webkit-appearance:none;appearance:none;width:16px;height:16px;border-radius:50%;background:var(--md-sys-color-primary);border:2px solid var(--md-sys-color-surface);box-shadow:0 0 8px #6366f159;cursor:pointer;transition:all var(--md-transition-duration) var(--md-transition-easing)}.m3-slider::-webkit-slider-thumb:hover{transform:scale(1.25);box-shadow:0 0 12px #6366f199}.m3-switch-row{display:flex;justify-content:space-between;align-items:center;padding:8px 0}.m3-switch-info{display:flex;flex-direction:column;gap:2px}.m3-switch-title{font-size:.9rem;font-weight:600;color:var(--md-sys-color-on-surface)}.m3-switch-description{font-size:.78rem;color:var(--md-sys-color-on-surface-variant);opacity:.8}.m3-switch{position:relative;display:inline-block;width:46px;height:26px}.m3-switch input{opacity:0;width:0;height:0}.m3-switch-slider{position:absolute;cursor:pointer;inset:0;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:26px;transition:.25s}.m3-switch-slider:before{position:absolute;content:"";height:18px;width:18px;left:3px;bottom:3px;background-color:var(--md-sys-color-on-surface-variant);border-radius:50%;transition:.25s}.m3-switch input:checked+.m3-switch-slider{background-color:var(--md-sys-color-primary);border-color:var(--md-sys-color-primary)}.m3-switch input:checked+.m3-switch-slider:before{transform:translate(20px);background-color:var(--md-sys-color-on-primary)}.m3-segmented-button{display:flex;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);border-radius:var(--md-shape-corner-medium);padding:3px;overflow:hidden;width:100%}.m3-segment-item{flex:1;text-align:center;padding:8px 0;font-size:.82rem;font-weight:600;cursor:pointer;background-color:transparent;color:var(--md-sys-color-on-surface-variant);transition:all var(--md-transition-duration) var(--md-transition-easing);border-radius:calc(var(--md-shape-corner-medium) - 2px);-webkit-user-select:none;user-select:none;border:none}.m3-segment-item:hover:not(.active):not(.disabled){color:var(--md-sys-color-on-surface);background-color:#00000008}html[data-theme=dark] .m3-segment-item:hover:not(.active):not(.disabled){background-color:#ffffff0a}.m3-segment-item.active{background-color:var(--md-sys-color-primary);color:var(--md-sys-color-on-primary);box-shadow:0 2px 8px #6366f133}.m3-segment-item.disabled{opacity:.45;cursor:not-allowed;text-decoration:line-through}.generator-layout{display:grid;grid-template-columns:1fr;gap:24px}@media(min-width:1000px){.generator-layout{grid-template-columns:1.15fr .85fr}}.chips-container{display:flex;flex-wrap:wrap;gap:6px;margin-top:8px}.status-chip{display:inline-flex;align-items:center;gap:6px;background-color:var(--md-sys-color-surface-variant);border:1px solid var(--border-color);color:var(--md-sys-color-on-surface-variant);padding:5px 12px;border-radius:var(--md-shape-corner-full);font-size:.78rem;font-weight:550;cursor:pointer;transition:all var(--md-transition-duration)}.status-chip:hover{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.prompt-actions{display:flex;justify-content:space-between;align-items:center;margin-top:16px}.aspect-ratio-btn{position:relative;transition:all var(--md-transition-duration) var(--md-transition-easing)}.aspect-ratio-btn.active{background-color:var(--md-sys-color-primary-container)!important;border-color:var(--md-sys-color-primary)!important;color:var(--md-sys-color-primary)!important;box-shadow:0 0 0 2px #6366f126}.aspect-ratio-preview{border:1.5px solid currentColor;border-radius:2px;opacity:.6;background-color:transparent;transition:all .2s ease;margin-bottom:6px}.aspect-ratio-btn:hover .aspect-ratio-preview,.aspect-ratio-btn.active .aspect-ratio-preview{opacity:1;background-color:#6366f10f}.ratio-1-1{width:16px;height:16px}.ratio-4-3{width:20px;height:15px}.ratio-16-9{width:24px;height:13.5px}.ratio-9-16{width:13.5px;height:24px}.output-panel{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:380px}.output-image-container{width:100%;aspect-ratio:1;background-color:var(--md-sys-color-surface-variant);border-radius:var(--md-shape-corner-large);border:1px solid var(--border-color);display:flex;align-items:center;justify-content:center;overflow:hidden;position:relative;box-shadow:inset 0 2px 8px #0000000d}.output-image{width:100%;height:100%;object-fit:contain;transition:transform .3s}.output-image:hover{transform:scale(1.015)}.progress-overlay{position:absolute;inset:0;background-color:#090a0fd9;backdrop-filter:blur(8px);-webkit-backdrop-filter:blur(8px);display:flex;flex-direction:column;align-items:center;justify-content:center;color:#fff;gap:14px;padding:24px;z-index:5}.progress-spinner{width:44px;height:44px;border:3px solid rgba(255,255,255,.15);border-top-color:var(--md-sys-color-primary);border-radius:50%;animation:spin .9s cubic-bezier(.5,.1,.4,.9) infinite;box-shadow:0 0 12px #6366f133}.loading-dot{width:8px;height:8px;border-radius:50%;background:var(--md-sys-color-primary);opacity:.9;animation:pulse 1.2s ease-in-out infinite;box-shadow:0 0 8px var(--md-sys-color-primary)}.progress-text{font-size:1.05rem;font-weight:700;letter-spacing:-.01em}.progress-bar-container{width:80%;height:5px;background-color:#ffffff1f;border-radius:var(--md-shape-corner-full);overflow:hidden;margin:4px 0}.progress-bar-fill{height:100%;background:linear-gradient(90deg,var(--md-sys-color-primary),#d946ef);width:0%;transition:width .4s cubic-bezier(.1,.8,.25,1);box-shadow:0 0 8px #6366f166}.output-placeholder-icon{width:48px;height:48px;color:var(--md-sys-color-on-surface-variant);opacity:.5;filter:drop-shadow(0 2px 10px rgba(0,0,0,.05))}.output-placeholder-text{font-size:.88rem;color:var(--md-sys-color-on-surface-variant);margin-top:12px;text-align:center;line-height:1.5;opacity:.8}.image-actions{display:flex;gap:10px;margin-top:16px;width:100%}.image-actions button{flex:1}.models-grid{display:grid;grid-template-columns:1fr;gap:20px}@media(min-width:800px){.models-grid{grid-template-columns:1fr 1fr}}.model-card{display:flex;flex-direction:column;justify-content:space-between;border:1px solid var(--border-color-muted)}.model-header{display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:12px}.model-name{font-size:1.05rem;font-weight:600}.model-badge{font-size:.72rem;font-weight:700;padding:3px 8px;border-radius:var(--md-shape-corner-full)}.model-badge-gguf{background-color:#f59e0b26;color:#d97706}.model-badge-safetensors{background-color:#0ea5e926;color:#0284c7}.model-description{font-size:.82rem;color:var(--md-sys-color-on-surface-variant);margin-bottom:16px;line-height:1.45;opacity:.9}.model-status-info{margin-top:auto;padding-top:12px;border-top:1px solid var(--border-color-muted);display:flex;align-items:center;justify-content:space-between}.model-size{font-size:.8rem;font-weight:550;color:var(--md-sys-color-on-surface-variant)}.model-progress-section{width:100%;margin-top:12px}.model-progress-label{display:flex;justify-content:space-between;font-size:.78rem;font-weight:600;margin-bottom:4px}.model-progress-bar{width:100%;height:6px;background-color:var(--border-color-muted);border-radius:var(--md-shape-corner-full);overflow:hidden}.model-progress-fill{height:100%;background:linear-gradient(90deg,var(--md-sys-color-primary),var(--md-sys-color-secondary));width:0%;transition:width .25s ease}.import-box{border:2px dashed var(--border-color);border-radius:var(--md-shape-corner-large);padding:32px;text-align:center;cursor:pointer;transition:all var(--md-transition-duration);background-color:var(--md-sys-color-surface);color:var(--md-sys-color-on-surface-variant);display:flex;flex-direction:column;align-items:center;gap:10px}.import-box:hover{background-color:var(--md-sys-color-primary-container);border-color:var(--md-sys-color-primary);color:var(--md-sys-color-primary)}.import-icon{width:40px;height:40px;color:var(--md-sys-color-primary);filter:drop-shadow(0 2px 6px rgba(99,102,241,.15))}.gallery-section{margin-top:36px}.gallery-header{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.gallery-selection-actions{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.gallery-selection-actions .m3-btn{height:34px;padding:0 14px}.gallery-selection-count{font-size:.82rem;font-weight:700;color:var(--md-sys-color-primary);padding:7px 10px;border-radius:var(--md-shape-corner-full);background:var(--md-sys-color-primary-container)}.gallery-hint{margin-top:8px;font-size:.78rem;color:var(--md-sys-color-outline)}.gallery-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:12px;margin-top:16px}.gallery-item{aspect-ratio:1;border-radius:var(--md-shape-corner-medium);overflow:hidden;border:1px solid var(--border-color-muted);cursor:pointer;position:relative;contain:layout paint style;transition:border-color var(--md-transition-duration),box-shadow var(--md-transition-duration),transform var(--md-transition-duration)}.gallery-item.selected{border-color:var(--md-sys-color-primary);box-shadow:0 0 0 3px #4f46e540}.gallery-thumb{width:100%;height:100%;object-fit:cover;transition:transform var(--md-transition-duration) var(--md-transition-easing)}.gallery-item:hover .gallery-thumb{transform:scale(1.05)}.gallery-select-badge{position:absolute;top:8px;right:8px;width:26px;height:26px;border-radius:50%;display:grid;place-items:center;color:var(--md-sys-color-on-primary);background:var(--md-sys-color-primary);box-shadow:0 2px 8px #00000047}.app-dialog-backdrop{position:fixed;inset:0;z-index:1000;display:flex;align-items:center;justify-content:center;padding:24px;background:#080c18a3;-webkit-backdrop-filter:blur(4px) saturate(.86);backdrop-filter:blur(4px) saturate(.86)}.app-dialog{width:min(460px,100%);background:color-mix(in srgb,var(--md-sys-color-surface) 96%,white 4%);color:var(--md-sys-color-on-surface);border:1px solid color-mix(in srgb,var(--md-sys-color-outline) 55%,transparent);border-radius:var(--md-shape-corner-large);box-shadow:0 22px 60px #0000006b,0 0 0 1px #ffffff14 inset;padding:24px}.app-dialog-title{font-size:1.15rem;font-weight:800;margin:0 0 10px}.app-dialog-message{font-size:.92rem;line-height:1.45;color:var(--md-sys-color-on-surface-variant);margin:0;white-space:pre-wrap}.app-dialog-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:22px;flex-wrap:wrap}.gallery-empty{text-align:center;padding:36px;color:var(--md-sys-color-on-surface-variant);font-size:.85rem;opacity:.8}@keyframes spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes pulse{0%,to{opacity:1;transform:scale(1)}50%{opacity:.55;transform:scale(1.06)}}.sidebar-specs-header{display:flex;align-items:center;gap:6px;margin-bottom:6px;font-weight:600;color:var(--md-sys-color-on-background)}.sidebar-specs-item{text-overflow:ellipsis;overflow:hidden;white-space:nowrap;opacity:.85;margin-bottom:2px;color:var(--md-sys-color-on-background)}.sidebar-specs-os{color:var(--md-sys-color-primary);font-weight:600;margin-top:4px} diff --git a/app/dist/index.html b/app/dist/index.html index d2c2477..4d279bd 100644 --- a/app/dist/index.html +++ b/app/dist/index.html @@ -8,8 +8,8 @@ Local AI Image Generator - - + + diff --git a/app/frontend/src/App.css b/app/frontend/src/App.css index ea14b94..e592830 100644 --- a/app/frontend/src/App.css +++ b/app/frontend/src/App.css @@ -777,46 +777,6 @@ html[data-theme="dark"] .m3-segment-item:hover:not(.active):not(.disabled) { margin-top: 16px; } -.image-to-image-section { - margin-top: 12px; - border-top: 1px solid var(--border-color); - padding-top: 16px; -} - -/* Drag and Drop Zone */ -.image-dropzone { - border: 2.5px dashed var(--border-color); - border-radius: var(--md-shape-corner-large); - padding: 24px; - text-align: center; - cursor: pointer; - background-color: var(--md-sys-color-surface-variant); - color: var(--md-sys-color-on-surface-variant); - transition: all var(--md-transition-duration); - position: relative; - overflow: hidden; - min-height: 120px; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - gap: 6px; -} - -.image-dropzone:hover { - background-color: var(--md-sys-color-primary-container); - border-color: var(--md-sys-color-primary); - color: var(--md-sys-color-primary); -} - -.dropped-image-preview { - max-width: 100%; - max-height: 160px; - border-radius: var(--md-shape-corner-medium); - object-fit: contain; - box-shadow: var(--glass-shadow); -} - /* Aspect Ratio Buttons with Previews */ .aspect-ratio-btn { position: relative; diff --git a/app/frontend/src/App.jsx b/app/frontend/src/App.jsx index a93d5be..817bfb1 100644 --- a/app/frontend/src/App.jsx +++ b/app/frontend/src/App.jsx @@ -50,7 +50,6 @@ function App() { // Prompts const [prompt, setPrompt] = useState(""); const [negativePrompt, setNegativePrompt] = useState(""); - const [inputImage, setInputImage] = useState(null); // base64 for Image-to-Image // Model & Server Status const [activeModel, setActiveModel] = useState(null); @@ -342,8 +341,6 @@ function App() { generationProgress={generationProgress} setGenerationProgress={setGenerationProgress} setActiveTab={setActiveTab} - inputImage={inputImage} - setInputImage={setInputImage} showAlert={showAlert} showConfirm={showConfirm} /> @@ -382,7 +379,6 @@ function App() { generatedImages, isGenerating, generationProgress, - inputImage, serverRunning, specs, backendOptions, diff --git a/app/frontend/src/components/Generator.jsx b/app/frontend/src/components/Generator.jsx index 877d0fc..7584d7f 100644 --- a/app/frontend/src/components/Generator.jsx +++ b/app/frontend/src/components/Generator.jsx @@ -1,6 +1,6 @@ import React, { memo, useState, useRef, useCallback } from "react"; -import { Sparkles, Download, Copy, RefreshCw, ImagePlus, Check, Sliders, Layers, Trash2 } from "lucide-react"; -import { generateImage, isTauri, startServer, stopServer, waitForServerReady, getBackendStatus, getGenerationProgress, saveGeneratedOutput, deleteGeneratedOutputs } from "../services/api"; +import { Sparkles, Download, Copy, RefreshCw, Check, Sliders, Layers, Trash2 } from "lucide-react"; +import { generateImage, startServer, stopServer, waitForServerReady, getBackendStatus, getGenerationProgress, saveGeneratedOutput, deleteGeneratedOutputs } from "../services/api"; const GalleryItem = memo(({ img, idx, isSelected, onClick }) => { const handleClick = (e) => { @@ -37,8 +37,6 @@ function Generator({ generationProgress, setGenerationProgress, setActiveTab, - inputImage, - setInputImage, showAlert = async ({ message }) => window.alert(message), showConfirm = async ({ message }) => window.confirm(message), }) { @@ -58,31 +56,8 @@ function Generator({ const [isDecoding, setIsDecoding] = useState(false); const [selectedGalleryIndexes, setSelectedGalleryIndexes] = useState([]); const timerRef = useRef(null); - const fileInputRef = useRef(null); const abortControllerRef = useRef(null); - - // Trigger file dialog for Image-to-Image - const handleDropzoneClick = () => { - fileInputRef.current.click(); - }; - - // Convert uploaded image file to Base64 - const handleFileChange = (e) => { - const file = e.target.files[0]; - if (file) { - const reader = new FileReader(); - reader.onload = () => { - setInputImage(reader.result); - }; - reader.readAsDataURL(file); - } - }; - - const clearInputImage = (e) => { - e.stopPropagation(); - setInputImage(null); - if (fileInputRef.current) fileInputRef.current.value = ""; - }; + const hasRealGenerationStepRef = useRef(false); // Trigger main image generation process const handleGenerate = async () => { @@ -170,6 +145,7 @@ function Generator({ setElapsedTime(0); setCurrentStep(0); setGenerationSpeed(""); + hasRealGenerationStepRef.current = false; setIsCpuFallback(false); setIsDecoding(false); setGenDuration(null); @@ -203,7 +179,10 @@ function Generator({ const steps = progress.steps || constraints.steps || 20; const speed = decoding ? "" : (progress.speed || ""); - setCurrentStep(step); + if (decoding || progress.steps > 0) { + hasRealGenerationStepRef.current = true; + setCurrentStep(step); + } if (!decoding) { setGenerationSpeed(speed); } else { @@ -218,7 +197,11 @@ function Generator({ progressPercent = Math.round((step / steps) * 100); } progressPercent = Math.min(99, progressPercent); - setGenerationProgress((prev) => Math.max(prev, progressPercent)); + if (decoding || progress.steps > 0) { + setGenerationProgress(progressPercent); + } else { + setGenerationProgress((prev) => Math.max(prev, progressPercent)); + } // Calculate remaining time let remaining = 0; @@ -275,8 +258,6 @@ function Generator({ expectedTotal = constraints.steps * activeStepTime; step = Math.min(constraints.steps - 1, Math.floor(elapsedSeconds / activeStepTime)); } - setCurrentStep(step); - const remaining = Math.max(1, expectedTotal - elapsedSeconds); setEstimatedLeftTime(Math.round(remaining)); @@ -305,7 +286,9 @@ function Generator({ progressPercent = Math.min(99, Math.round(85 + 14 * decay)); } } - setGenerationProgress((p) => Math.max(p, progressPercent)); + if (!hasRealGenerationStepRef.current) { + setGenerationProgress((p) => Math.max(p, progressPercent)); + } } }, 1000); @@ -316,7 +299,7 @@ function Generator({ negativePrompt, constraints, activeModel, - inputImage, // passes base64 if I2I + null, (prog) => setGenerationProgress((prev) => Math.max(prev, prog)), abortControllerRef.current.signal ); @@ -339,7 +322,6 @@ function Generator({ model: activeModel, duration_sec: result.duration_sec, timestamp: new Date().toLocaleTimeString(), - inputImage: Boolean(inputImage), }; let savedOutput = null; let savedUrl = null; @@ -396,31 +378,29 @@ function Generator({ abortControllerRef.current.abort(); } - // In native desktop mode, restart the server process to immediately free CPU threads/memory - if (isTauri()) { - try { - console.log("Cancelling: Stopping server to kill generation threads..."); - await stopServer(); - if (activeModel) { - console.log("Cancelling: Restarting server for future generations..."); - await startServer(activeModel, constraints); - const ready = await waitForServerReady(); - if (!ready) { - console.warn("Server failed to restart properly."); - } + try { + console.log("Cancelling: Stopping server to kill generation threads..."); + await stopServer(); + setCurrentStep(0); + setGenerationSpeed(""); + setIsDecoding(false); + hasRealGenerationStepRef.current = false; + + if (activeModel) { + console.log("Cancelling: Restarting server for future generations..."); + await startServer(activeModel, constraints); + const ready = await waitForServerReady(); + if (!ready) { + console.warn("Server failed to restart properly."); } - } catch (err) { - console.error("Failed to restart server on cancellation:", err); - } finally { - setIsCancelling(false); - setIsGenerating(false); - setGenerationProgress(0); } - } else { - // Browser Mode + } catch (err) { + console.error("Failed to restart server on cancellation:", err); + } finally { setIsCancelling(false); setIsGenerating(false); setGenerationProgress(0); + setEstimatedLeftTime(0); } } }; @@ -634,51 +614,6 @@ function Generator({ - {/* Image to Image Dropzone Toggle */} -
- -
- - - {inputImage ? ( -
- Source - -
- ) : ( - <> - - - Click or drag image here for Image-to-Image guidance - - - )} -
-
- {/* Generate Trigger Button */}