var i3=Object.defineProperty;var l3=(e,n,a)=>n in e?i3(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var Mx=(e,n,a)=>l3(e,typeof n!="symbol"?n+"":n,a);function c3(e,n){for(var a=0;ao[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))o(i);new MutationObserver(i=>{for(const c of i)if(c.type==="childList")for(const d of c.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(i){const c={};return i.integrity&&(c.integrity=i.integrity),i.referrerPolicy&&(c.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?c.credentials="include":i.crossOrigin==="anonymous"?c.credentials="omit":c.credentials="same-origin",c}function o(i){if(i.ep)return;i.ep=!0;const c=a(i);fetch(i.href,c)}})();function w0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Fm={exports:{}},Li={};/** * @license React * react-jsx-runtime.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var _x;function u3(){if(_x)return Li;_x=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(o,i,c){var d=null;if(c!==void 0&&(d=""+c),i.key!==void 0&&(d=""+i.key),"key"in i){c={};for(var m in i)m!=="key"&&(c[m]=i[m])}else c=i;return i=c.ref,{$$typeof:e,type:o,key:d,ref:i!==void 0?i:null,props:c}}return Li.Fragment=n,Li.jsx=a,Li.jsxs=a,Li}var Ox;function d3(){return Ox||(Ox=1,Fm.exports=u3()),Fm.exports}var l=d3(),Ym={exports:{}},Me={};/** * @license React * react.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Dx;function f3(){if(Dx)return Me;Dx=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),c=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),p=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(M){return M===null||typeof M!="object"?null:(M=x&&M[x]||M["@@iterator"],typeof M=="function"?M:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function E(M,_,U){this.props=M,this.context=_,this.refs=N,this.updater=U||j}E.prototype.isReactComponent={},E.prototype.setState=function(M,_){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,_,"setState")},E.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function k(){}k.prototype=E.prototype;function T(M,_,U){this.props=M,this.context=_,this.refs=N,this.updater=U||j}var R=T.prototype=new k;R.constructor=T,C(R,E.prototype),R.isPureReactComponent=!0;var D=Array.isArray;function P(){}var z={H:null,A:null,T:null,S:null},B=Object.prototype.hasOwnProperty;function H(M,_,U){var V=U.ref;return{$$typeof:e,type:M,key:_,ref:V!==void 0?V:null,props:U}}function Y(M,_){return H(M.type,_,M.props)}function Q(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function fe(M){var _={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(U){return _[U]})}var de=/\/+/g;function he(M,_){return typeof M=="object"&&M!==null&&M.key!=null?fe(""+M.key):_.toString(36)}function se(M){switch(M.status){case"fulfilled":return M.value;case"rejected":throw M.reason;default:switch(typeof M.status=="string"?M.then(P,P):(M.status="pending",M.then(function(_){M.status==="pending"&&(M.status="fulfilled",M.value=_)},function(_){M.status==="pending"&&(M.status="rejected",M.reason=_)})),M.status){case"fulfilled":return M.value;case"rejected":throw M.reason}}throw M}function O(M,_,U,V,F){var ae=typeof M;(ae==="undefined"||ae==="boolean")&&(M=null);var ne=!1;if(M===null)ne=!0;else switch(ae){case"bigint":case"string":case"number":ne=!0;break;case"object":switch(M.$$typeof){case e:case n:ne=!0;break;case y:return ne=M._init,O(ne(M._payload),_,U,V,F)}}if(ne)return F=F(M),ne=V===""?"."+he(M,0):V,D(F)?(U="",ne!=null&&(U=ne.replace(de,"$&/")+"/"),O(F,_,U,"",function(W){return W})):F!=null&&(Q(F)&&(F=Y(F,U+(F.key==null||M&&M.key===F.key?"":(""+F.key).replace(de,"$&/")+"/")+ne)),_.push(F)),1;ne=0;var me=V===""?".":V+":";if(D(M))for(var pe=0;pe>>1,te=O[J];if(0>>1;Ji(U,Z))Vi(F,U)?(O[J]=F,O[V]=Z,J=V):(O[J]=U,O[_]=Z,J=_);else if(Vi(F,Z))O[J]=F,O[V]=Z,J=V;else break e}}return $}function i(O,$){var Z=O.sortIndex-$.sortIndex;return Z!==0?Z:O.id-$.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var c=performance;e.unstable_now=function(){return c.now()}}else{var d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var p=[],h=[],y=1,v=null,x=3,S=!1,j=!1,C=!1,N=!1,E=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,T=typeof setImmediate<"u"?setImmediate:null;function R(O){for(var $=a(h);$!==null;){if($.callback===null)o(h);else if($.startTime<=O)o(h),$.sortIndex=$.expirationTime,n(p,$);else break;$=a(h)}}function D(O){if(C=!1,R(O),!j)if(a(p)!==null)j=!0,P||(P=!0,fe());else{var $=a(h);$!==null&&se(D,$.startTime-O)}}var P=!1,z=-1,B=5,H=-1;function Y(){return N?!0:!(e.unstable_now()-HO&&Y());){var J=v.callback;if(typeof J=="function"){v.callback=null,x=v.priorityLevel;var te=J(v.expirationTime<=O);if(O=e.unstable_now(),typeof te=="function"){v.callback=te,R(O),$=!0;break t}v===a(p)&&o(p),R(O)}else o(p);v=a(p)}if(v!==null)$=!0;else{var M=a(h);M!==null&&se(D,M.startTime-O),$=!1}}break e}finally{v=null,x=Z,S=!1}$=void 0}}finally{$?fe():P=!1}}}var fe;if(typeof T=="function")fe=function(){T(Q)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,he=de.port2;de.port1.onmessage=Q,fe=function(){he.postMessage(null)}}else fe=function(){E(Q,0)};function se(O,$){z=E(function(){O(e.unstable_now())},$)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(O){O.callback=null},e.unstable_forceFrameRate=function(O){0>O||125J?(O.sortIndex=Z,n(h,O),a(p)===null&&O===a(h)&&(C?(k(z),z=-1):C=!0,se(D,Z-J))):(O.sortIndex=te,n(p,O),j||S||(j=!0,P||(P=!0,fe()))),O},e.unstable_shouldYield=Y,e.unstable_wrapCallback=function(O){var $=x;return function(){var Z=x;x=$;try{return O.apply(this,arguments)}finally{x=Z}}}})(Km)),Km}var Px;function p3(){return Px||(Px=1,qm.exports=m3()),qm.exports}var Xm={exports:{}},Ft={};/** * @license React * react-dom.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Ix;function h3(){if(Ix)return Ft;Ix=1;var e=Lu();function n(p){var h="https://react.dev/errors/"+p;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Xm.exports=h3(),Xm.exports}/** * @license React * react-dom-client.production.js * * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */var Bx;function g3(){if(Bx)return zi;Bx=1;var e=p3(),n=Lu(),a=C0();function o(t){var r="https://react.dev/errors/"+t;if(1te||(t.current=J[te],J[te]=null,te--)}function U(t,r){te++,J[te]=t.current,t.current=r}var V=M(null),F=M(null),ae=M(null),ne=M(null);function me(t,r){switch(U(ae,r),U(F,t),U(V,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?ex(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=ex(r),t=tx(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}_(V),U(V,t)}function pe(){_(V),_(F),_(ae)}function W(t){t.memoizedState!==null&&U(ne,t);var r=V.current,s=tx(r,t.type);r!==s&&(U(F,t),U(V,s))}function ie(t){F.current===t&&(_(V),_(F)),ne.current===t&&(_(ne),Mi._currentValue=Z)}var ge,je;function Ae(t){if(ge===void 0)try{throw Error()}catch(s){var r=s.stack.trim().match(/\n( *(at )?)/);ge=r&&r[1]||"",je=-1)":-1g||L[u]!==K[g]){var re=` `+L[u].replace(" at new "," at ");return t.displayName&&re.includes("")&&(re=re.replace("",t.displayName)),re}while(1<=u&&0<=g);break}}}finally{tt=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Ae(s):""}function kt(t,r){switch(t.tag){case 26:case 27:case 5:return Ae(t.type);case 16:return Ae("Lazy");case 13:return t.child!==r&&r!==null?Ae("Suspense Fallback"):Ae("Suspense");case 19:return Ae("SuspenseList");case 0:case 15:return ct(t.type,!1);case 11:return ct(t.type.render,!1);case 1:return ct(t.type,!0);case 31:return Ae("Activity");default:return""}}function Ra(t){try{var r="",s=null;do r+=kt(t,s),s=t,t=t.return;while(t);return r}catch(u){return` Error generating stack: `+u.message+` `+u.stack}}var Tt=Object.prototype.hasOwnProperty,Hs=e.unstable_scheduleCallback,Vs=e.unstable_cancelCallback,Wt=e.unstable_shouldYield,Vr=e.unstable_requestPaint,qt=e.unstable_now,_d=e.unstable_getCurrentPriorityLevel,Aa=e.unstable_ImmediatePriority,Tl=e.unstable_UserBlockingPriority,Ma=e.unstable_NormalPriority,Gs=e.unstable_LowPriority,mr=e.unstable_IdlePriority,Rl=e.log,Gr=e.unstable_setDisableYieldValue,_a=null,Kt=null;function Un(t){if(typeof Rl=="function"&&Gr(t),Kt&&typeof Kt.setStrictMode=="function")try{Kt.setStrictMode(_a,t)}catch{}}var Vt=Math.clz32?Math.clz32:Qn,Od=Math.log,Fs=Math.LN2;function Qn(t){return t>>>=0,t===0?32:31-(Od(t)/Fs|0)|0}var yo=256,xo=262144,Oa=4194304;function Jn(t){var r=t&42;if(r!==0)return r;switch(t&-t){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 t&261888;case 262144:case 524288:case 1048576:case 2097152:return t&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return t&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return t}}function Re(t,r,s){var u=t.pendingLanes;if(u===0)return 0;var g=0,b=t.suspendedLanes,w=t.pingedLanes;t=t.warmLanes;var A=u&134217727;return A!==0?(u=A&~b,u!==0?g=Jn(u):(w&=A,w!==0?g=Jn(w):s||(s=A&~t,s!==0&&(g=Jn(s))))):(A=u&~b,A!==0?g=Jn(A):w!==0?g=Jn(w):s||(s=u&~t,s!==0&&(g=Jn(s)))),g===0?0:r!==0&&r!==g&&(r&b)===0&&(b=g&-g,s=r&-r,b>=s||b===32&&(s&4194048)!==0)?r:g}function ut(t,r){return(t.pendingLanes&~(t.suspendedLanes&~t.pingedLanes)&r)===0}function Rt(t,r){switch(t){case 1:case 2:case 4:case 8:case 64:return r+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 r+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 Gt(){var t=Oa;return Oa<<=1,(Oa&62914560)===0&&(Oa=4194304),t}function Fr(t){for(var r=[],s=0;31>s;s++)r.push(t);return r}function mt(t,r){t.pendingLanes|=r,r!==268435456&&(t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0)}function Jt(t,r,s,u,g,b){var w=t.pendingLanes;t.pendingLanes=s,t.suspendedLanes=0,t.pingedLanes=0,t.warmLanes=0,t.expiredLanes&=s,t.entangledLanes&=s,t.errorRecoveryDisabledLanes&=s,t.shellSuspendCounter=0;var A=t.entanglements,L=t.expirationTimes,K=t.hiddenUpdates;for(s=w&~s;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var tE=/[\n"\\]/g;function Tn(t){return t.replace(tE,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function Id(t,r,s,u,g,b,w,A){t.name="",w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"?t.type=w:t.removeAttribute("type"),r!=null?w==="number"?(r===0&&t.value===""||t.value!=r)&&(t.value=""+kn(r)):t.value!==""+kn(r)&&(t.value=""+kn(r)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),r!=null?$d(t,w,kn(r)):s!=null?$d(t,w,kn(s)):u!=null&&t.removeAttribute("value"),g==null&&b!=null&&(t.defaultChecked=!!b),g!=null&&(t.checked=g&&typeof g!="function"&&typeof g!="symbol"),A!=null&&typeof A!="function"&&typeof A!="symbol"&&typeof A!="boolean"?t.name=""+kn(A):t.removeAttribute("name")}function qg(t,r,s,u,g,b,w,A){if(b!=null&&typeof b!="function"&&typeof b!="symbol"&&typeof b!="boolean"&&(t.type=b),r!=null||s!=null){if(!(b!=="submit"&&b!=="reset"||r!=null)){Pd(t);return}s=s!=null?""+kn(s):"",r=r!=null?""+kn(r):s,A||r===t.value||(t.value=r),t.defaultValue=r}u=u??g,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=A?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),Pd(t)}function $d(t,r,s){r==="number"&&_l(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function ko(t,r,s,u){if(t=t.options,r){r={};for(var g=0;g"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Gd=!1;if(gr)try{var Ks={};Object.defineProperty(Ks,"passive",{get:function(){Gd=!0}}),window.addEventListener("test",Ks,Ks),window.removeEventListener("test",Ks,Ks)}catch{Gd=!1}var Wr=null,Fd=null,Dl=null;function tv(){if(Dl)return Dl;var t,r=Fd,s=r.length,u,g="value"in Wr?Wr.value:Wr.textContent,b=g.length;for(t=0;t=Qs),iv=" ",lv=!1;function cv(t,r){switch(t){case"keyup":return RE.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function uv(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var Mo=!1;function ME(t,r){switch(t){case"compositionend":return uv(r);case"keypress":return r.which!==32?null:(lv=!0,iv);case"textInput":return t=r.data,t===iv&&lv?null:t;default:return null}}function _E(t,r){if(Mo)return t==="compositionend"||!Xd&&cv(t,r)?(t=tv(),Dl=Fd=Wr=null,Mo=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(r.ctrlKey||r.altKey||r.metaKey)||r.ctrlKey&&r.altKey){if(r.char&&1=r)return{node:s,offset:r-t};t=u}e:{for(;s;){if(s.nextSibling){s=s.nextSibling;break e}s=s.parentNode}s=void 0}s=bv(s)}}function xv(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?xv(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function Sv(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=_l(t.document);r instanceof t.HTMLIFrameElement;){try{var s=typeof r.contentWindow.location.href=="string"}catch{s=!1}if(s)t=r.contentWindow;else break;r=_l(t.document)}return r}function Jd(t){var r=t&&t.nodeName&&t.nodeName.toLowerCase();return r&&(r==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||r==="textarea"||t.contentEditable==="true")}var BE=gr&&"documentMode"in document&&11>=document.documentMode,_o=null,ef=null,ni=null,tf=!1;function wv(t,r,s){var u=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;tf||_o==null||_o!==_l(u)||(u=_o,"selectionStart"in u&&Jd(u)?u={start:u.selectionStart,end:u.selectionEnd}:(u=(u.ownerDocument&&u.ownerDocument.defaultView||window).getSelection(),u={anchorNode:u.anchorNode,anchorOffset:u.anchorOffset,focusNode:u.focusNode,focusOffset:u.focusOffset}),ni&&ti(ni,u)||(ni=u,u=kc(ef,"onSelect"),0>=w,g-=w,er=1<<32-Vt(r)+g|s<Oe?(Be=Ce,Ce=null):Be=Ce.sibling;var Ke=X(G,Ce,q[Oe],oe);if(Ke===null){Ce===null&&(Ce=Be);break}t&&Ce&&Ke.alternate===null&&r(G,Ce),I=b(Ke,I,Oe),qe===null?Ee=Ke:qe.sibling=Ke,qe=Ke,Ce=Be}if(Oe===q.length)return s(G,Ce),He&&br(G,Oe),Ee;if(Ce===null){for(;OeOe?(Be=Ce,Ce=null):Be=Ce.sibling;var ha=X(G,Ce,Ke.value,oe);if(ha===null){Ce===null&&(Ce=Be);break}t&&Ce&&ha.alternate===null&&r(G,Ce),I=b(ha,I,Oe),qe===null?Ee=ha:qe.sibling=ha,qe=ha,Ce=Be}if(Ke.done)return s(G,Ce),He&&br(G,Oe),Ee;if(Ce===null){for(;!Ke.done;Oe++,Ke=q.next())Ke=le(G,Ke.value,oe),Ke!==null&&(I=b(Ke,I,Oe),qe===null?Ee=Ke:qe.sibling=Ke,qe=Ke);return He&&br(G,Oe),Ee}for(Ce=u(Ce);!Ke.done;Oe++,Ke=q.next())Ke=ee(Ce,G,Oe,Ke.value,oe),Ke!==null&&(t&&Ke.alternate!==null&&Ce.delete(Ke.key===null?Oe:Ke.key),I=b(Ke,I,Oe),qe===null?Ee=Ke:qe.sibling=Ke,qe=Ke);return t&&Ce.forEach(function(s3){return r(G,s3)}),He&&br(G,Oe),Ee}function at(G,I,q,oe){if(typeof q=="object"&&q!==null&&q.type===C&&q.key===null&&(q=q.props.children),typeof q=="object"&&q!==null){switch(q.$$typeof){case S:e:{for(var Ee=q.key;I!==null;){if(I.key===Ee){if(Ee=q.type,Ee===C){if(I.tag===7){s(G,I.sibling),oe=g(I,q.props.children),oe.return=G,G=oe;break e}}else if(I.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===B&&Fa(Ee)===I.type){s(G,I.sibling),oe=g(I,q.props),li(oe,q),oe.return=G,G=oe;break e}s(G,I);break}else r(G,I);I=I.sibling}q.type===C?(oe=Ba(q.props.children,G.mode,oe,q.key),oe.return=G,G=oe):(oe=Gl(q.type,q.key,q.props,null,G.mode,oe),li(oe,q),oe.return=G,G=oe)}return w(G);case j:e:{for(Ee=q.key;I!==null;){if(I.key===Ee)if(I.tag===4&&I.stateNode.containerInfo===q.containerInfo&&I.stateNode.implementation===q.implementation){s(G,I.sibling),oe=g(I,q.children||[]),oe.return=G,G=oe;break e}else{s(G,I);break}else r(G,I);I=I.sibling}oe=cf(q,G.mode,oe),oe.return=G,G=oe}return w(G);case B:return q=Fa(q),at(G,I,q,oe)}if(se(q))return we(G,I,q,oe);if(fe(q)){if(Ee=fe(q),typeof Ee!="function")throw Error(o(150));return q=Ee.call(q),ke(G,I,q,oe)}if(typeof q.then=="function")return at(G,I,Zl(q),oe);if(q.$$typeof===T)return at(G,I,Wl(G,q),oe);Ql(G,q)}return typeof q=="string"&&q!==""||typeof q=="number"||typeof q=="bigint"?(q=""+q,I!==null&&I.tag===6?(s(G,I.sibling),oe=g(I,q),oe.return=G,G=oe):(s(G,I),oe=lf(q,G.mode,oe),oe.return=G,G=oe),w(G)):s(G,I)}return function(G,I,q,oe){try{ii=0;var Ee=at(G,I,q,oe);return Vo=null,Ee}catch(Ce){if(Ce===Ho||Ce===Kl)throw Ce;var qe=pn(29,Ce,null,G.mode);return qe.lanes=oe,qe.return=G,qe}finally{}}}var Wa=Fv(!0),Yv=Fv(!1),Qr=!1;function Sf(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function wf(t,r){t=t.updateQueue,r.updateQueue===t&&(r.updateQueue={baseState:t.baseState,firstBaseUpdate:t.firstBaseUpdate,lastBaseUpdate:t.lastBaseUpdate,shared:t.shared,callbacks:null})}function Jr(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function ea(t,r,s){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(Xe&2)!==0){var g=u.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),u.pending=r,r=Vl(t),Rv(t,null,s),r}return Hl(t,u,r,s),Vl(t)}function ci(t,r,s){if(r=r.updateQueue,r!==null&&(r=r.shared,(s&4194048)!==0)){var u=r.lanes;u&=t.pendingLanes,s|=u,r.lanes=s,en(t,s)}}function Cf(t,r){var s=t.updateQueue,u=t.alternate;if(u!==null&&(u=u.updateQueue,s===u)){var g=null,b=null;if(s=s.firstBaseUpdate,s!==null){do{var w={lane:s.lane,tag:s.tag,payload:s.payload,callback:null,next:null};b===null?g=b=w:b=b.next=w,s=s.next}while(s!==null);b===null?g=b=r:b=b.next=r}else g=b=r;s={baseState:u.baseState,firstBaseUpdate:g,lastBaseUpdate:b,shared:u.shared,callbacks:u.callbacks},t.updateQueue=s;return}t=s.lastBaseUpdate,t===null?s.firstBaseUpdate=r:t.next=r,s.lastBaseUpdate=r}var jf=!1;function ui(){if(jf){var t=Uo;if(t!==null)throw t}}function di(t,r,s,u){jf=!1;var g=t.updateQueue;Qr=!1;var b=g.firstBaseUpdate,w=g.lastBaseUpdate,A=g.shared.pending;if(A!==null){g.shared.pending=null;var L=A,K=L.next;L.next=null,w===null?b=K:w.next=K,w=L;var re=t.alternate;re!==null&&(re=re.updateQueue,A=re.lastBaseUpdate,A!==w&&(A===null?re.firstBaseUpdate=K:A.next=K,re.lastBaseUpdate=L))}if(b!==null){var le=g.baseState;w=0,re=K=L=null,A=b;do{var X=A.lane&-536870913,ee=X!==A.lane;if(ee?($e&X)===X:(u&X)===X){X!==0&&X===Bo&&(jf=!0),re!==null&&(re=re.next={lane:0,tag:A.tag,payload:A.payload,callback:null,next:null});e:{var we=t,ke=A;X=r;var at=s;switch(ke.tag){case 1:if(we=ke.payload,typeof we=="function"){le=we.call(at,le,X);break e}le=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=ke.payload,X=typeof we=="function"?we.call(at,le,X):we,X==null)break e;le=v({},le,X);break e;case 2:Qr=!0}}X=A.callback,X!==null&&(t.flags|=64,ee&&(t.flags|=8192),ee=g.callbacks,ee===null?g.callbacks=[X]:ee.push(X))}else ee={lane:X,tag:A.tag,payload:A.payload,callback:A.callback,next:null},re===null?(K=re=ee,L=le):re=re.next=ee,w|=X;if(A=A.next,A===null){if(A=g.shared.pending,A===null)break;ee=A,A=ee.next,ee.next=null,g.lastBaseUpdate=ee,g.shared.pending=null}}while(!0);re===null&&(L=le),g.baseState=L,g.firstBaseUpdate=K,g.lastBaseUpdate=re,b===null&&(g.shared.lanes=0),oa|=w,t.lanes=w,t.memoizedState=le}}function Wv(t,r){if(typeof t!="function")throw Error(o(191,t));t.call(r)}function qv(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;tb?b:8;var w=O.T,A={};O.T=A,Vf(t,!1,r,s);try{var L=g(),K=O.S;if(K!==null&&K(A,L),L!==null&&typeof L=="object"&&typeof L.then=="function"){var re=KE(L,u);pi(t,r,re,yn(t))}else pi(t,r,u,yn(t))}catch(le){pi(t,r,{then:function(){},status:"rejected",reason:le},yn())}finally{$.p=b,w!==null&&A.types!==null&&(w.types=A.types),O.T=w}}function tN(){}function Uf(t,r,s,u){if(t.tag!==5)throw Error(o(476));var g=Nb(t).queue;Eb(t,g,r,Z,s===null?tN:function(){return kb(t),s(u)})}function Nb(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:Z,baseState:Z,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:Z},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:wr,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function kb(t){var r=Nb(t);r.next===null&&(r=t.alternate.memoizedState),pi(t,r.next.queue,{},yn())}function Hf(){return It(Mi)}function Tb(){return yt().memoizedState}function Rb(){return yt().memoizedState}function nN(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=yn();t=Jr(s);var u=ea(r,t,s);u!==null&&(cn(u,r,s),ci(u,r,s)),r={cache:vf()},t.payload=r;return}r=r.return}}function rN(t,r,s){var u=yn();s={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},lc(t)?Mb(r,s):(s=of(t,r,s,u),s!==null&&(cn(s,t,u),_b(s,r,u)))}function Ab(t,r,s){var u=yn();pi(t,r,s,u)}function pi(t,r,s,u){var g={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(lc(t))Mb(r,g);else{var b=t.alternate;if(t.lanes===0&&(b===null||b.lanes===0)&&(b=r.lastRenderedReducer,b!==null))try{var w=r.lastRenderedState,A=b(w,s);if(g.hasEagerState=!0,g.eagerState=A,mn(A,w))return Hl(t,r,g,0),ot===null&&Ul(),!1}catch{}finally{}if(s=of(t,r,g,u),s!==null)return cn(s,t,u),_b(s,r,u),!0}return!1}function Vf(t,r,s,u){if(u={lane:2,revertLane:Sm(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},lc(t)){if(r)throw Error(o(479))}else r=of(t,s,u,2),r!==null&&cn(r,t,2)}function lc(t){var r=t.alternate;return t===_e||r!==null&&r===_e}function Mb(t,r){Fo=tc=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function _b(t,r,s){if((s&4194048)!==0){var u=r.lanes;u&=t.pendingLanes,s|=u,r.lanes=s,en(t,s)}}var hi={readContext:It,use:ac,useCallback:gt,useContext:gt,useEffect:gt,useImperativeHandle:gt,useLayoutEffect:gt,useInsertionEffect:gt,useMemo:gt,useReducer:gt,useRef:gt,useState:gt,useDebugValue:gt,useDeferredValue:gt,useTransition:gt,useSyncExternalStore:gt,useId:gt,useHostTransitionStatus:gt,useFormState:gt,useActionState:gt,useOptimistic:gt,useMemoCache:gt,useCacheRefresh:gt};hi.useEffectEvent=gt;var Ob={readContext:It,use:ac,useCallback:function(t,r){return Xt().memoizedState=[t,r===void 0?null:r],t},useContext:It,useEffect:gb,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,sc(4194308,4,xb.bind(null,r,t),s)},useLayoutEffect:function(t,r){return sc(4194308,4,t,r)},useInsertionEffect:function(t,r){sc(4,2,t,r)},useMemo:function(t,r){var s=Xt();r=r===void 0?null:r;var u=t();if(qa){Un(!0);try{t()}finally{Un(!1)}}return s.memoizedState=[u,r],u},useReducer:function(t,r,s){var u=Xt();if(s!==void 0){var g=s(r);if(qa){Un(!0);try{s(r)}finally{Un(!1)}}}else g=r;return u.memoizedState=u.baseState=g,t={pending:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:g},u.queue=t,t=t.dispatch=rN.bind(null,_e,t),[u.memoizedState,t]},useRef:function(t){var r=Xt();return t={current:t},r.memoizedState=t},useState:function(t){t=zf(t);var r=t.queue,s=Ab.bind(null,_e,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:$f,useDeferredValue:function(t,r){var s=Xt();return Bf(s,t,r)},useTransition:function(){var t=zf(!1);return t=Eb.bind(null,_e,t.queue,!0,!1),Xt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var u=_e,g=Xt();if(He){if(s===void 0)throw Error(o(407));s=s()}else{if(s=r(),ot===null)throw Error(o(349));($e&127)!==0||eb(u,r,s)}g.memoizedState=s;var b={value:s,getSnapshot:r};return g.queue=b,gb(nb.bind(null,u,b,t),[t]),u.flags|=2048,Wo(9,{destroy:void 0},tb.bind(null,u,b,s,r),null),s},useId:function(){var t=Xt(),r=ot.identifierPrefix;if(He){var s=tr,u=er;s=(u&~(1<<32-Vt(u)-1)).toString(32)+s,r="_"+r+"R_"+s,s=nc++,0<\/script>",b=b.removeChild(b.firstChild);break;case"select":b=typeof u.is=="string"?w.createElement("select",{is:u.is}):w.createElement("select"),u.multiple?b.multiple=!0:u.size&&(b.size=u.size);break;default:b=typeof u.is=="string"?w.createElement(g,{is:u.is}):w.createElement(g)}}b[zt]=r,b[nn]=u;e:for(w=r.child;w!==null;){if(w.tag===5||w.tag===6)b.appendChild(w.stateNode);else if(w.tag!==4&&w.tag!==27&&w.child!==null){w.child.return=w,w=w.child;continue}if(w===r)break e;for(;w.sibling===null;){if(w.return===null||w.return===r)break e;w=w.return}w.sibling.return=w.return,w=w.sibling}r.stateNode=b;e:switch(Bt(b,g,u),g){case"button":case"input":case"select":case"textarea":u=!!u.autoFocus;break e;case"img":u=!0;break e;default:u=!1}u&&jr(r)}}return lt(r),rm(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==u&&jr(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(o(166));if(t=ae.current,Io(r)){if(t=r.stateNode,s=r.memoizedProps,u=null,g=Pt,g!==null)switch(g.tag){case 27:case 5:u=g.memoizedProps}t[zt]=r,t=!!(t.nodeValue===s||u!==null&&u.suppressHydrationWarning===!0||Qy(t.nodeValue,s)),t||Xr(r,!0)}else t=Tc(t).createTextNode(u),t[zt]=r,r.stateNode=t}return lt(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(u=Io(r),s!==null){if(t===null){if(!u)throw Error(o(318));if(t=r.memoizedState,t=t!==null?t.dehydrated:null,!t)throw Error(o(557));t[zt]=r}else Ua(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;lt(r),t=!1}else s=mf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(gn(r),r):(gn(r),null);if((r.flags&128)!==0)throw Error(o(558))}return lt(r),null;case 13:if(u=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(g=Io(r),u!==null&&u.dehydrated!==null){if(t===null){if(!g)throw Error(o(318));if(g=r.memoizedState,g=g!==null?g.dehydrated:null,!g)throw Error(o(317));g[zt]=r}else Ua(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;lt(r),g=!1}else g=mf(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=g),g=!0;if(!g)return r.flags&256?(gn(r),r):(gn(r),null)}return gn(r),(r.flags&128)!==0?(r.lanes=s,r):(s=u!==null,t=t!==null&&t.memoizedState!==null,s&&(u=r.child,g=null,u.alternate!==null&&u.alternate.memoizedState!==null&&u.alternate.memoizedState.cachePool!==null&&(g=u.alternate.memoizedState.cachePool.pool),b=null,u.memoizedState!==null&&u.memoizedState.cachePool!==null&&(b=u.memoizedState.cachePool.pool),b!==g&&(u.flags|=2048)),s!==t&&s&&(r.child.flags|=8192),mc(r,r.updateQueue),lt(r),null);case 4:return pe(),t===null&&Em(r.stateNode.containerInfo),lt(r),null;case 10:return xr(r.type),lt(r),null;case 19:if(_(bt),u=r.memoizedState,u===null)return lt(r),null;if(g=(r.flags&128)!==0,b=u.rendering,b===null)if(g)vi(u,!1);else{if(vt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(b=ec(t),b!==null){for(r.flags|=128,vi(u,!1),t=b.updateQueue,r.updateQueue=t,mc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)Av(s,t),s=s.sibling;return U(bt,bt.current&1|2),He&&br(r,u.treeForkCount),r.child}t=t.sibling}u.tail!==null&&qt()>bc&&(r.flags|=128,g=!0,vi(u,!1),r.lanes=4194304)}else{if(!g)if(t=ec(b),t!==null){if(r.flags|=128,g=!0,t=t.updateQueue,r.updateQueue=t,mc(r,t),vi(u,!0),u.tail===null&&u.tailMode==="hidden"&&!b.alternate&&!He)return lt(r),null}else 2*qt()-u.renderingStartTime>bc&&s!==536870912&&(r.flags|=128,g=!0,vi(u,!1),r.lanes=4194304);u.isBackwards?(b.sibling=r.child,r.child=b):(t=u.last,t!==null?t.sibling=b:r.child=b,u.last=b)}return u.tail!==null?(t=u.tail,u.rendering=t,u.tail=t.sibling,u.renderingStartTime=qt(),t.sibling=null,s=bt.current,U(bt,g?s&1|2:s&1),He&&br(r,u.treeForkCount),t):(lt(r),null);case 22:case 23:return gn(r),Nf(),u=r.memoizedState!==null,t!==null?t.memoizedState!==null!==u&&(r.flags|=8192):u&&(r.flags|=8192),u?(s&536870912)!==0&&(r.flags&128)===0&&(lt(r),r.subtreeFlags&6&&(r.flags|=8192)):lt(r),s=r.updateQueue,s!==null&&mc(r,s.retryQueue),s=null,t!==null&&t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(s=t.memoizedState.cachePool.pool),u=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(u=r.memoizedState.cachePool.pool),u!==s&&(r.flags|=2048),t!==null&&_(Ga),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),xr(xt),lt(r),null;case 25:return null;case 30:return null}throw Error(o(156,r.tag))}function lN(t,r){switch(df(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return xr(xt),pe(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return ie(r),null;case 31:if(r.memoizedState!==null){if(gn(r),r.alternate===null)throw Error(o(340));Ua()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(gn(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(o(340));Ua()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return _(bt),null;case 4:return pe(),null;case 10:return xr(r.type),null;case 22:case 23:return gn(r),Nf(),t!==null&&_(Ga),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return xr(xt),null;case 25:return null;default:return null}}function ry(t,r){switch(df(r),r.tag){case 3:xr(xt),pe();break;case 26:case 27:case 5:ie(r);break;case 4:pe();break;case 31:r.memoizedState!==null&&gn(r);break;case 13:gn(r);break;case 19:_(bt);break;case 10:xr(r.type);break;case 22:case 23:gn(r),Nf(),t!==null&&_(Ga);break;case 24:xr(xt)}}function bi(t,r){try{var s=r.updateQueue,u=s!==null?s.lastEffect:null;if(u!==null){var g=u.next;s=g;do{if((s.tag&t)===t){u=void 0;var b=s.create,w=s.inst;u=b(),w.destroy=u}s=s.next}while(s!==g)}}catch(A){et(r,r.return,A)}}function ra(t,r,s){try{var u=r.updateQueue,g=u!==null?u.lastEffect:null;if(g!==null){var b=g.next;u=b;do{if((u.tag&t)===t){var w=u.inst,A=w.destroy;if(A!==void 0){w.destroy=void 0,g=r;var L=s,K=A;try{K()}catch(re){et(g,L,re)}}}u=u.next}while(u!==b)}}catch(re){et(r,r.return,re)}}function ay(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{qv(r,s)}catch(u){et(t,t.return,u)}}}function oy(t,r,s){s.props=Ka(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(u){et(t,r,u)}}function yi(t,r){try{var s=t.ref;if(s!==null){switch(t.tag){case 26:case 27:case 5:var u=t.stateNode;break;case 30:u=t.stateNode;break;default:u=t.stateNode}typeof s=="function"?t.refCleanup=s(u):s.current=u}}catch(g){et(t,r,g)}}function nr(t,r){var s=t.ref,u=t.refCleanup;if(s!==null)if(typeof u=="function")try{u()}catch(g){et(t,r,g)}finally{t.refCleanup=null,t=t.alternate,t!=null&&(t.refCleanup=null)}else if(typeof s=="function")try{s(null)}catch(g){et(t,r,g)}else s.current=null}function sy(t){var r=t.type,s=t.memoizedProps,u=t.stateNode;try{e:switch(r){case"button":case"input":case"select":case"textarea":s.autoFocus&&u.focus();break e;case"img":s.src?u.src=s.src:s.srcSet&&(u.srcset=s.srcSet)}}catch(g){et(t,t.return,g)}}function am(t,r,s){try{var u=t.stateNode;AN(u,t.type,s,r),u[nn]=r}catch(g){et(t,t.return,g)}}function iy(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&ua(t.type)||t.tag===4}function om(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||iy(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.tag===27&&ua(t.type)||t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function sm(t,r,s){var u=t.tag;if(u===5||u===6)t=t.stateNode,r?(s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s).insertBefore(t,r):(r=s.nodeType===9?s.body:s.nodeName==="HTML"?s.ownerDocument.body:s,r.appendChild(t),s=s._reactRootContainer,s!=null||r.onclick!==null||(r.onclick=hr));else if(u!==4&&(u===27&&ua(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(sm(t,r,s),t=t.sibling;t!==null;)sm(t,r,s),t=t.sibling}function pc(t,r,s){var u=t.tag;if(u===5||u===6)t=t.stateNode,r?s.insertBefore(t,r):s.appendChild(t);else if(u!==4&&(u===27&&ua(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(pc(t,r,s),t=t.sibling;t!==null;)pc(t,r,s),t=t.sibling}function ly(t){var r=t.stateNode,s=t.memoizedProps;try{for(var u=t.type,g=r.attributes;g.length;)r.removeAttributeNode(g[0]);Bt(r,u,s),r[zt]=t,r[nn]=s}catch(b){et(t,t.return,b)}}var Er=!1,Ct=!1,im=!1,cy=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function cN(t,r){if(t=t.containerInfo,Tm=Lc,t=Sv(t),Jd(t)){if("selectionStart"in t)var s={start:t.selectionStart,end:t.selectionEnd};else e:{s=(s=t.ownerDocument)&&s.defaultView||window;var u=s.getSelection&&s.getSelection();if(u&&u.rangeCount!==0){s=u.anchorNode;var g=u.anchorOffset,b=u.focusNode;u=u.focusOffset;try{s.nodeType,b.nodeType}catch{s=null;break e}var w=0,A=-1,L=-1,K=0,re=0,le=t,X=null;t:for(;;){for(var ee;le!==s||g!==0&&le.nodeType!==3||(A=w+g),le!==b||u!==0&&le.nodeType!==3||(L=w+u),le.nodeType===3&&(w+=le.nodeValue.length),(ee=le.firstChild)!==null;)X=le,le=ee;for(;;){if(le===t)break t;if(X===s&&++K===g&&(A=w),X===b&&++re===u&&(L=w),(ee=le.nextSibling)!==null)break;le=X,X=le.parentNode}le=ee}s=A===-1||L===-1?null:{start:A,end:L}}else s=null}s=s||{start:0,end:0}}else s=null;for(Rm={focusedElem:t,selectionRange:s},Lc=!1,Mt=r;Mt!==null;)if(r=Mt,t=r.child,(r.subtreeFlags&1028)!==0&&t!==null)t.return=r,Mt=t;else for(;Mt!==null;){switch(r=Mt,b=r.alternate,t=r.flags,r.tag){case 0:if((t&4)!==0&&(t=r.updateQueue,t=t!==null?t.events:null,t!==null))for(s=0;s title"))),Bt(b,u,s),b[zt]=t,At(b),u=b;break e;case"link":var w=hx("link","href",g).get(u+(s.href||""));if(w){for(var A=0;Aat&&(w=at,at=ke,ke=w);var G=yv(A,ke),I=yv(A,at);if(G&&I&&(ee.rangeCount!==1||ee.anchorNode!==G.node||ee.anchorOffset!==G.offset||ee.focusNode!==I.node||ee.focusOffset!==I.offset)){var q=le.createRange();q.setStart(G.node,G.offset),ee.removeAllRanges(),ke>at?(ee.addRange(q),ee.extend(I.node,I.offset)):(q.setEnd(I.node,I.offset),ee.addRange(q))}}}}for(le=[],ee=A;ee=ee.parentNode;)ee.nodeType===1&&le.push({element:ee,left:ee.scrollLeft,top:ee.scrollTop});for(typeof A.focus=="function"&&A.focus(),A=0;As?32:s,O.T=null,s=pm,pm=null;var b=ia,w=Ar;if(Et=0,Qo=ia=null,Ar=0,(Xe&6)!==0)throw Error(o(331));var A=Xe;if(Xe|=4,xy(b.current),vy(b,b.current,w,s),Xe=A,Ei(0,!1),Kt&&typeof Kt.onPostCommitFiberRoot=="function")try{Kt.onPostCommitFiberRoot(_a,b)}catch{}return!0}finally{$.p=g,O.T=u,Iy(t,r)}}function By(t,r,s){r=An(s,r),r=Wf(t.stateNode,r,2),t=ea(t,r,2),t!==null&&(mt(t,2),rr(t))}function et(t,r,s){if(t.tag===3)By(t,t,s);else for(;r!==null;){if(r.tag===3){By(r,t,s);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(sa===null||!sa.has(u))){t=An(s,t),s=Ub(2),u=ea(r,s,2),u!==null&&(Hb(s,u,r,t),mt(u,2),rr(u));break}}r=r.return}}function bm(t,r,s){var u=t.pingCache;if(u===null){u=t.pingCache=new fN;var g=new Set;u.set(r,g)}else g=u.get(r),g===void 0&&(g=new Set,u.set(r,g));g.has(s)||(um=!0,g.add(s),t=vN.bind(null,t,r,s),r.then(t,t))}function vN(t,r,s){var u=t.pingCache;u!==null&&u.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,ot===t&&($e&s)===s&&(vt===4||vt===3&&($e&62914560)===$e&&300>qt()-vc?(Xe&2)===0&&Jo(t,0):dm|=s,Zo===$e&&(Zo=0)),rr(t)}function Uy(t,r){r===0&&(r=Gt()),t=$a(t,r),t!==null&&(mt(t,r),rr(t))}function bN(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),Uy(t,s)}function yN(t,r){var s=0;switch(t.tag){case 31:case 13:var u=t.stateNode,g=t.memoizedState;g!==null&&(s=g.retryLane);break;case 19:u=t.stateNode;break;case 22:u=t.stateNode._retryCache;break;default:throw Error(o(314))}u!==null&&u.delete(r),Uy(t,s)}function xN(t,r){return Hs(t,r)}var jc=null,ts=null,ym=!1,Ec=!1,xm=!1,ca=0;function rr(t){t!==ts&&t.next===null&&(ts===null?jc=ts=t:ts=ts.next=t),Ec=!0,ym||(ym=!0,wN())}function Ei(t,r){if(!xm&&Ec){xm=!0;do for(var s=!1,u=jc;u!==null;){if(t!==0){var g=u.pendingLanes;if(g===0)var b=0;else{var w=u.suspendedLanes,A=u.pingedLanes;b=(1<<31-Vt(42|t)+1)-1,b&=g&~(w&~A),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(s=!0,Fy(u,b))}else b=$e,b=Re(u,u===ot?b:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(b&3)===0||ut(u,b)||(s=!0,Fy(u,b));u=u.next}while(s);xm=!1}}function SN(){Hy()}function Hy(){Ec=ym=!1;var t=0;ca!==0&&_N()&&(t=ca);for(var r=qt(),s=null,u=jc;u!==null;){var g=u.next,b=Vy(u,r);b===0?(u.next=null,s===null?jc=g:s.next=g,g===null&&(ts=s)):(s=u,(t!==0||(b&3)!==0)&&(Ec=!0)),u=g}Et!==0&&Et!==5||Ei(t),ca!==0&&(ca=0)}function Vy(t,r){for(var s=t.suspendedLanes,u=t.pingedLanes,g=t.expirationTimes,b=t.pendingLanes&-62914561;0A)break;var re=L.transferSize,le=L.initiatorType;re&&Jy(le)&&(L=L.responseEnd,w+=re*(L"u"?null:document;function dx(t,r,s){var u=ns;if(u&&typeof r=="string"&&r){var g=Tn(r);g='link[rel="'+t+'"][href="'+g+'"]',typeof s=="string"&&(g+='[crossorigin="'+s+'"]'),ux.has(g)||(ux.add(g),t={rel:t,crossOrigin:s,href:r},u.querySelector(g)===null&&(r=u.createElement("link"),Bt(r,"link",t),At(r),u.head.appendChild(r)))}}function UN(t){Mr.D(t),dx("dns-prefetch",t,null)}function HN(t,r){Mr.C(t,r),dx("preconnect",t,r)}function VN(t,r,s){Mr.L(t,r,s);var u=ns;if(u&&t&&r){var g='link[rel="preload"][as="'+Tn(r)+'"]';r==="image"&&s&&s.imageSrcSet?(g+='[imagesrcset="'+Tn(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(g+='[imagesizes="'+Tn(s.imageSizes)+'"]')):g+='[href="'+Tn(t)+'"]';var b=g;switch(r){case"style":b=rs(t);break;case"script":b=as(t)}zn.has(b)||(t=v({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),zn.set(b,t),u.querySelector(g)!==null||r==="style"&&u.querySelector(Ri(b))||r==="script"&&u.querySelector(Ai(b))||(r=u.createElement("link"),Bt(r,"link",t),At(r),u.head.appendChild(r)))}}function GN(t,r){Mr.m(t,r);var s=ns;if(s&&t){var u=r&&typeof r.as=="string"?r.as:"script",g='link[rel="modulepreload"][as="'+Tn(u)+'"][href="'+Tn(t)+'"]',b=g;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=as(t)}if(!zn.has(b)&&(t=v({rel:"modulepreload",href:t},r),zn.set(b,t),s.querySelector(g)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Ai(b)))return}u=s.createElement("link"),Bt(u,"link",t),At(u),s.head.appendChild(u)}}}function FN(t,r,s){Mr.S(t,r,s);var u=ns;if(u&&t){var g=Eo(u).hoistableStyles,b=rs(t);r=r||"default";var w=g.get(b);if(!w){var A={loading:0,preload:null};if(w=u.querySelector(Ri(b)))A.loading=5;else{t=v({rel:"stylesheet",href:t,"data-precedence":r},s),(s=zn.get(b))&&zm(t,s);var L=w=u.createElement("link");At(L),Bt(L,"link",t),L._p=new Promise(function(K,re){L.onload=K,L.onerror=re}),L.addEventListener("load",function(){A.loading|=1}),L.addEventListener("error",function(){A.loading|=2}),A.loading|=4,Ac(w,r,u)}w={type:"stylesheet",instance:w,count:1,state:A},g.set(b,w)}}}function YN(t,r){Mr.X(t,r);var s=ns;if(s&&t){var u=Eo(s).hoistableScripts,g=as(t),b=u.get(g);b||(b=s.querySelector(Ai(g)),b||(t=v({src:t,async:!0},r),(r=zn.get(g))&&Pm(t,r),b=s.createElement("script"),At(b),Bt(b,"link",t),s.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},u.set(g,b))}}function WN(t,r){Mr.M(t,r);var s=ns;if(s&&t){var u=Eo(s).hoistableScripts,g=as(t),b=u.get(g);b||(b=s.querySelector(Ai(g)),b||(t=v({src:t,async:!0,type:"module"},r),(r=zn.get(g))&&Pm(t,r),b=s.createElement("script"),At(b),Bt(b,"link",t),s.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},u.set(g,b))}}function fx(t,r,s,u){var g=(g=ae.current)?Rc(g):null;if(!g)throw Error(o(446));switch(t){case"meta":case"title":return null;case"style":return typeof s.precedence=="string"&&typeof s.href=="string"?(r=rs(s.href),s=Eo(g).hoistableStyles,u=s.get(r),u||(u={type:"style",instance:null,count:0,state:null},s.set(r,u)),u):{type:"void",instance:null,count:0,state:null};case"link":if(s.rel==="stylesheet"&&typeof s.href=="string"&&typeof s.precedence=="string"){t=rs(s.href);var b=Eo(g).hoistableStyles,w=b.get(t);if(w||(g=g.ownerDocument||g,w={type:"stylesheet",instance:null,count:0,state:{loading:0,preload:null}},b.set(t,w),(b=g.querySelector(Ri(t)))&&!b._p&&(w.instance=b,w.state.loading=5),zn.has(t)||(s={rel:"preload",as:"style",href:s.href,crossOrigin:s.crossOrigin,integrity:s.integrity,media:s.media,hrefLang:s.hrefLang,referrerPolicy:s.referrerPolicy},zn.set(t,s),b||qN(g,t,s,w.state))),r&&u===null)throw Error(o(528,""));return w}if(r&&u!==null)throw Error(o(529,""));return null;case"script":return r=s.async,s=s.src,typeof s=="string"&&r&&typeof r!="function"&&typeof r!="symbol"?(r=as(s),s=Eo(g).hoistableScripts,u=s.get(r),u||(u={type:"script",instance:null,count:0,state:null},s.set(r,u)),u):{type:"void",instance:null,count:0,state:null};default:throw Error(o(444,t))}}function rs(t){return'href="'+Tn(t)+'"'}function Ri(t){return'link[rel="stylesheet"]['+t+"]"}function mx(t){return v({},t,{"data-precedence":t.precedence,precedence:null})}function qN(t,r,s,u){t.querySelector('link[rel="preload"][as="style"]['+r+"]")?u.loading=1:(r=t.createElement("link"),u.preload=r,r.addEventListener("load",function(){return u.loading|=1}),r.addEventListener("error",function(){return u.loading|=2}),Bt(r,"link",s),At(r),t.head.appendChild(r))}function as(t){return'[src="'+Tn(t)+'"]'}function Ai(t){return"script[async]"+t}function px(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var u=t.querySelector('style[data-href~="'+Tn(s.href)+'"]');if(u)return r.instance=u,At(u),u;var g=v({},s,{"data-href":s.href,"data-precedence":s.precedence,href:null,precedence:null});return u=(t.ownerDocument||t).createElement("style"),At(u),Bt(u,"style",g),Ac(u,s.precedence,t),r.instance=u;case"stylesheet":g=rs(s.href);var b=t.querySelector(Ri(g));if(b)return r.state.loading|=4,r.instance=b,At(b),b;u=mx(s),(g=zn.get(g))&&zm(u,g),b=(t.ownerDocument||t).createElement("link"),At(b);var w=b;return w._p=new Promise(function(A,L){w.onload=A,w.onerror=L}),Bt(b,"link",u),r.state.loading|=4,Ac(b,s.precedence,t),r.instance=b;case"script":return b=as(s.src),(g=t.querySelector(Ai(b)))?(r.instance=g,At(g),g):(u=s,(g=zn.get(b))&&(u=v({},s),Pm(u,g)),t=t.ownerDocument||t,g=t.createElement("script"),At(g),Bt(g,"link",u),t.head.appendChild(g),r.instance=g);case"void":return null;default:throw Error(o(443,r.type))}else r.type==="stylesheet"&&(r.state.loading&4)===0&&(u=r.instance,r.state.loading|=4,Ac(u,s.precedence,t));return r.instance}function Ac(t,r,s){for(var u=s.querySelectorAll('link[rel="stylesheet"][data-precedence],style[data-precedence]'),g=u.length?u[u.length-1]:null,b=g,w=0;w title"):null)}function KN(t,r,s){if(s===1||r.itemProp!=null)return!1;switch(t){case"meta":case"title":return!0;case"style":if(typeof r.precedence!="string"||typeof r.href!="string"||r.href==="")break;return!0;case"link":if(typeof r.rel!="string"||typeof r.href!="string"||r.href===""||r.onLoad||r.onError)break;switch(r.rel){case"stylesheet":return t=r.disabled,typeof r.precedence=="string"&&t==null;default:return!0}case"script":if(r.async&&typeof r.async!="function"&&typeof r.async!="symbol"&&!r.onLoad&&!r.onError&&r.src&&typeof r.src=="string")return!0}return!1}function vx(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function XN(t,r,s,u){if(s.type==="stylesheet"&&(typeof u.media!="string"||matchMedia(u.media).matches!==!1)&&(s.state.loading&4)===0){if(s.instance===null){var g=rs(u.href),b=r.querySelector(Ri(g));if(b){r=b._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=_c.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=b,At(b);return}b=r.ownerDocument||r,u=mx(u),(g=zn.get(g))&&zm(u,g),b=b.createElement("link"),At(b);var w=b;w._p=new Promise(function(A,L){w.onload=A,w.onerror=L}),Bt(b,"link",u),s.instance=b}t.stylesheets===null&&(t.stylesheets=new Map),t.stylesheets.set(s,r),(r=s.state.preload)&&(s.state.loading&3)===0&&(t.count++,s=_c.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var Im=0;function ZN(t,r){return t.stylesheets&&t.count===0&&Dc(t,t.stylesheets),0Im?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(g)}}:null}function _c(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Dc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Oc=null;function Dc(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Oc=new Map,r.forEach(QN,t),Oc=null,_c.call(t))}function QN(t,r){if(!(r.state.loading&4)){var s=Oc.get(t);if(s)var u=s.get(null);else{s=new Map,Oc.set(t,s);for(var g=t.querySelectorAll("link[data-precedence],style[data-precedence]"),b=0;b"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Wm.exports=g3(),Wm.exports}var b3=v3();/** * react-router v7.15.1 * * Copyright (c) Remix Software Inc. * * This source code is licensed under the MIT license found in the * LICENSE.md file in the root directory of this source tree. * * @license MIT */var Hx="popstate";function Vx(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function y3(e={}){function n(o,i){var h;let c=(h=i.state)==null?void 0:h.masked,{pathname:d,search:m,hash:p}=c||o.location;return Op("",{pathname:d,search:m,hash:p},i.state&&i.state.usr||null,i.state&&i.state.key||"default",c?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,i){return typeof i=="string"?i:Xi(i)}return S3(n,a,null,e)}function ft(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function $n(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function x3(){return Math.random().toString(36).substring(2,10)}function Gx(e,n){return{usr:e.state,key:e.key,idx:n,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Op(e,n,a=null,o,i){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof n=="string"?Rs(n):n,state:a,key:n&&n.key||o||x3(),mask:i}}function Xi({pathname:e="/",search:n="",hash:a=""}){return n&&n!=="?"&&(e+=n.charAt(0)==="?"?n:"?"+n),a&&a!=="#"&&(e+=a.charAt(0)==="#"?a:"#"+a),e}function Rs(e){let n={};if(e){let a=e.indexOf("#");a>=0&&(n.hash=e.substring(a),e=e.substring(0,a));let o=e.indexOf("?");o>=0&&(n.search=e.substring(o),e=e.substring(0,o)),e&&(n.pathname=e)}return n}function S3(e,n,a,o={}){let{window:i=document.defaultView,v5Compat:c=!1}=o,d=i.history,m="POP",p=null,h=y();h==null&&(h=0,d.replaceState({...d.state,idx:h},""));function y(){return(d.state||{idx:null}).idx}function v(){m="POP";let N=y(),E=N==null?null:N-h;h=N,p&&p({action:m,location:C.location,delta:E})}function x(N,E){m="PUSH";let k=Vx(N)?N:Op(C.location,N,E);h=y()+1;let T=Gx(k,h),R=C.createHref(k.mask||k);try{d.pushState(T,"",R)}catch(D){if(D instanceof DOMException&&D.name==="DataCloneError")throw D;i.location.assign(R)}c&&p&&p({action:m,location:C.location,delta:1})}function S(N,E){m="REPLACE";let k=Vx(N)?N:Op(C.location,N,E);h=y();let T=Gx(k,h),R=C.createHref(k.mask||k);d.replaceState(T,"",R),c&&p&&p({action:m,location:C.location,delta:0})}function j(N){return w3(N)}let C={get action(){return m},get location(){return e(i,d)},listen(N){if(p)throw new Error("A history only accepts one active listener");return i.addEventListener(Hx,v),p=N,()=>{i.removeEventListener(Hx,v),p=null}},createHref(N){return n(i,N)},createURL:j,encodeLocation(N){let E=j(N);return{pathname:E.pathname,search:E.search,hash:E.hash}},push:x,replace:S,go(N){return d.go(N)}};return C}function w3(e,n=!1){let a="http://localhost";typeof window<"u"&&(a=window.location.origin!=="null"?window.location.origin:window.location.href),ft(a,"No window.location.(origin|href) available to create URL");let o=typeof e=="string"?e:Xi(e);return o=o.replace(/ $/,"%20"),!n&&o.startsWith("//")&&(o=a+o),new URL(o,a)}function j0(e,n,a="/"){return C3(e,n,a,!1)}function C3(e,n,a,o,i){let c=typeof n=="string"?Rs(n):n,d=zr(c.pathname||"/",a);if(d==null)return null;let m=j3(e),p=null,h=z3(d);for(let y=0;p==null&&y{let y={relativePath:h===void 0?d.path||"":h,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&p)return;ft(y.relativePath.startsWith(o),`Absolute route path "${y.relativePath}" nested under path "${o}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),y.relativePath=y.relativePath.slice(o.length)}let v=Wn([o,y.relativePath]),x=a.concat(y);d.children&&d.children.length>0&&(ft(d.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${v}".`),E0(d.children,n,x,v,p)),!(d.path==null&&!d.index)&&n.push({path:v,score:_3(v,d.index),routesMeta:x})};return e.forEach((d,m)=>{var p;if(d.path===""||!((p=d.path)!=null&&p.includes("?")))c(d,m);else for(let h of N0(d.path))c(d,m,!0,h)}),n}function N0(e){let n=e.split("/");if(n.length===0)return[];let[a,...o]=n,i=a.endsWith("?"),c=a.replace(/\?$/,"");if(o.length===0)return i?[c,""]:[c];let d=N0(o.join("/")),m=[];return m.push(...d.map(p=>p===""?c:[c,p].join("/"))),i&&m.push(...d),m.map(p=>e.startsWith("/")&&p===""?"/":p)}function E3(e){e.sort((n,a)=>n.score!==a.score?a.score-n.score:O3(n.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var N3=/^:[\w-]+$/,k3=3,T3=2,R3=1,A3=10,M3=-2,Fx=e=>e==="*";function _3(e,n){let a=e.split("/"),o=a.length;return a.some(Fx)&&(o+=M3),n&&(o+=T3),a.filter(i=>!Fx(i)).reduce((i,c)=>i+(N3.test(c)?k3:c===""?R3:A3),o)}function O3(e,n){return e.length===n.length&&e.slice(0,-1).every((o,i)=>o===n[i])?e[e.length-1]-n[n.length-1]:0}function D3(e,n,a=!1){let{routesMeta:o}=e,i={},c="/",d=[];for(let m=0;m{if(y==="*"){let j=m[x]||"";d=c.slice(0,c.length-j.length).replace(/(.)\/+$/,"$1")}const S=m[x];return v&&!S?h[y]=void 0:h[y]=(S||"").replace(/%2F/g,"/"),h},{}),pathname:c,pathnameBase:d,pattern:e}}function L3(e,n=!1,a=!0){$n(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let o=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,p,h,y)=>{if(o.push({paramName:m,isOptional:p!=null}),p){let v=y.charAt(h+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,n?void 0:"i"),o]}function z3(e){try{return e.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return $n(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${n}).`),e}}function zr(e,n){if(n==="/")return e;if(!e.toLowerCase().startsWith(n.toLowerCase()))return null;let a=n.endsWith("/")?n.length-1:n.length,o=e.charAt(a);return o&&o!=="/"?null:e.slice(a)||"/"}var P3=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function I3(e,n="/"){let{pathname:a,search:o="",hash:i=""}=typeof e=="string"?Rs(e):e,c;return a?(a=k0(a),a.startsWith("/")?c=Yx(a.substring(1),"/"):c=Yx(a,n)):c=n,{pathname:c,search:U3(o),hash:H3(i)}}function Yx(e,n){let a=hu(n).split("/");return e.split("/").forEach(i=>{i===".."?a.length>1&&a.pop():i!=="."&&a.push(i)}),a.length>1?a.join("/"):"/"}function Zm(e,n,a,o){return`Cannot include a '${e}' character in a manually specified \`to.${n}\` field [${JSON.stringify(o)}]. Please separate it out to the \`to.${a}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function $3(e){return e.filter((n,a)=>a===0||n.route.path&&n.route.path.length>0)}function Ch(e){let n=$3(e);return n.map((a,o)=>o===n.length-1?a.pathname:a.pathnameBase)}function zu(e,n,a,o=!1){let i;typeof e=="string"?i=Rs(e):(i={...e},ft(!i.pathname||!i.pathname.includes("?"),Zm("?","pathname","search",i)),ft(!i.pathname||!i.pathname.includes("#"),Zm("#","pathname","hash",i)),ft(!i.search||!i.search.includes("#"),Zm("#","search","hash",i)));let c=e===""||i.pathname==="",d=c?"/":i.pathname,m;if(d==null)m=a;else{let v=n.length-1;if(!o&&d.startsWith("..")){let x=d.split("/");for(;x[0]==="..";)x.shift(),v-=1;i.pathname=x.join("/")}m=v>=0?n[v]:"/"}let p=I3(i,m),h=d&&d!=="/"&&d.endsWith("/"),y=(c||d===".")&&a.endsWith("/");return!p.pathname.endsWith("/")&&(h||y)&&(p.pathname+="/"),p}var k0=e=>e.replace(/\/\/+/g,"/"),Wn=e=>k0(e.join("/")),hu=e=>e.replace(/\/+$/,""),B3=e=>hu(e).replace(/^\/*/,"/"),U3=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,H3=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,V3=class{constructor(e,n,a,o=!1){this.status=e,this.statusText=n||"",this.internal=o,a instanceof Error?(this.data=a.toString(),this.error=a):this.data=a}};function G3(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function F3(e){let n=e.map(a=>a.route.path).filter(Boolean);return Wn(n)||"/"}var T0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function R0(e,n){let a=e;if(typeof a!="string"||!P3.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,i=!1;if(T0)try{let c=new URL(window.location.href),d=a.startsWith("//")?new URL(c.protocol+a):new URL(a),m=zr(d.pathname,n);d.origin===c.origin&&m!=null?a=m+d.search+d.hash:i=!0}catch{$n(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:i,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var A0=["POST","PUT","PATCH","DELETE"];new Set(A0);var Y3=["GET",...A0];new Set(Y3);var As=f.createContext(null);As.displayName="DataRouter";var Pu=f.createContext(null);Pu.displayName="DataRouterState";var M0=f.createContext(!1);function W3(){return f.useContext(M0)}var _0=f.createContext({isTransitioning:!1});_0.displayName="ViewTransition";var q3=f.createContext(new Map);q3.displayName="Fetchers";var K3=f.createContext(null);K3.displayName="Await";var Cn=f.createContext(null);Cn.displayName="Navigation";var cl=f.createContext(null);cl.displayName="Location";var Xn=f.createContext({outlet:null,matches:[],isDataRoute:!1});Xn.displayName="Route";var jh=f.createContext(null);jh.displayName="RouteError";var O0="REACT_ROUTER_ERROR",X3="REDIRECT",Z3="ROUTE_ERROR_RESPONSE";function Q3(e){if(e.startsWith(`${O0}:${X3}:{`))try{let n=JSON.parse(e.slice(28));if(typeof n=="object"&&n&&typeof n.status=="number"&&typeof n.statusText=="string"&&typeof n.location=="string"&&typeof n.reloadDocument=="boolean"&&typeof n.replace=="boolean")return n}catch{}}function J3(e){if(e.startsWith(`${O0}:${Z3}:{`))try{let n=JSON.parse(e.slice(40));if(typeof n=="object"&&n&&typeof n.status=="number"&&typeof n.statusText=="string")return new V3(n.status,n.statusText,n.data)}catch{}}function e4(e,{relative:n}={}){ft(Ms(),"useHref() may be used only in the context of a component.");let{basename:a,navigator:o}=f.useContext(Cn),{hash:i,pathname:c,search:d}=ul(e,{relative:n}),m=c;return a!=="/"&&(m=c==="/"?a:Wn([a,c])),o.createHref({pathname:m,search:d,hash:i})}function Ms(){return f.useContext(cl)!=null}function jn(){return ft(Ms(),"useLocation() may be used only in the context of a component."),f.useContext(cl).location}var D0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function L0(e){f.useContext(Cn).static||f.useLayoutEffect(e)}function mo(){let{isDataRoute:e}=f.useContext(Xn);return e?h4():t4()}function t4(){ft(Ms(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(As),{basename:n,navigator:a}=f.useContext(Cn),{matches:o}=f.useContext(Xn),{pathname:i}=jn(),c=JSON.stringify(Ch(o)),d=f.useRef(!1);return L0(()=>{d.current=!0}),f.useCallback((p,h={})=>{if($n(d.current,D0),!d.current)return;if(typeof p=="number"){a.go(p);return}let y=zu(p,JSON.parse(c),i,h.relative==="path");e==null&&n!=="/"&&(y.pathname=y.pathname==="/"?n:Wn([n,y.pathname])),(h.replace?a.replace:a.push)(y,h.state,h)},[n,a,c,i,e])}var n4=f.createContext(null);function r4(e){let n=f.useContext(Xn).outlet;return f.useMemo(()=>n&&f.createElement(n4.Provider,{value:e},n),[n,e])}function ul(e,{relative:n}={}){let{matches:a}=f.useContext(Xn),{pathname:o}=jn(),i=JSON.stringify(Ch(a));return f.useMemo(()=>zu(e,JSON.parse(i),o,n==="path"),[e,i,o,n])}function a4(e,n){return z0(e,n)}function z0(e,n,a){var N;ft(Ms(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(Cn),{matches:i}=f.useContext(Xn),c=i[i.length-1],d=c?c.params:{},m=c?c.pathname:"/",p=c?c.pathnameBase:"/",h=c&&c.route;{let E=h&&h.path||"";I0(m,!h||E.endsWith("*")||E.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${m}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. Please change the parent to .`)}let y=jn(),v;if(n){let E=typeof n=="string"?Rs(n):n;ft(p==="/"||((N=E.pathname)==null?void 0:N.startsWith(p)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${p}" but pathname "${E.pathname}" was given in the \`location\` prop.`),v=E}else v=y;let x=v.pathname||"/",S=x;if(p!=="/"){let E=p.replace(/^\//,"").split("/");S="/"+x.replace(/^\//,"").split("/").slice(E.length).join("/")}let j=a&&a.state.matches.length?a.state.matches.map(E=>Object.assign(E,{route:a.manifest[E.route.id]||E.route})):j0(e,{pathname:S});$n(h||j!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),$n(j==null||j[j.length-1].route.element!==void 0||j[j.length-1].route.Component!==void 0||j[j.length-1].route.lazy!==void 0,`Matched leaf route at location "${v.pathname}${v.search}${v.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let C=c4(j&&j.map(E=>Object.assign({},E,{params:Object.assign({},d,E.params),pathname:Wn([p,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?p:Wn([p,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),i,a);return n&&C?f.createElement(cl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...v},navigationType:"POP"}},C):C}function o4(){let e=p4(),n=G3(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),a=e instanceof Error?e.stack:null,o="rgba(200,200,200, 0.5)",i={padding:"0.5rem",backgroundColor:o},c={padding:"2px 4px",backgroundColor:o},d=null;return console.error("Error handled by React Router default ErrorBoundary:",e),d=f.createElement(f.Fragment,null,f.createElement("p",null,"💿 Hey developer 👋"),f.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",f.createElement("code",{style:c},"ErrorBoundary")," or"," ",f.createElement("code",{style:c},"errorElement")," prop on your route.")),f.createElement(f.Fragment,null,f.createElement("h2",null,"Unexpected Application Error!"),f.createElement("h3",{style:{fontStyle:"italic"}},n),a?f.createElement("pre",{style:i},a):null,d)}var s4=f.createElement(o4,null),P0=class extends f.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,n){return n.location!==e.location||n.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:n.error,location:n.location,revalidation:e.revalidation||n.revalidation}}componentDidCatch(e,n){this.props.onError?this.props.onError(e,n):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const a=J3(e.digest);a&&(e=a)}let n=e!==void 0?f.createElement(Xn.Provider,{value:this.props.routeContext},f.createElement(jh.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?f.createElement(i4,{error:e},n):n}};P0.contextType=M0;var Qm=new WeakMap;function i4({children:e,error:n}){let{basename:a}=f.useContext(Cn);if(typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){let o=Q3(n.digest);if(o){let i=Qm.get(n);if(i)throw i;let c=R0(o.location,a);if(T0&&!Qm.get(n))if(c.isExternal||o.reloadDocument)window.location.href=c.absoluteURL||c.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(c.to,{replace:o.replace}));throw Qm.set(n,d),d}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${c.absoluteURL||c.to}`})}}return e}function l4({routeContext:e,match:n,children:a}){let o=f.useContext(As);return o&&o.static&&o.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=n.route.id),f.createElement(Xn.Provider,{value:e},a)}function c4(e,n=[],a){let o=a==null?void 0:a.state;if(e==null){if(!o)return null;if(o.errors)e=o.matches;else if(n.length===0&&!o.initialized&&o.matches.length>0)e=o.matches;else return null}let i=e,c=o==null?void 0:o.errors;if(c!=null){let y=i.findIndex(v=>v.route.id&&(c==null?void 0:c[v.route.id])!==void 0);ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(c).join(",")}`),i=i.slice(0,Math.min(i.length,y+1))}let d=!1,m=-1;if(a&&o){d=o.renderFallback;for(let y=0;y=0?i=i.slice(0,m+1):i=[i[0]];break}}}}let p=a==null?void 0:a.onError,h=o&&p?(y,v)=>{var x,S;p(y,{location:o.location,params:((S=(x=o.matches)==null?void 0:x[0])==null?void 0:S.params)??{},pattern:F3(o.matches),errorInfo:v})}:void 0;return i.reduceRight((y,v,x)=>{let S,j=!1,C=null,N=null;o&&(S=c&&v.route.id?c[v.route.id]:void 0,C=v.route.errorElement||s4,d&&(m<0&&x===0?(I0("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),j=!0,N=null):m===x&&(j=!0,N=v.route.hydrateFallbackElement||null)));let E=n.concat(i.slice(0,x+1)),k=()=>{let T;return S?T=C:j?T=N:v.route.Component?T=f.createElement(v.route.Component,null):v.route.element?T=v.route.element:T=y,f.createElement(l4,{match:v,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:T})};return o&&(v.route.ErrorBoundary||v.route.errorElement||x===0)?f.createElement(P0,{location:o.location,revalidation:o.revalidation,component:C,error:S,children:k(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:h}):k()},null)}function Eh(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function u4(e){let n=f.useContext(As);return ft(n,Eh(e)),n}function d4(e){let n=f.useContext(Pu);return ft(n,Eh(e)),n}function f4(e){let n=f.useContext(Xn);return ft(n,Eh(e)),n}function Nh(e){let n=f4(e),a=n.matches[n.matches.length-1];return ft(a.route.id,`${e} can only be used on routes that contain a unique "id"`),a.route.id}function m4(){return Nh("useRouteId")}function p4(){var o;let e=f.useContext(jh),n=d4("useRouteError"),a=Nh("useRouteError");return e!==void 0?e:(o=n.errors)==null?void 0:o[a]}function h4(){let{router:e}=u4("useNavigate"),n=Nh("useNavigate"),a=f.useRef(!1);return L0(()=>{a.current=!0}),f.useCallback(async(i,c={})=>{$n(a.current,D0),a.current&&(typeof i=="number"?await e.navigate(i):await e.navigate(i,{fromRouteId:n,...c}))},[e,n])}var Wx={};function I0(e,n,a){!n&&!Wx[e]&&(Wx[e]=!0,$n(!1,a))}f.memo(g4);function g4({routes:e,manifest:n,future:a,state:o,isStatic:i,onError:c}){return z0(e,void 0,{manifest:n,state:o,isStatic:i,onError:c})}function Lr({to:e,replace:n,state:a,relative:o}){ft(Ms()," may be used only in the context of a component.");let{static:i}=f.useContext(Cn);$n(!i," must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.");let{matches:c}=f.useContext(Xn),{pathname:d}=jn(),m=mo(),p=zu(e,Ch(c),d,o==="path"),h=JSON.stringify(p);return f.useEffect(()=>{m(JSON.parse(h),{replace:n,state:a,relative:o})},[m,h,o,n,a]),null}function v4(e){return r4(e.context)}function Yt(e){ft(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function b4({basename:e="/",children:n=null,location:a,navigationType:o="POP",navigator:i,static:c=!1,useTransitions:d}){ft(!Ms(),"You cannot render a inside another . You should never have more than one in your app.");let m=e.replace(/^\/*/,"/"),p=f.useMemo(()=>({basename:m,navigator:i,static:c,useTransitions:d,future:{}}),[m,i,c,d]);typeof a=="string"&&(a=Rs(a));let{pathname:h="/",search:y="",hash:v="",state:x=null,key:S="default",mask:j}=a,C=f.useMemo(()=>{let N=zr(h,m);return N==null?null:{location:{pathname:N,search:y,hash:v,state:x,key:S,mask:j},navigationType:o}},[m,h,y,v,x,S,o,j]);return $n(C!=null,` is not able to match the URL "${h}${y}${v}" because it does not start with the basename, so the won't render anything.`),C==null?null:f.createElement(Cn.Provider,{value:p},f.createElement(cl.Provider,{children:n,value:C}))}function qx({children:e,location:n}){return a4(Dp(e),n)}function Dp(e,n=[]){let a=[];return f.Children.forEach(e,(o,i)=>{if(!f.isValidElement(o))return;let c=[...n,i];if(o.type===f.Fragment){a.push.apply(a,Dp(o.props.children,c));return}ft(o.type===Yt,`[${typeof o.type=="string"?o.type:o.type.name}] is not a component. All component children of must be a or `),ft(!o.props.index||!o.props.children,"An index route cannot have child routes.");let d={id:o.props.id||c.join("-"),caseSensitive:o.props.caseSensitive,element:o.props.element,Component:o.props.Component,index:o.props.index,path:o.props.path,middleware:o.props.middleware,loader:o.props.loader,action:o.props.action,hydrateFallbackElement:o.props.hydrateFallbackElement,HydrateFallback:o.props.HydrateFallback,errorElement:o.props.errorElement,ErrorBoundary:o.props.ErrorBoundary,hasErrorBoundary:o.props.hasErrorBoundary===!0||o.props.ErrorBoundary!=null||o.props.errorElement!=null,shouldRevalidate:o.props.shouldRevalidate,handle:o.props.handle,lazy:o.props.lazy};o.props.children&&(d.children=Dp(o.props.children,c)),a.push(d)}),a}var au="get",ou="application/x-www-form-urlencoded";function Iu(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function y4(e){return Iu(e)&&e.tagName.toLowerCase()==="button"}function x4(e){return Iu(e)&&e.tagName.toLowerCase()==="form"}function S4(e){return Iu(e)&&e.tagName.toLowerCase()==="input"}function w4(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function C4(e,n){return e.button===0&&(!n||n==="_self")&&!w4(e)}function Lp(e=""){return new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((n,a)=>{let o=e[a];return n.concat(Array.isArray(o)?o.map(i=>[a,i]):[[a,o]])},[]))}function j4(e,n){let a=Lp(e);return n&&n.forEach((o,i)=>{a.has(i)||n.getAll(i).forEach(c=>{a.append(i,c)})}),a}var Hc=null;function E4(){if(Hc===null)try{new FormData(document.createElement("form"),0),Hc=!1}catch{Hc=!0}return Hc}var N4=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Jm(e){return e!=null&&!N4.has(e)?($n(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${ou}"`),null):e}function k4(e,n){let a,o,i,c,d;if(x4(e)){let m=e.getAttribute("action");o=m?zr(m,n):null,a=e.getAttribute("method")||au,i=Jm(e.getAttribute("enctype"))||ou,c=new FormData(e)}else if(y4(e)||S4(e)&&(e.type==="submit"||e.type==="image")){let m=e.form;if(m==null)throw new Error('Cannot submit a `,D=>`${R}-${D.id}`)}const N=x`
${n.i18n.searchDescription}
${n.i18n.skinToneDescription}
${S(n.skinTones,(k,T)=>x`
${k}
`,k=>k)}
${S(n.currentEmojisWithCategories,(k,T)=>x`
${j(k.emojis,n.searchMode,"emo")}
`,k=>k.category)}
`,E=(k,T)=>{for(const R of e.querySelectorAll(`[${k}]`))T(R,R.getAttribute(k))};if(p){e.appendChild(N);for(const k of["click","focusout","input","keydown","keyup"])E(`data-on-${k}`,(T,R)=>{T.addEventListener(k,o[R])});E("data-ref",(k,T)=>{c[T]=k}),d.addEventListener("abort",()=>{e.removeChild(N)})}E("data-action",(k,T)=>{let R=m.get(T);R||m.set(T,R=new WeakSet),R.has(k)||(R.add(k),i[T](k))})}const Ou=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function oP(e){let n=!1,a;const o=new Map,i=new Set;let c;const d=()=>{if(n)return;const h=[...i];i.clear();try{for(const y of h)y()}finally{c=!1,i.size&&(c=!0,Ou(d))}},m=new Proxy({},{get(h,y){if(a){let v=o.get(y);v||(v=new Set,o.set(y,v)),v.add(a)}return h[y]},set(h,y,v){if(h[y]!==v){h[y]=v;const x=o.get(y);if(x){for(const S of x)i.add(S);c||(c=!0,Ou(d))}}return!0}}),p=h=>{const y=()=>{const v=a;a=y;try{return h()}finally{a=v}};return y()};return e.addEventListener("abort",()=>{n=!0}),{state:m,createEffect:p}}function Tp(e,n,a){if(e.length!==n.length)return!1;for(let o=0;o{i.disconnect()})),i.observe(e)}}const Rp=[],{assign:eu}=Object;function iP(e,n){const a={},o=new AbortController,i=o.signal,{state:c,createEffect:d}=oP(i),m=new Map;eu(c,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),eu(c,n),eu(c,{initialLoad:!0,currentEmojis:[],currentEmojisWithCategories:[],rawSearchText:"",searchText:"",searchMode:!1,activeSearchItem:-1,message:void 0,skinTonePickerExpanded:!1,skinTonePickerExpandedAfterAnimation:!1,currentSkinTone:0,activeSkinTone:0,skinToneButtonText:void 0,pickerStyle:void 0,skinToneButtonLabel:"",skinTones:[],currentFavorites:[],defaultFavoriteEmojis:void 0,numColumns:Nz,isRtl:!1,currentGroupIndex:0,groups:Cp,databaseLoaded:!1,activeSearchItemId:void 0}),d(()=>{c.currentGroup!==c.groups[c.currentGroupIndex]&&(c.currentGroup=c.groups[c.currentGroupIndex])});const p=W=>{e.getElementById(W).focus()},h=W=>e.getElementById(`emo-${W.id}`),y=(W,ie)=>{a.rootElement.dispatchEvent(new CustomEvent(W,{detail:ie,bubbles:!0,composed:!0}))},v=(W,ie)=>W.id===ie.id,x=(W,ie)=>{const{category:ge,emojis:je}=W,{category:Ae,emojis:tt}=ie;return ge!==Ae?!1:Tp(je,tt,v)},S=W=>{Tp(c.currentEmojis,W,v)||(c.currentEmojis=W)},j=W=>{c.searchMode!==W&&(c.searchMode=W)},C=W=>{Tp(c.currentEmojisWithCategories,W,x)||(c.currentEmojisWithCategories=W)},N=(W,ie)=>ie&&W.skins&&W.skins[ie]||W.unicode,T={labelWithSkin:(W,ie)=>Vz([W.name||N(W,ie),W.annotation,...W.shortcodes||Rp].filter(Boolean)).join(", "),titleForEmoji:W=>W.annotation||(W.shortcodes||Rp).join(", "),unicodeWithSkin:N},R={onClickSkinToneButton:F,onEmojiClick:_,onNavClick:Z,onNavKeydown:J,onSearchKeydown:$,onSkinToneOptionsClick:V,onSkinToneOptionsFocusOut:me,onSkinToneOptionsKeydown:ae,onSkinToneOptionsKeyup:ne,onSearchInput:pe},D={calculateEmojiGridStyle:B,updateOnIntersection:H};let P=!0;d(()=>{aP(e,c,T,R,D,a,i,m,P),P=!1}),c.emojiVersion||Ep().then(W=>{W||(c.message=c.i18n.emojiUnsupportedMessage)}),d(()=>{async function W(){let ie=!1;const ge=setTimeout(()=>{ie=!0,c.message=c.i18n.loadingMessage},jz);try{await c.database.ready(),c.databaseLoaded=!0}catch(je){console.error(je),c.message=c.i18n.networkErrorMessage}finally{clearTimeout(ge),ie&&(ie=!1,c.message="")}}c.database&&W()}),d(()=>{c.pickerStyle=` --num-groups: ${c.groups.length}; --indicator-opacity: ${c.searchMode?0:1}; --num-skintones: ${Q1};`}),d(()=>{c.customEmoji&&c.database&&z()}),d(()=>{c.customEmoji&&c.customEmoji.length?c.groups!==vh&&(c.groups=vh):c.groups!==Cp&&(c.currentGroupIndex&&c.currentGroupIndex--,c.groups=Cp)}),d(()=>{async function W(){c.databaseLoaded&&(c.currentSkinTone=await c.database.getPreferredSkinTone())}W()}),d(()=>{c.skinTones=Array(Q1).fill().map((W,ie)=>Pz(c.skinToneEmoji,ie))}),d(()=>{c.skinToneButtonText=c.skinTones[c.currentSkinTone]}),d(()=>{c.skinToneButtonLabel=c.i18n.skinToneLabel.replace("{skinTone}",c.i18n.skinTones[c.currentSkinTone])}),d(()=>{async function W(){const{database:ie}=c,ge=(await Promise.all(kz.map(je=>ie.getEmojiByUnicodeOrName(je)))).filter(Boolean);c.defaultFavoriteEmojis=ge}c.databaseLoaded&&W()});function z(){const{customEmoji:W,database:ie}=c,ge=W||Rp;ie.customEmoji!==ge&&(ie.customEmoji=ge)}d(()=>{async function W(){z();const{database:ie,defaultFavoriteEmojis:ge,numColumns:je}=c,Ae=await ie.getTopFavoriteEmoji(je),tt=await he(D5([...Ae,...ge],ct=>ct.unicode||ct.name).slice(0,je));c.currentFavorites=tt}c.databaseLoaded&&c.defaultFavoriteEmojis&&W()});function B(W){Bz(W,i,()=>{{const ie=getComputedStyle(a.rootElement),ge=parseInt(ie.getPropertyValue("--num-columns"),10),je=ie.getPropertyValue("direction")==="rtl";c.numColumns=ge,c.isRtl=je}})}function H(W){sP(W,i,ie=>{for(const{target:ge,isIntersecting:je}of ie)ge.classList.toggle("onscreen",je)})}d(()=>{async function W(){const{searchText:ie,currentGroup:ge,databaseLoaded:je,customEmoji:Ae}=c;if(!je)c.currentEmojis=[],c.searchMode=!1;else if(ie.length>=wz){const tt=await O(ie);c.searchText===ie&&(S(tt),j(!0))}else{const{id:tt}=ge;if(tt!==-1||Ae&&Ae.length){const ct=await se(tt);c.currentGroup.id===tt&&(S(ct),j(!1))}}}W()});const Y=()=>{du(()=>Gz(a.tabpanelElement))};d(()=>{const{currentEmojis:W,emojiVersion:ie}=c,ge=W.filter(je=>je.unicode).filter(je=>J1(je)&&!bh.has(je.unicode));if(!ie&&ge.length)S(W),du(()=>Q(ge));else{const je=ie?W:W.filter(fe);S(je),Y()}});function Q(W){Hz(W,a.baselineEmoji,h)?Y():c.currentEmojis=[...c.currentEmojis]}function fe(W){return!W.unicode||!J1(W)||bh.get(W.unicode)}async function de(W){const ie=c.emojiVersion||await Ep();return W.filter(({version:ge})=>!ge||ge<=ie)}async function he(W){return Iz(W,c.emojiVersion||await Ep())}async function se(W){const ie=W===-1?c.customEmoji:await c.database.getEmojiByGroup(W);return he(await de(ie))}async function O(W){return he(await de(await c.database.getEmojiBySearchQuery(W)))}d(()=>{}),d(()=>{function W(){const{searchMode:ge,currentEmojis:je}=c;if(ge)return[{category:"",emojis:je}];const Ae=new Map;for(const tt of je){const ct=tt.category||"";let kt=Ae.get(ct);kt||(kt=[],Ae.set(ct,kt)),kt.push(tt)}return[...Ae.entries()].map(([tt,ct])=>({category:tt,emojis:ct})).sort((tt,ct)=>c.customCategorySorting(tt.category,ct.category))}const ie=W();C(ie)}),d(()=>{c.activeSearchItemId=c.activeSearchItem!==-1&&c.currentEmojis[c.activeSearchItem].id}),d(()=>{const{rawSearchText:W}=c;_5(()=>{c.searchText=(W||"").trim(),c.activeSearchItem=-1})});function $(W){if(!c.searchMode||!c.currentEmojis.length)return;const ie=ge=>{or(W),c.activeSearchItem=Np(ge,c.activeSearchItem,c.currentEmojis)};switch(W.key){case"ArrowDown":return ie(!1);case"ArrowUp":return ie(!0);case"Enter":if(c.activeSearchItem===-1)c.activeSearchItem=0;else return or(W),M(c.currentEmojis[c.activeSearchItem].id)}}function Z(W){const{target:ie}=W,ge=ie.closest(".nav-button");if(!ge)return;const je=parseInt(ge.dataset.groupId,10);a.searchElement.value="",c.rawSearchText="",c.searchText="",c.activeSearchItem=-1,c.currentGroupIndex=c.groups.findIndex(Ae=>Ae.id===je)}function J(W){const{target:ie,key:ge}=W,je=Ae=>{Ae&&(or(W),Ae.focus())};switch(ge){case"ArrowLeft":return je(ie.previousElementSibling);case"ArrowRight":return je(ie.nextElementSibling);case"Home":return je(ie.parentElement.firstElementChild);case"End":return je(ie.parentElement.lastElementChild)}}async function te(W){const ie=await c.database.getEmojiByUnicodeOrName(W),ge=[...c.currentEmojis,...c.currentFavorites].find(Ae=>Ae.id===W),je=ge.unicode&&N(ge,c.currentSkinTone);return await c.database.incrementFavoriteEmojiCount(W),{emoji:ie,skinTone:c.currentSkinTone,...je&&{unicode:je},...ge.name&&{name:ge.name}}}async function M(W){const ie=te(W);y("emoji-click-sync",ie),y("emoji-click",await ie)}function _(W){const{target:ie}=W;if(!ie.classList.contains("emoji"))return;or(W);const ge=ie.id.substring(4);M(ge)}function U(W){c.currentSkinTone=W,c.skinTonePickerExpanded=!1,p("skintone-button"),y("skin-tone-change",{skinTone:W}),c.database.setPreferredSkinTone(W)}function V(W){const{target:{id:ie}}=W,ge=ie&&ie.match(/^skintone-(\d)/);if(!ge)return;or(W);const je=parseInt(ge[1],10);U(je)}function F(W){c.skinTonePickerExpanded=!c.skinTonePickerExpanded,c.activeSkinTone=c.currentSkinTone,c.skinTonePickerExpanded&&(or(W),du(()=>p("skintone-list")))}d(()=>{c.skinTonePickerExpanded?a.skinToneDropdown.addEventListener("transitionend",()=>{c.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):c.skinTonePickerExpandedAfterAnimation=!1});function ae(W){if(!c.skinTonePickerExpanded)return;const ie=async ge=>{or(W),c.activeSkinTone=ge};switch(W.key){case"ArrowUp":return ie(Np(!0,c.activeSkinTone,c.skinTones));case"ArrowDown":return ie(Np(!1,c.activeSkinTone,c.skinTones));case"Home":return ie(0);case"End":return ie(c.skinTones.length-1);case"Enter":return or(W),U(c.activeSkinTone);case"Escape":return or(W),c.skinTonePickerExpanded=!1,p("skintone-button")}}function ne(W){if(c.skinTonePickerExpanded)switch(W.key){case" ":return or(W),U(c.activeSkinTone)}}async function me(W){const{relatedTarget:ie}=W;(!ie||ie.id!=="skintone-list")&&(c.skinTonePickerExpanded=!1)}function pe(W){c.rawSearchText=W.target.value}return{$set(W){eu(c,W)},$destroy(){o.abort()}}}const lP="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",cP="en";var uP={categoriesLabel:"Categories",emojiUnsupportedMessage:"Your browser does not support color emoji.",favoritesLabel:"Favorites",loadingMessage:"Loading…",networkErrorMessage:"Could not load emoji.",regionLabel:"Emoji picker",searchDescription:"When search results are available, press up or down to select and enter to choose.",searchLabel:"Search",searchResultsLabel:"Search results",skinToneDescription:"When expanded, press up or down to select and enter to choose.",skinToneLabel:"Choose a skin tone (currently {skinTone})",skinTonesLabel:"Skin tones",skinTones:["Default","Light","Medium-Light","Medium","Medium-Dark","Dark"],categories:{custom:"Custom","smileys-emotion":"Smileys and emoticons","people-body":"People and body","animals-nature":"Animals and nature","food-drink":"Food and drink","travel-places":"Travel and places",activities:"Activities",objects:"Objects",symbols:"Symbols",flags:"Flags"}},dP=':host{--emoji-size:1.375rem;--emoji-padding:0.5rem;--category-emoji-size:var(--emoji-size);--category-emoji-padding:var(--emoji-padding);--indicator-height:3px;--input-border-radius:0.5rem;--input-border-size:1px;--input-font-size:1rem;--input-line-height:1.5;--input-padding:0.25rem;--num-columns:8;--outline-size:2px;--border-size:1px;--border-radius:0;--skintone-border-radius:1rem;--category-font-size:1rem;display:flex;width:min-content;height:400px}:host,:host(.light){color-scheme:light;--background:#fff;--border-color:#e0e0e0;--indicator-color:#385ac1;--input-border-color:#999;--input-font-color:#111;--input-placeholder-color:#999;--outline-color:#999;--category-font-color:#111;--button-active-background:#e6e6e6;--button-hover-background:#d9d9d9}:host(.dark){color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}@media (prefers-color-scheme:dark){:host{color-scheme:dark;--background:#222;--border-color:#444;--indicator-color:#5373ec;--input-border-color:#ccc;--input-font-color:#efefef;--input-placeholder-color:#ccc;--outline-color:#fff;--category-font-color:#efefef;--button-active-background:#555555;--button-hover-background:#484848}}:host([hidden]){display:none}button{margin:0;padding:0;border:0;background:0 0;box-shadow:none;-webkit-tap-highlight-color:transparent}button::-moz-focus-inner{border:0}input{padding:0;margin:0;line-height:1.15;font-family:inherit}input[type=search]{-webkit-appearance:none}:focus{outline:var(--outline-color) solid var(--outline-size);outline-offset:calc(-1*var(--outline-size))}:host([data-js-focus-visible]) :focus:not([data-focus-visible-added]){outline:0}:focus:not(:focus-visible){outline:0}.hide-focus{outline:0}*{box-sizing:border-box}.picker{contain:content;display:flex;flex-direction:column;background:var(--background);border:var(--border-size) solid var(--border-color);border-radius:var(--border-radius);width:100%;height:100%;overflow:hidden;--total-emoji-size:calc(var(--emoji-size) + (2 * var(--emoji-padding)));--total-category-emoji-size:calc(var(--category-emoji-size) + (2 * var(--category-emoji-padding)))}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.hidden{opacity:0;pointer-events:none}.abs-pos{position:absolute;left:0;top:0}.gone{display:none!important}.skintone-button-wrapper,.skintone-list{background:var(--background);z-index:3}.skintone-button-wrapper.expanded{z-index:1}.skintone-list{position:absolute;inset-inline-end:0;top:0;z-index:2;overflow:visible;border-bottom:var(--border-size) solid var(--border-color);border-radius:0 0 var(--skintone-border-radius) var(--skintone-border-radius);will-change:transform;transition:transform .2s ease-in-out;transform-origin:center 0}@media (prefers-reduced-motion:reduce){.skintone-list{transition-duration:.001s}}@supports not (inset-inline-end:0){.skintone-list{right:0}}.skintone-list.no-animate{transition:none}.tabpanel{overflow-y:auto;scrollbar-gutter:stable;-webkit-overflow-scrolling:touch;will-change:transform;min-height:0;flex:1;contain:content}.emoji-menu{display:grid;grid-template-columns:repeat(var(--num-columns),var(--total-emoji-size));justify-content:space-around;align-items:flex-start;width:100%}.emoji-menu.visibility-auto{content-visibility:auto;contain-intrinsic-size:calc(var(--num-columns)*var(--total-emoji-size)) calc(var(--num-rows)*var(--total-emoji-size))}.category{padding:var(--emoji-padding);font-size:var(--category-font-size);color:var(--category-font-color)}.emoji,button.emoji{font-size:var(--emoji-size);display:flex;align-items:center;justify-content:center;border-radius:100%;height:var(--total-emoji-size);width:var(--total-emoji-size);line-height:1;overflow:hidden;font-family:var(--emoji-font-family);cursor:pointer}@media (hover:hover) and (pointer:fine){.emoji:hover,button.emoji:hover{background:var(--button-hover-background)}}.emoji.active,.emoji:active,button.emoji.active,button.emoji:active{background:var(--button-active-background)}.onscreen .custom-emoji::after{content:"";width:var(--emoji-size);height:var(--emoji-size);background-repeat:no-repeat;background-position:center center;background-size:contain;background-image:var(--custom-emoji-background)}.nav,.nav-button{align-items:center}.nav{display:grid;justify-content:space-between;contain:content}.nav-button{display:flex;justify-content:center}.nav-emoji{font-size:var(--category-emoji-size);width:var(--total-category-emoji-size);height:var(--total-category-emoji-size)}.indicator-wrapper{display:flex;border-bottom:1px solid var(--border-color)}.indicator{width:calc(100%/var(--num-groups));height:var(--indicator-height);opacity:var(--indicator-opacity);background-color:var(--indicator-color);will-change:transform,opacity;transition:opacity .1s linear,transform .25s ease-in-out}@media (prefers-reduced-motion:reduce){.indicator{will-change:opacity;transition:opacity .1s linear}}.pad-top,input.search{background:var(--background);width:100%}.pad-top{height:var(--emoji-padding);z-index:3}.search-row{display:flex;align-items:center;position:relative;padding-inline-start:var(--emoji-padding);padding-bottom:var(--emoji-padding)}.search-wrapper{flex:1;min-width:0}input.search{padding:var(--input-padding);border-radius:var(--input-border-radius);border:var(--input-border-size) solid var(--input-border-color);color:var(--input-font-color);font-size:var(--input-font-size);line-height:var(--input-line-height)}input.search::placeholder{color:var(--input-placeholder-color)}.favorites{overflow-y:auto;scrollbar-gutter:stable;display:flex;flex-direction:row;border-top:var(--border-size) solid var(--border-color);contain:content}.message{padding:var(--emoji-padding)}';const L5=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],fP=`:host{--emoji-font-family:${O5}}`;class Lg extends HTMLElement{constructor(n){super(),this.attachShadow({mode:"open"});const a=document.createElement("style");a.textContent=dP+fP,this.shadowRoot.appendChild(a),this._ctx={locale:cP,dataSource:lP,skinToneEmoji:Ez,customCategorySorting:Tz,customEmoji:null,i18n:uP,emojiVersion:null,...n};for(const o of L5)o!=="database"&&Object.prototype.hasOwnProperty.call(this,o)&&(this._ctx[o]=this[o],delete this[o]);this._dbFlush()}connectedCallback(){s0(this),this._cmp||(this._cmp=iP(this.shadowRoot,this._ctx))}disconnectedCallback(){s0(this),Ou(()=>{if(!this.isConnected&&this._cmp){this._cmp.$destroy(),this._cmp=void 0;const{database:n}=this._ctx;n.close().catch(a=>console.error(a))}})}static get observedAttributes(){return["locale","data-source","skin-tone-emoji","emoji-version"]}attributeChangedCallback(n,a,o){this._set(n.replace(/-([a-z])/g,(i,c)=>c.toUpperCase()),n==="emoji-version"?parseFloat(o):o)}_set(n,a){this._ctx[n]=a,this._cmp&&this._cmp.$set({[n]:a}),["locale","dataSource"].includes(n)&&this._dbFlush()}_dbCreate(){const{locale:n,dataSource:a,database:o}=this._ctx;(!o||o.locale!==n||o.dataSource!==a)&&this._set("database",new Sz({locale:n,dataSource:a}))}_dbFlush(){Ou(()=>this._dbCreate())}}const z5={};for(const e of L5)z5[e]={get(){return e==="database"&&this._dbCreate(),this._ctx[e]},set(n){if(e==="database")throw new Error("database is read-only");this._set(e,n)}};Object.defineProperties(Lg.prototype,z5);function s0(e){e instanceof Lg||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",Lg);function mP({onPick:e}){const n=f.useRef(null);return f.useEffect(()=>{const a=n.current;if(!a)return;const o=document.createElement("emoji-picker");o.className="unicode-emoji-picker-el",o.setAttribute("data-theme","dark");const i=c=>{var p;const d=c.detail,m=(d==null?void 0:d.unicode)??((p=d==null?void 0:d.emoji)==null?void 0:p.unicode);m&&e(m)};return o.addEventListener("emoji-click",i),a.appendChild(o),()=>{o.removeEventListener("emoji-click",i),o.remove()}},[e]),l.jsx("div",{ref:n,className:"unicode-emoji-panel-host overflow-hidden rounded-lg border border-border/50"})}const pP=/^<(a?):([^:>]+):(\d{17,20})>$/;function fu(e,n,a=!1){return`${a?"`}function P5(e){const n=String(e??"").trim();if(!n)return{kind:"empty",value:""};const a=n.match(pP);return a?{kind:"custom",value:n,animated:a[1]==="a",name:a[2],id:a[3]}:{kind:"unicode",value:n}}function I5(e,n=!1){return`https://cdn.discordapp.com/emojis/${e}.${n?"gif":"png"}?size=64`}function hP(e,n=[]){const a=P5(e);if(a.kind==="custom"&&a.id&&!a.name){const o=n.find(i=>i.id===a.id);if(o)return{kind:"custom",value:fu(o.name,o.id,o.animated),name:o.name,id:o.id,animated:o.animated}}if(a.kind==="custom"&&a.id){const o=n.find(i=>i.id===a.id);if(o&&a.value!==fu(o.name,o.id,o.animated))return{kind:"custom",value:fu(o.name,o.id,o.animated),name:o.name,id:o.id,animated:o.animated}}return a}function gP({value:e,guildEmojis:n,size:a="md"}){const o=hP(e,n),i=a==="lg"?"size-10":"size-7",c=a==="lg"?"text-3xl":"text-2xl";return o.kind==="empty"?l.jsx("span",{className:"text-sm text-muted-foreground",children:"No emoji selected"}):o.kind==="custom"&&o.id?l.jsxs("span",{className:"inline-flex items-center gap-3",children:[l.jsx("img",{src:I5(o.id,o.animated),alt:o.name??"custom emoji",className:ce(i,"shrink-0 rounded-md"),loading:"lazy"}),l.jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[l.jsxs("span",{className:"text-sm font-medium",children:[":",o.name,":"]}),l.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:o.value})]})]}):l.jsx("span",{className:ce(c,"leading-none"),title:o.value,children:o.value})}function vP({id:e,label:n,description:a,value:o,onChange:i,readOnly:c}){const[d,m]=f.useState(!1),[p,h]=f.useState("server"),[y,v]=f.useState(null),[x,S]=f.useState(""),[j,C]=f.useState(!1),[N,E]=f.useState(""),k=f.useCallback(async(Y=!1)=>{C(!0),S("");try{const Q=await Ne.getGuildResources(Y);Q.data?(v(Q.data),Array.isArray(Q.data.emojis)||S("Server response is missing emojis. Restart the bot after updating.")):S("No guild data returned.")}catch(Q){S(Q instanceof Error?Q.message:"Could not load server emojis")}finally{C(!1)}},[]);f.useEffect(()=>{d&&k(!0)},[d,k]);const T=f.useMemo(()=>Array.isArray(y==null?void 0:y.emojis)?y.emojis:[],[y]),R=f.useMemo(()=>{const Y=N.trim().toLowerCase();return Y?T.filter(Q=>Q.name.toLowerCase().includes(Y)):T},[T,N]),D=String(o??""),P=P5(D);function z(Y){i(Y),m(!1)}function B(Y){i(fu(Y.name,Y.id,Y.animated)),m(!1)}function H(){i("")}return l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:e,children:n}),a?l.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null,l.jsxs("div",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 sm:flex-row sm:items-center sm:justify-between",children:[l.jsx("div",{className:"min-w-0 flex-1",children:l.jsx(gP,{value:o,guildEmojis:T,size:"lg"})}),l.jsxs("div",{className:"flex shrink-0 gap-2",children:[l.jsx(ve,{type:"button",variant:"secondary",size:"sm",disabled:c,onClick:()=>m(!0),children:"Choose emoji"}),D?l.jsx(ve,{type:"button",variant:"ghost",size:"sm",disabled:c,onClick:H,children:"Clear"}):null]})]}),l.jsx(gg,{open:d,onOpenChange:m,children:l.jsxs(hd,{className:"max-h-[min(90vh,720px)] max-w-lg gap-0 overflow-hidden p-0 sm:max-w-xl",children:[l.jsxs(gd,{className:"space-y-1 border-b border-border px-5 py-4",children:[l.jsx(vd,{children:"Choose emoji"}),l.jsxs(bd,{children:["Server emojis save as"," ",l.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"<:name:id>"}),". Standard emojis save as Unicode characters."]})]}),l.jsxs(v5,{value:p,onValueChange:Y=>h(Y),className:"flex min-h-0 flex-1 flex-col",children:[l.jsxs(Rg,{className:"mx-5 mt-3 grid h-9 w-auto grid-cols-2",children:[l.jsx(to,{value:"server",children:"Server"}),l.jsx(to,{value:"unicode",children:"All emojis"})]}),l.jsxs(mh,{value:"server",className:"mt-0 flex-1 px-5 pb-4 pt-3",children:[l.jsxs("div",{className:"relative mb-3",children:[l.jsx(ye,{icon:Gu,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),l.jsx(Ue,{placeholder:"Search by name…",value:N,onChange:Y=>E(Y.target.value),className:"h-9 border-border bg-secondary/30 pl-9"})]}),y?l.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[y.guildName," · ",T.length," custom emoji",T.length===1?"":"s"]}):null,l.jsx(Sd,{className:"h-[min(50vh,320px)] rounded-lg border border-border/50 bg-secondary/20",children:j?l.jsx("div",{className:"grid grid-cols-6 gap-2 p-3 sm:grid-cols-8",children:Array.from({length:24}).map((Y,Q)=>l.jsx(Ve,{className:"aspect-square rounded-lg"},Q))}):x?l.jsxs("div",{className:"space-y-3 p-4 text-center",children:[l.jsx("p",{className:"text-sm text-destructive",children:x}),l.jsx(ve,{type:"button",variant:"outline",size:"sm",onClick:()=>void k(!0),children:"Retry"})]}):R.length===0?l.jsx("p",{className:"p-6 text-center text-sm text-muted-foreground",children:T.length===0?"No custom emojis in this server, or the bot needs the Guild Emojis intent (restart after update).":"No emojis match your search."}):l.jsx("div",{className:"grid grid-cols-6 gap-1.5 p-2 sm:grid-cols-8",children:R.map(Y=>{const Q=P.kind==="custom"&&P.id===Y.id;return l.jsx("button",{type:"button",title:`:${Y.name}:`,className:ce("flex aspect-square items-center justify-center rounded-lg border border-transparent bg-background/50 transition-colors hover:border-primary/30 hover:bg-accent",Q&&"border-primary/50 bg-primary/15 ring-2 ring-primary/30"),onClick:()=>B(Y),children:l.jsx("img",{src:Y.url??I5(Y.id,Y.animated),alt:Y.name,className:"size-8 object-contain",loading:"lazy"})},Y.id)})})})]}),l.jsx(mh,{value:"unicode",className:"mt-0 px-5 pb-4 pt-3",children:l.jsx(mP,{onPick:z})})]})]})}),l.jsx(Ue,{value:D,disabled:c,onChange:Y=>i(Y.target.value),placeholder:"Unicode or <:name:id>",className:"border-border bg-secondary/30 font-mono text-xs"})]})}const i0="BOT_TOKEN",bP="MODEL_API_KEY";function zg({field:e,value:n,onChange:a,readOnly:o}){const i=e.path.replace(/\./g,"-");if(e.type==="googleFont")return l.jsx(SL,{field:e,value:n,onChange:a,readOnly:o});if(e.type==="boolean")return l.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border bg-secondary/20 px-3 py-2.5",children:[l.jsxs("div",{children:[l.jsx(De,{htmlFor:i,className:"font-medium",children:e.label}),e.description?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null]}),l.jsx(dn,{id:i,checked:!!n,disabled:o,onCheckedChange:a})]});if(e.type==="stringList")return l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:e.label}),e.description?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,l.jsx(bL,{value:Array.isArray(n)?n:[],onChange:a})]});if(e.type==="select"&&e.options)return l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:i,children:e.label}),l.jsxs(Es,{value:String(n??""),disabled:o,onValueChange:a,children:[l.jsx(lo,{id:i,className:"border-border bg-secondary/30",children:l.jsx(Ns,{placeholder:"Select…"})}),l.jsx(co,{children:e.options.map(d=>l.jsx(Zt,{value:d.value,children:d.label},d.value))})]})]});if(e.type==="color"){const d=cr(String(n??"#000000"));return l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:i,children:e.label}),e.description?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ng,{value:d,onChange:a}),l.jsx(Ue,{id:i,value:d,disabled:o,onChange:m=>a(m.target.value),onBlur:m=>a(cr(m.target.value,d)),className:"border-border bg-secondary/30 font-mono uppercase",placeholder:"#000000",maxLength:7})]})]})}if(e.type==="emoji")return l.jsx(vP,{id:i,label:e.label,description:e.description,value:n,onChange:a,readOnly:o});if(e.type==="discordChannel"||e.type==="discordRole"||e.type==="discordCategory"){const d=e.type==="discordRole"?"role":e.type==="discordCategory"?"category":"channel";return l.jsx(wL,{id:i,label:e.label,description:e.description,kind:d,value:n,onChange:a,readOnly:o})}if(e.type==="secret"){const d=n===i0||n===bP||!n?"":"••••••••••••";return l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:i,children:e.label}),e.description?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,l.jsx(Ue,{id:i,type:"password",value:d,disabled:o,placeholder:e.placeholder??"Unchanged if empty",onChange:m=>{const p=m.target.value;a(p||(e.placeholder??i0))},className:"border-border bg-secondary/30"})]})}const c="border-border bg-secondary/30";return e.type==="textarea"?l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:i,children:e.label}),l.jsx(Cd,{id:i,value:String(n??""),disabled:o,onChange:d=>a(d.target.value),className:`min-h-[88px] ${c}`})]}):l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:i,children:e.label}),e.description?l.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,l.jsx(Ue,{id:i,type:e.type==="number"?"number":"text",value:n==null?"":String(n),disabled:o,onChange:d=>a(e.type==="number"?Number(d.target.value):d.target.value),placeholder:e.placeholder??(e.type==="discordId"?"Discord snowflake ID":void 0),className:c})]})}const Ge=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("rounded-xl border border-border bg-card text-card-foreground shadow-none",e),...n}));Ge.displayName="Card";const Ze=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("flex flex-col space-y-1.5 p-6",e),...n}));Ze.displayName="CardHeader";const Qe=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("font-semibold leading-none tracking-tight",e),...n}));Qe.displayName="CardTitle";const ht=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("text-sm text-muted-foreground",e),...n}));ht.displayName="CardDescription";const Fe=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("p-6 pt-0",e),...n}));Fe.displayName="CardContent";const Pg=f.forwardRef(({className:e,...n},a)=>l.jsx("div",{ref:a,className:ce("flex items-center p-6 pt-0",e),...n}));Pg.displayName="CardFooter";function l0(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function yP(e,n){if(typeof n=="boolean")return"boolean";if(typeof n=="number")return"number";if(Array.isArray(n))return"stringList";if(typeof n=="string"){const a=e.toLowerCase();return/emoji/.test(a)?"emoji":/guild.?id|guild_id/.test(a)?"discordId":/category/.test(a)?"discordCategory":/channel|forum/.test(a)?"discordChannel":/role|staff|admin|moderator/.test(a)?"discordRole":n.length>100?"textarea":"text"}return"text"}function Ig(e,n=""){const a=[];for(const[o,i]of Object.entries(e)){const c=n?`${n}.${o}`:o;if(Array.isArray(i)){if(i.length>0&&typeof i[0]=="object"&&i[0]!==null&&!Array.isArray(i[0]))continue;a.push({path:c,label:l0(o),type:"stringList"});continue}if(i&&typeof i=="object"&&Object.keys(i).length>0){a.push(...Ig(i,c));continue}a.push({path:c,label:l0(o),type:yP(o,i)})}return a}function xP(e){const n=Ig(e);return n.length===0?[{title:"Configuration",fields:[]}]:[{title:"Settings",description:"Values from this addon’s config file.",fields:n}]}function fo(e,n){const a=n.split(".");let o=e;for(const i of a){if(o==null||typeof o!="object")return;o=o[i]}return o}function il(e,n,a){const o=n.split("."),i=structuredClone(e);let c=i;for(let d=0;d"u")return;let n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css",n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}const wP=e=>{switch(e){case"success":return EP;case"info":return kP;case"warning":return NP;case"error":return TP;default:return null}},CP=Array(12).fill(0),jP=({visible:e,className:n})=>ue.createElement("div",{className:["sonner-loading-wrapper",n].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},CP.map((a,o)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${o}`})))),EP=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M10 18a8 8 0 100-16 8 8 0 000 16zm3.857-9.809a.75.75 0 00-1.214-.882l-3.483 4.79-1.88-1.88a.75.75 0 10-1.06 1.061l2.5 2.5a.75.75 0 001.137-.089l4-5.5z",clipRule:"evenodd"})),NP=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M9.401 3.003c1.155-2 4.043-2 5.197 0l7.355 12.748c1.154 2-.29 4.5-2.599 4.5H4.645c-2.309 0-3.752-2.5-2.598-4.5L9.4 3.003zM12 8.25a.75.75 0 01.75.75v3.75a.75.75 0 01-1.5 0V9a.75.75 0 01.75-.75zm0 8.25a.75.75 0 100-1.5.75.75 0 000 1.5z",clipRule:"evenodd"})),kP=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a.75.75 0 000 1.5h.253a.25.25 0 01.244.304l-.459 2.066A1.75 1.75 0 0010.747 15H11a.75.75 0 000-1.5h-.253a.25.25 0 01-.244-.304l.459-2.066A1.75 1.75 0 009.253 9H9z",clipRule:"evenodd"})),TP=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ue.createElement("path",{fillRule:"evenodd",d:"M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-8-5a.75.75 0 01.75.75v4.5a.75.75 0 01-1.5 0v-4.5A.75.75 0 0110 5zm0 10a1 1 0 100-2 1 1 0 000 2z",clipRule:"evenodd"})),RP=ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"},ue.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ue.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),AP=()=>{const[e,n]=ue.useState(document.hidden);return ue.useEffect(()=>{const a=()=>{n(document.hidden)};return document.addEventListener("visibilitychange",a),()=>window.removeEventListener("visibilitychange",a)},[]),e};let yh=1;class MP{constructor(){this.subscribe=n=>(this.subscribers.push(n),()=>{const a=this.subscribers.indexOf(n);this.subscribers.splice(a,1)}),this.publish=n=>{this.subscribers.forEach(a=>a(n))},this.addToast=n=>{this.publish(n),this.toasts=[...this.toasts,n]},this.create=n=>{var a;const{message:o,...i}=n,c=typeof(n==null?void 0:n.id)=="number"||((a=n.id)==null?void 0:a.length)>0?n.id:yh++,d=this.toasts.find(p=>p.id===c),m=n.dismissible===void 0?!0:n.dismissible;return this.dismissedToasts.has(c)&&this.dismissedToasts.delete(c),d?this.toasts=this.toasts.map(p=>p.id===c?(this.publish({...p,...n,id:c,title:o}),{...p,...n,id:c,dismissible:m,title:o}):p):this.addToast({title:o,...i,dismissible:m,id:c}),c},this.dismiss=n=>(n?(this.dismissedToasts.add(n),requestAnimationFrame(()=>this.subscribers.forEach(a=>a({id:n,dismiss:!0})))):this.toasts.forEach(a=>{this.subscribers.forEach(o=>o({id:a.id,dismiss:!0}))}),n),this.message=(n,a)=>this.create({...a,message:n}),this.error=(n,a)=>this.create({...a,message:n,type:"error"}),this.success=(n,a)=>this.create({...a,type:"success",message:n}),this.info=(n,a)=>this.create({...a,type:"info",message:n}),this.warning=(n,a)=>this.create({...a,type:"warning",message:n}),this.loading=(n,a)=>this.create({...a,type:"loading",message:n}),this.promise=(n,a)=>{if(!a)return;let o;a.loading!==void 0&&(o=this.create({...a,promise:n,type:"loading",message:a.loading,description:typeof a.description!="function"?a.description:void 0}));const i=Promise.resolve(n instanceof Function?n():n);let c=o!==void 0,d;const m=i.then(async h=>{if(d=["resolve",h],ue.isValidElement(h))c=!1,this.create({id:o,type:"default",message:h});else if(OP(h)&&!h.ok){c=!1;const v=typeof a.error=="function"?await a.error(`HTTP error! status: ${h.status}`):a.error,x=typeof a.description=="function"?await a.description(`HTTP error! status: ${h.status}`):a.description,j=typeof v=="object"&&!ue.isValidElement(v)?v:{message:v};this.create({id:o,type:"error",description:x,...j})}else if(h instanceof Error){c=!1;const v=typeof a.error=="function"?await a.error(h):a.error,x=typeof a.description=="function"?await a.description(h):a.description,j=typeof v=="object"&&!ue.isValidElement(v)?v:{message:v};this.create({id:o,type:"error",description:x,...j})}else if(a.success!==void 0){c=!1;const v=typeof a.success=="function"?await a.success(h):a.success,x=typeof a.description=="function"?await a.description(h):a.description,j=typeof v=="object"&&!ue.isValidElement(v)?v:{message:v};this.create({id:o,type:"success",description:x,...j})}}).catch(async h=>{if(d=["reject",h],a.error!==void 0){c=!1;const y=typeof a.error=="function"?await a.error(h):a.error,v=typeof a.description=="function"?await a.description(h):a.description,S=typeof y=="object"&&!ue.isValidElement(y)?y:{message:y};this.create({id:o,type:"error",description:v,...S})}}).finally(()=>{c&&(this.dismiss(o),o=void 0),a.finally==null||a.finally.call(a)}),p=()=>new Promise((h,y)=>m.then(()=>d[0]==="reject"?y(d[1]):h(d[1])).catch(y));return typeof o!="string"&&typeof o!="number"?{unwrap:p}:Object.assign(o,{unwrap:p})},this.custom=(n,a)=>{const o=(a==null?void 0:a.id)||yh++;return this.create({jsx:n(o),id:o,...a}),o},this.getActiveToasts=()=>this.toasts.filter(n=>!this.dismissedToasts.has(n.id)),this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set}}const un=new MP,_P=(e,n)=>{const a=(n==null?void 0:n.id)||yh++;return un.addToast({title:e,...n,id:a}),a},OP=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",DP=_P,LP=()=>un.toasts,zP=()=>un.getActiveToasts(),Dr=Object.assign(DP,{success:un.success,info:un.info,warning:un.warning,error:un.error,custom:un.custom,message:un.message,promise:un.promise,dismiss:un.dismiss,loading:un.loading},{getHistory:LP,getToasts:zP});SP("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--gray12);background:var(--normal-bg);border:1px solid var(--gray4);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}");function tu(e){return e.label!==void 0}const PP=3,IP="24px",$P="16px",c0=4e3,BP=356,UP=14,HP=45,VP=200;function sr(...e){return e.filter(Boolean).join(" ")}function GP(e){const[n,a]=e.split("-"),o=[];return n&&o.push(n),a&&o.push(a),o}const FP=e=>{var n,a,o,i,c,d,m,p,h;const{invert:y,toast:v,unstyled:x,interacting:S,setHeights:j,visibleToasts:C,heights:N,index:E,toasts:k,expanded:T,removeToast:R,defaultRichColors:D,closeButton:P,style:z,cancelButtonStyle:B,actionButtonStyle:H,className:Y="",descriptionClassName:Q="",duration:fe,position:de,gap:he,expandByDefault:se,classNames:O,icons:$,closeButtonAriaLabel:Z="Close toast"}=e,[J,te]=ue.useState(null),[M,_]=ue.useState(null),[U,V]=ue.useState(!1),[F,ae]=ue.useState(!1),[ne,me]=ue.useState(!1),[pe,W]=ue.useState(!1),[ie,ge]=ue.useState(!1),[je,Ae]=ue.useState(0),[tt,ct]=ue.useState(0),kt=ue.useRef(v.duration||fe||c0),Ra=ue.useRef(null),Tt=ue.useRef(null),Hs=E===0,Vs=E+1<=C,Wt=v.type,Vr=v.dismissible!==!1,qt=v.className||"",_d=v.descriptionClassName||"",Aa=ue.useMemo(()=>N.findIndex(Re=>Re.toastId===v.id)||0,[N,v.id]),Tl=ue.useMemo(()=>{var Re;return(Re=v.closeButton)!=null?Re:P},[v.closeButton,P]),Ma=ue.useMemo(()=>v.duration||fe||c0,[v.duration,fe]),Gs=ue.useRef(0),mr=ue.useRef(0),Rl=ue.useRef(0),Gr=ue.useRef(null),[_a,Kt]=de.split("-"),Un=ue.useMemo(()=>N.reduce((Re,ut,Rt)=>Rt>=Aa?Re:Re+ut.height,0),[N,Aa]),Vt=AP(),Od=v.invert||y,Fs=Wt==="loading";mr.current=ue.useMemo(()=>Aa*he+Un,[Aa,Un]),ue.useEffect(()=>{kt.current=Ma},[Ma]),ue.useEffect(()=>{V(!0)},[]),ue.useEffect(()=>{const Re=Tt.current;if(Re){const ut=Re.getBoundingClientRect().height;return ct(ut),j(Rt=>[{toastId:v.id,height:ut,position:v.position},...Rt]),()=>j(Rt=>Rt.filter(Gt=>Gt.toastId!==v.id))}},[j,v.id]),ue.useLayoutEffect(()=>{if(!U)return;const Re=Tt.current,ut=Re.style.height;Re.style.height="auto";const Rt=Re.getBoundingClientRect().height;Re.style.height=ut,ct(Rt),j(Gt=>Gt.find(mt=>mt.toastId===v.id)?Gt.map(mt=>mt.toastId===v.id?{...mt,height:Rt}:mt):[{toastId:v.id,height:Rt,position:v.position},...Gt])},[U,v.title,v.description,j,v.id,v.jsx,v.action,v.cancel]);const Qn=ue.useCallback(()=>{ae(!0),Ae(mr.current),j(Re=>Re.filter(ut=>ut.toastId!==v.id)),setTimeout(()=>{R(v)},VP)},[v,R,j,mr]);ue.useEffect(()=>{if(v.promise&&Wt==="loading"||v.duration===1/0||v.type==="loading")return;let Re;return T||S||Vt?(()=>{if(Rl.current{kt.current!==1/0&&(Gs.current=new Date().getTime(),Re=setTimeout(()=>{v.onAutoClose==null||v.onAutoClose.call(v,v),Qn()},kt.current))})(),()=>clearTimeout(Re)},[T,S,v,Wt,Vt,Qn]),ue.useEffect(()=>{v.delete&&(Qn(),v.onDismiss==null||v.onDismiss.call(v,v))},[Qn,v.delete]);function yo(){var Re;if($!=null&&$.loading){var ut;return ue.createElement("div",{className:sr(O==null?void 0:O.loader,v==null||(ut=v.classNames)==null?void 0:ut.loader,"sonner-loader"),"data-visible":Wt==="loading"},$.loading)}return ue.createElement(jP,{className:sr(O==null?void 0:O.loader,v==null||(Re=v.classNames)==null?void 0:Re.loader),visible:Wt==="loading"})}const xo=v.icon||($==null?void 0:$[Wt])||wP(Wt);var Oa,Jn;return ue.createElement("li",{tabIndex:0,ref:Tt,className:sr(Y,qt,O==null?void 0:O.toast,v==null||(n=v.classNames)==null?void 0:n.toast,O==null?void 0:O.default,O==null?void 0:O[Wt],v==null||(a=v.classNames)==null?void 0:a[Wt]),"data-sonner-toast":"","data-rich-colors":(Oa=v.richColors)!=null?Oa:D,"data-styled":!(v.jsx||v.unstyled||x),"data-mounted":U,"data-promise":!!v.promise,"data-swiped":ie,"data-removed":F,"data-visible":Vs,"data-y-position":_a,"data-x-position":Kt,"data-index":E,"data-front":Hs,"data-swiping":ne,"data-dismissible":Vr,"data-type":Wt,"data-invert":Od,"data-swipe-out":pe,"data-swipe-direction":M,"data-expanded":!!(T||se&&U),"data-testid":v.testId,style:{"--index":E,"--toasts-before":E,"--z-index":k.length-E,"--offset":`${F?je:mr.current}px`,"--initial-height":se?"auto":`${tt}px`,...z,...v.style},onDragEnd:()=>{me(!1),te(null),Gr.current=null},onPointerDown:Re=>{Re.button!==2&&(Fs||!Vr||(Ra.current=new Date,Ae(mr.current),Re.target.setPointerCapture(Re.pointerId),Re.target.tagName!=="BUTTON"&&(me(!0),Gr.current={x:Re.clientX,y:Re.clientY})))},onPointerUp:()=>{var Re,ut,Rt;if(pe||!Vr)return;Gr.current=null;const Gt=Number(((Re=Tt.current)==null?void 0:Re.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Fr=Number(((ut=Tt.current)==null?void 0:ut.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((Rt=Ra.current)==null?void 0:Rt.getTime()),Jt=J==="x"?Gt:Fr,Da=Math.abs(Jt)/mt;if(Math.abs(Jt)>=HP||Da>.11){Ae(mr.current),v.onDismiss==null||v.onDismiss.call(v,v),_(J==="x"?Gt>0?"right":"left":Fr>0?"down":"up"),Qn(),W(!0);return}else{var en,tn;(en=Tt.current)==null||en.style.setProperty("--swipe-amount-x","0px"),(tn=Tt.current)==null||tn.style.setProperty("--swipe-amount-y","0px")}ge(!1),me(!1),te(null)},onPointerMove:Re=>{var ut,Rt,Gt;if(!Gr.current||!Vr||((ut=window.getSelection())==null?void 0:ut.toString().length)>0)return;const mt=Re.clientY-Gr.current.y,Jt=Re.clientX-Gr.current.x;var Da;const en=(Da=e.swipeDirections)!=null?Da:GP(de);!J&&(Math.abs(Jt)>1||Math.abs(mt)>1)&&te(Math.abs(Jt)>Math.abs(mt)?"x":"y");let tn={x:0,y:0};const So=Hn=>1/(1.5+Math.abs(Hn)/20);if(J==="y"){if(en.includes("top")||en.includes("bottom"))if(en.includes("top")&&mt<0||en.includes("bottom")&&mt>0)tn.y=mt;else{const Hn=mt*So(mt);tn.y=Math.abs(Hn)0)tn.x=Jt;else{const Hn=Jt*So(Jt);tn.x=Math.abs(Hn)0||Math.abs(tn.y)>0)&&ge(!0),(Rt=Tt.current)==null||Rt.style.setProperty("--swipe-amount-x",`${tn.x}px`),(Gt=Tt.current)==null||Gt.style.setProperty("--swipe-amount-y",`${tn.y}px`)}},Tl&&!v.jsx&&Wt!=="loading"?ue.createElement("button",{"aria-label":Z,"data-disabled":Fs,"data-close-button":!0,onClick:Fs||!Vr?()=>{}:()=>{Qn(),v.onDismiss==null||v.onDismiss.call(v,v)},className:sr(O==null?void 0:O.closeButton,v==null||(o=v.classNames)==null?void 0:o.closeButton)},(Jn=$==null?void 0:$.close)!=null?Jn:RP):null,(Wt||v.icon||v.promise)&&v.icon!==null&&(($==null?void 0:$[Wt])!==null||v.icon)?ue.createElement("div",{"data-icon":"",className:sr(O==null?void 0:O.icon,v==null||(i=v.classNames)==null?void 0:i.icon)},v.promise||v.type==="loading"&&!v.icon?v.icon||yo():null,v.type!=="loading"?xo:null):null,ue.createElement("div",{"data-content":"",className:sr(O==null?void 0:O.content,v==null||(c=v.classNames)==null?void 0:c.content)},ue.createElement("div",{"data-title":"",className:sr(O==null?void 0:O.title,v==null||(d=v.classNames)==null?void 0:d.title)},v.jsx?v.jsx:typeof v.title=="function"?v.title():v.title),v.description?ue.createElement("div",{"data-description":"",className:sr(Q,_d,O==null?void 0:O.description,v==null||(m=v.classNames)==null?void 0:m.description)},typeof v.description=="function"?v.description():v.description):null),ue.isValidElement(v.cancel)?v.cancel:v.cancel&&tu(v.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:v.cancelButtonStyle||B,onClick:Re=>{tu(v.cancel)&&Vr&&(v.cancel.onClick==null||v.cancel.onClick.call(v.cancel,Re),Qn())},className:sr(O==null?void 0:O.cancelButton,v==null||(p=v.classNames)==null?void 0:p.cancelButton)},v.cancel.label):null,ue.isValidElement(v.action)?v.action:v.action&&tu(v.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:v.actionButtonStyle||H,onClick:Re=>{tu(v.action)&&(v.action.onClick==null||v.action.onClick.call(v.action,Re),!Re.defaultPrevented&&Qn())},className:sr(O==null?void 0:O.actionButton,v==null||(h=v.classNames)==null?void 0:h.actionButton)},v.action.label):null)};function u0(){if(typeof window>"u"||typeof document>"u")return"ltr";const e=document.documentElement.getAttribute("dir");return e==="auto"||!e?window.getComputedStyle(document.documentElement).direction:e}function YP(e,n){const a={};return[e,n].forEach((o,i)=>{const c=i===1,d=c?"--mobile-offset":"--offset",m=c?$P:IP;function p(h){["top","right","bottom","left"].forEach(y=>{a[`${d}-${y}`]=typeof h=="number"?`${h}px`:h})}typeof o=="number"||typeof o=="string"?p(o):typeof o=="object"?["top","right","bottom","left"].forEach(h=>{o[h]===void 0?a[`${d}-${h}`]=m:a[`${d}-${h}`]=typeof o[h]=="number"?`${o[h]}px`:o[h]}):p(m)}),a}const WP=ue.forwardRef(function(n,a){const{id:o,invert:i,position:c="bottom-right",hotkey:d=["altKey","KeyT"],expand:m,closeButton:p,className:h,offset:y,mobileOffset:v,theme:x="light",richColors:S,duration:j,style:C,visibleToasts:N=PP,toastOptions:E,dir:k=u0(),gap:T=UP,icons:R,containerAriaLabel:D="Notifications"}=n,[P,z]=ue.useState([]),B=ue.useMemo(()=>o?P.filter(U=>U.toasterId===o):P.filter(U=>!U.toasterId),[P,o]),H=ue.useMemo(()=>Array.from(new Set([c].concat(B.filter(U=>U.position).map(U=>U.position)))),[B,c]),[Y,Q]=ue.useState([]),[fe,de]=ue.useState(!1),[he,se]=ue.useState(!1),[O,$]=ue.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),Z=ue.useRef(null),J=d.join("+").replace(/Key/g,"").replace(/Digit/g,""),te=ue.useRef(null),M=ue.useRef(!1),_=ue.useCallback(U=>{z(V=>{var F;return(F=V.find(ae=>ae.id===U.id))!=null&&F.delete||un.dismiss(U.id),V.filter(({id:ae})=>ae!==U.id)})},[]);return ue.useEffect(()=>un.subscribe(U=>{if(U.dismiss){requestAnimationFrame(()=>{z(V=>V.map(F=>F.id===U.id?{...F,delete:!0}:F))});return}setTimeout(()=>{H0.flushSync(()=>{z(V=>{const F=V.findIndex(ae=>ae.id===U.id);return F!==-1?[...V.slice(0,F),{...V[F],...U},...V.slice(F+1)]:[U,...V]})})})}),[P]),ue.useEffect(()=>{if(x!=="system"){$(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?$("dark"):$("light")),typeof window>"u")return;const U=window.matchMedia("(prefers-color-scheme: dark)");try{U.addEventListener("change",({matches:V})=>{$(V?"dark":"light")})}catch{U.addListener(({matches:F})=>{try{$(F?"dark":"light")}catch(ae){console.error(ae)}})}},[x]),ue.useEffect(()=>{P.length<=1&&de(!1)},[P]),ue.useEffect(()=>{const U=V=>{var F;if(d.every(me=>V[me]||V.code===me)){var ne;de(!0),(ne=Z.current)==null||ne.focus()}V.code==="Escape"&&(document.activeElement===Z.current||(F=Z.current)!=null&&F.contains(document.activeElement))&&de(!1)};return document.addEventListener("keydown",U),()=>document.removeEventListener("keydown",U)},[d]),ue.useEffect(()=>{if(Z.current)return()=>{te.current&&(te.current.focus({preventScroll:!0}),te.current=null,M.current=!1)}},[Z.current]),ue.createElement("section",{ref:a,"aria-label":`${D} ${J}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},H.map((U,V)=>{var F;const[ae,ne]=U.split("-");return B.length?ue.createElement("ol",{key:U,dir:k==="auto"?u0():k,tabIndex:-1,ref:Z,className:h,"data-sonner-toaster":!0,"data-sonner-theme":O,"data-y-position":ae,"data-x-position":ne,style:{"--front-toast-height":`${((F=Y[0])==null?void 0:F.height)||0}px`,"--width":`${BP}px`,"--gap":`${T}px`,...C,...YP(y,v)},onBlur:me=>{M.current&&!me.currentTarget.contains(me.relatedTarget)&&(M.current=!1,te.current&&(te.current.focus({preventScroll:!0}),te.current=null))},onFocus:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||M.current||(M.current=!0,te.current=me.relatedTarget)},onMouseEnter:()=>de(!0),onMouseMove:()=>de(!0),onMouseLeave:()=>{he||de(!1)},onDragEnd:()=>de(!1),onPointerDown:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||se(!0)},onPointerUp:()=>se(!1)},B.filter(me=>!me.position&&V===0||me.position===U).map((me,pe)=>{var W,ie;return ue.createElement(FP,{key:me.id,icons:R,index:pe,toast:me,defaultRichColors:S,duration:(W=E==null?void 0:E.duration)!=null?W:j,className:E==null?void 0:E.className,descriptionClassName:E==null?void 0:E.descriptionClassName,invert:i,visibleToasts:N,closeButton:(ie=E==null?void 0:E.closeButton)!=null?ie:p,interacting:he,position:U,style:E==null?void 0:E.style,unstyled:E==null?void 0:E.unstyled,classNames:E==null?void 0:E.classNames,cancelButtonStyle:E==null?void 0:E.cancelButtonStyle,actionButtonStyle:E==null?void 0:E.actionButtonStyle,closeButtonAriaLabel:E==null?void 0:E.closeButtonAriaLabel,removeToast:_,toasts:B.filter(ge=>ge.position==me.position),heights:Y.filter(ge=>ge.position==me.position),setHeights:Q,expandByDefault:m,gap:T,expanded:fe,swipeDirections:n.swipeDirections})})):null}))});async function mu(e){const n=Dr.loading("Saving changes…");try{const a=await e();if(Dr.success("Changes saved",{id:n}),a.botRestart){const o=Dr.loading("Restarting bot…");a.botRestart.success?Dr.success("Bot started",{id:o}):Dr.error(a.botRestart.error??"Could not start bot",{id:o})}return a}catch(a){throw Dr.error(a instanceof Error?a.message:"Save failed",{id:n}),a}}function qP({filename:e}){const{canEditConfig:n}=Lt(),a=!n("supportbot"),[o,i]=f.useState(null),[c,d]=f.useState(null),[m,p]=f.useState(!0),[h,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),C=f.useCallback(async()=>{p(!0),x(""),j("");try{const D=(await Ne.getAddonConfigJson(e)).data??{};i(D),d(structuredClone(D))}catch(R){x(R instanceof Error?R.message:"Failed to load config")}finally{p(!1)}},[e]);f.useEffect(()=>{C()},[C]);const N=o?xP(o):null;function E(R,D){i(P=>P&&il(P,R,D))}async function k(){if(!(a||!o)){y(!0),x(""),j("");try{const R=await mu(()=>Ne.saveAddonConfig(e,o));j(R.message||"Saved."),await C()}catch(R){x(R instanceof Error?R.message:"Save failed")}finally{y(!1)}}}if(m)return l.jsxs("div",{className:"space-y-4",children:[l.jsx(Ve,{className:"h-24 w-full rounded-xl"}),l.jsx(Ve,{className:"h-48 w-full rounded-xl"})]});if(!o||!N)return l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v||"Failed to load"})});const T=c&&JSON.stringify(o)!==JSON.stringify(c);return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[T?l.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,l.jsx(ve,{variant:"outline",size:"sm",onClick:C,disabled:m||h,children:"Reload"}),a?l.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):l.jsxs(ve,{size:"sm",onClick:k,disabled:h||!T,children:[l.jsx(ye,{icon:Hu,size:16,className:"mr-1.5"}),h?"Saving…":"Save"]})]}),v?l.jsxs(Ye,{variant:"destructive",children:[l.jsx(ye,{icon:_h,size:18}),l.jsx(We,{children:v})]}):null,S?l.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:l.jsx(We,{children:S})}):null,N.map(R=>l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"pb-3",children:[l.jsx(Qe,{className:"text-base",children:R.title}),R.description?l.jsx(ht,{children:R.description}):null]}),l.jsx(Fe,{className:"grid gap-4 sm:grid-cols-2",children:R.fields.map(D=>l.jsx("div",{className:D.type==="textarea"||D.type==="stringList"?"sm:col-span-2":"",children:l.jsx(zg,{field:D,value:fo(o,D.path),readOnly:a,onChange:P=>E(D.path,P)})},D.path))})]},R.title))]})}function KP(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function XP(e,n){const a=new Set(e.flatMap(d=>d.fields.map(m=>m.path))),o=Ig(n).filter(d=>!a.has(d.path));if(o.length===0)return e;const i=new Map;for(const d of o){const m=d.path.split(".")[0]??"Other",p=i.get(m)??[];p.push(d),i.set(m,p)}const c=[...i.entries()].sort(([d],[m])=>d.localeCompare(m)).map(([d,m])=>({title:KP(d),description:"These options exist in your config file but are not in the main editor sections.",fields:m.sort((p,h)=>p.path.localeCompare(h.path))}));return[...e,...c]}function d0(e,n){(n==null||n>e.length)&&(n=e.length);for(var a=0,o=Array(n);a=e.length?e.apply(this,i):function(){for(var d=arguments.length,m=new Array(d),p=0;p1&&arguments[1]!==void 0?arguments[1]:{};nu.initial(e),nu.handler(n);var a={current:e},o=Vi(xI)(a,n),i=Vi(yI)(a),c=Vi(nu.changes)(e),d=Vi(bI)(a);function m(){var h=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(y){return y};return nu.selector(h),h(a.current)}function p(h){lI(o,i,c,d)(h)}return[m,p]}function bI(e,n){return ll(n)?n(e.current):n}function yI(e,n){return e.current=h0(h0({},e.current),n),n}function xI(e,n,a){return ll(n)?n(e.current):Object.keys(a).forEach(function(o){var i;return(i=n[o])===null||i===void 0?void 0:i.call(n,e.current[o])}),a}var SI={create:vI},wI={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function CI(e){return function n(){for(var a=this,o=arguments.length,i=new Array(o),c=0;c=e.length?e.apply(this,i):function(){for(var d=arguments.length,m=new Array(d),p=0;p{o.current=!1}:e,n)}var xn=KI;function qi(){}function ms(e,n,a,o){return XI(e,o)||ZI(e,n,a,o)}function XI(e,n){return e.editor.getModel(Y5(e,n))}function ZI(e,n,a,o){return e.editor.createModel(n,a,o?Y5(e,o):void 0)}function Y5(e,n){return e.Uri.parse(n)}function QI({original:e,modified:n,language:a,originalLanguage:o,modifiedLanguage:i,originalModelPath:c,modifiedModelPath:d,keepCurrentOriginalModel:m=!1,keepCurrentModifiedModel:p=!1,theme:h="light",loading:y="Loading...",options:v={},height:x="100%",width:S="100%",className:j,wrapperProps:C={},beforeMount:N=qi,onMount:E=qi}){let[k,T]=f.useState(!1),[R,D]=f.useState(!0),P=f.useRef(null),z=f.useRef(null),B=f.useRef(null),H=f.useRef(E),Y=f.useRef(N),Q=f.useRef(!1);F5(()=>{let se=V5.init();return se.then(O=>(z.current=O)&&D(!1)).catch(O=>(O==null?void 0:O.type)!=="cancelation"&&console.error("Monaco initialization: error:",O)),()=>P.current?he():se.cancel()}),xn(()=>{if(P.current&&z.current){let se=P.current.getOriginalEditor(),O=ms(z.current,e||"",o||a||"text",c||"");O!==se.getModel()&&se.setModel(O)}},[c],k),xn(()=>{if(P.current&&z.current){let se=P.current.getModifiedEditor(),O=ms(z.current,n||"",i||a||"text",d||"");O!==se.getModel()&&se.setModel(O)}},[d],k),xn(()=>{let se=P.current.getModifiedEditor();se.getOption(z.current.editor.EditorOption.readOnly)?se.setValue(n||""):n!==se.getValue()&&(se.executeEdits("",[{range:se.getModel().getFullModelRange(),text:n||"",forceMoveMarkers:!0}]),se.pushUndoStop())},[n],k),xn(()=>{var se,O;(O=(se=P.current)==null?void 0:se.getModel())==null||O.original.setValue(e||"")},[e],k),xn(()=>{let{original:se,modified:O}=P.current.getModel();z.current.editor.setModelLanguage(se,o||a||"text"),z.current.editor.setModelLanguage(O,i||a||"text")},[a,o,i],k),xn(()=>{var se;(se=z.current)==null||se.editor.setTheme(h)},[h],k),xn(()=>{var se;(se=P.current)==null||se.updateOptions(v)},[v],k);let fe=f.useCallback(()=>{var $;if(!z.current)return;Y.current(z.current);let se=ms(z.current,e||"",o||a||"text",c||""),O=ms(z.current,n||"",i||a||"text",d||"");($=P.current)==null||$.setModel({original:se,modified:O})},[a,n,i,e,o,c,d]),de=f.useCallback(()=>{var se;!Q.current&&B.current&&(P.current=z.current.editor.createDiffEditor(B.current,{automaticLayout:!0,...v}),fe(),(se=z.current)==null||se.editor.setTheme(h),T(!0),Q.current=!0)},[v,h,fe]);f.useEffect(()=>{k&&H.current(P.current,z.current)},[k]),f.useEffect(()=>{!R&&!k&&de()},[R,k,de]);function he(){var O,$,Z,J;let se=(O=P.current)==null?void 0:O.getModel();m||(($=se==null?void 0:se.original)==null||$.dispose()),p||((Z=se==null?void 0:se.modified)==null||Z.dispose()),(J=P.current)==null||J.dispose()}return ue.createElement(G5,{width:S,height:x,isEditorReady:k,loading:y,_ref:B,className:j,wrapperProps:C})}var JI=QI;f.memo(JI);function e$(e){let n=f.useRef();return f.useEffect(()=>{n.current=e},[e]),n.current}var t$=e$,ru=new Map;function n$({defaultValue:e,defaultLanguage:n,defaultPath:a,value:o,language:i,path:c,theme:d="light",line:m,loading:p="Loading...",options:h={},overrideServices:y={},saveViewState:v=!0,keepCurrentModel:x=!1,width:S="100%",height:j="100%",className:C,wrapperProps:N={},beforeMount:E=qi,onMount:k=qi,onChange:T,onValidate:R=qi}){let[D,P]=f.useState(!1),[z,B]=f.useState(!0),H=f.useRef(null),Y=f.useRef(null),Q=f.useRef(null),fe=f.useRef(k),de=f.useRef(E),he=f.useRef(),se=f.useRef(o),O=t$(c),$=f.useRef(!1),Z=f.useRef(!1);F5(()=>{let M=V5.init();return M.then(_=>(H.current=_)&&B(!1)).catch(_=>(_==null?void 0:_.type)!=="cancelation"&&console.error("Monaco initialization: error:",_)),()=>Y.current?te():M.cancel()}),xn(()=>{var _,U,V,F;let M=ms(H.current,e||o||"",n||i||"",c||a||"");M!==((_=Y.current)==null?void 0:_.getModel())&&(v&&ru.set(O,(U=Y.current)==null?void 0:U.saveViewState()),(V=Y.current)==null||V.setModel(M),v&&((F=Y.current)==null||F.restoreViewState(ru.get(c))))},[c],D),xn(()=>{var M;(M=Y.current)==null||M.updateOptions(h)},[h],D),xn(()=>{!Y.current||o===void 0||(Y.current.getOption(H.current.editor.EditorOption.readOnly)?Y.current.setValue(o):o!==Y.current.getValue()&&(Z.current=!0,Y.current.executeEdits("",[{range:Y.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),Y.current.pushUndoStop(),Z.current=!1))},[o],D),xn(()=>{var _,U;let M=(_=Y.current)==null?void 0:_.getModel();M&&i&&((U=H.current)==null||U.editor.setModelLanguage(M,i))},[i],D),xn(()=>{var M;m!==void 0&&((M=Y.current)==null||M.revealLine(m))},[m],D),xn(()=>{var M;(M=H.current)==null||M.editor.setTheme(d)},[d],D);let J=f.useCallback(()=>{var M;if(!(!Q.current||!H.current)&&!$.current){de.current(H.current);let _=c||a,U=ms(H.current,o||e||"",n||i||"",_||"");Y.current=(M=H.current)==null?void 0:M.editor.create(Q.current,{model:U,automaticLayout:!0,...h},y),v&&Y.current.restoreViewState(ru.get(_)),H.current.editor.setTheme(d),m!==void 0&&Y.current.revealLine(m),P(!0),$.current=!0}},[e,n,a,o,i,c,h,y,v,d,m]);f.useEffect(()=>{D&&fe.current(Y.current,H.current)},[D]),f.useEffect(()=>{!z&&!D&&J()},[z,D,J]),se.current=o,f.useEffect(()=>{var M,_;D&&T&&((M=he.current)==null||M.dispose(),he.current=(_=Y.current)==null?void 0:_.onDidChangeModelContent(U=>{Z.current||T(Y.current.getValue(),U)}))},[D,T]),f.useEffect(()=>{if(D){let M=H.current.editor.onDidChangeMarkers(_=>{var V;let U=(V=Y.current.getModel())==null?void 0:V.uri;if(U&&_.find(F=>F.path===U.path)){let F=H.current.editor.getModelMarkers({resource:U});R==null||R(F)}});return()=>{M==null||M.dispose()}}return()=>{}},[D,R]);function te(){var M,_;(M=he.current)==null||M.dispose(),x?v&&ru.set(c,Y.current.saveViewState()):(_=Y.current.getModel())==null||_.dispose(),Y.current.dispose()}return ue.createElement(G5,{width:S,height:j,isEditorReady:D,loading:p,_ref:Q,className:C,wrapperProps:N})}var r$=n$,a$=f.memo(r$),o$=a$;function s$(e){return e!==null&&typeof e=="object"&&"Command"in e}function i$(e){return Object.entries(e).filter(([,n])=>s$(n)).map(([n,a])=>({key:n,...a}))}function l$({data:e,onChange:n}){const a=i$(e);function o(i,c){const d=e[i];n({...e,[i]:{...d,...c}})}return a.length===0?l.jsx("p",{className:"text-sm text-muted-foreground",children:"No commands found in this config."}):l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(i=>l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"flex flex-row items-center gap-2 space-y-0 pb-2",children:[l.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-primary/15 text-primary",children:l.jsx(ye,{icon:xa,size:18})}),l.jsx(Qe,{className:"text-base",children:i.key})]}),l.jsxs(Fe,{className:"space-y-3",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx(De,{htmlFor:`${i.key}-enabled`,children:"Enabled"}),l.jsx(dn,{id:`${i.key}-enabled`,checked:i.Enabled!==!1,onCheckedChange:c=>o(i.key,{Enabled:c})})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(De,{children:"Slash command"}),l.jsx(Ue,{value:i.Command??"",onChange:c=>o(i.key,{Command:c.target.value}),className:"border-border bg-secondary/30 font-mono"})]}),l.jsxs("div",{className:"space-y-1.5",children:[l.jsx(De,{children:"Description"}),l.jsx(Ue,{value:i.Description??"",onChange:c=>o(i.key,{Description:c.target.value}),className:"border-border bg-secondary/30"})]})]})]},i.key))})}function c$(e,n){let a=structuredClone(n);if(e==="supportbot"){const o=fo(a,"General.Token");o&&o!=="BOT_TOKEN"&&(a=il(a,"General.Token","BOT_TOKEN"))}if(e==="supportbot-ai"){const o=fo(a,"General.Model_API_Key");o&&o!=="MODEL_API_KEY"&&(a=il(a,"General.Model_API_Key","MODEL_API_KEY"))}return a}function u$(e,n,a,o){const i={};for(const c of n)for(const d of c.fields){const m=fo(a,d.path),p=fo(o,d.path);d.type==="secret"&&(m==="BOT_TOKEN"||m==="MODEL_API_KEY"||m===""||m===void 0)||JSON.stringify(m)!==JSON.stringify(p)&&(i[`${e}:${d.path}`]=m)}return i}function d$({configFile:e}){const{canEditConfig:n}=Lt(),a=!n(e),[o,i]=f.useState(null),[c,d]=f.useState(null),[m,p]=f.useState(!0),[h,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState("visual"),[E,k]=f.useState(""),[T,R]=f.useState(""),[D]=$u(),[P,z]=f.useState(()=>D.get("tab")||null),B=C_(e),H=f.useMemo(()=>!B||B==="commands"||!o?B:XP(B,o),[B,o]);f.useEffect(()=>{var $;if(H&&H!=="commands"){const Z=D.get("tab");if(Z&&H.find(J=>J.title.toLowerCase()===Z.toLowerCase())){const J=H.find(te=>te.title.toLowerCase()===Z.toLowerCase());J&&J.title!==P&&z(J.title)}else(!P||!H.find(J=>J.title===P))&&z((($=H[0])==null?void 0:$.title)||null)}},[H,P,D]);const Y=f.useCallback(async()=>{p(!0),x(""),j("");try{const Z=(await Ne.getConfigJson(e)).data??{},J=c$(e,Z);i(J),d(J);const M=(await Ne.getConfigRaw(e)).data??"",_=m8(M,e);k(_),R(_)}catch($){x($ instanceof Error?$.message:"Failed to load config")}finally{p(!1)}},[e]);f.useEffect(()=>{Y()},[Y]);function Q($,Z){i(J=>J&&il(J,$,Z))}async function fe(){if(!(a||E===T)){y(!0),x(""),j("");try{const $=await mu(()=>Ne.saveConfigRaw(e,E));j($.message||"Config saved."),await Y()}catch($){x($ instanceof Error?$.message:"Save failed")}finally{y(!1)}}}async function de(){if(!(a||!o||!c)){if(C==="yaml"){await fe();return}y(!0),x(""),j("");try{if(B==="commands"){const $={};for(const J of Object.keys(o))JSON.stringify(o[J])!==JSON.stringify(c[J])&&($[`${e}:${J}`]=o[J]);if(Object.keys($).length===0){j("No changes to save.");return}const Z=await mu(()=>Ne.updateConfigFields($));j(Z.message||"")}else if(H&&H!=="commands"){const $=u$(e,H,o,c);if(Object.keys($).length===0){j("No changes to save.");return}const Z=await mu(()=>Ne.updateConfigFields($));j(Z.message||"")}await Y()}catch($){x($ instanceof Error?$.message:"Save failed")}finally{y(!1)}}}if(B===null)return l.jsx(Ye,{children:l.jsx(We,{children:"No visual editor available for this file."})});if(m)return l.jsxs("div",{className:"space-y-4",children:[l.jsx(Ve,{className:"h-24 w-full rounded-xl"}),l.jsx(Ve,{className:"h-48 w-full rounded-xl"})]});if(!o)return l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v||"Failed to load"})});const he=c&&JSON.stringify(o)!==JSON.stringify(c),O=C==="yaml"?E!==T:he;return l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[l.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[l.jsx(ve,{type:"button",variant:C==="visual"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("visual"),children:"Visual"}),l.jsx(ve,{type:"button",variant:C==="yaml"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("yaml"),children:"YAML"})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[O?l.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,l.jsx(ve,{variant:"outline",size:"sm",onClick:Y,disabled:m||h,children:"Reload"}),a?l.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):l.jsxs(ve,{size:"sm",onClick:de,disabled:h||!O,children:[l.jsx(ye,{icon:Hu,size:16,className:"mr-1.5"}),h?"Saving…":"Save"]})]})]}),v?l.jsxs(Ye,{variant:"destructive",children:[l.jsx(ye,{icon:_h,size:18}),l.jsx(We,{children:v})]}):null,S?l.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:l.jsx(We,{children:S})}):null,C==="yaml"?l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"pb-3",children:[l.jsx(Qe,{className:"text-base",children:"Raw YAML"}),l.jsx(ht,{children:"Edit the full file. Use this for nested lists (e.g. welcome buttons) or any option not in Visual mode."})]}),l.jsx(Fe,{className:"h-[min(520px,60vh)] overflow-hidden rounded-b-xl border-t border-border p-0",children:l.jsx(o$,{height:"100%",language:"yaml",theme:"vs-dark",value:E,onChange:$=>k($||""),options:{readOnly:a,minimap:{enabled:!1},fontSize:13,wordWrap:"on",scrollBeyondLastLine:!1,padding:{top:16},tabSize:2}})})]}):B==="commands"?l.jsx(l$,{data:o,onChange:$=>i($)}):H&&H!=="commands"?l.jsxs("div",{className:"grid gap-6 lg:grid-cols-[200px_1fr]",children:[l.jsx("nav",{className:"flex flex-col gap-1",children:H.map($=>l.jsx("button",{onClick:()=>z($.title),className:ce("text-left px-3 py-2 text-sm rounded-md transition-colors",P===$.title?"bg-primary text-primary-foreground font-medium":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:$.title},$.title))}),l.jsx("div",{className:"min-w-0",children:H.filter($=>$.title===P).map($=>l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"pb-3",children:[l.jsx(Qe,{className:"text-base",children:$.title}),$.description?l.jsx(ht,{children:$.description}):null]}),l.jsx(Fe,{className:"grid gap-4 sm:grid-cols-2",children:$.fields.map(Z=>l.jsx("div",{className:Z.type==="textarea"||Z.type==="stringList"?"sm:col-span-2":"",children:l.jsx(zg,{field:Z,value:fo(o,Z.path),readOnly:a,onChange:J=>Q(Z.path,J)})},Z.path))})]},$.title))})]}):null]})}const f$=Ne.listConfigs(),m$={supportbot:"Bot config","ticket-panel":"Ticket panel",commands:"Commands",messages:"Messages","supportbot-ai":"AI assistant"};function p$(){var T,R;const{permissions:e,canViewConfig:n}=Lt(),{files:a}=t2(),[o,i]=$u(),c=o.get("file"),d=n("supportbot"),m=f.useMemo(()=>f$.filter(D=>n(D)),[n]),p=f.useMemo(()=>d?a:[],[d,a]),h=f.useMemo(()=>[...m,...p.map(D=>Gi(D))],[m,p]),y=h[0]??"",[v,x]=f.useState(()=>c&&h.includes(c)?c:y);if(f.useEffect(()=>{c&&h.includes(c)?x(c):h.includes(v)||(x(y),y&&i({file:y}))},[c,h,v,y,i]),h.length===0)return l.jsx(Lr,{to:Bh(e),replace:!0});const S=S8(v),j=(S==null?void 0:S.type)==="addon",C=j?S.file:null,N=j?n2(C):m$[v]??"Configuration",E=j?!!((T=e==null?void 0:e.configs.supportbot)!=null&&T.edit):e?!!((R=e.configs[v])!=null&&R.edit):!1,k=j?C:`${v}.yml`;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:N}),l.jsx("p",{className:"text-muted-foreground",children:E?`Edit ${k} — changes apply to the running bot without restarting the dashboard.`:`Viewing ${k} — you do not have permission to save changes.`})]}),l.jsx("div",{className:"mt-6",children:j&&C?l.jsx(qP,{filename:C},C):l.jsx(d$,{configFile:v},v)})]})}const h$={oauth_not_configured:"Discord OAuth is not configured. Complete setup at /setup first.",not_allowed:"Your Discord account is not allowed. Ask an owner to add you under Users, or add your ID to OwnerUserIds in Configs/api.yml.",invalid_state:"Login session expired. Please try again.",missing_code:"Discord did not return an authorization code. Please try again.",oauth_failed:"Could not complete Discord sign-in. Check your OAuth settings.",access_denied:"You cancelled Discord sign-in."};function g$(e){return e?h$[e]||"Sign-in failed. Please try again.":""}function v$(){const{branding:e}=Fu(),{isAuthenticated:n,loading:a,loginWithDiscord:o}=Lt(),[i]=$u(),c=f.useMemo(()=>g$(i.get("error")),[i]);return!a&&n?l.jsx(Lr,{to:"/",replace:!0}):l.jsx("div",{className:"relative flex min-h-svh items-center justify-center bg-[#0c0c10] p-4 overflow-hidden",children:l.jsxs(Ge,{className:"relative z-10 w-full max-w-md overflow-hidden rounded-3xl border border-white/10 bg-card/30 p-2 shadow-2xl backdrop-blur-2xl",children:[l.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-white/5 to-transparent pointer-events-none"}),l.jsxs(Ze,{className:"space-y-6 pt-10 pb-4 text-center",children:[l.jsx("div",{className:"mx-auto flex size-28 items-center justify-center overflow-hidden rounded-3xl bg-white/5 p-4 shadow-inner ring-1 ring-white/10 transition-transform duration-500 hover:scale-105",children:l.jsx("img",{src:"/logo.png",alt:"SupportBot Logo",className:"h-full w-full object-contain drop-shadow-xl"})}),l.jsxs("div",{children:[l.jsx(Qe,{className:"bg-gradient-to-br from-white to-white/50 bg-clip-text text-3xl font-extrabold tracking-tight text-transparent",children:e.title||"SupportBot"}),l.jsx(ht,{className:"mt-2 text-base font-medium text-white/50",children:"Sign in to your dashboard"})]})]}),l.jsxs(Fe,{className:"space-y-6 pb-10",children:[l.jsxs("div",{className:"text-center space-y-1",children:[l.jsx("p",{className:"text-sm font-medium text-white/50",children:"Securely authenticate using your Discord account."}),l.jsxs("p",{className:"text-xs text-white/30",children:["Credentials are configured in ",l.jsx("code",{className:"rounded bg-white/5 px-1 py-0.5 text-white/40",children:"Configs/api.yml"})]})]}),c?l.jsx(Ye,{variant:"destructive",className:"border-red-500/50 bg-red-500/10 text-red-200 backdrop-blur-md",children:l.jsx(We,{className:"font-medium",children:c})}):null,l.jsxs(ve,{type:"button",className:"group relative w-full overflow-hidden rounded-2xl bg-primary px-8 py-6 text-base font-bold text-primary-foreground shadow-[0_0_20px_rgba(var(--primary),0.3)] transition-all duration-300 hover:scale-[1.02] hover:shadow-[0_0_30px_rgba(var(--primary),0.5)] active:scale-95",disabled:a,onClick:o,children:[l.jsx("div",{className:"absolute inset-0 translate-x-[-100%] bg-gradient-to-r from-transparent via-white/20 to-transparent transition-transform duration-1000 group-hover:translate-x-[100%]"}),l.jsxs("span",{className:"relative flex items-center justify-center gap-2",children:[l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 127.14 96.36",fill:"currentColor",children:l.jsx("path",{d:"M107.7,8.07A105.15,105.15,0,0,0,81.47,0a72.06,72.06,0,0,0-3.36,6.83A97.68,97.68,0,0,0,49,6.83,72.37,72.37,0,0,0,45.64,0,105.89,105.89,0,0,0,19.39,8.09C2.79,32.65-1.71,56.6.54,80.21h0A105.73,105.73,0,0,0,32.71,96.36,77.7,77.7,0,0,0,39.6,85.25a68.42,68.42,0,0,1-10.85-5.18c.91-.66,1.8-1.34,2.66-2a75.57,75.57,0,0,0,64.32,0c.87.71,1.76,1.39,2.66,2a68.68,68.68,0,0,1-10.87,5.19,77,77,0,0,0,6.89,11.1,105.25,105.25,0,0,0,32.19-16.14c2.64-27.38-4.51-51.11-19.32-72.15ZM42.68,68.22c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C52.34,63.32,48.09,68.22,42.68,68.22Zm41.76,0c-5.28,0-9.66-4.9-9.66-10.89s4.29-10.89,9.66-10.89c5.41,0,9.75,4.9,9.66,10.89C84.44,63.32,80.19,68.22,84.44,68.22Z"})}),a?"Authenticating...":"Continue with Discord"]})]})]})]})})}const bs=[{id:"botToken",title:"Bot token",subtitle:"Connect your Discord bot",icon:Dh},{id:"secretKey",title:"Session secret",subtitle:"Secure dashboard logins",icon:u8},{id:"oauth",title:"Discord OAuth",subtitle:"Sign in with Discord",icon:Xx},{id:"redirectUri",title:"Redirect URL",subtitle:"OAuth callback address",icon:Vu},{id:"owners",title:"Dashboard owners",subtitle:"Who can access this panel",icon:Pp},{id:"emeraldApi",title:"Emerald API",subtitle:"One-click addons",icon:Xx}];function b$(e){return e==="oauth"?"oauth":e==="owners"?"owners":e}function y$({brandingTitle:e,faviconUrl:n,faviconVersion:a,hasFavicon:o,children:i}){return l.jsx("div",{className:"min-h-svh bg-background",children:l.jsxs("div",{className:"mx-auto flex min-h-svh max-w-6xl flex-col px-4 py-6 md:px-8 md:py-10",children:[l.jsxs("header",{className:"mb-8 flex items-center gap-4",children:[o&&n?l.jsx("img",{src:`${n}${a?`?v=${a}`:""}`,alt:"",className:"size-12 rounded-2xl border border-border object-contain"}):l.jsx("div",{className:"flex size-12 items-center justify-center rounded-2xl border border-border bg-primary text-primary-foreground",children:l.jsx(ye,{icon:Dh,size:24})}),l.jsxs("div",{children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"First-time setup"}),l.jsx("h1",{className:"text-2xl font-semibold tracking-tight md:text-3xl",children:e})]})]}),i]})})}function x$({currentIndex:e,validation:n}){const a=(e+1)/bs.length*100;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[l.jsxs("span",{children:["Step ",e+1," of ",bs.length]}),l.jsxs("span",{children:[Math.round(a),"%"]})]}),l.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-secondary",children:l.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300 ease-out",style:{width:`${a}%`}})})]}),l.jsx("nav",{className:"hidden space-y-1 md:block","aria-label":"Setup steps",children:bs.map((o,i)=>{var h;const c=b$(o.id),d=(h=n[c])==null?void 0:h.ok,m=i===e,p=il.jsxs("li",{className:"flex items-center gap-2",children:[l.jsx(ye,{icon:Bu,size:14}),o.globalName||o.username,l.jsx("span",{className:"font-mono text-xs opacity-80",children:o.id})]},o.id))}):null,!e.bot&&!((a=e.users)!=null&&a.length)?l.jsx("p",{children:e.warning||"Verified successfully."}):null]})}):l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:e.error})}):null}function w$({values:e,setValues:n,validation:a,validating:o,onValidate:i}){return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Open the"," ",l.jsx("a",{href:"https://discord.com/developers/applications",target:"_blank",rel:"noreferrer",className:"font-medium text-primary hover:underline",children:"Discord Developer Portal"}),", select your application, go to ",l.jsx("strong",{children:"Bot"}),", and reset or copy the token."]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"botToken",children:"Bot token"}),l.jsx(Ue,{id:"botToken",type:"password",autoComplete:"off",value:e.botToken,onChange:c=>n({...e,botToken:c.target.value}),placeholder:"MTI…",className:"h-11 font-mono text-sm"})]}),l.jsx(Us,{result:a.botToken}),l.jsx("div",{className:"mt-auto",children:l.jsx(ve,{type:"button",variant:"secondary",disabled:o||!e.botToken,onClick:i,children:o?"Checking with Discord…":"Verify bot token"})})]})}function C$({values:e,setValues:n,validation:a,validating:o,onValidate:i,onGenerate:c}){return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsx("p",{className:"text-sm leading-relaxed text-muted-foreground",children:"This random string signs your login cookies. Store it like a password — do not commit it to public repos."}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"secretKey",children:"Session secret"}),l.jsx(Ue,{id:"secretKey",type:"password",autoComplete:"off",value:e.secretKey,onChange:d=>n({...e,secretKey:d.target.value}),className:"h-11 font-mono text-sm"})]}),l.jsx(Us,{result:a.secretKey}),l.jsxs("div",{className:"mt-auto flex flex-wrap gap-2",children:[l.jsx(ve,{type:"button",variant:"outline",onClick:c,children:"Generate secure secret"}),l.jsx(ve,{type:"button",variant:"secondary",disabled:o||!e.secretKey,onClick:i,children:o?"Checking…":"Validate"})]})]})}function j$({values:e,setValues:n,validation:a,validating:o,onValidate:i}){return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Use the ",l.jsx("strong",{children:"same application"})," as your bot. Under OAuth2, copy the Client ID and Client Secret."]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[l.jsx(De,{htmlFor:"clientId",children:"Client ID"}),l.jsx(Ue,{id:"clientId",value:e.clientId,onChange:c=>n({...e,clientId:c.target.value}),className:"h-11 font-mono text-sm"})]}),l.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[l.jsx(De,{htmlFor:"clientSecret",children:"Client Secret"}),l.jsx(Ue,{id:"clientSecret",type:"password",autoComplete:"off",value:e.clientSecret,onChange:c=>n({...e,clientSecret:c.target.value}),className:"h-11 font-mono text-sm"})]})]}),l.jsx(Us,{result:a.oauth}),l.jsx("div",{className:"mt-auto",children:l.jsx(ve,{type:"button",variant:"secondary",disabled:o||!e.clientId||!e.clientSecret,onClick:i,children:o?"Checking with Discord…":"Verify OAuth credentials"})})]})}function E$({values:e,setValues:n,validation:a}){async function o(){if(e.redirectUri)try{await navigator.clipboard.writeText(e.redirectUri)}catch{}}return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Add this exact URL under ",l.jsx("strong",{children:"OAuth2 → Redirects"})," in the Developer Portal. It must match character-for-character."]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"redirectUri",children:"Redirect URI"}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(Ue,{id:"redirectUri",value:e.redirectUri,onChange:i=>n({...e,redirectUri:i.target.value}),className:"h-11 flex-1 font-mono text-xs"}),l.jsx(ve,{type:"button",variant:"outline",size:"icon",className:"size-11 shrink-0",onClick:()=>void o(),title:"Copy URL",children:l.jsx(ye,{icon:Y0,size:18})})]})]}),a.redirectUri&&!a.redirectUri.ok?l.jsx(Us,{result:a.redirectUri}):l.jsx(Ye,{className:"border-border bg-secondary",children:l.jsx(We,{className:"text-sm text-muted-foreground",children:"We pre-filled this from your current dashboard URL. If you access the panel from a different domain later, update this and add the new URL in Discord too."})})]})}function N$({values:e,setValues:n,validation:a,validating:o,onValidate:i}){return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Enable ",l.jsx("strong",{children:"Developer Mode"})," in Discord (Settings → Advanced), then right-click your profile and ",l.jsx("strong",{children:"Copy User ID"}),". Add one ID per line."]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"owners",children:"Owner user IDs"}),l.jsx(Cd,{id:"owners",value:e.ownerUserIds,onChange:c=>n({...e,ownerUserIds:c.target.value}),placeholder:`829112572816130058 987654321098765432`,className:"min-h-[120px] font-mono text-sm"})]}),l.jsx(Us,{result:a.owners}),l.jsx("div",{className:"mt-auto",children:l.jsx(ve,{type:"button",variant:"secondary",disabled:o||!e.ownerUserIds.trim(),onClick:i,children:o?"Checking with Discord…":"Verify owner IDs"})})]})}function k$({onContinue:e}){return l.jsx("div",{className:"mx-auto flex w-full max-w-lg flex-1 flex-col justify-center py-8",children:l.jsxs("div",{className:"rounded-2xl border border-border bg-card px-6 py-10 text-center md:px-10",children:[l.jsx("div",{className:"mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:l.jsx(ye,{icon:Bu,size:40})}),l.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Setup complete"}),l.jsxs("p",{className:"mx-auto mt-3 max-w-sm text-sm leading-relaxed text-muted-foreground",children:["Your configuration has been saved. Restart the server for changes to take effect — stop the running process, then start it again (for example"," ",l.jsx("code",{className:"rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm start"}),")."]}),l.jsx(Ye,{className:"mt-6 text-left",children:l.jsx(We,{children:"After restarting, sign in with Discord to open the dashboard."})}),l.jsx(ve,{type:"button",size:"lg",className:"mt-8 min-w-[220px]",onClick:e,children:"Continue to sign in"})]})})}function T$({currentIndex:e,validating:n,saving:a,onBack:o,onNext:i,onFinish:c}){const d=e===bs.length-1;return l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs(ve,{type:"button",variant:"ghost",disabled:e===0||a,onClick:o,children:[l.jsx(ye,{icon:G0,size:18,className:"mr-1"}),"Back"]}),l.jsx("div",{className:"flex flex-1 justify-end gap-2",children:d?l.jsx(ve,{type:"button",size:"lg",disabled:a||n,onClick:c,className:"min-w-[200px]",children:a?"Saving…":"Finish setup"}):l.jsxs(ve,{type:"button",size:"lg",disabled:n||a,onClick:i,children:["Continue",l.jsx(ye,{icon:Oh,size:18,className:"ml-1"})]})})]})}function R$({values:e,setValues:n,validation:a,validating:o,onValidate:i}){return l.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[l.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["An Emerald Services API key is optional, but required to use the one-click addon installer in the dashboard. You can get yours from the"," ",l.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"font-medium text-primary hover:underline",children:"Emerald Services Marketplace"}),"."]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"emeraldApiKey",children:"Emerald API key (Optional)"}),l.jsx(Ue,{id:"emeraldApiKey",type:"password",autoComplete:"off",value:e.emeraldApiKey,onChange:c=>n({...e,emeraldApiKey:c.target.value}),placeholder:"em_...",className:"h-11 font-mono text-sm"})]}),l.jsx(Us,{result:a.emeraldApi}),l.jsx("div",{className:"mt-auto",children:l.jsx(ve,{type:"button",variant:"secondary",disabled:o,onClick:i,children:o?"Checking…":e.emeraldApiKey?"Verify key":"Skip step"})})]})}function A$(){const e=crypto.randomUUID().replace(/-/g,""),n=crypto.randomUUID().replace(/-/g,"");return e+n}function M$(e){return e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean)}function v0(e){return e==="oauth"?"oauth":e==="owners"?"owners":e==="emeraldApi"?"emeraldApi":e}function _$(){const e=mo(),{branding:n}=Fu(),{loading:a,error:o,refresh:i,status:c}=GC(),[d,m]=f.useState(0),[p,h]=f.useState({botToken:"",secretKey:"",clientId:"",clientSecret:"",redirectUri:"",ownerUserIds:"",emeraldApiKey:""}),[y,v]=f.useState({}),[x,S]=f.useState(!1),[j,C]=f.useState(!1),[N,E]=f.useState(""),[k,T]=f.useState(!1),R=bs[d];f.useEffect(()=>{c!=null&&c.suggestedRedirectUri&&!p.redirectUri&&h(Q=>({...Q,redirectUri:c.suggestedRedirectUri}))},[c==null?void 0:c.suggestedRedirectUri,p.redirectUri]);const D=f.useMemo(()=>({botToken:p.botToken,secretKey:p.secretKey,clientId:p.clientId,clientSecret:p.clientSecret,redirectUri:p.redirectUri,ownerUserIds:M$(p.ownerUserIds),emeraldApiKey:p.emeraldApiKey}),[p]);async function P(){S(!0),E("");try{const Q=await Ne.validateSetup(D);return v(fe=>{var de;return{...fe,...(de=Q.data)==null?void 0:de.results}}),Q.data}catch(Q){return E(Q instanceof Error?Q.message:"Validation failed"),null}finally{S(!1)}}async function z(){var de,he;const Q=v0(R.id),fe=await P();return!!((he=(de=fe==null?void 0:fe.results)==null?void 0:de[Q])!=null&&he.ok)}async function B(){const Q=v0(R.id),fe=y[Q];!(fe!=null&&fe.ok)&&!await z()||m(de=>Math.min(de+1,bs.length-1))}async function H(){C(!0),E("");try{const Q=await P();if(!(Q!=null&&Q.ok)){E("Fix the steps marked with errors before finishing.");return}await Ne.completeSetup(D),T(!0)}catch(Q){E(Q instanceof Error?Q.message:"Could not save setup")}finally{C(!1)}}function Y(){const Q={values:p,setValues:h,validation:y,validating:x};switch(R.id){case"botToken":return l.jsx(w$,{...Q,onValidate:()=>void z()});case"secretKey":return l.jsx(C$,{...Q,onGenerate:()=>h(fe=>({...fe,secretKey:A$()})),onValidate:()=>void z()});case"oauth":return l.jsx(j$,{...Q,onValidate:()=>void z()});case"redirectUri":return l.jsx(E$,{values:p,setValues:h,validation:y});case"owners":return l.jsx(N$,{...Q,onValidate:()=>void z()});case"emeraldApi":return l.jsx(R$,{...Q,onValidate:()=>void z()})}}return a?l.jsx("div",{className:"min-h-svh bg-background px-4 py-10",children:l.jsxs("div",{className:"mx-auto max-w-6xl space-y-8",children:[l.jsx(Ve,{className:"h-14 w-64"}),l.jsxs("div",{className:"grid gap-8 lg:grid-cols-[280px_1fr]",children:[l.jsx(Ve,{className:"hidden h-80 lg:block"}),l.jsx(Ve,{className:"h-[520px] rounded-2xl"})]})]})}):l.jsxs(y$,{brandingTitle:n.title,faviconUrl:n.faviconUrl,faviconVersion:n.updatedAt??void 0,hasFavicon:n.hasFavicon,children:[o?l.jsx(Ye,{variant:"destructive",className:"mb-6",children:l.jsx(We,{children:o})}):null,N?l.jsx(Ye,{variant:"destructive",className:"mb-6",children:l.jsx(We,{children:N})}):null,k?l.jsx(k$,{onContinue:async()=>{await i(),e("/login",{replace:!0})}}):l.jsxs("div",{className:"grid flex-1 gap-8 lg:grid-cols-[minmax(0,280px)_1fr]",children:[l.jsx(x$,{currentIndex:d,validation:y}),l.jsx(S$,{step:R,footer:l.jsx(T$,{currentIndex:d,validating:x,saving:j,onBack:()=>m(Q=>Math.max(0,Q-1)),onNext:()=>void B(),onFinish:()=>void H()}),children:Y()})]})]})}const O$={todo:"bg-rose-500/15 text-rose-400",progress:"bg-amber-500/15 text-amber-400",done:"bg-emerald-500/15 text-emerald-400"};function D$({title:e,icon:n,href:a,badge:o="Configured",status:i="done"}){return l.jsxs(_t,{to:a,className:ce("flex items-center gap-3 rounded-2xl border border-border bg-card p-4 transition-colors","hover:border-primary hover:bg-secondary"),children:[l.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-full bg-secondary text-primary",children:l.jsx(ye,{icon:n,size:20})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate font-semibold",children:e}),l.jsx("span",{className:ce("mt-1 inline-flex rounded-md px-2 py-0.5 text-[10px] font-semibold",O$[i]),children:o})]})]})}function L$({percent:e,size:n=128,className:a,trackClassName:o="stroke-white/20",strokeClassName:i="stroke-white"}){const d=2*Math.PI*42,m=Math.min(100,Math.max(0,e)),p=d-m/100*d;return l.jsxs("div",{className:ce("relative inline-flex",a),children:[l.jsxs("svg",{width:n,height:n,viewBox:"0 0 100 100",className:"-rotate-90","aria-hidden":!0,children:[l.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",className:o}),l.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",strokeLinecap:"round",strokeDasharray:d,strokeDashoffset:p,className:i})]}),l.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:[l.jsxs("span",{className:"text-2xl font-bold tabular-nums leading-none",children:[Math.round(m),"%"]}),l.jsx("span",{className:"mt-0.5 text-[10px] font-medium uppercase tracking-wide opacity-80",children:"Complete"})]})]})}const z$={todo:{dot:"bg-rose-500",badge:"bg-rose-500/15 text-rose-400",label:"Needs setup"},progress:{dot:"bg-amber-400",badge:"bg-amber-500/15 text-amber-400",label:"In progress"},done:{dot:"bg-sky-400",badge:"bg-sky-500/15 text-sky-400",label:"Active"}};function P$({title:e,subtitle:n,icon:a,href:o,status:i,meta:c="Open in dashboard"}){const d=z$[i];return l.jsxs(_t,{to:o,className:ce("group flex min-w-[280px] flex-1 flex-col gap-4 rounded-2xl border border-border bg-card p-4 transition-colors","hover:border-primary hover:bg-secondary","sm:min-w-[300px] lg:min-w-0"),children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsx("span",{className:ce("mt-1.5 size-2 shrink-0 rounded-full",d.dot)}),l.jsx("span",{className:"text-xs text-muted-foreground",children:n})]}),l.jsxs("div",{children:[l.jsx("h3",{className:"font-semibold leading-snug tracking-tight",children:e}),l.jsx("span",{className:ce("mt-2 inline-flex rounded-md px-2 py-0.5 text-[11px] font-semibold",d.badge),children:d.label})]}),l.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border pt-3",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-secondary text-primary",children:l.jsx(ye,{icon:a,size:16})}),l.jsx("span",{className:"text-xs text-muted-foreground",children:c})]}),l.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[l.jsx(ye,{icon:Vu,size:14,className:"opacity-60"}),l.jsx(ye,{icon:no,size:14,className:"opacity-60 group-hover:text-primary"}),l.jsx(ye,{icon:Oh,size:14,className:"text-primary opacity-0 transition-opacity group-hover:opacity-100"})]})]})]})}function I$({stats:e}){const n=[{id:"ping",label:"Gateway latency",detail:`${e.bot.ping}ms`,badge:e.bot.ping<200?"Good":"High",badgeClass:e.bot.ping<200?"bg-emerald-500/15 text-emerald-400":"bg-amber-500/15 text-amber-400"},{id:"uptime",label:"Bot uptime",detail:Ih(e.bot.uptime),badge:"Live",badgeClass:"bg-primary/20 text-primary"},{id:"ram",label:"Memory usage",detail:`${e.hosting.ram_used} / ${e.hosting.ram_total}`,badge:`${e.hosting.ram_percent}%`,badgeClass:"bg-sky-500/15 text-sky-400"}];return l.jsxs("aside",{className:"hidden w-[min(100%,320px)] shrink-0 space-y-4 xl:block",children:[l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"flex flex-row items-center justify-between space-y-0 pb-3",children:[l.jsxs(Qe,{className:"text-sm font-semibold",children:["Connected servers (",e.servers,")"]}),l.jsx(ve,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:l.jsx("span",{className:"text-lg leading-none",children:"+"})})]}),l.jsxs(Fe,{className:"pt-0",children:[l.jsxs("div",{className:"flex -space-x-2",children:[Array.from({length:Math.min(6,e.servers)}).map((a,o)=>l.jsxs(Ss,{className:"size-9 border-2 border-card ring-0",children:[l.jsx(ws,{src:e.bot.avatar,alt:""}),l.jsx(Cs,{className:"bg-primary/25 text-[10px] text-primary",children:String(o+1)})]},o)),e.servers>6?l.jsxs("div",{className:"flex size-9 items-center justify-center rounded-full border-2 border-card bg-secondary text-xs font-medium text-muted-foreground",children:["+",e.servers-6]}):null]}),l.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[e.users.toLocaleString()," members across your guilds"]})]})]}),l.jsx(Ge,{className:"overflow-hidden border-border bg-secondary",children:l.jsx(Fe,{className:"p-5",children:l.jsxs("div",{className:"space-y-3",children:[l.jsx("div",{className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:l.jsx(ye,{icon:c8,size:22})}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold",children:"Keep SupportBot up to date"}),l.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check for releases and install updates from settings."})]}),l.jsx(ve,{asChild:!0,size:"sm",className:"w-full",children:l.jsxs(_t,{to:"/settings",children:[l.jsx(ye,{icon:Uu,size:16,className:"mr-2"}),"Open settings"]})})]})})}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[l.jsx(Qe,{className:"text-sm font-semibold",children:"System activity"}),l.jsx(ve,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:l.jsx("span",{className:"text-base leading-none",children:"⋯"})})]}),l.jsxs(Fe,{className:"space-y-1 p-0 pb-2",children:[n.map(a=>l.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-secondary/40",children:[l.jsxs(Ss,{className:"size-9",children:[l.jsx(ws,{src:e.bot.avatar,alt:e.bot.username}),l.jsx(Cs,{className:"bg-secondary text-xs",children:"SB"})]}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsx("p",{className:"truncate text-sm font-medium",children:a.label}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.detail})]}),l.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ${a.badgeClass}`,children:a.badge})]},a.id)),l.jsx(ve,{asChild:!0,variant:"ghost",className:"mx-2 mt-1 w-[calc(100%-1rem)] justify-between text-xs text-muted-foreground",children:l.jsxs(_t,{to:"/system",children:["All system details",l.jsx(ye,{icon:Oh,size:14})]})})]})]}),l.jsx(Ge,{className:"border-border bg-card",children:l.jsxs(Fe,{className:"flex items-center gap-3 p-4",children:[l.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-secondary text-primary",children:l.jsx(ye,{icon:no,size:18})}),l.jsxs("div",{className:"min-w-0 flex-1",children:[l.jsxs("p",{className:"text-sm font-medium",children:["v",e.bot.version]}),l.jsxs("p",{className:"text-xs text-muted-foreground",children:["CPU ",e.hosting.cpu_load]})]})]})})]})}const W5={todo:"Needs setup",progress:"In progress",done:"Active"};function xh(e,n,a="Configure module"){const o=n==null?void 0:n[e];return o||{status:"todo",subtitle:a}}function $$(){return l.jsxs("div",{className:"flex gap-6",children:[l.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Ve,{className:"h-44 rounded-2xl"}),l.jsx(Ve,{className:"h-44 rounded-2xl"})]}),l.jsx(Ve,{className:"h-8 w-48"}),l.jsx("div",{className:"flex gap-4 overflow-hidden",children:Array.from({length:3}).map((e,n)=>l.jsx(Ve,{className:"h-40 min-w-[280px] rounded-2xl"},n))}),l.jsx(Ve,{className:"h-8 w-56"}),l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Array.from({length:4}).map((e,n)=>l.jsx(Ve,{className:"h-20 rounded-2xl"},n))})]}),l.jsx(Ve,{className:"hidden h-[520px] w-80 shrink-0 rounded-2xl xl:block"})]})}function B$(){const{stats:e,loading:n,error:a}=Yu(),[o,i]=f.useState("all"),c=f.useMemo(()=>{if(!e)return 0;const y=e.tickets.total||0;return y===0?100:Math.round(e.tickets.closed/y*100)},[e]),d=f.useMemo(()=>o==="open"||o==="closed"?fs.filter(y=>y.category==="tickets"):o==="all"?fs:fs.filter(y=>y.category===o),[o]);if(n)return l.jsx($$,{});if(a||!e)return l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:a||"No stats available"})});const m=e.tickets.open,p=e.tickets.closed,h=e.tickets.total;return l.jsxs("div",{className:"flex flex-col gap-6 xl:flex-row xl:items-start",children:[l.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Ge,{className:"overflow-hidden border-border bg-card",children:l.jsxs(Fe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsxs("p",{className:"text-lg font-semibold leading-snug",children:["You have"," ",l.jsx("span",{className:"text-primary",children:m})," open ticket",m===1?"":"s"]}),l.jsx("p",{className:"max-w-xs text-sm text-muted-foreground",children:"Review transcripts or tune your ticket panel so new requests are handled smoothly."}),l.jsx(ve,{asChild:!0,size:"sm",className:"rounded-lg px-5",children:l.jsx(_t,{to:"/transcripts",children:"Review"})})]}),l.jsxs("div",{className:"relative mx-auto flex size-28 shrink-0 items-end justify-center sm:mx-0 sm:size-32","aria-hidden":!0,children:[l.jsx("div",{className:"absolute inset-0 rounded-2xl bg-secondary"}),l.jsx("span",{className:"relative text-6xl",children:"🎫"})]})]})}),l.jsx(Ge,{className:"overflow-hidden border-border bg-primary text-primary-foreground",children:l.jsxs(Fe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm font-medium text-white/80",children:"Ticket summary"}),l.jsxs("ul",{className:"space-y-1.5 text-sm",children:[l.jsxs("li",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),l.jsxs("span",{className:"text-white/90",children:[h," total"]})]}),l.jsxs("li",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),l.jsxs("span",{className:"text-white/90",children:[p," closed"]})]}),l.jsxs("li",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),l.jsxs("span",{className:"text-white/90",children:[m," open"]})]})]})]}),l.jsx(L$,{percent:c,size:120})]})})]}),l.jsxs("section",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[l.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Module overview"}),l.jsx(v5,{value:o,onValueChange:y=>i(y),children:l.jsxs(Rg,{className:"h-auto flex-wrap rounded-xl bg-secondary/60 p-1",children:[l.jsx(to,{value:"all",className:"rounded-lg text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"All"}),l.jsx(to,{value:"open",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Open"}),l.jsx(to,{value:"closed",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Closed"}),j_.filter(y=>y.id!=="all").map(y=>l.jsx(to,{value:y.id,className:"rounded-lg text-xs data-[state=active]:bg-background",children:y.label},y.id))]})})]}),l.jsx("div",{className:"-mx-1 flex gap-4 overflow-x-auto px-1 pb-2 lg:grid lg:grid-cols-3 lg:overflow-visible",children:(o==="open"?[{id:"open-queue",title:"Open ticket queue",subtitle:`${m} waiting`,icon:Qi,href:"/tickets",status:"done",meta:"View live tickets"}]:o==="closed"?[{id:"closed-archive",title:"Closed tickets",subtitle:`${p} resolved`,icon:Bu,href:"/transcripts",status:"done",meta:"Browse archive"}]:d.map(y=>{const v=xh(y.id,e.modules,y.description);return{id:y.id,title:y.title,subtitle:v.subtitle,icon:y.icon,href:y.href,status:v.status,meta:v.status==="done"?"View settings":"Configure"}})).map(y=>l.jsx(P$,{title:y.title,subtitle:y.subtitle,icon:y.icon,href:y.href,status:y.status,meta:y.meta},y.id))})]}),l.jsxs("section",{className:"space-y-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Active modules"}),l.jsx(_t,{to:"/configs",className:"text-sm font-medium text-primary hover:underline",children:"See all"})]}),l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:fs.slice(0,4).map(y=>{const v=xh(y.id,e.modules);return l.jsx(D$,{title:y.title,icon:y.icon,href:y.href,badge:W5[v.status],status:v.status},y.id)})})]})]}),l.jsx(I$,{stats:e})]})}function U$(){const{permissions:e}=Lt();return Pn(e,"overview")?l.jsx(B$,{}):l.jsx(Lr,{to:Bh(e),replace:!0})}function va({permission:e,children:n}){const{loading:a,isAuthenticated:o,permissions:i}=Lt();return a?l.jsx("div",{className:"flex flex-1 items-center justify-center py-16 text-sm text-muted-foreground",children:"Loading…"}):o?Pn(i,e)?l.jsx(l.Fragment,{children:n}):l.jsx(Lr,{to:Bh(i),replace:!0}):l.jsx(Lr,{to:"/login",replace:!0})}function H$(){const{hasPermission:e}=Lt(),n=e("settings.update"),a=mo(),[o,i]=f.useState([]),[c,d]=f.useState(""),[m,p]=f.useState(!0),[h,y]=f.useState(""),[v,x]=f.useState(""),[S,j]=f.useState(null),C=f.useCallback(async()=>{p(!0),y("");try{const E=await Ne.getAddonsCatalog();E.data&&(i(E.data.addons),d(E.data.repository))}catch(E){y(E instanceof Error?E.message:"Failed to load addons")}finally{p(!1)}},[]);f.useEffect(()=>{C()},[C]);async function N(E){if(n){j(E.id),x(""),y("");try{const k=await Ne.installAddon(E.id);x(k.message||`${E.name} installed.`),await C();const T=E.configFiles[0];T&&a(`/configs?file=${Gi(T)}`)}catch(k){y(k instanceof Error?k.message:"Install failed")}finally{j(null)}}}return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addons"}),l.jsxs("p",{className:"text-muted-foreground",children:["Requires an API key from"," ",l.jsx("a",{href:"https://emeraldsrv.dev",target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"emeraldsrv.dev"})," ","to browse and install addons. Configs will appear in the sidebar once installed."]})]}),l.jsxs(ve,{variant:"outline",size:"sm",onClick:C,disabled:m,children:[l.jsx(ye,{icon:q0,size:16,className:ce("mr-1.5",m&&"animate-spin")}),"Refresh"]})]}),h?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:h})}):null,v?l.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:l.jsx(We,{children:v})}):null,l.jsxs("section",{className:"space-y-4",children:[l.jsx("h2",{className:"text-sm font-semibold uppercase tracking-widest text-muted-foreground",children:"Marketplace"}),m?l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[l.jsx(Ve,{className:"h-40 rounded-xl"}),l.jsx(Ve,{className:"h-40 rounded-xl"}),l.jsx(Ve,{className:"h-40 rounded-xl"})]}):l.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(E=>l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"pb-2",children:[l.jsxs("div",{className:"flex items-start justify-between gap-2",children:[l.jsxs(Qe,{className:"flex items-center gap-2 text-lg",children:[l.jsx(ye,{icon:Ph,size:20,className:"text-primary"}),E.name]}),l.jsxs("div",{className:"flex gap-2",children:[l.jsx(gs,{variant:"outline",className:"shrink-0 uppercase tracking-widest text-[10px]",children:E.price===0||!E.price?"Free":`$${E.price}`}),E.installed?l.jsxs(gs,{variant:"secondary",className:"shrink-0 gap-1",children:[l.jsx(ye,{icon:f8,size:14}),"Installed"]}):null]})]}),l.jsx(ht,{children:E.description})]}),l.jsxs(Fe,{className:"space-y-2 text-xs text-muted-foreground",children:[E.is_external?l.jsxs("p",{children:["Available on: ",l.jsx("span",{className:"font-medium text-foreground",children:E.external_store||"External Store"})]}):null,E.configFiles&&E.configFiles.length>0?l.jsxs("p",{children:["Config:"," ",E.configFiles.map((k,T)=>l.jsxs("span",{children:[T>0?", ":null,l.jsx(_t,{to:`/configs?file=${Gi(k)}`,className:"font-mono text-primary hover:underline",children:k})]},k))]}):null]}),l.jsxs(Pg,{className:"flex flex-wrap gap-2",children:[E.is_external?l.jsx(ve,{variant:"outline",size:"sm",asChild:!0,children:l.jsx("a",{href:E.repositoryUrl,target:"_blank",rel:"noreferrer",children:"View Store"})}):null,E.installed&&E.configFiles&&E.configFiles[0]?l.jsx(ve,{size:"sm",variant:"secondary",asChild:!0,children:l.jsx(_t,{to:`/configs?file=${Gi(E.configFiles[0])}`,children:"Edit config"})}):null,E.installed?l.jsx(ve,{size:"sm",disabled:!0,variant:"secondary",children:"Installed"}):E.is_external?null:l.jsxs(ve,{size:"sm",disabled:!n||S===E.id,onClick:()=>N(E),children:[l.jsx(ye,{icon:Uu,size:14,className:"mr-1"}),S===E.id?"Installing…":"Install"]})]})]},E.id))})]})]})}function V$(){const{permissions:e}=Lt(),[n,a]=f.useState(!1),[o,i]=f.useState(!1),[c,d]=f.useState(""),[m,p]=f.useState(""),[h,y]=f.useState(""),[v,x]=f.useState("Administrator"),[S,j]=f.useState(""),[C,N]=f.useState(""),[E,k]=f.useState("General"),T=X0(e,"supportbot"),R=async()=>{if(!m.match(/^[a-z0-9_-]+$/i)){Dr.error("Command name can only contain letters, numbers, underscores and dashes.");return}a(!0),i(!1);try{const D=await Ne.buildAddon({name:m.toLowerCase(),description:h||"A custom command",permission:v,embed:{title:S,description:C||"Hello from your custom command!",color:E}});i(!0),d(D.message||"Restart required."),Dr.success(`Addon ${m}.js created successfully!`)}catch(D){Dr.error(D instanceof Error?D.message:"Failed to build addon")}finally{a(!1)}};return T?l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addon Builder"}),l.jsx("p",{className:"text-muted-foreground",children:"Visually scaffold a custom slash command addon for your bot."})]}),o?l.jsxs(Ye,{className:"border-green-500/20 bg-green-500/10 text-green-600 dark:text-green-400",children:[l.jsx(D1,{className:"h-4 w-4"}),l.jsxs(We,{className:"ml-2",children:["Successfully built ",l.jsxs("strong",{children:[m,".js"]}),"! ",c]})]}):null,l.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[l.jsxs("div",{className:"space-y-6",children:[l.jsxs(Ge,{children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Command Details"}),l.jsx(ht,{children:"Configure how users trigger the command."})]}),l.jsxs(Fe,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Command Name"}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"text-muted-foreground",children:"/"}),l.jsx(Ue,{placeholder:"ping",value:m,onChange:D=>p(D.target.value.replace(/[^a-z0-9_-]/gi,"").toLowerCase())})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Description"}),l.jsx(Ue,{placeholder:"Replies with a custom embed",value:h,onChange:D=>y(D.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Required Permission"}),l.jsxs(Es,{value:v,onValueChange:x,children:[l.jsx(lo,{children:l.jsx(Ns,{})}),l.jsxs(co,{children:[l.jsx(Zt,{value:"none",children:"@everyone"}),l.jsx(Zt,{value:"Administrator",children:"Administrator"}),l.jsx(Zt,{value:"ManageMessages",children:"Manage Messages"}),l.jsx(Zt,{value:"ManageGuild",children:"Manage Server"})]})]})]})]})]}),l.jsxs(Ge,{children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Response Embed"}),l.jsx(ht,{children:"What the bot will reply with."})]}),l.jsxs(Fe,{className:"space-y-4",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Embed Title (Optional)"}),l.jsx(Ue,{placeholder:"Hello!",value:S,onChange:D=>j(D.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Embed Description"}),l.jsx(Cd,{placeholder:"Type your message here...",className:"resize-none",rows:4,value:C,onChange:D=>N(D.target.value)})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Embed Color"}),l.jsxs(Es,{value:E,onValueChange:k,children:[l.jsx(lo,{children:l.jsx(Ns,{})}),l.jsxs(co,{children:[l.jsx(Zt,{value:"General",children:"Theme General"}),l.jsx(Zt,{value:"Success",children:"Theme Success"}),l.jsx(Zt,{value:"Warning",children:"Theme Warning"}),l.jsx(Zt,{value:"Error",children:"Theme Error"})]})]})]})]})]})]}),l.jsx("div",{className:"space-y-6",children:l.jsxs(Ge,{className:"sticky top-6 border-primary/20",children:[l.jsx(Ze,{children:l.jsxs(Qe,{className:"text-sm font-medium flex items-center gap-2",children:[l.jsx(ye,{icon:d8,size:16,className:"text-primary"}),"Live Preview"]})}),l.jsx(Fe,{children:l.jsx("div",{className:"rounded-md border bg-[#313338] p-4 font-sans text-sm text-[#dbdee1]",children:l.jsxs("div",{className:"flex gap-4",children:[l.jsx("div",{className:"size-10 shrink-0 rounded-full bg-indigo-500 flex items-center justify-center font-bold text-white",children:"B"}),l.jsxs("div",{className:"flex-1 space-y-1",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:"font-medium text-white",children:"SupportBot"}),l.jsxs("span",{className:"text-[10px] text-white font-medium uppercase px-1.5 py-0.5 rounded bg-[#5865F2] flex items-center gap-1",children:[l.jsx(D1,{size:10})," BOT"]}),l.jsx("span",{className:"text-xs text-[#949ba4]",children:"Today at 12:00 PM"})]}),l.jsxs("div",{className:"mt-2 rounded bg-[#2b2d31] border-l-4 border-l-[#5865F2] px-4 py-3 max-w-[432px]",children:[S&&l.jsx("div",{className:"mb-1 font-semibold text-white",children:S}),l.jsx("div",{className:"whitespace-pre-wrap",children:C||"Hello from your custom command!"})]})]})]})})}),l.jsx(Pg,{children:l.jsxs(ve,{className:"w-full gap-2",size:"lg",disabled:!m||n,onClick:R,children:[l.jsx(ye,{icon:xa,size:18}),n?"Building...":"Generate Addon"]})})]})})]})]}):l.jsx("div",{className:"flex h-[50vh] items-center justify-center text-muted-foreground",children:"You don't have permission to build addons."})}const $g="supportbot-dashboard-accent",Ki="#45b46c",G$=["--primary","--ring","--chart-1","--sidebar-primary","--sidebar-ring","--accent","--accent-foreground","--sidebar-accent","--sidebar-accent-foreground"];function F$(e){const n=cr(e,Ki),a=parseInt(n.slice(1,3),16)/255,o=parseInt(n.slice(3,5),16)/255,i=parseInt(n.slice(5,7),16)/255,c=Math.max(a,o,i),d=Math.min(a,o,i),m=(c+d)/2;let p=0,h=0;if(c!==d){const y=c-d;switch(h=m>.5?y/(2-c-d):y/(c+d),c){case a:p=((o-i)/y+(o{const o=new FileReader;o.onload=()=>n(String(o.result)),o.onerror=()=>a(new Error("Could not read file")),o.readAsDataURL(e)})}function X$({canEdit:e}){const[n,a]=f.useState(!1),[o,i]=f.useState(""),[c,d]=f.useState(!1);async function m(){if(e){a(!0),i("");try{const p=await Ne.resetDashboard();i(p.message||"Dashboard reset successfully."),setTimeout(()=>{window.location.href="/setup"},1500)}catch(p){i(p instanceof Error?p.message:"Reset failed"),a(!1)}}}return e?l.jsxs("div",{className:"space-y-4",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"Reset the dashboard to factory settings. This clears the configuration and returns you to the initial setup screen."}),l.jsxs(gg,{open:c,onOpenChange:d,children:[l.jsx(s_,{asChild:!0,children:l.jsx(ve,{type:"button",variant:"destructive",children:"Reset Dashboard"})}),l.jsxs(hd,{children:[l.jsxs(gd,{children:[l.jsx(vd,{children:"Are you absolutely sure?"}),l.jsx(bd,{children:"This action cannot be undone. This will reset the dashboard to setup mode. You will need to reconnect the Discord OAuth and reconfigure the dashboard owners."})]}),o&&l.jsx("p",{className:"text-sm font-medium text-destructive",children:o}),l.jsxs(vg,{children:[l.jsx(ve,{variant:"outline",onClick:()=>d(!1),disabled:n,children:"Cancel"}),l.jsx(ve,{variant:"destructive",onClick:()=>void m(),disabled:n,children:n?"Resetting...":"Yes, reset dashboard"})]})]})]})]}):null}function Z$({canEdit:e}){const{branding:n,setBrandingLocal:a}=Fu(),o=f.useRef(null),[i,c]=f.useState(n.title),[d,m]=f.useState(n.pageTitle),[p,h]=f.useState(!1),[y,v]=f.useState(!1),[x,S]=f.useState("");f.useEffect(()=>{c(n.title),m(n.pageTitle)},[n.title,n.pageTitle]);const j=n.hasFavicon&&n.faviconUrl?`${n.faviconUrl}${n.updatedAt?`?v=${n.updatedAt}`:""}`:null;async function C(){if(e){h(!0),S("");try{const T=await Ne.updateBranding({title:i,pageTitle:d});T.data&&a(T.data),S(T.message||"Branding saved.")}catch(T){S(T instanceof Error?T.message:"Save failed")}finally{h(!1)}}}async function N(T){if(!(!e||!T)){v(!0),S("");try{const R=await K$(T),D=await Ne.uploadBrandingFavicon(R);D.data&&a(D.data),S(D.message||"Favicon uploaded.")}catch(R){S(R instanceof Error?R.message:"Upload failed")}finally{v(!1),o.current&&(o.current.value="")}}}async function E(){if(e){v(!0),S("");try{const T=await Ne.removeBrandingFavicon();T.data&&a(T.data),S(T.message||"Favicon removed.")}catch(T){S(T instanceof Error?T.message:"Remove failed")}finally{v(!1)}}}const k=i.trim()!==n.title||d.trim()!==n.pageTitle;return l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium",children:"Branding Text"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Sidebar title and browser tab title — saved on the server for everyone using this dashboard."})]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"brand-title",children:"Sidebar title"}),l.jsx(Ue,{id:"brand-title",value:i,disabled:!e,maxLength:64,onChange:T=>c(T.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"brand-page-title",children:"Browser tab title"}),l.jsx(Ue,{id:"brand-page-title",value:d,disabled:!e,maxLength:80,onChange:T=>m(T.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot Dashboard"})]})]}),e?l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(ve,{type:"button",disabled:p||!k,onClick:()=>void C(),children:p?"Saving…":"Save titles"}),x&&k?l.jsx("span",{className:"text-xs text-muted-foreground",children:x}):null]}):null]}),l.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium",children:"Favicon"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, ICO, SVG, JPEG, or WebP — max 512 KB. Shown in the browser tab and beside the sidebar title."})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[l.jsx("div",{className:"flex size-16 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary/30",children:j?l.jsx("img",{src:j,alt:"Favicon preview",className:"size-full object-contain p-2"}):l.jsx(ye,{icon:r8,size:24,className:"text-muted-foreground/50"})}),l.jsx("input",{ref:o,type:"file",accept:"image/png,image/jpeg,image/x-icon,image/vnd.microsoft.icon,image/svg+xml,image/webp,.ico",className:"hidden",disabled:!e||y,onChange:T=>{var R;return void N(((R=T.target.files)==null?void 0:R[0])??null)}}),l.jsxs("div",{className:"flex flex-col gap-2",children:[e?l.jsxs("div",{className:"flex gap-2",children:[l.jsx(ve,{type:"button",variant:"secondary",disabled:y,onClick:()=>{var T;return(T=o.current)==null?void 0:T.click()},children:y?"Uploading…":"Upload Favicon"}),n.hasFavicon?l.jsx(ve,{type:"button",variant:"destructive",disabled:y,onClick:()=>void E(),children:"Remove"}):null]}):l.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}),!k&&x?l.jsx("span",{className:"text-xs text-muted-foreground",children:x}):null]})]})]})]})}function Q$(){var v,x,S,j,C,N,E,k,T,R,D;const{hasPermission:e}=Lt(),n=e("settings.update"),[a,o]=f.useState(!0),[i,c]=f.useState(!1),[d,m]=f.useState(""),[p,h]=f.useState(null);f.useEffect(()=>{Ne.getConfigJson("api").then(P=>{P.data&&h(P.data)}).catch(()=>m("Failed to load API config")).finally(()=>o(!1))},[]);async function y(){var P,z,B,H,Y,Q,fe,de,he,se,O;if(!(!n||!p)){c(!0),m("");try{const $={"api:API.Port":(P=p.API)==null?void 0:P.Port,"api:API.EmeraldAPIKey":(z=p.API)==null?void 0:z.EmeraldAPIKey,"api:API.TrustProxy":(B=p.API)==null?void 0:B.TrustProxy,"api:API.OAuth.Enabled":(Y=(H=p.API)==null?void 0:H.OAuth)==null?void 0:Y.Enabled,"api:API.OAuth.ClientId":(fe=(Q=p.API)==null?void 0:Q.OAuth)==null?void 0:fe.ClientId,"api:API.OAuth.ClientSecret":(he=(de=p.API)==null?void 0:de.OAuth)==null?void 0:he.ClientSecret,"api:API.OAuth.RedirectUri":(O=(se=p.API)==null?void 0:se.OAuth)==null?void 0:O.RedirectUri};await Ne.updateConfigFields($),m("API settings saved and backend restarted.")}catch($){m($ instanceof Error?$.message:"Save failed")}finally{c(!1)}}}return a?l.jsx("div",{className:"animate-pulse h-32 bg-secondary/20 rounded-md"}):p?l.jsxs("div",{className:"space-y-8",children:[l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium",children:"Core API Settings"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Configure the internal API that powers this dashboard."})]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"API Port"}),l.jsx(Ue,{type:"number",value:((v=p.API)==null?void 0:v.Port)||"",disabled:!n,onChange:P=>h({...p,API:{...p.API,Port:parseInt(P.target.value)||3e3}}),className:"border-border bg-secondary/30"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Emerald API Key"}),l.jsx(Ue,{type:"password",value:((x=p.API)==null?void 0:x.EmeraldAPIKey)||"",disabled:!n,onChange:P=>h({...p,API:{...p.API,EmeraldAPIKey:P.target.value}}),className:"border-border bg-secondary/30"})]})]}),l.jsxs("div",{className:"flex items-center gap-2 pt-2",children:[l.jsx(dn,{checked:((S=p.API)==null?void 0:S.TrustProxy)||!1,disabled:!n,onCheckedChange:P=>h({...p,API:{...p.API,TrustProxy:P}})}),l.jsx(De,{className:"text-sm",children:"Trust Proxy (Enable if using Cloudflare/Nginx)"})]})]}),l.jsxs("div",{className:"space-y-4 border-t border-border pt-6",children:[l.jsxs("div",{children:[l.jsx("p",{className:"text-sm font-medium",children:"OAuth Authentication"}),l.jsx("p",{className:"text-xs text-muted-foreground",children:"Discord application credentials for dashboard login."})]}),l.jsxs("div",{className:"flex items-center gap-2 pb-2",children:[l.jsx(dn,{checked:((C=(j=p.API)==null?void 0:j.OAuth)==null?void 0:C.Enabled)||!1,disabled:!n,onCheckedChange:P=>{var z;return h({...p,API:{...p.API,OAuth:{...(z=p.API)==null?void 0:z.OAuth,Enabled:P}}})}}),l.jsx(De,{className:"text-sm",children:"Enable OAuth"})]}),l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Client ID"}),l.jsx(Ue,{value:((E=(N=p.API)==null?void 0:N.OAuth)==null?void 0:E.ClientId)||"",disabled:!n,onChange:P=>{var z;return h({...p,API:{...p.API,OAuth:{...(z=p.API)==null?void 0:z.OAuth,ClientId:P.target.value}}})},className:"border-border bg-secondary/30"})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Client Secret"}),l.jsx(Ue,{type:"password",value:((T=(k=p.API)==null?void 0:k.OAuth)==null?void 0:T.ClientSecret)||"",disabled:!n,onChange:P=>{var z;return h({...p,API:{...p.API,OAuth:{...(z=p.API)==null?void 0:z.OAuth,ClientSecret:P.target.value}}})},className:"border-border bg-secondary/30"})]}),l.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[l.jsx(De,{children:"Redirect URI"}),l.jsx(Ue,{value:((D=(R=p.API)==null?void 0:R.OAuth)==null?void 0:D.RedirectUri)||"",disabled:!n,onChange:P=>{var z;return h({...p,API:{...p.API,OAuth:{...(z=p.API)==null?void 0:z.OAuth,RedirectUri:P.target.value}}})},className:"border-border bg-secondary/30"}),l.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Must match the OAuth2 callback URL registered in the Discord Developer Portal exactly."})]})]})]}),n?l.jsxs("div",{className:"flex items-center gap-2 border-t border-border pt-6",children:[l.jsx(ve,{type:"button",disabled:i,onClick:()=>void y(),children:i?"Saving…":"Save API Config"}),d?l.jsx("span",{className:"text-xs text-muted-foreground",children:d}):null]}):null]}):null}function J$(){const{hasPermission:e}=Lt(),n=e("settings.update"),[a,o]=f.useState(null),[i,c]=f.useState(!0),[d,m]=f.useState(!1),[p,h]=f.useState(""),[y,v]=f.useState(""),[x,S]=f.useState(()=>K5()??Ki),[j,C]=f.useState(""),[N,E]=f.useState("appearance"),k=f.useCallback(async()=>{c(!0),h("");try{const R=await Ne.checkForUpdates();R.data&&o(R.data)}catch(R){h(R instanceof Error?R.message:"Could not check for updates")}finally{c(!1)}},[]);f.useEffect(()=>{k()},[k]);async function T(R){if(R.updateAvailable){m(!0),h(""),v("");try{const D=await Ne.runUpdate(R.id,R.latest,R.zipUrl);v(D.message||"Update installed. Restart your server (stop and run npm start again) to finish applying changes."),await k()}catch(D){h(D instanceof Error?D.message:"Update failed")}finally{m(!1)}}}return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),l.jsx("p",{className:"text-muted-foreground",children:"Application updates and maintenance — config files are edited under each module in the sidebar."})]}),l.jsxs("div",{className:"flex flex-col md:flex-row gap-8 items-start",children:[l.jsx("aside",{className:"w-full md:w-56 shrink-0 sticky top-6",children:l.jsxs("nav",{className:"flex flex-row md:flex-col overflow-x-auto space-x-2 md:space-x-0 md:space-y-1 pb-2 md:pb-0",children:[l.jsx(ve,{variant:N==="appearance"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("appearance"),children:"Appearance"}),l.jsx(ve,{variant:N==="api"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("api"),children:"API Config"}),l.jsx(ve,{variant:N==="updates"?"secondary":"ghost",className:"justify-start w-full",onClick:()=>E("updates"),children:"Update Checker"}),n&&l.jsx(ve,{variant:"ghost",className:`justify-start w-full text-destructive hover:bg-destructive/10 hover:text-destructive ${N==="danger"?"bg-destructive/10 border-l-2 border-destructive rounded-l-none":""}`,onClick:()=>E("danger"),children:"Danger Zone"})]})}),l.jsxs("main",{className:"flex-1 w-full max-w-4xl space-y-6",children:[N==="appearance"&&l.jsx("div",{className:"space-y-6",children:l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Dashboard appearance"}),l.jsx(ht,{children:"Customise branding for all users, and pick an accent colour for this browser only."})]}),l.jsxs(Fe,{className:"space-y-4",children:[l.jsx(Z$,{canEdit:n}),l.jsxs("div",{className:"border-t border-border pt-4",children:[l.jsx("p",{className:"mb-1 text-sm font-medium",children:"Accent colour"}),l.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Buttons, links, and highlights — saved in this browser only."}),l.jsxs("div",{className:"flex flex-wrap items-center gap-4",children:[l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx(Ng,{value:x,onChange:R=>{S(R),b0(R),C("Accent updated.")}}),l.jsx(Ue,{id:"accent-colour",value:x,onChange:R=>S(R.target.value),onBlur:()=>{const R=cr(x,Ki);S(R),b0(R),C("Accent updated.")},className:"w-32 border-border bg-secondary/30 font-mono uppercase",maxLength:7})]}),l.jsx(ve,{type:"button",variant:"outline",onClick:()=>{W$(),S(Ki),C("Reset to default purple.")},children:"Reset to default"})]}),l.jsxs("div",{className:"flex flex-wrap gap-2 text-sm mt-5",children:[l.jsx("span",{className:"rounded-md bg-primary px-3 py-1.5 font-medium text-primary-foreground",children:"Primary button"}),l.jsx("span",{className:"rounded-md bg-primary/15 px-3 py-1.5 text-primary",children:"Highlight"}),l.jsx("span",{className:"rounded-md bg-accent px-3 py-1.5 text-accent-foreground",children:"Accent surface"})]}),j?l.jsx("p",{className:"text-xs text-muted-foreground",children:j}):null]})]})]})}),N==="danger"&&n&&l.jsxs(Ge,{className:"border-destructive/50 bg-destructive/5",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg text-destructive",children:"Danger Zone"}),l.jsx(ht,{className:"text-destructive/80",children:"Destructive actions that reset or permanently alter your dashboard."})]}),l.jsx(Fe,{children:l.jsx(X$,{canEdit:n})})]}),N==="api"&&l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"API Configuration"}),l.jsx(ht,{children:"Configure the internal API settings, Emerald API key, and OAuth."})]}),l.jsx(Fe,{children:l.jsx(Q$,{})})]}),N==="updates"&&l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Software updates"}),l.jsx(ht,{children:"Manage updates for the bot and dashboard."})]}),l.jsxs(Fe,{className:"space-y-4",children:[i?l.jsx(Ve,{className:"h-24 w-full"}):a&&a.length>0?l.jsx("div",{className:"space-y-4",children:a.map(R=>l.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/20 p-4",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("p",{className:"font-medium text-sm",children:[l.jsx("a",{href:R.repository,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:R.name})," ","(",R.branch," branch)"]}),l.jsxs("div",{className:"flex gap-x-4 text-sm",children:[l.jsxs("p",{children:[l.jsx("span",{className:"text-muted-foreground",children:"Installed: "}),l.jsxs("span",{className:"font-mono font-medium",children:["v",R.current]})]}),l.jsxs("p",{children:[l.jsx("span",{className:"text-muted-foreground",children:"Latest: "}),l.jsxs("span",{className:"font-mono font-medium",children:["v",R.latest]})]})]})]}),l.jsxs("div",{className:"flex items-center justify-between",children:[R.updateAvailable?l.jsx("p",{className:"text-sm text-amber-500",children:"A newer version is available. Update downloads files while keeping your Configs and Data."}):l.jsx("p",{className:"text-sm text-emerald-500",children:"You are on the latest release."}),R.updateAvailable&&n?l.jsxs(ve,{type:"button",size:"sm",onClick:()=>void T(R),disabled:d,children:[d?l.jsx(ye,{icon:q0,size:16,className:"mr-2 animate-spin"}):l.jsx(ye,{icon:Uu,size:16,className:"mr-2"}),d?"Installing…":"Update now"]}):null,R.updateAvailable&&!n?l.jsx("p",{className:"text-xs text-muted-foreground",children:"You cannot install updates with your role."}):null]})]},R.id))}):null,p?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:p})}):null,y?l.jsx(Ye,{children:l.jsx(We,{children:y})}):null,l.jsx("div",{className:"flex flex-wrap gap-2 pt-2",children:l.jsxs(ve,{type:"button",variant:"outline",onClick:k,disabled:i||d,children:[l.jsx(ye,{icon:_s,size:16,className:"mr-2"}),"Check again"]})})]})]})]})]})]})}function pt({label:e,value:n,mono:a=!1}){return l.jsxs("div",{className:"flex flex-col gap-1 border-b border-border py-3 last:border-0 sm:flex-row sm:items-center sm:justify-between",children:[l.jsx("dt",{className:"text-sm text-muted-foreground",children:e}),l.jsx("dd",{className:`text-sm font-medium text-foreground ${a?"font-mono text-xs sm:text-sm":""}`,children:n})]})}const eB={ok:"Healthy",missing_config:"Guild ID not set",not_in_guild:"Not in configured server",extra_guilds:"Extra servers joined",offline:"Bot offline"};function tB(e){return e==="ok"?"text-emerald-500":e==="offline"?"text-destructive":"text-amber-500"}function nB(){var S;const{stats:e,loading:n,error:a,refresh:o}=Yu(),[i,c]=f.useState(null),[d,m]=f.useState(null),[p,h]=f.useState(!1),y=f.useCallback(async()=>{const[j,C]=await Promise.all([Ne.getGuildStatus().catch(()=>null),Ne.health().catch(()=>null)]);j!=null&&j.data&&c(j.data),C!=null&&C.success&&m({dashboard:C.dashboard,botReady:C.botReady,oauthEnabled:C.oauthEnabled,setupComplete:C.setupComplete})},[]);f.useEffect(()=>{y()},[y]);async function v(){h(!0);try{await Promise.all([o(),y()])}finally{h(!1)}}if(n&&!e)return l.jsxs("div",{className:"space-y-6",children:[l.jsx(Ve,{className:"h-10 w-64"}),l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Ve,{className:"h-56 rounded-2xl"}),l.jsx(Ve,{className:"h-56 rounded-2xl"})]})]});if(a||!e)return l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:a||"Could not load system details."})});const x=e.bot.ping<200;return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(ve,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-8 px-2 text-muted-foreground",children:l.jsxs(_t,{to:"/",children:[l.jsx(ye,{icon:G0,size:16,className:"mr-1.5"}),"Back to dashboard"]})}),l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"System details"}),l.jsx("p",{className:"text-muted-foreground",children:"Live bot, host, and dashboard status — refreshed every 30 seconds."})]})]}),l.jsxs(ve,{type:"button",variant:"outline",disabled:p,onClick:()=>void v(),children:[l.jsx(ye,{icon:_s,size:16,className:"mr-2"}),p?"Refreshing…":"Refresh now"]})]}),l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Discord bot"}),l.jsx(ht,{children:"Connection and identity"})]}),l.jsxs(Fe,{children:[l.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[l.jsxs(Ss,{className:"size-12",children:[l.jsx(ws,{src:e.bot.avatar,alt:e.bot.username}),l.jsx(Cs,{children:"SB"})]}),l.jsxs("div",{children:[l.jsx("p",{className:"font-semibold",children:e.bot.username}),l.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:e.bot.id})]})]}),l.jsxs("dl",{children:[l.jsx(pt,{label:"Version",value:`v${e.bot.version}`,mono:!0}),l.jsx(pt,{label:"Gateway latency",value:l.jsxs("span",{className:x?"text-emerald-500":"text-amber-500",children:[e.bot.ping," ms"]})}),l.jsx(pt,{label:"Process uptime",value:Ih(e.bot.uptime)}),l.jsx(pt,{label:"Connected servers",value:e.servers.toLocaleString()}),l.jsx(pt,{label:"Members tracked",value:e.users.toLocaleString()}),e.bot.inviteUrl?l.jsx(pt,{label:"Invite link",value:l.jsx("a",{href:e.bot.inviteUrl,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"Open in Discord"})}):null]})]})]}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Host machine"}),l.jsx(ht,{children:"Server resources running this instance"})]}),l.jsx(Fe,{children:l.jsxs("dl",{children:[l.jsx(pt,{label:"Memory used",value:`${e.hosting.ram_used} / ${e.hosting.ram_total}`}),l.jsx(pt,{label:"Memory usage",value:l.jsxs("span",{className:e.hosting.ram_percent>85?"text-amber-500":"text-foreground",children:[e.hosting.ram_percent,"%"]})}),l.jsx(pt,{label:"CPU load (1 min avg)",value:e.hosting.cpu_load,mono:!0}),l.jsx(pt,{label:"Host uptime",value:e.hosting.uptime})]})})]}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Tickets"}),l.jsx(ht,{children:"Database snapshot"})]}),l.jsx(Fe,{children:l.jsxs("dl",{children:[l.jsx(pt,{label:"Total tickets",value:e.tickets.total}),l.jsx(pt,{label:"Open",value:l.jsx("span",{className:"text-primary",children:e.tickets.open})}),l.jsx(pt,{label:"Closed",value:e.tickets.closed}),l.jsx(pt,{label:"Transcripts",value:l.jsx(_t,{to:"/transcripts",className:"text-primary underline-offset-4 hover:underline",children:"Browse archive"})})]})})]}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Guild health"}),l.jsx(ht,{children:"Configured server and membership"})]}),l.jsx(Fe,{children:i?l.jsxs("dl",{children:[l.jsx(pt,{label:"Status",value:l.jsx("span",{className:tB(i.status),children:eB[i.status]})}),l.jsx(pt,{label:"Configured guild ID",value:i.configuredGuildId||"Not set",mono:!0}),i.configuredGuild?l.jsx(pt,{label:"Configured server",value:`${i.configuredGuild.name} (${((S=i.configuredGuild.memberCount)==null?void 0:S.toLocaleString())??"?"} members)`}):null,i.message?l.jsx("div",{className:"mt-3 rounded-lg border border-border bg-secondary/30 px-3 py-2 text-sm text-muted-foreground",children:i.message}):null,i.extraGuilds.length>0?l.jsxs("div",{className:"mt-3 space-y-2",children:[l.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Extra servers"}),l.jsx("ul",{className:"space-y-1 text-sm",children:i.extraGuilds.map(j=>l.jsxs("li",{className:"font-mono text-xs",children:[j.name," · ",j.id]},j.id))})]}):null]}):l.jsx(Ve,{className:"h-24 w-full"})})]})]}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Dashboard services"}),l.jsx(ht,{children:"API and authentication"})]}),l.jsx(Fe,{children:d?l.jsxs("dl",{className:"max-w-xl",children:[l.jsx(pt,{label:"Dashboard UI",value:d.dashboard?"Available":"Missing build"}),l.jsx(pt,{label:"Bot connection",value:d.botReady?"Online":"Starting or offline"}),l.jsx(pt,{label:"Discord OAuth",value:d.oauthEnabled?"Configured":"Not configured"}),l.jsx(pt,{label:"Initial setup",value:d.setupComplete?"Complete":"Incomplete"}),l.jsx(pt,{label:"Software updates",value:l.jsx(_t,{to:"/settings",className:"text-primary underline-offset-4 hover:underline",children:"Open settings"})}),l.jsx(pt,{label:"Logs",value:l.jsx(_t,{to:"/logs",className:"text-primary underline-offset-4 hover:underline",children:"View log files"})})]}):l.jsx(Ve,{className:"h-32 w-full max-w-xl"})})]}),e.modules?l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-lg",children:"Module setup status"}),l.jsx(ht,{children:"Which features are configured and active"})]}),l.jsx(Fe,{children:l.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:fs.map(j=>{const C=xh(j.id,e.modules);return l.jsxs(_t,{to:j.href,className:"flex items-start justify-between gap-3 rounded-xl border border-border bg-secondary/20 px-4 py-3 transition-colors hover:bg-secondary/40",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx("p",{className:"text-sm font-medium",children:j.title}),l.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:C.subtitle})]}),l.jsx("span",{className:"shrink-0 rounded-full bg-secondary px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground",children:W5[C.status]})]},j.id)})})})]}):null]})}function rB(e){if(!e)return"—";const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit"})}const aB=[{id:"all",label:"All"},{id:"Output",label:"Output"},{id:"Warn",label:"Warn"},{id:"Error",label:"Error"}],oB=["Output","Warn","Error"],sB={Output:"text-foreground/90",Warn:"text-amber-400",Error:"text-rose-400"},iB={Output:"bg-muted text-muted-foreground",Warn:"bg-amber-500/15 text-amber-400",Error:"bg-rose-500/15 text-rose-400"},y0=2e3,lB=2e3;function Sh(e,n){return`${e.type}-${e.timestamp??"na"}-${n}-${e.message.slice(0,32)}`}function cB(e,n,a){const o=a?[]:e,i=new Set(o.map((m,p)=>Sh(m,p))),c=[];for(let m=0;my0?d.slice(d.length-y0):d}function uB(){const[e,n]=f.useState([]),[a,o]=f.useState(!0),[i,c]=f.useState(""),[d,m]=f.useState(!1),[p,h]=f.useState(!0),[y,v]=f.useState("all"),[x,S]=f.useState(""),[j,C]=f.useState(!0),[N,E]=f.useState(""),k=f.useRef(null),T=f.useRef(null),R=f.useRef(d);R.current=d;const D=f.useMemo(()=>y==="all"?oB:[y],[y]),P=f.useCallback(async H=>{var fe,de;const Y=await Ne.getLogs({types:D,cursor:H?void 0:k.current??void 0,tail:H?500:0}),Q=((fe=Y.data)==null?void 0:fe.entries)??[];return k.current=((de=Y.data)==null?void 0:de.cursor)??{},n(he=>cB(he,Q,H)),Q.length},[D]),z=f.useCallback(async()=>{var H;o(!0),c(""),k.current=null;try{const fe=(((H=(await Ne.getLogsMeta()).data)==null?void 0:H.files)??[]).filter(de=>de.file).map(de=>`${de.type}: ${de.file}`).join(" · ");E(fe||"No log files yet — output appears when the bot runs."),await P(!0),C(!0)}catch(Y){c(Y instanceof Error?Y.message:"Failed to load logs"),C(!1)}finally{o(!1)}},[P]);f.useEffect(()=>{z()},[z]),f.useEffect(()=>{if(d||a)return;const H=window.setInterval(async()=>{if(!R.current)try{await P(!1),C(!0),c("")}catch(Y){C(!1),c(Y instanceof Error?Y.message:"Live update failed")}},lB);return()=>window.clearInterval(H)},[d,a,P]),f.useEffect(()=>{if(!p||d)return;const H=T.current;H&&(H.scrollTop=H.scrollHeight)},[e,p,d]);const B=f.useMemo(()=>e.filter(H=>{var Q;if(y!=="all"&&H.type!==y)return!1;if(!x.trim())return!0;const Y=x.toLowerCase();return H.message.toLowerCase().includes(Y)||(((Q=H.timestamp)==null?void 0:Q.toLowerCase().includes(Y))??!1)}),[e,y,x]);return l.jsxs("div",{className:"flex h-[calc(100svh-8rem)] min-h-[480px] flex-col gap-4",children:[l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Logs"}),l.jsx("p",{className:"text-muted-foreground",children:"Live bot output — updates every 2 seconds"}),N?l.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:N}):null]}),l.jsxs("div",{className:"flex items-center gap-2",children:[l.jsx("span",{className:ce("size-2 rounded-full",j&&!d?"animate-pulse bg-emerald-500":"bg-muted-foreground")}),l.jsx("span",{className:"text-xs text-muted-foreground",children:d?"Paused":j?"Live":"Disconnected"})]})]}),i?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:i})}):null,l.jsxs(Ge,{className:"flex min-h-0 flex-1 flex-col border-border bg-card",children:[l.jsxs(Ze,{className:"shrink-0 space-y-4 border-b border-border pb-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[l.jsxs(Qe,{className:"text-base font-medium",children:["Console",a?null:l.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[B.length," line",B.length===1?"":"s"]})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border px-2 py-1",children:[l.jsx(dn,{id:"auto-scroll",checked:p,onCheckedChange:h}),l.jsx(De,{htmlFor:"auto-scroll",className:"text-xs font-normal",children:"Auto-scroll"})]}),l.jsxs(ve,{type:"button",variant:"outline",size:"sm",onClick:()=>m(H=>!H),children:[l.jsx(ye,{icon:d?l8:i8,size:16,className:"mr-1.5"}),d?"Resume":"Pause"]}),l.jsxs(ve,{type:"button",variant:"outline",size:"sm",onClick:()=>{n([]),z()},disabled:a,children:[l.jsx(ye,{icon:_s,size:16,className:"mr-1.5"}),"Refresh"]})]})]}),l.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[l.jsx("div",{className:"flex flex-wrap gap-1 rounded-xl bg-secondary/50 p-1",children:aB.map(H=>l.jsx(ve,{type:"button",variant:y===H.id?"secondary":"ghost",size:"sm",className:"h-8 rounded-lg text-xs",onClick:()=>v(H.id),children:H.label},H.id))}),l.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[l.jsx(ye,{icon:Gu,size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),l.jsx(Ue,{placeholder:"Filter lines…",value:x,onChange:H=>S(H.target.value),className:"h-9 pl-9"})]})]})]}),l.jsx(Fe,{className:"min-h-0 flex-1 p-0",children:a?l.jsx("div",{className:"space-y-2 p-4",children:Array.from({length:8}).map((H,Y)=>l.jsx(Ve,{className:"h-4 w-full"},Y))}):l.jsx("div",{ref:T,className:"h-full max-h-[calc(100svh-18rem)] overflow-y-auto bg-[#0d0d12] p-4 font-mono text-[13px] leading-relaxed",children:B.length===0?l.jsx("p",{className:"text-muted-foreground",children:"No log lines yet. Start the bot and activity will appear here (also written to the Logs folder on disk)."}):l.jsx("ul",{className:"space-y-1",children:B.map((H,Y)=>l.jsxs("li",{className:"flex gap-2 rounded px-1 py-0.5 hover:bg-white/[0.03]",children:[l.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:rB(H.timestamp)}),l.jsx("span",{className:ce("shrink-0 rounded px-1.5 py-0 text-[10px] font-semibold uppercase",iB[H.type]),children:H.type}),l.jsx("span",{className:ce("min-w-0 flex-1 whitespace-pre-wrap break-words",sB[H.type]),children:H.message||" "})]},Sh(H,Y)))})})})]})]})}const dB=[{title:"Colors",description:"Theme colors used across the transcript page.",fields:[{path:"Theme.Background",label:"Page background",type:"color"},{path:"Theme.Panel",label:"Panel background",type:"color"},{path:"Theme.PanelSecondary",label:"Secondary panel",type:"color"},{path:"Theme.Border",label:"Borders",type:"color"},{path:"Theme.Text",label:"Main text",type:"color"},{path:"Theme.Muted",label:"Muted text",type:"color"},{path:"Theme.Accent",label:"Accent",type:"color"},{path:"Theme.Link",label:"Links",type:"color"},{path:"Theme.AttachmentLink",label:"Attachment links",type:"color"},{path:"Theme.CodeBackground",label:"Code blocks",type:"color"}]},{title:"Typography",fields:[{path:"Typography.FontFamily",label:"Font family",type:"googleFont",description:"Google Fonts are loaded automatically in saved transcripts."}]},{title:"Header",fields:[{path:"Header.Title",label:"Title",type:"text"},{path:"Header.Subtitle",label:"Subtitle",type:"textarea",description:"Placeholders: {{ticketName}} {{ticketId}} {{messageCount}} {{reason}}. Use **text** for bold."},{path:"Header.Badge",label:"Badge label",type:"text"},{path:"Header.ShowMetaCards",label:"Show info cards",type:"boolean"}]},{title:"Info card labels",fields:[{path:"Meta.ChannelLabel",label:"Channel label",type:"text"},{path:"Meta.TicketIdLabel",label:"Ticket ID label",type:"text"},{path:"Meta.MessageCountLabel",label:"Message count label",type:"text"},{path:"Meta.CloseReasonLabel",label:"Close reason label",type:"text"},{path:"Meta.DefaultCloseReason",label:"Default close reason",type:"text"}]},{title:"Messages section",fields:[{path:"Messages.SectionTitle",label:"Section heading",type:"text"},{path:"Messages.EmptyState",label:"Empty state text",type:"text"}]},{title:"Advanced CSS",description:"Optional extra CSS appended to the transcript stylesheet.",fields:[{path:"Advanced.CustomCss",label:"Custom CSS",type:"textarea",description:"Example: .badge { font-size: 1rem; }"}]}],fB=450;function mB(e,n){return n&&e!=="viewer"}function pB(){const{user:e,hasPermission:n}=Lt(),a=!mB(e==null?void 0:e.role,n("transcripts")),[o,i]=f.useState(null),[c,d]=f.useState(null),[m,p]=f.useState(!0),[h,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState(""),[E,k]=f.useState(!1),T=f.useRef(null),R=f.useCallback(async()=>{var H;p(!0),x(""),j("");try{const Q=(await Ne.getTranscriptTemplate()).data??null;if(Q){const fe={...Q,Typography:{...Q.Typography,FontFamily:r5((H=Q.Typography)==null?void 0:H.FontFamily)}};i(fe),d(structuredClone(fe))}}catch(Y){x(Y instanceof Error?Y.message:"Failed to load template")}finally{p(!1)}},[]);f.useEffect(()=>{R()},[R]);const D=f.useCallback(async H=>{k(!0);try{const Y=await Ne.previewTranscriptTemplate(H);N(Y)}catch{N("

Preview failed to load.

")}finally{k(!1)}},[]);f.useEffect(()=>{if(o)return T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{D(o)},fB),()=>{T.current&&clearTimeout(T.current)}},[o,D]);function P(H,Y){i(Q=>Q&&il(Q,H,Y))}async function z(){if(!(a||!o)){y(!0),x(""),j("");try{const H=await Ne.saveTranscriptTemplate(o);j(H.message||"Saved."),d(structuredClone(o))}catch(H){x(H instanceof Error?H.message:"Save failed")}finally{y(!1)}}}const B=o&&c&&JSON.stringify(o)!==JSON.stringify(c);return m?l.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[l.jsx(Ve,{className:"h-96 rounded-xl"}),l.jsx(Ve,{className:"h-96 rounded-xl"})]}):o?l.jsxs("div",{className:"space-y-4",children:[l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[l.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize how new ticket transcripts look. Existing saved transcripts are not changed."}),l.jsxs("div",{className:"flex items-center gap-2",children:[B?l.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,a?l.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):l.jsxs(ve,{size:"sm",onClick:z,disabled:h||!B,children:[l.jsx(ye,{icon:Hu,size:16,className:"mr-1.5"}),h?"Saving…":"Save appearance"]})]})]}),v?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v})}):null,S?l.jsx(Ye,{className:"border-primary/30 bg-primary/10 text-primary",children:l.jsx(We,{children:S})}):null,l.jsxs("div",{className:"grid min-h-0 gap-4 xl:grid-cols-[minmax(320px,420px)_1fr]",children:[l.jsx(hB,{data:o,readOnly:a,onPatch:P}),l.jsxs(Ge,{className:"flex min-h-[520px] flex-col overflow-hidden border-border bg-card",children:[l.jsxs(Ze,{className:"pb-2",children:[l.jsx(Qe,{className:"text-base",children:"Live preview"}),l.jsxs(ht,{children:["Sample ticket with your current settings",E?" · updating…":""]})]}),l.jsx(Fe,{className:"min-h-0 flex-1 p-4 pt-0",children:l.jsx("iframe",{title:"Transcript template preview",srcDoc:C,className:ce("h-[min(640px,calc(100svh-14rem))] w-full rounded-lg border border-border bg-background",E&&"opacity-60"),sandbox:"allow-same-origin"})})]})]})]}):l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v||"Failed to load template"})})}function hB({data:e,readOnly:n,onPatch:a}){return l.jsx("div",{className:"max-h-[min(720px,calc(100svh-12rem))] space-y-4 overflow-y-auto pr-1",children:dB.map(o=>l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{className:"pb-3",children:[l.jsx(Qe,{className:"text-base",children:o.title}),o.description?l.jsx(ht,{children:o.description}):null]}),l.jsx(Fe,{className:"grid gap-4 sm:grid-cols-2",children:o.fields.map(i=>l.jsx("div",{className:i.type==="textarea"?"sm:col-span-2":"",children:l.jsx(zg,{field:i,value:fo(e,i.path),readOnly:n,onChange:c=>a(i.path,c)})},i.path))})]},o.title))})}function gB(e,n){return n&&e!=="viewer"}function vB(){const{user:e,hasPermission:n}=Lt(),a=!gB(e==null?void 0:e.role,n("transcripts")),[o,i]=f.useState(null),[c,d]=f.useState(!0),[m,p]=f.useState(!1),[h,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),C=f.useCallback(async()=>{var k,T,R;d(!0),x(""),j("");try{const P=(await Ne.getTranscriptSettings()).data;P&&i({autoDelete:{enabled:!!((k=P.autoDelete)!=null&&k.enabled),afterDays:((T=P.autoDelete)==null?void 0:T.afterDays)??30},publicAccess:{enabled:!!((R=P.publicAccess)!=null&&R.enabled)}})}catch(D){x(D instanceof Error?D.message:"Failed to load settings")}finally{d(!1)}},[]);f.useEffect(()=>{C()},[C]);async function N(){if(!(!o||a)){p(!0),x(""),j("");try{const k=await Ne.updateTranscriptSettings(o);k.data&&i({autoDelete:{enabled:k.data.autoDelete.enabled,afterDays:k.data.autoDelete.afterDays},publicAccess:{enabled:k.data.publicAccess.enabled}}),j(k.message??"Settings saved.")}catch(k){x(k instanceof Error?k.message:"Failed to save settings")}finally{p(!1)}}}async function E(){var k,T;if(!a){y(!0),x(""),j("");try{const R=await Ne.purgeTranscripts();j(R.message??((k=R.data)!=null&&k.skipped?"Auto-delete is disabled.":`Removed ${((T=R.data)==null?void 0:T.deleted)??0} transcript(s).`))}catch(R){x(R instanceof Error?R.message:"Purge failed")}finally{y(!1)}}}return c?l.jsxs("div",{className:"space-y-4",children:[l.jsx(Ve,{className:"h-40 w-full rounded-xl"}),l.jsx(Ve,{className:"h-40 w-full rounded-xl"})]}):o?l.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[a?l.jsx(Ye,{children:l.jsx(We,{children:"You have view-only access. An admin or editor can change these settings."})}):null,v?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v})}):null,S?l.jsx(Ye,{children:l.jsx(We,{children:S})}):null,l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-base",children:"Auto-delete"}),l.jsx(ht,{children:"Remove transcript files automatically after they reach a certain age. The server checks hourly and whenever you open the library."})]}),l.jsxs(Fe,{className:"space-y-4",children:[l.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[l.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.autoDelete.enabled,disabled:a,onChange:k=>i(T=>T&&{...T,autoDelete:{...T.autoDelete,enabled:k.target.checked}})}),l.jsxs("span",{className:"text-sm",children:[l.jsx("span",{className:"font-medium",children:"Enable auto-delete"}),l.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Deletes HTML files in Data/Transcripts based on last modified time."})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx("label",{className:"text-sm font-medium",htmlFor:"transcript-after-days",children:"Delete after (days)"}),l.jsx(Ue,{id:"transcript-after-days",type:"number",min:1,max:3650,disabled:a||!o.autoDelete.enabled,value:o.autoDelete.afterDays,onChange:k=>i(T=>T&&{...T,autoDelete:{...T.autoDelete,afterDays:Math.min(3650,Math.max(1,parseInt(k.target.value,10)||1))}}),className:"max-w-[8rem]"})]}),l.jsxs(ve,{type:"button",variant:"outline",size:"sm",disabled:a||h,onClick:()=>void E(),children:[l.jsx(ye,{icon:_s,size:16,className:ce(h&&"animate-spin")}),"Run cleanup now"]})]})]}),l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-base",children:"Public transcripts"}),l.jsxs(ht,{children:["When enabled, anyone with the link can view a transcript at"," ",l.jsx("code",{className:"rounded bg-muted px-1 py-0.5 text-xs",children:typeof window<"u"?`${window.location.origin}/transcripts/:id`:"/transcripts/:id"})," ","without signing in. Channel IDs are numeric but not secret—only enable if you are comfortable sharing links."]})]}),l.jsx(Fe,{children:l.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[l.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.publicAccess.enabled,disabled:a,onChange:k=>i(T=>T&&{...T,publicAccess:{enabled:k.target.checked}})}),l.jsxs("span",{className:"text-sm",children:[l.jsx("span",{className:"font-medium",children:"Allow public transcript URLs"}),l.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Dashboard preview and download still require login."})]})]})})]}),a?null:l.jsxs(ve,{type:"button",disabled:m,onClick:()=>void N(),children:[l.jsx(ye,{icon:Hu,size:16}),m?"Saving…":"Save settings"]})]}):l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:"Could not load transcript settings."})})}function bB(e,n){return n&&e!=="viewer"}function x0(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function S0(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function yB(){var U;const{user:e,hasPermission:n}=Lt(),a=bB(e==null?void 0:e.role,n("transcripts")),[o,i]=f.useState("browse"),[c,d]=f.useState([]),[m,p]=f.useState(null),[h,y]=f.useState(!0),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState(""),[E,k]=f.useState(0),[T,R]=f.useState(!1),[D,P]=f.useState(!1),[z,B]=f.useState(!1),[H,Y]=f.useState(!1),Q=f.useCallback(async()=>{y(!0),j("");try{const F=(await Ne.listTranscripts()).data??[];d(F),p(ae=>{var ne;return ae&&F.some(me=>me.id===ae)?ae:((ne=F[0])==null?void 0:ne.id)??null})}catch(V){j(V instanceof Error?V.message:"Failed to load transcripts")}finally{y(!1)}},[]);f.useEffect(()=>{Q()},[Q]),f.useEffect(()=>{o==="browse"&&Ne.getTranscriptSettings().then(V=>{var F,ae;B(!!((ae=(F=V.data)==null?void 0:F.publicAccess)!=null&&ae.enabled))}).catch(()=>B(!1))},[o]);const fe=f.useMemo(()=>{if(!C.trim())return c;const V=C.toLowerCase();return c.filter(F=>F.id.includes(V)||F.filename.toLowerCase().includes(V)||F.ticketName&&F.ticketName.toLowerCase().includes(V))},[c,C]),de=f.useMemo(()=>c.find(V=>V.id===m)??null,[c,m]),he=m?`/api/system/transcripts/${encodeURIComponent(m)}/view`:null,se=m?`/api/system/transcripts/${encodeURIComponent(m)}/download`:null,O=m&&z?`${window.location.origin}/transcripts/${encodeURIComponent(m)}`:null;function $(V){x(""),p(V),k(F=>F+1)}function Z(){he&&window.open(he,"_blank","noopener,noreferrer")}function J(){O&&window.open(O,"_blank","noopener,noreferrer")}async function te(){if(O)try{await navigator.clipboard.writeText(O),Y(!0),window.setTimeout(()=>Y(!1),2e3)}catch{x("Could not copy link to clipboard.")}}async function M(){var F;if(!m||!a)return;const V=((F=de==null?void 0:de.ticketName)==null?void 0:F.trim())||`channel ${m}`;if(window.confirm(`Delete the transcript for ${V}? This cannot be undone.`)){P(!0),x("");try{await Ne.deleteTranscript(m),await Q()}catch(ae){x(ae instanceof Error?ae.message:"Failed to delete transcript")}finally{P(!1)}}}async function _(){if(!(!se||!de)){R(!0),x("");try{const V=await fetch(se,{credentials:"include"});if(!V.ok){const me=await V.json().catch(()=>({}));throw new Error(me.error||`Download failed (${V.status})`)}const F=await V.blob(),ae=URL.createObjectURL(F),ne=document.createElement("a");ne.href=ae,ne.download=de.filename,ne.click(),URL.revokeObjectURL(ae)}catch(V){x(V instanceof Error?V.message:"Failed to download transcript")}finally{R(!1)}}}return l.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Transcripts"}),l.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Browse saved transcripts or customize how new ones look when tickets close."})]}),l.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[l.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[l.jsx(ve,{type:"button",variant:o==="browse"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>i("browse"),children:"Library"}),l.jsx(ve,{type:"button",variant:o==="appearance"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>i("appearance"),children:"Appearance"}),l.jsx(ve,{type:"button",variant:o==="settings"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>i("settings"),children:"Settings"})]}),o==="browse"?l.jsxs(ve,{variant:"outline",size:"sm",onClick:()=>Q(),disabled:h,children:[l.jsx(ye,{icon:_s,size:16,className:ce(h&&"animate-spin")}),"Refresh"]}):null]})]}),o==="appearance"?l.jsx(pB,{}):o==="settings"?l.jsx(vB,{}):l.jsxs(l.Fragment,{children:[S?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:S})}):null,l.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(240px,320px)_1fr]",children:[l.jsxs(Ge,{className:"flex min-h-[420px] flex-col border-border bg-card",children:[l.jsxs(Ze,{className:"space-y-3 pb-3",children:[l.jsxs(Qe,{className:"text-base font-medium",children:["Saved transcripts",!h&&c.length>0?l.jsxs("span",{className:"ml-2 font-normal text-muted-foreground",children:["(",c.length,")"]}):null]}),l.jsxs("div",{className:"relative",children:[l.jsx(ye,{icon:Gu,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),l.jsx(Ue,{placeholder:"Search by ticket name or channel ID…",value:C,onChange:V=>N(V.target.value),className:"pl-9"})]})]}),l.jsx(Fe,{className:"min-h-0 flex-1 p-0 pb-4",children:l.jsx(Sd,{className:"h-[min(520px,calc(100svh-16rem))] px-4",children:h?l.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((V,F)=>l.jsx(Ve,{className:"h-16 w-full rounded-lg"},F))}):fe.length===0?l.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-muted-foreground",children:[l.jsx(ye,{icon:Zi,size:32,className:"opacity-40"}),l.jsx("p",{children:c.length===0?"No transcripts yet. They appear when tickets are closed.":"No transcripts match your search."})]}):l.jsx("ul",{className:"space-y-1.5",children:fe.map(V=>{var ne;const F=V.id===m,ae=((ne=V.ticketName)==null?void 0:ne.trim())||`Channel ${V.id}`;return l.jsx("li",{children:l.jsxs("button",{type:"button",onClick:()=>$(V.id),className:ce("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",F?"border-primary/50 bg-primary/10":"border-transparent bg-secondary/30 hover:bg-secondary/50"),children:[l.jsx("p",{className:"truncate text-sm font-medium",children:ae}),l.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[S0(V.createdAt),V.size!=null?` · ${x0(V.size)}`:""]})]})},V.id)})})})})]}),l.jsxs(Ge,{className:"flex min-h-[420px] flex-col overflow-hidden border-border bg-card",children:[l.jsxs(Ze,{className:"flex flex-row flex-wrap items-center justify-between gap-2 space-y-0 pb-3",children:[l.jsxs("div",{className:"min-w-0",children:[l.jsx(Qe,{className:"truncate text-base font-medium",children:de?((U=de.ticketName)==null?void 0:U.trim())||`Channel ${de.id}`:"Preview"}),de?l.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[S0(de.createdAt),de.size!=null?` · ${x0(de.size)}`:""]}):null]}),l.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[O?l.jsxs(l.Fragment,{children:[l.jsxs(ve,{variant:"outline",size:"sm",onClick:()=>void te(),children:[l.jsx(ye,{icon:Y0,size:16}),H?"Copied":"Copy link"]}),l.jsxs(ve,{variant:"outline",size:"sm",onClick:J,children:[l.jsx(ye,{icon:Vu,size:16}),"Public page"]})]}):null,l.jsxs(ve,{variant:"outline",size:"sm",disabled:!he,onClick:Z,children:[l.jsx(ye,{icon:J4,size:16}),"Open tab"]}),l.jsxs(ve,{variant:"outline",size:"sm",disabled:!se||T,onClick:()=>void _(),children:[l.jsx(ye,{icon:Uu,size:16}),T?"Saving…":"Download"]}),a?l.jsxs(ve,{variant:"outline",size:"sm",disabled:!m||D,className:"text-destructive hover:text-destructive",onClick:()=>void M(),children:[l.jsx(ye,{icon:Lh,size:16}),D?"Deleting…":"Delete"]}):null]})]}),l.jsxs(Fe,{className:"flex min-h-0 flex-1 flex-col gap-2 p-4 pt-0",children:[v?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:v})}):null,de&&he?l.jsx("iframe",{title:`Transcript ${de.id}`,src:he,className:"min-h-[min(560px,calc(100svh-18rem))] w-full flex-1 rounded-lg border border-border bg-background",sandbox:"allow-same-origin"},E):l.jsxs("div",{className:"flex flex-1 flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-border py-16 text-center text-sm text-muted-foreground",children:[l.jsx(ye,{icon:Zi,size:40,className:"opacity-30"}),l.jsx("p",{children:"Select a transcript from the list to preview it here."})]})]})]})]})]})]})}function xB(){const[e,n]=f.useState([]),[a,o]=f.useState(""),[i,c]=f.useState(!0),[d,m]=f.useState(""),p=f.useCallback(async()=>{c(!0),m("");try{const y=await Ne.listOpenTickets();y.data&&(o(y.data.guildId),n(y.data.tickets.sort((v,x)=>x.created_at-v.created_at)))}catch(y){m(y instanceof Error?y.message:"Failed to load open tickets")}finally{c(!1)}},[]);f.useEffect(()=>{p()},[p]);const h=y=>{const v=Math.floor((Date.now()-y)/1e3);return Ih(v)};return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Open Tickets"}),l.jsx("p",{className:"text-muted-foreground",children:"View live tickets currently active in Discord."})]}),l.jsxs(ve,{onClick:()=>void p(),disabled:i,variant:"outline",size:"sm",children:[l.jsx(ye,{icon:_s,size:16,className:i?"animate-spin mr-2":"mr-2"}),"Refresh"]})]}),l.jsx(Ge,{className:"border-border bg-card",children:l.jsx(Fe,{className:"p-0",children:i?l.jsxs("div",{className:"space-y-4 p-6",children:[l.jsx(Ve,{className:"h-12 w-full"}),l.jsx(Ve,{className:"h-12 w-full"}),l.jsx(Ve,{className:"h-12 w-full"})]}):d?l.jsx("div",{className:"p-6",children:l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:d})})}):e.length===0?l.jsx("div",{className:"p-12 text-center text-muted-foreground",children:"No open tickets at the moment!"}):l.jsx("div",{className:"divide-y divide-border",children:e.map(y=>l.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center justify-between p-4 hover:bg-secondary/10 transition-colors gap-4",children:[l.jsxs("div",{className:"space-y-1",children:[l.jsxs("p",{className:"font-medium text-primary",children:[y.subject||"Untitled Ticket",l.jsxs("span",{className:"ml-2 text-xs font-mono text-muted-foreground",children:["#",y.ticket_id]})]}),l.jsxs("p",{className:"text-sm text-muted-foreground",children:["User ID: ",y.user_id," • Dept: ",y.department," • Priority: ",y.priority]})]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("div",{className:"text-sm text-muted-foreground flex items-center whitespace-nowrap",children:[l.jsx(ye,{icon:t8,size:14,className:"mr-1.5"}),h(y.created_at)]}),a&&l.jsx(ve,{variant:"secondary",size:"sm",asChild:!0,children:l.jsxs("a",{href:`https://discord.com/channels/${a}/${y.ticket_id}`,target:"_blank",rel:"noreferrer",children:[l.jsx(ye,{icon:Vu,size:16,className:"mr-2"}),"View"]})})]})]},y.ticket_id))})})})]})}const SB=["admin","moderator","editor","viewer","custom"];function wB(){return{mode:"add",id:"",username:"",globalName:"",role:"viewer",enabled:!0,permissions:Ji("viewer"),yamlOwner:!1}}function CB({permissions:e,onChange:n,disabled:a}){const o=i=>n({...e,...i});return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[[["Dashboard overview","overview"],["Logs","logs"],["Transcripts","transcripts"]].map(([i,c])=>l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:i}),l.jsx(dn,{checked:e[c],disabled:a,onCheckedChange:d=>o({[c]:d})})]},c)),l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:"Settings — view"}),l.jsx(dn,{checked:e.settings.view,disabled:a,onCheckedChange:i=>o({settings:{...e.settings,view:i}})})]}),l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:"Settings — install updates"}),l.jsx(dn,{checked:e.settings.update,disabled:a,onCheckedChange:i=>o({settings:{...e.settings,update:i}})})]}),l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:"Users — view"}),l.jsx(dn,{checked:e.users.view,disabled:a,onCheckedChange:i=>o({users:{...e.users,view:i}})})]}),l.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:"Users — manage"}),l.jsx(dn,{checked:e.users.manage,disabled:a,onCheckedChange:i=>o({users:{...e.users,manage:i}})})]})]}),l.jsxs("div",{className:"space-y-3",children:[l.jsx("p",{className:"text-sm font-medium",children:"Configuration files"}),l.jsx("div",{className:"space-y-2",children:$h.map(i=>l.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:h8[i]}),l.jsxs("div",{className:"flex items-center gap-4",children:[l.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:["View",l.jsx(dn,{checked:e.configs[i].view,disabled:a,onCheckedChange:c=>n({...e,configs:{...e.configs,[i]:{...e.configs[i],view:c}}})})]}),l.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:["Edit",l.jsx(dn,{checked:e.configs[i].edit,disabled:a,onCheckedChange:c=>n({...e,configs:{...e.configs,[i]:{...e.configs[i],edit:c,view:c?!0:e.configs[i].view}}})})]})]})]},i))})]})]})}function jB(e){return e.permissions.users.manage?"Full + user management":e.permissions.settings.update?"Configs + settings updates":Object.values(e.permissions.configs).some(n=>n.edit)?"Can edit configs":"View only"}function EB(){const{user:e,hasPermission:n}=Lt(),a=n("users.manage"),[o,i]=f.useState([]),[c,d]=f.useState(!0),[m,p]=f.useState(""),[h,y]=f.useState(null),[v,x]=f.useState(!1),S=f.useCallback(async()=>{d(!0),p("");try{const R=await Ne.listDashboardUsers();R.data&&i(R.data.users)}catch(R){p(R instanceof Error?R.message:"Failed to load users")}finally{d(!1)}},[]);f.useEffect(()=>{S()},[S]);const j=f.useMemo(()=>[...o].sort((R,D)=>R.yamlOwner!==D.yamlOwner?R.yamlOwner?-1:1:(R.username||R.id).localeCompare(D.username||D.id)),[o]);function C(){y(wB())}function N(R){y({mode:"edit",id:R.id,username:R.username||"",globalName:R.globalName||"",role:R.yamlOwner?"owner":R.role,enabled:R.enabled,permissions:R.role==="custom"?R.permissions:Ji(R.role),yamlOwner:R.yamlOwner})}function E(R){h&&y({...h,role:R,permissions:Ji(R,h.permissions)})}async function k(){if(!(!h||!a)){x(!0),p("");try{h.mode==="add"?await Ne.addDashboardUser({id:h.id.trim(),role:h.role,username:h.username||void 0,globalName:h.globalName||void 0,enabled:h.enabled,permissions:h.role==="custom"?h.permissions:void 0}):await Ne.updateDashboardUser(h.id,{role:h.yamlOwner?void 0:h.role,enabled:h.enabled,username:h.username||void 0,globalName:h.globalName||void 0,permissions:h.role==="custom"?h.permissions:void 0}),y(null),await S()}catch(R){p(R instanceof Error?R.message:"Could not save user")}finally{x(!1)}}}async function T(R){if(a&&window.confirm("Remove this user from the dashboard?")){p("");try{await Ne.removeDashboardUser(R),await S()}catch(D){p(D instanceof Error?D.message:"Could not remove user")}}}return l.jsxs("div",{className:"space-y-6",children:[l.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[l.jsxs("div",{children:[l.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Users"}),l.jsxs("p",{className:"text-muted-foreground",children:["Control who can sign in and what they can view or edit. Owners in"," ",l.jsx("code",{className:"rounded bg-primary/10 px-1 text-xs text-primary",children:"api.yml"})," ","always have full access."]})]}),a?l.jsxs(ve,{onClick:C,children:[l.jsx(ye,{icon:Q4,size:16,className:"mr-2"}),"Add user"]}):null]}),m?l.jsx(Ye,{variant:"destructive",children:l.jsx(We,{children:m})}):null,l.jsxs(Ge,{className:"border-border bg-card",children:[l.jsxs(Ze,{children:[l.jsx(Qe,{className:"text-base",children:"Dashboard access"}),l.jsxs(ht,{children:[j.length," user",j.length===1?"":"s",a?" — use edit to change permissions":""]})]}),l.jsx(Fe,{children:c?l.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading users…"}):l.jsx("div",{className:"divide-y divide-border/60",children:j.map(R=>l.jsxs("div",{className:"flex flex-wrap items-center gap-4 py-4 first:pt-0 last:pb-0",children:[l.jsxs("div",{className:"flex min-w-[200px] flex-1 items-center gap-3",children:[l.jsxs(Ss,{className:"size-9",children:[l.jsx(ws,{src:R.avatar,alt:R.username}),l.jsx(Cs,{children:(R.username||R.id).slice(0,2).toUpperCase()})]}),l.jsxs("div",{className:"min-w-0",children:[l.jsxs("p",{className:"truncate font-medium",children:[Z0(R),R.id===(e==null?void 0:e.id)?" (you)":""]}),l.jsx("p",{className:"truncate text-xs text-muted-foreground",children:R.id})]})]}),l.jsx(gs,{variant:"secondary",children:Zx[R.yamlOwner?"owner":R.role]}),l.jsx("p",{className:"max-w-[200px] text-xs text-muted-foreground",children:jB(R)}),R.enabled?l.jsx(gs,{className:"bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/15",children:"Active"}):l.jsx(gs,{variant:"outline",children:"Disabled"}),a?l.jsxs("div",{className:"ml-auto flex gap-1",children:[l.jsx(ve,{variant:"ghost",size:"icon",onClick:()=>N(R),"aria-label":"Edit user",children:l.jsx(ye,{icon:n8,size:16})}),R.yamlOwner?null:l.jsx(ve,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>T(R.id),"aria-label":"Remove user",children:l.jsx(ye,{icon:Lh,size:16})})]}):null]},R.id))})})]}),l.jsx(gg,{open:!!h,onOpenChange:R=>!R&&y(null),children:l.jsxs(hd,{className:"max-h-[90vh] max-w-lg overflow-y-auto",children:[l.jsxs(gd,{children:[l.jsx(vd,{children:(h==null?void 0:h.mode)==="add"?"Add dashboard user":"Edit user"}),l.jsx(bd,{children:h!=null&&h.yamlOwner?"This user is an owner in api.yml. Role and removal are managed in the config file.":p8[(h==null?void 0:h.role)??"viewer"]})]}),h?l.jsxs("div",{className:"space-y-4",children:[h.mode==="add"?l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{htmlFor:"discord-id",children:"Discord user ID"}),l.jsx(Ue,{id:"discord-id",value:h.id,onChange:R=>y({...h,id:R.target.value}),placeholder:"829112572816130058"})]}):null,l.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Display name (optional)"}),l.jsx(Ue,{value:h.globalName,onChange:R=>y({...h,globalName:R.target.value})})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Username (optional)"}),l.jsx(Ue,{value:h.username,onChange:R=>y({...h,username:R.target.value})})]})]}),l.jsxs("div",{className:"space-y-2",children:[l.jsx(De,{children:"Role"}),l.jsxs(Es,{value:h.role,disabled:h.yamlOwner,onValueChange:R=>E(R),children:[l.jsx(lo,{children:l.jsx(Ns,{})}),l.jsx(co,{children:h.yamlOwner?l.jsx(Zt,{value:"owner",children:"Owner"}):SB.map(R=>l.jsx(Zt,{value:R,children:Zx[R]},R))})]})]}),l.jsxs("label",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2",children:[l.jsx("span",{className:"text-sm",children:"Account enabled"}),l.jsx(dn,{checked:h.enabled,disabled:h.yamlOwner,onCheckedChange:R=>y({...h,enabled:R})})]}),h.role==="custom"&&!h.yamlOwner?l.jsx(CB,{permissions:h.permissions,onChange:R=>y({...h,permissions:R})}):null]}):null,l.jsxs(vg,{children:[l.jsx(ve,{variant:"outline",onClick:()=>y(null),children:"Cancel"}),l.jsx(ve,{disabled:v||!a||(h==null?void 0:h.mode)==="add"&&!/^\d{17,20}$/.test(h.id.trim()),onClick:()=>void k(),children:v?"Saving…":"Save"})]})]})})]})}function NB({children:e}){const{isAuthenticated:n,loading:a}=Lt();return a?l.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):n?l.jsx(l.Fragment,{children:e}):l.jsx(Lr,{to:"/login",replace:!0})}function kB(){const{complete:e,loading:n}=GC(),a=jn();return n?l.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):e?a.pathname==="/setup"?l.jsx(Lr,{to:"/login",replace:!0}):l.jsxs(qx,{children:[l.jsx(Yt,{path:"/login",element:l.jsx(v$,{})}),l.jsxs(Yt,{element:l.jsx(NB,{children:l.jsx(AO,{})}),children:[l.jsx(Yt,{index:!0,element:l.jsx(U$,{})}),l.jsx(Yt,{path:"system",element:l.jsx(va,{permission:"overview",children:l.jsx(nB,{})})}),l.jsx(Yt,{path:"settings",element:l.jsx(va,{permission:"settings.view",children:l.jsx(J$,{})})}),l.jsx(Yt,{path:"configs",element:l.jsx(p$,{})}),l.jsx(Yt,{path:"logs",element:l.jsx(va,{permission:"logs",children:l.jsx(uB,{})})}),l.jsx(Yt,{path:"tickets",element:l.jsx(va,{permission:"transcripts",children:l.jsx(xB,{})})}),l.jsx(Yt,{path:"transcripts",element:l.jsx(va,{permission:"transcripts",children:l.jsx(yB,{})})}),l.jsx(Yt,{path:"users",element:l.jsx(va,{permission:"users.view",children:l.jsx(EB,{})})}),l.jsx(Yt,{path:"addons",element:l.jsx(va,{permission:"settings.view",children:l.jsx(H$,{})})}),l.jsx(Yt,{path:"addons/builder",element:l.jsx(va,{permission:"settings.update",children:l.jsx(V$,{})})})]}),l.jsx(Yt,{path:"*",element:l.jsx(Lr,{to:"/",replace:!0})})]}):l.jsxs(qx,{children:[l.jsx(Yt,{path:"/setup",element:l.jsx(_$,{})}),l.jsx(Yt,{path:"*",element:l.jsx(Lr,{to:"/setup",replace:!0})})]})}function TB({...e}){return l.jsx(WP,{theme:"dark",position:"bottom-right",richColors:!0,closeButton:!0,style:{fontFamily:'"Poppins", system-ui, sans-serif'},toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-card group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground"}},...e})}q$();b3.createRoot(document.getElementById("root")).render(l.jsx(f.StrictMode,{children:l.jsx(V4,{children:l.jsx(Ww,{children:l.jsx(y8,{children:l.jsx(MO,{children:l.jsxs(b8,{children:[l.jsx(kB,{}),l.jsx(TB,{})]})})})})})}));