var RN=Object.defineProperty;var AN=(e,n,a)=>n in e?RN(e,n,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[n]=a;var m1=(e,n,a)=>AN(e,typeof n!="symbol"?n+"":n,a);function _N(e,n){for(var a=0;ao[l]})}}}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 l of document.querySelectorAll('link[rel="modulepreload"]'))o(l);new MutationObserver(l=>{for(const i of l)if(i.type==="childList")for(const d of i.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&o(d)}).observe(document,{childList:!0,subtree:!0});function a(l){const i={};return l.integrity&&(i.integrity=l.integrity),l.referrerPolicy&&(i.referrerPolicy=l.referrerPolicy),l.crossOrigin==="use-credentials"?i.credentials="include":l.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function o(l){if(l.ep)return;l.ep=!0;const i=a(l);fetch(l.href,i)}})();function Xx(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Rm={exports:{}},Nl={};/** * @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 p1;function MN(){if(p1)return Nl;p1=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function a(o,l,i){var d=null;if(i!==void 0&&(d=""+i),l.key!==void 0&&(d=""+l.key),"key"in l){i={};for(var m in l)m!=="key"&&(i[m]=l[m])}else i=l;return l=i.ref,{$$typeof:e,type:o,key:d,ref:l!==void 0?l:null,props:i}}return Nl.Fragment=n,Nl.jsx=a,Nl.jsxs=a,Nl}var h1;function ON(){return h1||(h1=1,Rm.exports=MN()),Rm.exports}var c=ON(),Am={exports:{}},_e={};/** * @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 g1;function DN(){if(g1)return _e;g1=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),o=Symbol.for("react.strict_mode"),l=Symbol.for("react.profiler"),i=Symbol.for("react.consumer"),d=Symbol.for("react.context"),m=Symbol.for("react.forward_ref"),h=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),y=Symbol.for("react.lazy"),v=Symbol.for("react.activity"),x=Symbol.iterator;function S(_){return _===null||typeof _!="object"?null:(_=x&&_[x]||_["@@iterator"],typeof _=="function"?_:null)}var j={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},C=Object.assign,N={};function E(_,O,H){this.props=_,this.context=O,this.refs=N,this.updater=H||j}E.prototype.isReactComponent={},E.prototype.setState=function(_,O){if(typeof _!="object"&&typeof _!="function"&&_!=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,_,O,"setState")},E.prototype.forceUpdate=function(_){this.updater.enqueueForceUpdate(this,_,"forceUpdate")};function k(){}k.prototype=E.prototype;function A(_,O,H){this.props=_,this.context=O,this.refs=N,this.updater=H||j}var R=A.prototype=new k;R.constructor=A,C(R,E.prototype),R.isPureReactComponent=!0;var L=Array.isArray;function z(){}var B={H:null,A:null,T:null,S:null},U=Object.prototype.hasOwnProperty;function q(_,O,H){var I=H.ref;return{$$typeof:e,type:_,key:O,ref:I!==void 0?I:null,props:H}}function Z(_,O){return q(_.type,O,_.props)}function Q(_){return typeof _=="object"&&_!==null&&_.$$typeof===e}function fe(_){var O={"=":"=0",":":"=2"};return"$"+_.replace(/[=:]/g,function(H){return O[H]})}var de=/\/+/g;function ce(_,O){return typeof _=="object"&&_!==null&&_.key!=null?fe(""+_.key):O.toString(36)}function he(_){switch(_.status){case"fulfilled":return _.value;case"rejected":throw _.reason;default:switch(typeof _.status=="string"?_.then(z,z):(_.status="pending",_.then(function(O){_.status==="pending"&&(_.status="fulfilled",_.value=O)},function(O){_.status==="pending"&&(_.status="rejected",_.reason=O)})),_.status){case"fulfilled":return _.value;case"rejected":throw _.reason}}throw _}function M(_,O,H,I,V){var ne=typeof _;(ne==="undefined"||ne==="boolean")&&(_=null);var J=!1;if(_===null)J=!0;else switch(ne){case"bigint":case"string":case"number":J=!0;break;case"object":switch(_.$$typeof){case e:case n:J=!0;break;case y:return J=_._init,M(J(_._payload),O,H,I,V)}}if(J)return V=V(_),J=I===""?"."+ce(_,0):I,L(V)?(H="",J!=null&&(H=J.replace(de,"$&/")+"/"),M(V,O,H,"",function(G){return G})):V!=null&&(Q(V)&&(V=Z(V,H+(V.key==null||_&&_.key===V.key?"":(""+V.key).replace(de,"$&/")+"/")+J)),O.push(V)),1;J=0;var me=I===""?".":I+":";if(L(_))for(var pe=0;pe<_.length;pe++)I=_[pe],ne=me+ce(I,pe),J+=M(I,O,H,ne,V);else if(pe=S(_),typeof pe=="function")for(_=pe.call(_),pe=0;!(I=_.next()).done;)I=I.value,ne=me+ce(I,pe++),J+=M(I,O,H,ne,V);else if(ne==="object"){if(typeof _.then=="function")return M(he(_),O,H,I,V);throw O=String(_),Error("Objects are not valid as a React child (found: "+(O==="[object Object]"?"object with keys {"+Object.keys(_).join(", ")+"}":O)+"). If you meant to render a collection of children, use an array instead.")}return J}function K(_,O,H){if(_==null)return _;var I=[],V=0;return M(_,I,"","",function(ne){return O.call(H,ne,V++)}),I}function re(_){if(_._status===-1){var O=_._result;O=O(),O.then(function(H){(_._status===0||_._status===-1)&&(_._status=1,_._result=H)},function(H){(_._status===0||_._status===-1)&&(_._status=2,_._result=H)}),_._status===-1&&(_._status=0,_._result=O)}if(_._status===1)return _._result.default;throw _._result}var oe=typeof reportError=="function"?reportError:function(_){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var O=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof _=="object"&&_!==null&&typeof _.message=="string"?String(_.message):String(_),error:_});if(!window.dispatchEvent(O))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",_);return}console.error(_)},ee={map:K,forEach:function(_,O,H){K(_,function(){O.apply(this,arguments)},H)},count:function(_){var O=0;return K(_,function(){O++}),O},toArray:function(_){return K(_,function(O){return O})||[]},only:function(_){if(!Q(_))throw Error("React.Children.only expected to receive a single React element child.");return _}};return _e.Activity=v,_e.Children=ee,_e.Component=E,_e.Fragment=a,_e.Profiler=l,_e.PureComponent=A,_e.StrictMode=o,_e.Suspense=h,_e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=B,_e.__COMPILER_RUNTIME={__proto__:null,c:function(_){return B.H.useMemoCache(_)}},_e.cache=function(_){return function(){return _.apply(null,arguments)}},_e.cacheSignal=function(){return null},_e.cloneElement=function(_,O,H){if(_==null)throw Error("The argument must be a React element, but you passed "+_+".");var I=C({},_.props),V=_.key;if(O!=null)for(ne in O.key!==void 0&&(V=""+O.key),O)!U.call(O,ne)||ne==="key"||ne==="__self"||ne==="__source"||ne==="ref"&&O.ref===void 0||(I[ne]=O[ne]);var ne=arguments.length-2;if(ne===1)I.children=H;else if(1>>1,ee=M[oe];if(0>>1;oe<_;){var O=2*(oe+1)-1,H=M[O],I=O+1,V=M[I];if(0>l(H,re))Il(V,H)?(M[oe]=V,M[I]=re,oe=I):(M[oe]=H,M[O]=re,oe=O);else if(Il(V,re))M[oe]=V,M[I]=re,oe=I;else break e}}return K}function l(M,K){var re=M.sortIndex-K.sortIndex;return re!==0?re:M.id-K.id}if(e.unstable_now=void 0,typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var d=Date,m=d.now();e.unstable_now=function(){return d.now()-m}}var h=[],p=[],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,A=typeof setImmediate<"u"?setImmediate:null;function R(M){for(var K=a(p);K!==null;){if(K.callback===null)o(p);else if(K.startTime<=M)o(p),K.sortIndex=K.expirationTime,n(h,K);else break;K=a(p)}}function L(M){if(C=!1,R(M),!j)if(a(h)!==null)j=!0,z||(z=!0,fe());else{var K=a(p);K!==null&&he(L,K.startTime-M)}}var z=!1,B=-1,U=5,q=-1;function Z(){return N?!0:!(e.unstable_now()-qM&&Z());){var oe=v.callback;if(typeof oe=="function"){v.callback=null,x=v.priorityLevel;var ee=oe(v.expirationTime<=M);if(M=e.unstable_now(),typeof ee=="function"){v.callback=ee,R(M),K=!0;break t}v===a(h)&&o(h),R(M)}else o(h);v=a(h)}if(v!==null)K=!0;else{var _=a(p);_!==null&&he(L,_.startTime-M),K=!1}}break e}finally{v=null,x=re,S=!1}K=void 0}}finally{K?fe():z=!1}}}var fe;if(typeof A=="function")fe=function(){A(Q)};else if(typeof MessageChannel<"u"){var de=new MessageChannel,ce=de.port2;de.port1.onmessage=Q,fe=function(){ce.postMessage(null)}}else fe=function(){E(Q,0)};function he(M,K){B=E(function(){M(e.unstable_now())},K)}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(M){M.callback=null},e.unstable_forceFrameRate=function(M){0>M||125oe?(M.sortIndex=re,n(p,M),a(h)===null&&M===a(p)&&(C?(k(B),B=-1):C=!0,he(L,re-oe))):(M.sortIndex=ee,n(h,M),j||S||(j=!0,z||(z=!0,fe()))),M},e.unstable_shouldYield=Z,e.unstable_wrapCallback=function(M){var K=x;return function(){var re=x;x=K;try{return M.apply(this,arguments)}finally{x=re}}}})(Om)),Om}var y1;function zN(){return y1||(y1=1,Mm.exports=LN()),Mm.exports}var Dm={exports:{}},Gt={};/** * @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 x1;function PN(){if(x1)return Gt;x1=1;var e=Cu();function n(h){var p="https://react.dev/errors/"+h;if(1"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(n){console.error(n)}}return e(),Dm.exports=PN(),Dm.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 w1;function BN(){if(w1)return kl;w1=1;var e=zN(),n=Cu(),a=Zx();function o(t){var r="https://react.dev/errors/"+t;if(1ee||(t.current=oe[ee],oe[ee]=null,ee--)}function H(t,r){ee++,oe[ee]=t.current,t.current=r}var I=_(null),V=_(null),ne=_(null),J=_(null);function me(t,r){switch(H(ne,r),H(V,t),H(I,null),r.nodeType){case 9:case 11:t=(t=r.documentElement)&&(t=t.namespaceURI)?zy(t):0;break;default:if(t=r.tagName,r=r.namespaceURI)r=zy(r),t=Py(r,t);else switch(t){case"svg":t=1;break;case"math":t=2;break;default:t=0}}O(I),H(I,t)}function pe(){O(I),O(V),O(ne)}function G(t){t.memoizedState!==null&&H(J,t);var r=I.current,s=Py(r,t.type);r!==s&&(H(V,t),H(I,s))}function se(t){V.current===t&&(O(I),O(V)),J.current===t&&(O(J),wl._currentValue=re)}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||D[u]!==Y[g]){var te=` `+D[u].replace(" at new "," at ");return t.displayName&&te.includes("")&&(te=te.replace("",t.displayName)),te}while(1<=u&&0<=g);break}}}finally{Qe=!1,Error.prepareStackTrace=s}return(s=t?t.displayName||t.name:"")?Ae(s):""}function Tt(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 Ca(t){try{var r="",s=null;do r+=Tt(t,s),s=t,t=t.return;while(t);return r}catch(u){return` Error generating stack: `+u.message+` `+u.stack}}var Rt=Object.prototype.hasOwnProperty,Os=e.unstable_scheduleCallback,Ds=e.unstable_cancelCallback,Yt=e.unstable_shouldYield,$r=e.unstable_requestPaint,Wt=e.unstable_now,gd=e.unstable_getCurrentPriorityLevel,ja=e.unstable_ImmediatePriority,xi=e.unstable_UserBlockingPriority,Ea=e.unstable_NormalPriority,Ls=e.unstable_LowPriority,dr=e.unstable_IdlePriority,Si=e.log,Ir=e.unstable_setDisableYieldValue,Na=null,qt=null;function $n(t){if(typeof Si=="function"&&Ir(t),qt&&typeof qt.setStrictMode=="function")try{qt.setStrictMode(Na,t)}catch{}}var Ht=Math.clz32?Math.clz32:Xn,vd=Math.log,zs=Math.LN2;function Xn(t){return t>>>=0,t===0?32:31-(vd(t)/zs|0)|0}var fo=256,mo=262144,ka=4194304;function Zn(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 Te(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 T=u&134217727;return T!==0?(u=T&~b,u!==0?g=Zn(u):(w&=T,w!==0?g=Zn(w):s||(s=T&~t,s!==0&&(g=Zn(s))))):(T=u&~b,T!==0?g=Zn(T):w!==0?g=Zn(w):s||(s=u&~t,s!==0&&(g=Zn(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 At(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 Vt(){var t=ka;return ka<<=1,(ka&62914560)===0&&(ka=4194304),t}function Ur(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 Zt(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 T=t.entanglements,D=t.expirationTimes,Y=t.hiddenUpdates;for(s=w&~s;0"u")return null;try{return t.activeElement||t.body}catch{return t.body}}var C5=/[\n"\\]/g;function En(t){return t.replace(C5,function(r){return"\\"+r.charCodeAt(0).toString(16)+" "})}function wd(t,r,s,u,g,b,w,T){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=""+jn(r)):t.value!==""+jn(r)&&(t.value=""+jn(r)):w!=="submit"&&w!=="reset"||t.removeAttribute("value"),r!=null?Cd(t,w,jn(r)):s!=null?Cd(t,w,jn(s)):u!=null&&t.removeAttribute("value"),g==null&&b!=null&&(t.defaultChecked=!!b),g!=null&&(t.checked=g&&typeof g!="function"&&typeof g!="symbol"),T!=null&&typeof T!="function"&&typeof T!="symbol"&&typeof T!="boolean"?t.name=""+jn(T):t.removeAttribute("name")}function Ag(t,r,s,u,g,b,w,T){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)){Sd(t);return}s=s!=null?""+jn(s):"",r=r!=null?""+jn(r):s,T||r===t.value||(t.value=r),t.defaultValue=r}u=u??g,u=typeof u!="function"&&typeof u!="symbol"&&!!u,t.checked=T?t.checked:!!u,t.defaultChecked=!!u,w!=null&&typeof w!="function"&&typeof w!="symbol"&&typeof w!="boolean"&&(t.name=w),Sd(t)}function Cd(t,r,s){r==="number"&&ji(t.ownerDocument)===t||t.defaultValue===""+s||(t.defaultValue=""+s)}function xo(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"),Td=!1;if(pr)try{var Is={};Object.defineProperty(Is,"passive",{get:function(){Td=!0}}),window.addEventListener("test",Is,Is),window.removeEventListener("test",Is,Is)}catch{Td=!1}var Vr=null,Rd=null,Ni=null;function Pg(){if(Ni)return Ni;var t,r=Rd,s=r.length,u,g="value"in Vr?Vr.value:Vr.textContent,b=g.length;for(t=0;t=Vs),Vg=" ",Gg=!1;function Fg(t,r){switch(t){case"keyup":return Z5.indexOf(r.keyCode)!==-1;case"keydown":return r.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var jo=!1;function J5(t,r){switch(t){case"compositionend":return Yg(r);case"keypress":return r.which!==32?null:(Gg=!0,Vg);case"textInput":return t=r.data,t===Vg&&Gg?null:t;default:return null}}function eE(t,r){if(jo)return t==="compositionend"||!Dd&&Fg(t,r)?(t=Pg(),Ni=Rd=Vr=null,jo=!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=ev(s)}}function nv(t,r){return t&&r?t===r?!0:t&&t.nodeType===3?!1:r&&r.nodeType===3?nv(t,r.parentNode):"contains"in t?t.contains(r):t.compareDocumentPosition?!!(t.compareDocumentPosition(r)&16):!1:!1}function rv(t){t=t!=null&&t.ownerDocument!=null&&t.ownerDocument.defaultView!=null?t.ownerDocument.defaultView:window;for(var r=ji(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=ji(t.document)}return r}function Pd(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 iE=pr&&"documentMode"in document&&11>=document.documentMode,Eo=null,Bd=null,Ws=null,$d=!1;function av(t,r,s){var u=s.window===s?s.document:s.nodeType===9?s:s.ownerDocument;$d||Eo==null||Eo!==ji(u)||(u=Eo,"selectionStart"in u&&Pd(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}),Ws&&Ys(Ws,u)||(Ws=u,u=yc(Bd,"onSelect"),0>=w,g-=w,Qn=1<<32-Ht(r)+g|s<Oe?($e=Ce,Ce=null):$e=Ce.sibling;var Ge=W($,Ce,F[Oe],ae);if(Ge===null){Ce===null&&(Ce=$e);break}t&&Ce&&Ge.alternate===null&&r($,Ce),P=b(Ge,P,Oe),Ve===null?Ee=Ge:Ve.sibling=Ge,Ve=Ge,Ce=$e}if(Oe===F.length)return s($,Ce),Ie&&gr($,Oe),Ee;if(Ce===null){for(;OeOe?($e=Ce,Ce=null):$e=Ce.sibling;var da=W($,Ce,Ge.value,ae);if(da===null){Ce===null&&(Ce=$e);break}t&&Ce&&da.alternate===null&&r($,Ce),P=b(da,P,Oe),Ve===null?Ee=da:Ve.sibling=da,Ve=da,Ce=$e}if(Ge.done)return s($,Ce),Ie&&gr($,Oe),Ee;if(Ce===null){for(;!Ge.done;Oe++,Ge=F.next())Ge=le($,Ge.value,ae),Ge!==null&&(P=b(Ge,P,Oe),Ve===null?Ee=Ge:Ve.sibling=Ge,Ve=Ge);return Ie&&gr($,Oe),Ee}for(Ce=u(Ce);!Ge.done;Oe++,Ge=F.next())Ge=X(Ce,$,Oe,Ge.value,ae),Ge!==null&&(t&&Ge.alternate!==null&&Ce.delete(Ge.key===null?Oe:Ge.key),P=b(Ge,P,Oe),Ve===null?Ee=Ge:Ve.sibling=Ge,Ve=Ge);return t&&Ce.forEach(function(TN){return r($,TN)}),Ie&&gr($,Oe),Ee}function tt($,P,F,ae){if(typeof F=="object"&&F!==null&&F.type===C&&F.key===null&&(F=F.props.children),typeof F=="object"&&F!==null){switch(F.$$typeof){case S:e:{for(var Ee=F.key;P!==null;){if(P.key===Ee){if(Ee=F.type,Ee===C){if(P.tag===7){s($,P.sibling),ae=g(P,F.props.children),ae.return=$,$=ae;break e}}else if(P.elementType===Ee||typeof Ee=="object"&&Ee!==null&&Ee.$$typeof===U&&$a(Ee)===P.type){s($,P.sibling),ae=g(P,F.props),Js(ae,F),ae.return=$,$=ae;break e}s($,P);break}else r($,P);P=P.sibling}F.type===C?(ae=Da(F.props.children,$.mode,ae,F.key),ae.return=$,$=ae):(ae=zi(F.type,F.key,F.props,null,$.mode,ae),Js(ae,F),ae.return=$,$=ae)}return w($);case j:e:{for(Ee=F.key;P!==null;){if(P.key===Ee)if(P.tag===4&&P.stateNode.containerInfo===F.containerInfo&&P.stateNode.implementation===F.implementation){s($,P.sibling),ae=g(P,F.children||[]),ae.return=$,$=ae;break e}else{s($,P);break}else r($,P);P=P.sibling}ae=Yd(F,$.mode,ae),ae.return=$,$=ae}return w($);case U:return F=$a(F),tt($,P,F,ae)}if(he(F))return we($,P,F,ae);if(fe(F)){if(Ee=fe(F),typeof Ee!="function")throw Error(o(150));return F=Ee.call(F),Ne($,P,F,ae)}if(typeof F.then=="function")return tt($,P,Vi(F),ae);if(F.$$typeof===A)return tt($,P,$i($,F),ae);Gi($,F)}return typeof F=="string"&&F!==""||typeof F=="number"||typeof F=="bigint"?(F=""+F,P!==null&&P.tag===6?(s($,P.sibling),ae=g(P,F),ae.return=$,$=ae):(s($,P),ae=Fd(F,$.mode,ae),ae.return=$,$=ae),w($)):s($,P)}return function($,P,F,ae){try{Qs=0;var Ee=tt($,P,F,ae);return zo=null,Ee}catch(Ce){if(Ce===Lo||Ce===Ui)throw Ce;var Ve=fn(29,Ce,null,$.mode);return Ve.lanes=ae,Ve.return=$,Ve}finally{}}}var Ua=kv(!0),Tv=kv(!1),qr=!1;function af(t){t.updateQueue={baseState:t.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function of(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 Kr(t){return{lane:t,tag:0,payload:null,callback:null,next:null}}function Xr(t,r,s){var u=t.updateQueue;if(u===null)return null;if(u=u.shared,(Ye&2)!==0){var g=u.pending;return g===null?r.next=r:(r.next=g.next,g.next=r),u.pending=r,r=Li(t),dv(t,null,s),r}return Di(t,u,r,s),Li(t)}function el(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,Qt(t,s)}}function sf(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 lf=!1;function tl(){if(lf){var t=Do;if(t!==null)throw t}}function nl(t,r,s,u){lf=!1;var g=t.updateQueue;qr=!1;var b=g.firstBaseUpdate,w=g.lastBaseUpdate,T=g.shared.pending;if(T!==null){g.shared.pending=null;var D=T,Y=D.next;D.next=null,w===null?b=Y:w.next=Y,w=D;var te=t.alternate;te!==null&&(te=te.updateQueue,T=te.lastBaseUpdate,T!==w&&(T===null?te.firstBaseUpdate=Y:T.next=Y,te.lastBaseUpdate=D))}if(b!==null){var le=g.baseState;w=0,te=Y=D=null,T=b;do{var W=T.lane&-536870913,X=W!==T.lane;if(X?(Be&W)===W:(u&W)===W){W!==0&&W===Oo&&(lf=!0),te!==null&&(te=te.next={lane:0,tag:T.tag,payload:T.payload,callback:null,next:null});e:{var we=t,Ne=T;W=r;var tt=s;switch(Ne.tag){case 1:if(we=Ne.payload,typeof we=="function"){le=we.call(tt,le,W);break e}le=we;break e;case 3:we.flags=we.flags&-65537|128;case 0:if(we=Ne.payload,W=typeof we=="function"?we.call(tt,le,W):we,W==null)break e;le=v({},le,W);break e;case 2:qr=!0}}W=T.callback,W!==null&&(t.flags|=64,X&&(t.flags|=8192),X=g.callbacks,X===null?g.callbacks=[W]:X.push(W))}else X={lane:W,tag:T.tag,payload:T.payload,callback:T.callback,next:null},te===null?(Y=te=X,D=le):te=te.next=X,w|=W;if(T=T.next,T===null){if(T=g.shared.pending,T===null)break;X=T,T=X.next,X.next=null,g.lastBaseUpdate=X,g.shared.pending=null}}while(!0);te===null&&(D=le),g.baseState=D,g.firstBaseUpdate=Y,g.lastBaseUpdate=te,b===null&&(g.shared.lanes=0),ta|=w,t.lanes=w,t.memoizedState=le}}function Rv(t,r){if(typeof t!="function")throw Error(o(191,t));t.call(r)}function Av(t,r){var s=t.callbacks;if(s!==null)for(t.callbacks=null,t=0;tb?b:8;var w=M.T,T={};M.T=T,kf(t,!1,r,s);try{var D=g(),Y=M.S;if(Y!==null&&Y(T,D),D!==null&&typeof D=="object"&&typeof D.then=="function"){var te=vE(D,u);ol(t,r,te,vn(t))}else ol(t,r,u,vn(t))}catch(le){ol(t,r,{then:function(){},status:"rejected",reason:le},vn())}finally{K.p=b,w!==null&&T.types!==null&&(w.types=T.types),M.T=w}}function CE(){}function Ef(t,r,s,u){if(t.tag!==5)throw Error(o(476));var g=ib(t).queue;lb(t,g,r,re,s===null?CE:function(){return cb(t),s(u)})}function ib(t){var r=t.memoizedState;if(r!==null)return r;r={memoizedState:re,baseState:re,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xr,lastRenderedState:re},next:null};var s={};return r.next={memoizedState:s,baseState:s,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:xr,lastRenderedState:s},next:null},t.memoizedState=r,t=t.alternate,t!==null&&(t.memoizedState=r),r}function cb(t){var r=ib(t);r.next===null&&(r=t.alternate.memoizedState),ol(t,r.next.queue,{},vn())}function Nf(){return Pt(wl)}function ub(){return bt().memoizedState}function db(){return bt().memoizedState}function jE(t){for(var r=t.return;r!==null;){switch(r.tag){case 24:case 3:var s=vn();t=Kr(s);var u=Xr(r,t,s);u!==null&&(sn(u,r,s),el(u,r,s)),r={cache:ef()},t.payload=r;return}r=r.return}}function EE(t,r,s){var u=vn();s={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null},ec(t)?mb(r,s):(s=Vd(t,r,s,u),s!==null&&(sn(s,t,u),pb(s,r,u)))}function fb(t,r,s){var u=vn();ol(t,r,s,u)}function ol(t,r,s,u){var g={lane:u,revertLane:0,gesture:null,action:s,hasEagerState:!1,eagerState:null,next:null};if(ec(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,T=b(w,s);if(g.hasEagerState=!0,g.eagerState=T,dn(T,w))return Di(t,r,g,0),nt===null&&Oi(),!1}catch{}finally{}if(s=Vd(t,r,g,u),s!==null)return sn(s,t,u),pb(s,r,u),!0}return!1}function kf(t,r,s,u){if(u={lane:2,revertLane:om(),gesture:null,action:u,hasEagerState:!1,eagerState:null,next:null},ec(t)){if(r)throw Error(o(479))}else r=Vd(t,s,u,2),r!==null&&sn(r,t,2)}function ec(t){var r=t.alternate;return t===Me||r!==null&&r===Me}function mb(t,r){Bo=Wi=!0;var s=t.pending;s===null?r.next=r:(r.next=s.next,s.next=r),t.pending=r}function pb(t,r,s){if((s&4194048)!==0){var u=r.lanes;u&=t.pendingLanes,s|=u,r.lanes=s,Qt(t,s)}}var sl={readContext:Pt,use:Xi,useCallback:ht,useContext:ht,useEffect:ht,useImperativeHandle:ht,useLayoutEffect:ht,useInsertionEffect:ht,useMemo:ht,useReducer:ht,useRef:ht,useState:ht,useDebugValue:ht,useDeferredValue:ht,useTransition:ht,useSyncExternalStore:ht,useId:ht,useHostTransitionStatus:ht,useFormState:ht,useActionState:ht,useOptimistic:ht,useMemoCache:ht,useCacheRefresh:ht};sl.useEffectEvent=ht;var hb={readContext:Pt,use:Xi,useCallback:function(t,r){return Kt().memoizedState=[t,r===void 0?null:r],t},useContext:Pt,useEffect:Qv,useImperativeHandle:function(t,r,s){s=s!=null?s.concat([t]):null,Qi(4194308,4,nb.bind(null,r,t),s)},useLayoutEffect:function(t,r){return Qi(4194308,4,t,r)},useInsertionEffect:function(t,r){Qi(4,2,t,r)},useMemo:function(t,r){var s=Kt();r=r===void 0?null:r;var u=t();if(Ha){$n(!0);try{t()}finally{$n(!1)}}return s.memoizedState=[u,r],u},useReducer:function(t,r,s){var u=Kt();if(s!==void 0){var g=s(r);if(Ha){$n(!0);try{s(r)}finally{$n(!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=EE.bind(null,Me,t),[u.memoizedState,t]},useRef:function(t){var r=Kt();return t={current:t},r.memoizedState=t},useState:function(t){t=xf(t);var r=t.queue,s=fb.bind(null,Me,r);return r.dispatch=s,[t.memoizedState,s]},useDebugValue:Cf,useDeferredValue:function(t,r){var s=Kt();return jf(s,t,r)},useTransition:function(){var t=xf(!1);return t=lb.bind(null,Me,t.queue,!0,!1),Kt().memoizedState=t,[!1,t]},useSyncExternalStore:function(t,r,s){var u=Me,g=Kt();if(Ie){if(s===void 0)throw Error(o(407));s=s()}else{if(s=r(),nt===null)throw Error(o(349));(Be&127)!==0||zv(u,r,s)}g.memoizedState=s;var b={value:s,getSnapshot:r};return g.queue=b,Qv(Bv.bind(null,u,b,t),[t]),u.flags|=2048,Io(9,{destroy:void 0},Pv.bind(null,u,b,s,r),null),s},useId:function(){var t=Kt(),r=nt.identifierPrefix;if(Ie){var s=Jn,u=Qn;s=(u&~(1<<32-Ht(u)-1)).toString(32)+s,r="_"+r+"R_"+s,s=qi++,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[Lt]=r,b[en]=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($t(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&&wr(r)}}return it(r),Uf(r,r.type,t===null?null:t.memoizedProps,r.pendingProps,s),null;case 6:if(t&&r.stateNode!=null)t.memoizedProps!==u&&wr(r);else{if(typeof u!="string"&&r.stateNode===null)throw Error(o(166));if(t=ne.current,_o(r)){if(t=r.stateNode,s=r.memoizedProps,u=null,g=zt,g!==null)switch(g.tag){case 27:case 5:u=g.memoizedProps}t[Lt]=r,t=!!(t.nodeValue===s||u!==null&&u.suppressHydrationWarning===!0||Dy(t.nodeValue,s)),t||Yr(r,!0)}else t=xc(t).createTextNode(u),t[Lt]=r,r.stateNode=t}return it(r),null;case 31:if(s=r.memoizedState,t===null||t.memoizedState!==null){if(u=_o(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[Lt]=r}else La(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),t=!1}else s=Xd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=s),t=!0;if(!t)return r.flags&256?(pn(r),r):(pn(r),null);if((r.flags&128)!==0)throw Error(o(558))}return it(r),null;case 13:if(u=r.memoizedState,t===null||t.memoizedState!==null&&t.memoizedState.dehydrated!==null){if(g=_o(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[Lt]=r}else La(),(r.flags&128)===0&&(r.memoizedState=null),r.flags|=4;it(r),g=!1}else g=Xd(),t!==null&&t.memoizedState!==null&&(t.memoizedState.hydrationErrors=g),g=!0;if(!g)return r.flags&256?(pn(r),r):(pn(r),null)}return pn(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),oc(r,r.updateQueue),it(r),null);case 4:return pe(),t===null&&cm(r.stateNode.containerInfo),it(r),null;case 10:return br(r.type),it(r),null;case 19:if(O(vt),u=r.memoizedState,u===null)return it(r),null;if(g=(r.flags&128)!==0,b=u.rendering,b===null)if(g)il(u,!1);else{if(gt!==0||t!==null&&(t.flags&128)!==0)for(t=r.child;t!==null;){if(b=Yi(t),b!==null){for(r.flags|=128,il(u,!1),t=b.updateQueue,r.updateQueue=t,oc(r,t),r.subtreeFlags=0,t=s,s=r.child;s!==null;)fv(s,t),s=s.sibling;return H(vt,vt.current&1|2),Ie&&gr(r,u.treeForkCount),r.child}t=t.sibling}u.tail!==null&&Wt()>uc&&(r.flags|=128,g=!0,il(u,!1),r.lanes=4194304)}else{if(!g)if(t=Yi(b),t!==null){if(r.flags|=128,g=!0,t=t.updateQueue,r.updateQueue=t,oc(r,t),il(u,!0),u.tail===null&&u.tailMode==="hidden"&&!b.alternate&&!Ie)return it(r),null}else 2*Wt()-u.renderingStartTime>uc&&s!==536870912&&(r.flags|=128,g=!0,il(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=Wt(),t.sibling=null,s=vt.current,H(vt,g?s&1|2:s&1),Ie&&gr(r,u.treeForkCount),t):(it(r),null);case 22:case 23:return pn(r),uf(),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&&(it(r),r.subtreeFlags&6&&(r.flags|=8192)):it(r),s=r.updateQueue,s!==null&&oc(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&&O(Ba),null;case 24:return s=null,t!==null&&(s=t.memoizedState.cache),r.memoizedState.cache!==s&&(r.flags|=2048),br(yt),it(r),null;case 25:return null;case 30:return null}throw Error(o(156,r.tag))}function AE(t,r){switch(qd(r),r.tag){case 1:return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 3:return br(yt),pe(),t=r.flags,(t&65536)!==0&&(t&128)===0?(r.flags=t&-65537|128,r):null;case 26:case 27:case 5:return se(r),null;case 31:if(r.memoizedState!==null){if(pn(r),r.alternate===null)throw Error(o(340));La()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 13:if(pn(r),t=r.memoizedState,t!==null&&t.dehydrated!==null){if(r.alternate===null)throw Error(o(340));La()}return t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 19:return O(vt),null;case 4:return pe(),null;case 10:return br(r.type),null;case 22:case 23:return pn(r),uf(),t!==null&&O(Ba),t=r.flags,t&65536?(r.flags=t&-65537|128,r):null;case 24:return br(yt),null;case 25:return null;default:return null}}function $b(t,r){switch(qd(r),r.tag){case 3:br(yt),pe();break;case 26:case 27:case 5:se(r);break;case 4:pe();break;case 31:r.memoizedState!==null&&pn(r);break;case 13:pn(r);break;case 19:O(vt);break;case 10:br(r.type);break;case 22:case 23:pn(r),uf(),t!==null&&O(Ba);break;case 24:br(yt)}}function cl(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(T){Xe(r,r.return,T)}}function Jr(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,T=w.destroy;if(T!==void 0){w.destroy=void 0,g=r;var D=s,Y=T;try{Y()}catch(te){Xe(g,D,te)}}}u=u.next}while(u!==b)}}catch(te){Xe(r,r.return,te)}}function Ib(t){var r=t.updateQueue;if(r!==null){var s=t.stateNode;try{Av(r,s)}catch(u){Xe(t,t.return,u)}}}function Ub(t,r,s){s.props=Va(t.type,t.memoizedProps),s.state=t.memoizedState;try{s.componentWillUnmount()}catch(u){Xe(t,r,u)}}function ul(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){Xe(t,r,g)}}function er(t,r){var s=t.ref,u=t.refCleanup;if(s!==null)if(typeof u=="function")try{u()}catch(g){Xe(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){Xe(t,r,g)}else s.current=null}function Hb(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){Xe(t,t.return,g)}}function Hf(t,r,s){try{var u=t.stateNode;QE(u,t.type,s,r),u[en]=r}catch(g){Xe(t,t.return,g)}}function Vb(t){return t.tag===5||t.tag===3||t.tag===26||t.tag===27&&sa(t.type)||t.tag===4}function Vf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Vb(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&&sa(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 Gf(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=mr));else if(u!==4&&(u===27&&sa(t.type)&&(s=t.stateNode,r=null),t=t.child,t!==null))for(Gf(t,r,s),t=t.sibling;t!==null;)Gf(t,r,s),t=t.sibling}function sc(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&&sa(t.type)&&(s=t.stateNode),t=t.child,t!==null))for(sc(t,r,s),t=t.sibling;t!==null;)sc(t,r,s),t=t.sibling}function Gb(t){var r=t.stateNode,s=t.memoizedProps;try{for(var u=t.type,g=r.attributes;g.length;)r.removeAttributeNode(g[0]);$t(r,u,s),r[Lt]=t,r[en]=s}catch(b){Xe(t,t.return,b)}}var Cr=!1,wt=!1,Ff=!1,Fb=typeof WeakSet=="function"?WeakSet:Set,Mt=null;function _E(t,r){if(t=t.containerInfo,fm=kc,t=rv(t),Pd(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,T=-1,D=-1,Y=0,te=0,le=t,W=null;t:for(;;){for(var X;le!==s||g!==0&&le.nodeType!==3||(T=w+g),le!==b||u!==0&&le.nodeType!==3||(D=w+u),le.nodeType===3&&(w+=le.nodeValue.length),(X=le.firstChild)!==null;)W=le,le=X;for(;;){if(le===t)break t;if(W===s&&++Y===g&&(T=w),W===b&&++te===u&&(D=w),(X=le.nextSibling)!==null)break;le=W,W=le.parentNode}le=X}s=T===-1||D===-1?null:{start:T,end:D}}else s=null}s=s||{start:0,end:0}}else s=null;for(mm={focusedElem:t,selectionRange:s},kc=!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"))),$t(b,u,s),b[Lt]=t,_t(b),u=b;break e;case"link":var w=Zy("link","href",g).get(u+(s.href||""));if(w){for(var T=0;Ttt&&(w=tt,tt=Ne,Ne=w);var $=tv(T,Ne),P=tv(T,tt);if($&&P&&(X.rangeCount!==1||X.anchorNode!==$.node||X.anchorOffset!==$.offset||X.focusNode!==P.node||X.focusOffset!==P.offset)){var F=le.createRange();F.setStart($.node,$.offset),X.removeAllRanges(),Ne>tt?(X.addRange(F),X.extend(P.node,P.offset)):(F.setEnd(P.node,P.offset),X.addRange(F))}}}}for(le=[],X=T;X=X.parentNode;)X.nodeType===1&&le.push({element:X,left:X.scrollLeft,top:X.scrollTop});for(typeof T.focus=="function"&&T.focus(),T=0;Ts?32:s,M.T=null,s=Qf,Qf=null;var b=ra,w=Tr;if(jt=0,Fo=ra=null,Tr=0,(Ye&6)!==0)throw Error(o(331));var T=Ye;if(Ye|=4,ny(b.current),Jb(b,b.current,w,s),Ye=T,gl(0,!1),qt&&typeof qt.onPostCommitFiberRoot=="function")try{qt.onPostCommitFiberRoot(Na,b)}catch{}return!0}finally{K.p=g,M.T=u,xy(t,r)}}function wy(t,r,s){r=kn(s,r),r=_f(t.stateNode,r,2),t=Xr(t,r,2),t!==null&&(mt(t,2),tr(t))}function Xe(t,r,s){if(t.tag===3)wy(t,t,s);else for(;r!==null;){if(r.tag===3){wy(r,t,s);break}else if(r.tag===1){var u=r.stateNode;if(typeof r.type.getDerivedStateFromError=="function"||typeof u.componentDidCatch=="function"&&(na===null||!na.has(u))){t=kn(s,t),s=Cb(2),u=Xr(r,s,2),u!==null&&(jb(s,u,r,t),mt(u,2),tr(u));break}}r=r.return}}function nm(t,r,s){var u=t.pingCache;if(u===null){u=t.pingCache=new DE;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)||(qf=!0,g.add(s),t=$E.bind(null,t,r,s),r.then(t,t))}function $E(t,r,s){var u=t.pingCache;u!==null&&u.delete(r),t.pingedLanes|=t.suspendedLanes&s,t.warmLanes&=~s,nt===t&&(Be&s)===s&&(gt===4||gt===3&&(Be&62914560)===Be&&300>Wt()-cc?(Ye&2)===0&&Yo(t,0):Kf|=s,Go===Be&&(Go=0)),tr(t)}function Cy(t,r){r===0&&(r=Vt()),t=Oa(t,r),t!==null&&(mt(t,r),tr(t))}function IE(t){var r=t.memoizedState,s=0;r!==null&&(s=r.retryLane),Cy(t,s)}function UE(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),Cy(t,s)}function HE(t,r){return Os(t,r)}var gc=null,qo=null,rm=!1,vc=!1,am=!1,oa=0;function tr(t){t!==qo&&t.next===null&&(qo===null?gc=qo=t:qo=qo.next=t),vc=!0,rm||(rm=!0,GE())}function gl(t,r){if(!am&&vc){am=!0;do for(var s=!1,u=gc;u!==null;){if(t!==0){var g=u.pendingLanes;if(g===0)var b=0;else{var w=u.suspendedLanes,T=u.pingedLanes;b=(1<<31-Ht(42|t)+1)-1,b&=g&~(w&~T),b=b&201326741?b&201326741|1:b?b|2:0}b!==0&&(s=!0,ky(u,b))}else b=Be,b=Te(u,u===nt?b:0,u.cancelPendingCommit!==null||u.timeoutHandle!==-1),(b&3)===0||ut(u,b)||(s=!0,ky(u,b));u=u.next}while(s);am=!1}}function VE(){jy()}function jy(){vc=rm=!1;var t=0;oa!==0&&eN()&&(t=oa);for(var r=Wt(),s=null,u=gc;u!==null;){var g=u.next,b=Ey(u,r);b===0?(u.next=null,s===null?gc=g:s.next=g,g===null&&(qo=s)):(s=u,(t!==0||(b&3)!==0)&&(vc=!0)),u=g}jt!==0&&jt!==5||gl(t),oa!==0&&(oa=0)}function Ey(t,r){for(var s=t.suspendedLanes,u=t.pingedLanes,g=t.expirationTimes,b=t.pendingLanes&-62914561;0T)break;var te=D.transferSize,le=D.initiatorType;te&&Ly(le)&&(D=D.responseEnd,w+=te*(D"u"?null:document;function Wy(t,r,s){var u=Ko;if(u&&typeof r=="string"&&r){var g=En(r);g='link[rel="'+t+'"][href="'+g+'"]',typeof s=="string"&&(g+='[crossorigin="'+s+'"]'),Yy.has(g)||(Yy.add(g),t={rel:t,crossOrigin:s,href:r},u.querySelector(g)===null&&(r=u.createElement("link"),$t(r,"link",t),_t(r),u.head.appendChild(r)))}}function cN(t){Rr.D(t),Wy("dns-prefetch",t,null)}function uN(t,r){Rr.C(t,r),Wy("preconnect",t,r)}function dN(t,r,s){Rr.L(t,r,s);var u=Ko;if(u&&t&&r){var g='link[rel="preload"][as="'+En(r)+'"]';r==="image"&&s&&s.imageSrcSet?(g+='[imagesrcset="'+En(s.imageSrcSet)+'"]',typeof s.imageSizes=="string"&&(g+='[imagesizes="'+En(s.imageSizes)+'"]')):g+='[href="'+En(t)+'"]';var b=g;switch(r){case"style":b=Xo(t);break;case"script":b=Zo(t)}On.has(b)||(t=v({rel:"preload",href:r==="image"&&s&&s.imageSrcSet?void 0:t,as:r},s),On.set(b,t),u.querySelector(g)!==null||r==="style"&&u.querySelector(xl(b))||r==="script"&&u.querySelector(Sl(b))||(r=u.createElement("link"),$t(r,"link",t),_t(r),u.head.appendChild(r)))}}function fN(t,r){Rr.m(t,r);var s=Ko;if(s&&t){var u=r&&typeof r.as=="string"?r.as:"script",g='link[rel="modulepreload"][as="'+En(u)+'"][href="'+En(t)+'"]',b=g;switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":b=Zo(t)}if(!On.has(b)&&(t=v({rel:"modulepreload",href:t},r),On.set(b,t),s.querySelector(g)===null)){switch(u){case"audioworklet":case"paintworklet":case"serviceworker":case"sharedworker":case"worker":case"script":if(s.querySelector(Sl(b)))return}u=s.createElement("link"),$t(u,"link",t),_t(u),s.head.appendChild(u)}}}function mN(t,r,s){Rr.S(t,r,s);var u=Ko;if(u&&t){var g=bo(u).hoistableStyles,b=Xo(t);r=r||"default";var w=g.get(b);if(!w){var T={loading:0,preload:null};if(w=u.querySelector(xl(b)))T.loading=5;else{t=v({rel:"stylesheet",href:t,"data-precedence":r},s),(s=On.get(b))&&xm(t,s);var D=w=u.createElement("link");_t(D),$t(D,"link",t),D._p=new Promise(function(Y,te){D.onload=Y,D.onerror=te}),D.addEventListener("load",function(){T.loading|=1}),D.addEventListener("error",function(){T.loading|=2}),T.loading|=4,wc(w,r,u)}w={type:"stylesheet",instance:w,count:1,state:T},g.set(b,w)}}}function pN(t,r){Rr.X(t,r);var s=Ko;if(s&&t){var u=bo(s).hoistableScripts,g=Zo(t),b=u.get(g);b||(b=s.querySelector(Sl(g)),b||(t=v({src:t,async:!0},r),(r=On.get(g))&&Sm(t,r),b=s.createElement("script"),_t(b),$t(b,"link",t),s.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},u.set(g,b))}}function hN(t,r){Rr.M(t,r);var s=Ko;if(s&&t){var u=bo(s).hoistableScripts,g=Zo(t),b=u.get(g);b||(b=s.querySelector(Sl(g)),b||(t=v({src:t,async:!0,type:"module"},r),(r=On.get(g))&&Sm(t,r),b=s.createElement("script"),_t(b),$t(b,"link",t),s.head.appendChild(b)),b={type:"script",instance:b,count:1,state:null},u.set(g,b))}}function qy(t,r,s,u){var g=(g=ne.current)?Sc(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=Xo(s.href),s=bo(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=Xo(s.href);var b=bo(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(xl(t)))&&!b._p&&(w.instance=b,w.state.loading=5),On.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},On.set(t,s),b||gN(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=Zo(s),s=bo(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 Xo(t){return'href="'+En(t)+'"'}function xl(t){return'link[rel="stylesheet"]['+t+"]"}function Ky(t){return v({},t,{"data-precedence":t.precedence,precedence:null})}function gN(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}),$t(r,"link",s),_t(r),t.head.appendChild(r))}function Zo(t){return'[src="'+En(t)+'"]'}function Sl(t){return"script[async]"+t}function Xy(t,r,s){if(r.count++,r.instance===null)switch(r.type){case"style":var u=t.querySelector('style[data-href~="'+En(s.href)+'"]');if(u)return r.instance=u,_t(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"),_t(u),$t(u,"style",g),wc(u,s.precedence,t),r.instance=u;case"stylesheet":g=Xo(s.href);var b=t.querySelector(xl(g));if(b)return r.state.loading|=4,r.instance=b,_t(b),b;u=Ky(s),(g=On.get(g))&&xm(u,g),b=(t.ownerDocument||t).createElement("link"),_t(b);var w=b;return w._p=new Promise(function(T,D){w.onload=T,w.onerror=D}),$t(b,"link",u),r.state.loading|=4,wc(b,s.precedence,t),r.instance=b;case"script":return b=Zo(s.src),(g=t.querySelector(Sl(b)))?(r.instance=g,_t(g),g):(u=s,(g=On.get(b))&&(u=v({},s),Sm(u,g)),t=t.ownerDocument||t,g=t.createElement("script"),_t(g),$t(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,wc(u,s.precedence,t));return r.instance}function wc(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 vN(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 Jy(t){return!(t.type==="stylesheet"&&(t.state.loading&3)===0)}function bN(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=Xo(u.href),b=r.querySelector(xl(g));if(b){r=b._p,r!==null&&typeof r=="object"&&typeof r.then=="function"&&(t.count++,t=jc.bind(t),r.then(t,t)),s.state.loading|=4,s.instance=b,_t(b);return}b=r.ownerDocument||r,u=Ky(u),(g=On.get(g))&&xm(u,g),b=b.createElement("link"),_t(b);var w=b;w._p=new Promise(function(T,D){w.onload=T,w.onerror=D}),$t(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=jc.bind(t),r.addEventListener("load",s),r.addEventListener("error",s))}}var wm=0;function yN(t,r){return t.stylesheets&&t.count===0&&Nc(t,t.stylesheets),0wm?50:800)+r);return t.unsuspend=s,function(){t.unsuspend=null,clearTimeout(u),clearTimeout(g)}}:null}function jc(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Nc(this,this.stylesheets);else if(this.unsuspend){var t=this.unsuspend;this.unsuspend=null,t()}}}var Ec=null;function Nc(t,r){t.stylesheets=null,t.unsuspend!==null&&(t.count++,Ec=new Map,r.forEach(xN,t),Ec=null,jc.call(t))}function xN(t,r){if(!(r.state.loading&4)){var s=Ec.get(t);if(s)var u=s.get(null);else{s=new Map,Ec.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(),_m.exports=BN(),_m.exports}var IN=$N();/** * 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 j1="popstate";function E1(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function UN(e={}){function n(o,l){var p;let i=(p=l.state)==null?void 0:p.masked,{pathname:d,search:m,hash:h}=i||o.location;return pp("",{pathname:d,search:m,hash:h},l.state&&l.state.usr||null,l.state&&l.state.key||"default",i?{pathname:o.location.pathname,search:o.location.search,hash:o.location.hash}:void 0)}function a(o,l){return typeof l=="string"?l:Il(l)}return VN(n,a,null,e)}function ft(e,n){if(e===!1||e===null||typeof e>"u")throw new Error(n)}function Pn(e,n){if(!e){typeof console<"u"&&console.warn(n);try{throw new Error(n)}catch{}}}function HN(){return Math.random().toString(36).substring(2,10)}function N1(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 pp(e,n,a=null,o,l){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof n=="string"?ws(n):n,state:a,key:n&&n.key||o||HN(),mask:l}}function Il({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 ws(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 VN(e,n,a,o={}){let{window:l=document.defaultView,v5Compat:i=!1}=o,d=l.history,m="POP",h=null,p=y();p==null&&(p=0,d.replaceState({...d.state,idx:p},""));function y(){return(d.state||{idx:null}).idx}function v(){m="POP";let N=y(),E=N==null?null:N-p;p=N,h&&h({action:m,location:C.location,delta:E})}function x(N,E){m="PUSH";let k=E1(N)?N:pp(C.location,N,E);p=y()+1;let A=N1(k,p),R=C.createHref(k.mask||k);try{d.pushState(A,"",R)}catch(L){if(L instanceof DOMException&&L.name==="DataCloneError")throw L;l.location.assign(R)}i&&h&&h({action:m,location:C.location,delta:1})}function S(N,E){m="REPLACE";let k=E1(N)?N:pp(C.location,N,E);p=y();let A=N1(k,p),R=C.createHref(k.mask||k);d.replaceState(A,"",R),i&&h&&h({action:m,location:C.location,delta:0})}function j(N){return GN(N)}let C={get action(){return m},get location(){return e(l,d)},listen(N){if(h)throw new Error("A history only accepts one active listener");return l.addEventListener(j1,v),h=N,()=>{l.removeEventListener(j1,v),h=null}},createHref(N){return n(l,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 GN(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:Il(e);return o=o.replace(/ $/,"%20"),!n&&o.startsWith("//")&&(o=a+o),new URL(o,a)}function Qx(e,n,a="/"){return FN(e,n,a,!1)}function FN(e,n,a,o,l){let i=typeof n=="string"?ws(n):n,d=Or(i.pathname||"/",a);if(d==null)return null;let m=YN(e),h=null,p=a3(d);for(let y=0;h==null&&y{let y={relativePath:p===void 0?d.path||"":p,caseSensitive:d.caseSensitive===!0,childrenIndex:m,route:d};if(y.relativePath.startsWith("/")){if(!y.relativePath.startsWith(o)&&h)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=Fn([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}".`),Jx(d.children,n,x,v,h)),!(d.path==null&&!d.index)&&n.push({path:v,score:e3(v,d.index),routesMeta:x})};return e.forEach((d,m)=>{var h;if(d.path===""||!((h=d.path)!=null&&h.includes("?")))i(d,m);else for(let p of e0(d.path))i(d,m,!0,p)}),n}function e0(e){let n=e.split("/");if(n.length===0)return[];let[a,...o]=n,l=a.endsWith("?"),i=a.replace(/\?$/,"");if(o.length===0)return l?[i,""]:[i];let d=e0(o.join("/")),m=[];return m.push(...d.map(h=>h===""?i:[i,h].join("/"))),l&&m.push(...d),m.map(h=>e.startsWith("/")&&h===""?"/":h)}function WN(e){e.sort((n,a)=>n.score!==a.score?a.score-n.score:t3(n.routesMeta.map(o=>o.childrenIndex),a.routesMeta.map(o=>o.childrenIndex)))}var qN=/^:[\w-]+$/,KN=3,XN=2,ZN=1,QN=10,JN=-2,k1=e=>e==="*";function e3(e,n){let a=e.split("/"),o=a.length;return a.some(k1)&&(o+=JN),n&&(o+=XN),a.filter(l=>!k1(l)).reduce((l,i)=>l+(qN.test(i)?KN:i===""?ZN:QN),o)}function t3(e,n){return e.length===n.length&&e.slice(0,-1).every((o,l)=>o===n[l])?e[e.length-1]-n[n.length-1]:0}function n3(e,n,a=!1){let{routesMeta:o}=e,l={},i="/",d=[];for(let m=0;m{if(y==="*"){let j=m[x]||"";d=i.slice(0,i.length-j.length).replace(/(.)\/+$/,"$1")}const S=m[x];return v&&!S?p[y]=void 0:p[y]=(S||"").replace(/%2F/g,"/"),p},{}),pathname:i,pathnameBase:d,pattern:e}}function r3(e,n=!1,a=!0){Pn(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=[],l="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(d,m,h,p,y)=>{if(o.push({paramName:m,isOptional:h!=null}),h){let v=y.charAt(p+d.length);return v&&v!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(o.push({paramName:"*"}),l+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):a?l+="\\/*$":e!==""&&e!=="/"&&(l+="(?:(?=\\/|$))"),[new RegExp(l,n?void 0:"i"),o]}function a3(e){try{return e.split("/").map(n=>decodeURIComponent(n).replace(/\//g,"%2F")).join("/")}catch(n){return Pn(!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 Or(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 o3=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function s3(e,n="/"){let{pathname:a,search:o="",hash:l=""}=typeof e=="string"?ws(e):e,i;return a?(a=t0(a),a.startsWith("/")?i=T1(a.substring(1),"/"):i=T1(a,n)):i=n,{pathname:i,search:c3(o),hash:u3(l)}}function T1(e,n){let a=ou(n).split("/");return e.split("/").forEach(l=>{l===".."?a.length>1&&a.pop():l!=="."&&a.push(l)}),a.length>1?a.join("/"):"/"}function Lm(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 l3(e){return e.filter((n,a)=>a===0||n.route.path&&n.route.path.length>0)}function rh(e){let n=l3(e);return n.map((a,o)=>o===n.length-1?a.pathname:a.pathnameBase)}function ju(e,n,a,o=!1){let l;typeof e=="string"?l=ws(e):(l={...e},ft(!l.pathname||!l.pathname.includes("?"),Lm("?","pathname","search",l)),ft(!l.pathname||!l.pathname.includes("#"),Lm("#","pathname","hash",l)),ft(!l.search||!l.search.includes("#"),Lm("#","search","hash",l)));let i=e===""||l.pathname==="",d=i?"/":l.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;l.pathname=x.join("/")}m=v>=0?n[v]:"/"}let h=s3(l,m),p=d&&d!=="/"&&d.endsWith("/"),y=(i||d===".")&&a.endsWith("/");return!h.pathname.endsWith("/")&&(p||y)&&(h.pathname+="/"),h}var t0=e=>e.replace(/\/\/+/g,"/"),Fn=e=>t0(e.join("/")),ou=e=>e.replace(/\/+$/,""),i3=e=>ou(e).replace(/^\/*/,"/"),c3=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,u3=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,d3=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 f3(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function m3(e){let n=e.map(a=>a.route.path).filter(Boolean);return Fn(n)||"/"}var n0=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function r0(e,n){let a=e;if(typeof a!="string"||!o3.test(a))return{absoluteURL:void 0,isExternal:!1,to:a};let o=a,l=!1;if(n0)try{let i=new URL(window.location.href),d=a.startsWith("//")?new URL(i.protocol+a):new URL(a),m=Or(d.pathname,n);d.origin===i.origin&&m!=null?a=m+d.search+d.hash:l=!0}catch{Pn(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:o,isExternal:l,to:a}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var a0=["POST","PUT","PATCH","DELETE"];new Set(a0);var p3=["GET",...a0];new Set(p3);var Cs=f.createContext(null);Cs.displayName="DataRouter";var Eu=f.createContext(null);Eu.displayName="DataRouterState";var o0=f.createContext(!1);function h3(){return f.useContext(o0)}var s0=f.createContext({isTransitioning:!1});s0.displayName="ViewTransition";var g3=f.createContext(new Map);g3.displayName="Fetchers";var v3=f.createContext(null);v3.displayName="Await";var xn=f.createContext(null);xn.displayName="Navigation";var Zl=f.createContext(null);Zl.displayName="Location";var qn=f.createContext({outlet:null,matches:[],isDataRoute:!1});qn.displayName="Route";var ah=f.createContext(null);ah.displayName="RouteError";var l0="REACT_ROUTER_ERROR",b3="REDIRECT",y3="ROUTE_ERROR_RESPONSE";function x3(e){if(e.startsWith(`${l0}:${b3}:{`))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 S3(e){if(e.startsWith(`${l0}:${y3}:{`))try{let n=JSON.parse(e.slice(40));if(typeof n=="object"&&n&&typeof n.status=="number"&&typeof n.statusText=="string")return new d3(n.status,n.statusText,n.data)}catch{}}function w3(e,{relative:n}={}){ft(js(),"useHref() may be used only in the context of a component.");let{basename:a,navigator:o}=f.useContext(xn),{hash:l,pathname:i,search:d}=Ql(e,{relative:n}),m=i;return a!=="/"&&(m=i==="/"?a:Fn([a,i])),o.createHref({pathname:m,search:d,hash:l})}function js(){return f.useContext(Zl)!=null}function Sn(){return ft(js(),"useLocation() may be used only in the context of a component."),f.useContext(Zl).location}var i0="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function c0(e){f.useContext(xn).static||f.useLayoutEffect(e)}function oo(){let{isDataRoute:e}=f.useContext(qn);return e?P3():C3()}function C3(){ft(js(),"useNavigate() may be used only in the context of a component.");let e=f.useContext(Cs),{basename:n,navigator:a}=f.useContext(xn),{matches:o}=f.useContext(qn),{pathname:l}=Sn(),i=JSON.stringify(rh(o)),d=f.useRef(!1);return c0(()=>{d.current=!0}),f.useCallback((h,p={})=>{if(Pn(d.current,i0),!d.current)return;if(typeof h=="number"){a.go(h);return}let y=ju(h,JSON.parse(i),l,p.relative==="path");e==null&&n!=="/"&&(y.pathname=y.pathname==="/"?n:Fn([n,y.pathname])),(p.replace?a.replace:a.push)(y,p.state,p)},[n,a,i,l,e])}var j3=f.createContext(null);function E3(e){let n=f.useContext(qn).outlet;return f.useMemo(()=>n&&f.createElement(j3.Provider,{value:e},n),[n,e])}function Ql(e,{relative:n}={}){let{matches:a}=f.useContext(qn),{pathname:o}=Sn(),l=JSON.stringify(rh(a));return f.useMemo(()=>ju(e,JSON.parse(l),o,n==="path"),[e,l,o,n])}function N3(e,n){return u0(e,n)}function u0(e,n,a){var N;ft(js(),"useRoutes() may be used only in the context of a component.");let{navigator:o}=f.useContext(xn),{matches:l}=f.useContext(qn),i=l[l.length-1],d=i?i.params:{},m=i?i.pathname:"/",h=i?i.pathnameBase:"/",p=i&&i.route;{let E=p&&p.path||"";f0(m,!p||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=Sn(),v;if(n){let E=typeof n=="string"?ws(n):n;ft(h==="/"||((N=E.pathname)==null?void 0:N.startsWith(h)),`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 "${h}" but pathname "${E.pathname}" was given in the \`location\` prop.`),v=E}else v=y;let x=v.pathname||"/",S=x;if(h!=="/"){let E=h.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})):Qx(e,{pathname:S});Pn(p||j!=null,`No routes matched location "${v.pathname}${v.search}${v.hash}" `),Pn(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=_3(j&&j.map(E=>Object.assign({},E,{params:Object.assign({},d,E.params),pathname:Fn([h,o.encodeLocation?o.encodeLocation(E.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathname]),pathnameBase:E.pathnameBase==="/"?h:Fn([h,o.encodeLocation?o.encodeLocation(E.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:E.pathnameBase])})),l,a);return n&&C?f.createElement(Zl.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...v},navigationType:"POP"}},C):C}function k3(){let e=z3(),n=f3(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)",l={padding:"0.5rem",backgroundColor:o},i={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:i},"ErrorBoundary")," or"," ",f.createElement("code",{style:i},"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:l},a):null,d)}var T3=f.createElement(k3,null),d0=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=S3(e.digest);a&&(e=a)}let n=e!==void 0?f.createElement(qn.Provider,{value:this.props.routeContext},f.createElement(ah.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?f.createElement(R3,{error:e},n):n}};d0.contextType=o0;var zm=new WeakMap;function R3({children:e,error:n}){let{basename:a}=f.useContext(xn);if(typeof n=="object"&&n&&"digest"in n&&typeof n.digest=="string"){let o=x3(n.digest);if(o){let l=zm.get(n);if(l)throw l;let i=r0(o.location,a);if(n0&&!zm.get(n))if(i.isExternal||o.reloadDocument)window.location.href=i.absoluteURL||i.to;else{const d=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:o.replace}));throw zm.set(n,d),d}return f.createElement("meta",{httpEquiv:"refresh",content:`0;url=${i.absoluteURL||i.to}`})}}return e}function A3({routeContext:e,match:n,children:a}){let o=f.useContext(Cs);return o&&o.static&&o.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(o.staticContext._deepestRenderedBoundaryId=n.route.id),f.createElement(qn.Provider,{value:e},a)}function _3(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 l=e,i=o==null?void 0:o.errors;if(i!=null){let y=l.findIndex(v=>v.route.id&&(i==null?void 0:i[v.route.id])!==void 0);ft(y>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(i).join(",")}`),l=l.slice(0,Math.min(l.length,y+1))}let d=!1,m=-1;if(a&&o){d=o.renderFallback;for(let y=0;y=0?l=l.slice(0,m+1):l=[l[0]];break}}}}let h=a==null?void 0:a.onError,p=o&&h?(y,v)=>{var x,S;h(y,{location:o.location,params:((S=(x=o.matches)==null?void 0:x[0])==null?void 0:S.params)??{},pattern:m3(o.matches),errorInfo:v})}:void 0;return l.reduceRight((y,v,x)=>{let S,j=!1,C=null,N=null;o&&(S=i&&v.route.id?i[v.route.id]:void 0,C=v.route.errorElement||T3,d&&(m<0&&x===0?(f0("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(l.slice(0,x+1)),k=()=>{let A;return S?A=C:j?A=N:v.route.Component?A=f.createElement(v.route.Component,null):v.route.element?A=v.route.element:A=y,f.createElement(A3,{match:v,routeContext:{outlet:y,matches:E,isDataRoute:o!=null},children:A})};return o&&(v.route.ErrorBoundary||v.route.errorElement||x===0)?f.createElement(d0,{location:o.location,revalidation:o.revalidation,component:C,error:S,children:k(),routeContext:{outlet:null,matches:E,isDataRoute:!0},onError:p}):k()},null)}function oh(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function M3(e){let n=f.useContext(Cs);return ft(n,oh(e)),n}function O3(e){let n=f.useContext(Eu);return ft(n,oh(e)),n}function D3(e){let n=f.useContext(qn);return ft(n,oh(e)),n}function sh(e){let n=D3(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 L3(){return sh("useRouteId")}function z3(){var o;let e=f.useContext(ah),n=O3("useRouteError"),a=sh("useRouteError");return e!==void 0?e:(o=n.errors)==null?void 0:o[a]}function P3(){let{router:e}=M3("useNavigate"),n=sh("useNavigate"),a=f.useRef(!1);return c0(()=>{a.current=!0}),f.useCallback(async(l,i={})=>{Pn(a.current,i0),a.current&&(typeof l=="number"?await e.navigate(l):await e.navigate(l,{fromRouteId:n,...i}))},[e,n])}var R1={};function f0(e,n,a){!n&&!R1[e]&&(R1[e]=!0,Pn(!1,a))}f.memo(B3);function B3({routes:e,manifest:n,future:a,state:o,isStatic:l,onError:i}){return u0(e,void 0,{manifest:n,state:o,isStatic:l,onError:i})}function Mr({to:e,replace:n,state:a,relative:o}){ft(js()," may be used only in the context of a component.");let{static:l}=f.useContext(xn);Pn(!l," 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:i}=f.useContext(qn),{pathname:d}=Sn(),m=oo(),h=ju(e,rh(i),d,o==="path"),p=JSON.stringify(h);return f.useEffect(()=>{m(JSON.parse(p),{replace:n,state:a,relative:o})},[m,p,o,n,a]),null}function $3(e){return E3(e.context)}function ln(e){ft(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function I3({basename:e="/",children:n=null,location:a,navigationType:o="POP",navigator:l,static:i=!1,useTransitions:d}){ft(!js(),"You cannot render a inside another . You should never have more than one in your app.");let m=e.replace(/^\/*/,"/"),h=f.useMemo(()=>({basename:m,navigator:l,static:i,useTransitions:d,future:{}}),[m,l,i,d]);typeof a=="string"&&(a=ws(a));let{pathname:p="/",search:y="",hash:v="",state:x=null,key:S="default",mask:j}=a,C=f.useMemo(()=>{let N=Or(p,m);return N==null?null:{location:{pathname:N,search:y,hash:v,state:x,key:S,mask:j},navigationType:o}},[m,p,y,v,x,S,o,j]);return Pn(C!=null,` is not able to match the URL "${p}${y}${v}" because it does not start with the basename, so the won't render anything.`),C==null?null:f.createElement(xn.Provider,{value:h},f.createElement(Zl.Provider,{children:n,value:C}))}function A1({children:e,location:n}){return N3(hp(e),n)}function hp(e,n=[]){let a=[];return f.Children.forEach(e,(o,l)=>{if(!f.isValidElement(o))return;let i=[...n,l];if(o.type===f.Fragment){a.push.apply(a,hp(o.props.children,i));return}ft(o.type===ln,`[${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||i.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=hp(o.props.children,i)),a.push(d)}),a}var qc="get",Kc="application/x-www-form-urlencoded";function Nu(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function U3(e){return Nu(e)&&e.tagName.toLowerCase()==="button"}function H3(e){return Nu(e)&&e.tagName.toLowerCase()==="form"}function V3(e){return Nu(e)&&e.tagName.toLowerCase()==="input"}function G3(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function F3(e,n){return e.button===0&&(!n||n==="_self")&&!G3(e)}function gp(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(l=>[a,l]):[[a,o]])},[]))}function Y3(e,n){let a=gp(e);return n&&n.forEach((o,l)=>{a.has(l)||n.getAll(l).forEach(i=>{a.append(l,i)})}),a}var Dc=null;function W3(){if(Dc===null)try{new FormData(document.createElement("form"),0),Dc=!1}catch{Dc=!0}return Dc}var q3=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Pm(e){return e!=null&&!q3.has(e)?(Pn(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Kc}"`),null):e}function K3(e,n){let a,o,l,i,d;if(H3(e)){let m=e.getAttribute("action");o=m?Or(m,n):null,a=e.getAttribute("method")||qc,l=Pm(e.getAttribute("enctype"))||Kc,i=new FormData(e)}else if(U3(e)||V3(e)&&(e.type==="submit"||e.type==="image")){let m=e.form;if(m==null)throw new Error('Cannot submit a `,L=>`${R}-${L.id}`)}const N=x`
${n.i18n.searchDescription}
${n.i18n.skinToneDescription}
${S(n.skinTones,(k,A)=>x`
${k}
`,k=>k)}
${S(n.currentEmojisWithCategories,(k,A)=>x`
${j(k.emojis,n.searchMode,"emo")}
`,k=>k.category)}
`,E=(k,A)=>{for(const R of e.querySelectorAll(`[${k}]`))A(R,R.getAttribute(k))};if(h){e.appendChild(N);for(const k of["click","focusout","input","keydown","keyup"])E(`data-on-${k}`,(A,R)=>{A.addEventListener(k,o[R])});E("data-ref",(k,A)=>{i[A]=k}),d.addEventListener("abort",()=>{e.removeChild(N)})}E("data-action",(k,A)=>{let R=m.get(A);R||m.set(A,R=new WeakSet),R.has(k)||(R.add(k),l[A](k))})}const wu=typeof queueMicrotask=="function"?queueMicrotask:e=>Promise.resolve().then(e);function Ez(e){let n=!1,a;const o=new Map,l=new Set;let i;const d=()=>{if(n)return;const p=[...l];l.clear();try{for(const y of p)y()}finally{i=!1,l.size&&(i=!0,wu(d))}},m=new Proxy({},{get(p,y){if(a){let v=o.get(y);v||(v=new Set,o.set(y,v)),v.add(a)}return p[y]},set(p,y,v){if(p[y]!==v){p[y]=v;const x=o.get(y);if(x){for(const S of x)l.add(S);i||(i=!0,wu(d))}}return!0}}),h=p=>{const y=()=>{const v=a;a=y;try{return p()}finally{a=v}};return y()};return e.addEventListener("abort",()=>{n=!0}),{state:m,createEffect:h}}function fp(e,n,a){if(e.length!==n.length)return!1;for(let o=0;o{l.disconnect()})),l.observe(e)}}const mp=[],{assign:Yc}=Object;function kz(e,n){const a={},o=new AbortController,l=o.signal,{state:i,createEffect:d}=Ez(l),m=new Map;Yc(i,{skinToneEmoji:void 0,i18n:void 0,database:void 0,customEmoji:void 0,customCategorySorting:void 0,emojiVersion:void 0}),Yc(i,n),Yc(i,{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:YL,isRtl:!1,currentGroupIndex:0,groups:lp,databaseLoaded:!1,activeSearchItemId:void 0}),d(()=>{i.currentGroup!==i.groups[i.currentGroupIndex]&&(i.currentGroup=i.groups[i.currentGroupIndex])});const h=G=>{e.getElementById(G).focus()},p=G=>e.getElementById(`emo-${G.id}`),y=(G,se)=>{a.rootElement.dispatchEvent(new CustomEvent(G,{detail:se,bubbles:!0,composed:!0}))},v=(G,se)=>G.id===se.id,x=(G,se)=>{const{category:ge,emojis:je}=G,{category:Ae,emojis:Qe}=se;return ge!==Ae?!1:fp(je,Qe,v)},S=G=>{fp(i.currentEmojis,G,v)||(i.currentEmojis=G)},j=G=>{i.searchMode!==G&&(i.searchMode=G)},C=G=>{fp(i.currentEmojisWithCategories,G,x)||(i.currentEmojisWithCategories=G)},N=(G,se)=>se&&G.skins&&G.skins[se]||G.unicode,A={labelWithSkin:(G,se)=>cz([G.name||N(G,se),G.annotation,...G.shortcodes||mp].filter(Boolean)).join(", "),titleForEmoji:G=>G.annotation||(G.shortcodes||mp).join(", "),unicodeWithSkin:N},R={onClickSkinToneButton:V,onEmojiClick:O,onNavClick:re,onNavKeydown:oe,onSearchKeydown:K,onSkinToneOptionsClick:I,onSkinToneOptionsFocusOut:me,onSkinToneOptionsKeydown:ne,onSkinToneOptionsKeyup:J,onSearchInput:pe},L={calculateEmojiGridStyle:U,updateOnIntersection:q};let z=!0;d(()=>{jz(e,i,A,R,L,a,l,m,z),z=!1}),i.emojiVersion||cp().then(G=>{G||(i.message=i.i18n.emojiUnsupportedMessage)}),d(()=>{async function G(){let se=!1;const ge=setTimeout(()=>{se=!0,i.message=i.i18n.loadingMessage},GL);try{await i.database.ready(),i.databaseLoaded=!0}catch(je){console.error(je),i.message=i.i18n.networkErrorMessage}finally{clearTimeout(ge),se&&(se=!1,i.message="")}}i.database&&G()}),d(()=>{i.pickerStyle=` --num-groups: ${i.groups.length}; --indicator-opacity: ${i.searchMode?0:1}; --num-skintones: ${Mx};`}),d(()=>{i.customEmoji&&i.database&&B()}),d(()=>{i.customEmoji&&i.customEmoji.length?i.groups!==Zp&&(i.groups=Zp):i.groups!==lp&&(i.currentGroupIndex&&i.currentGroupIndex--,i.groups=lp)}),d(()=>{async function G(){i.databaseLoaded&&(i.currentSkinTone=await i.database.getPreferredSkinTone())}G()}),d(()=>{i.skinTones=Array(Mx).fill().map((G,se)=>rz(i.skinToneEmoji,se))}),d(()=>{i.skinToneButtonText=i.skinTones[i.currentSkinTone]}),d(()=>{i.skinToneButtonLabel=i.i18n.skinToneLabel.replace("{skinTone}",i.i18n.skinTones[i.currentSkinTone])}),d(()=>{async function G(){const{database:se}=i,ge=(await Promise.all(WL.map(je=>se.getEmojiByUnicodeOrName(je)))).filter(Boolean);i.defaultFavoriteEmojis=ge}i.databaseLoaded&&G()});function B(){const{customEmoji:G,database:se}=i,ge=G||mp;se.customEmoji!==ge&&(se.customEmoji=ge)}d(()=>{async function G(){B();const{database:se,defaultFavoriteEmojis:ge,numColumns:je}=i,Ae=await se.getTopFavoriteEmoji(je),Qe=await ce(c5([...Ae,...ge],ct=>ct.unicode||ct.name).slice(0,je));i.currentFavorites=Qe}i.databaseLoaded&&i.defaultFavoriteEmojis&&G()});function U(G){sz(G,l,()=>{{const se=getComputedStyle(a.rootElement),ge=parseInt(se.getPropertyValue("--num-columns"),10),je=se.getPropertyValue("direction")==="rtl";i.numColumns=ge,i.isRtl=je}})}function q(G){Nz(G,l,se=>{for(const{target:ge,isIntersecting:je}of se)ge.classList.toggle("onscreen",je)})}d(()=>{async function G(){const{searchText:se,currentGroup:ge,databaseLoaded:je,customEmoji:Ae}=i;if(!je)i.currentEmojis=[],i.searchMode=!1;else if(se.length>=HL){const Qe=await M(se);i.searchText===se&&(S(Qe),j(!0))}else{const{id:Qe}=ge;if(Qe!==-1||Ae&&Ae.length){const ct=await he(Qe);i.currentGroup.id===Qe&&(S(ct),j(!1))}}}G()});const Z=()=>{tu(()=>uz(a.tabpanelElement))};d(()=>{const{currentEmojis:G,emojiVersion:se}=i,ge=G.filter(je=>je.unicode).filter(je=>Ox(je)&&!Qp.has(je.unicode));if(!se&&ge.length)S(G),tu(()=>Q(ge));else{const je=se?G:G.filter(fe);S(je),Z()}});function Q(G){iz(G,a.baselineEmoji,p)?Z():i.currentEmojis=[...i.currentEmojis]}function fe(G){return!G.unicode||!Ox(G)||Qp.get(G.unicode)}async function de(G){const se=i.emojiVersion||await cp();return G.filter(({version:ge})=>!ge||ge<=se)}async function ce(G){return az(G,i.emojiVersion||await cp())}async function he(G){const se=G===-1?i.customEmoji:await i.database.getEmojiByGroup(G);return ce(await de(se))}async function M(G){return ce(await de(await i.database.getEmojiBySearchQuery(G)))}d(()=>{}),d(()=>{function G(){const{searchMode:ge,currentEmojis:je}=i;if(ge)return[{category:"",emojis:je}];const Ae=new Map;for(const Qe of je){const ct=Qe.category||"";let Tt=Ae.get(ct);Tt||(Tt=[],Ae.set(ct,Tt)),Tt.push(Qe)}return[...Ae.entries()].map(([Qe,ct])=>({category:Qe,emojis:ct})).sort((Qe,ct)=>i.customCategorySorting(Qe.category,ct.category))}const se=G();C(se)}),d(()=>{i.activeSearchItemId=i.activeSearchItem!==-1&&i.currentEmojis[i.activeSearchItem].id}),d(()=>{const{rawSearchText:G}=i;l5(()=>{i.searchText=(G||"").trim(),i.activeSearchItem=-1})});function K(G){if(!i.searchMode||!i.currentEmojis.length)return;const se=ge=>{rr(G),i.activeSearchItem=up(ge,i.activeSearchItem,i.currentEmojis)};switch(G.key){case"ArrowDown":return se(!1);case"ArrowUp":return se(!0);case"Enter":if(i.activeSearchItem===-1)i.activeSearchItem=0;else return rr(G),_(i.currentEmojis[i.activeSearchItem].id)}}function re(G){const{target:se}=G,ge=se.closest(".nav-button");if(!ge)return;const je=parseInt(ge.dataset.groupId,10);a.searchElement.value="",i.rawSearchText="",i.searchText="",i.activeSearchItem=-1,i.currentGroupIndex=i.groups.findIndex(Ae=>Ae.id===je)}function oe(G){const{target:se,key:ge}=G,je=Ae=>{Ae&&(rr(G),Ae.focus())};switch(ge){case"ArrowLeft":return je(se.previousElementSibling);case"ArrowRight":return je(se.nextElementSibling);case"Home":return je(se.parentElement.firstElementChild);case"End":return je(se.parentElement.lastElementChild)}}async function ee(G){const se=await i.database.getEmojiByUnicodeOrName(G),ge=[...i.currentEmojis,...i.currentFavorites].find(Ae=>Ae.id===G),je=ge.unicode&&N(ge,i.currentSkinTone);return await i.database.incrementFavoriteEmojiCount(G),{emoji:se,skinTone:i.currentSkinTone,...je&&{unicode:je},...ge.name&&{name:ge.name}}}async function _(G){const se=ee(G);y("emoji-click-sync",se),y("emoji-click",await se)}function O(G){const{target:se}=G;if(!se.classList.contains("emoji"))return;rr(G);const ge=se.id.substring(4);_(ge)}function H(G){i.currentSkinTone=G,i.skinTonePickerExpanded=!1,h("skintone-button"),y("skin-tone-change",{skinTone:G}),i.database.setPreferredSkinTone(G)}function I(G){const{target:{id:se}}=G,ge=se&&se.match(/^skintone-(\d)/);if(!ge)return;rr(G);const je=parseInt(ge[1],10);H(je)}function V(G){i.skinTonePickerExpanded=!i.skinTonePickerExpanded,i.activeSkinTone=i.currentSkinTone,i.skinTonePickerExpanded&&(rr(G),tu(()=>h("skintone-list")))}d(()=>{i.skinTonePickerExpanded?a.skinToneDropdown.addEventListener("transitionend",()=>{i.skinTonePickerExpandedAfterAnimation=!0},{once:!0}):i.skinTonePickerExpandedAfterAnimation=!1});function ne(G){if(!i.skinTonePickerExpanded)return;const se=async ge=>{rr(G),i.activeSkinTone=ge};switch(G.key){case"ArrowUp":return se(up(!0,i.activeSkinTone,i.skinTones));case"ArrowDown":return se(up(!1,i.activeSkinTone,i.skinTones));case"Home":return se(0);case"End":return se(i.skinTones.length-1);case"Enter":return rr(G),H(i.activeSkinTone);case"Escape":return rr(G),i.skinTonePickerExpanded=!1,h("skintone-button")}}function J(G){if(i.skinTonePickerExpanded)switch(G.key){case" ":return rr(G),H(i.activeSkinTone)}}async function me(G){const{relatedTarget:se}=G;(!se||se.id!=="skintone-list")&&(i.skinTonePickerExpanded=!1)}function pe(G){i.rawSearchText=G.target.value}return{$set(G){Yc(i,G)},$destroy(){o.abort()}}}const Tz="https://cdn.jsdelivr.net/npm/emoji-picker-element-data@^1/en/emojibase/data.json",Rz="en";var Az={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"}},_z=':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 u5=["customEmoji","customCategorySorting","database","dataSource","i18n","locale","skinToneEmoji","emojiVersion"],Mz=`:host{--emoji-font-family:${i5}}`;class bg extends HTMLElement{constructor(n){super(),this.attachShadow({mode:"open"});const a=document.createElement("style");a.textContent=_z+Mz,this.shadowRoot.appendChild(a),this._ctx={locale:Rz,dataSource:Tz,skinToneEmoji:FL,customCategorySorting:qL,customEmoji:null,i18n:Az,emojiVersion:null,...n};for(const o of u5)o!=="database"&&Object.prototype.hasOwnProperty.call(this,o)&&(this._ctx[o]=this[o],delete this[o]);this._dbFlush()}connectedCallback(){Ix(this),this._cmp||(this._cmp=kz(this.shadowRoot,this._ctx))}disconnectedCallback(){Ix(this),wu(()=>{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,(l,i)=>i.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 UL({locale:n,dataSource:a}))}_dbFlush(){wu(()=>this._dbCreate())}}const d5={};for(const e of u5)d5[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(bg.prototype,d5);function Ix(e){e instanceof bg||Object.setPrototypeOf(e,customElements.get(e.tagName.toLowerCase()).prototype)}customElements.get("emoji-picker")||customElements.define("emoji-picker",bg);function Oz({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 l=i=>{var h;const d=i.detail,m=(d==null?void 0:d.unicode)??((h=d==null?void 0:d.emoji)==null?void 0:h.unicode);m&&e(m)};return o.addEventListener("emoji-click",l),a.appendChild(o),()=>{o.removeEventListener("emoji-click",l),o.remove()}},[e]),c.jsx("div",{ref:n,className:"unicode-emoji-panel-host overflow-hidden rounded-lg border border-border/50"})}const Dz=/^<(a?):([^:>]+):(\d{17,20})>$/;function nu(e,n,a=!1){return`${a?"`}function f5(e){const n=String(e??"").trim();if(!n)return{kind:"empty",value:""};const a=n.match(Dz);return a?{kind:"custom",value:n,animated:a[1]==="a",name:a[2],id:a[3]}:{kind:"unicode",value:n}}function m5(e,n=!1){return`https://cdn.discordapp.com/emojis/${e}.${n?"gif":"png"}?size=64`}function Lz(e,n=[]){const a=f5(e);if(a.kind==="custom"&&a.id&&!a.name){const o=n.find(l=>l.id===a.id);if(o)return{kind:"custom",value:nu(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(l=>l.id===a.id);if(o&&a.value!==nu(o.name,o.id,o.animated))return{kind:"custom",value:nu(o.name,o.id,o.animated),name:o.name,id:o.id,animated:o.animated}}return a}function zz({value:e,guildEmojis:n,size:a="md"}){const o=Lz(e,n),l=a==="lg"?"size-10":"size-7",i=a==="lg"?"text-3xl":"text-2xl";return o.kind==="empty"?c.jsx("span",{className:"text-sm text-muted-foreground",children:"No emoji selected"}):o.kind==="custom"&&o.id?c.jsxs("span",{className:"inline-flex items-center gap-3",children:[c.jsx("img",{src:m5(o.id,o.animated),alt:o.name??"custom emoji",className:ie(l,"shrink-0 rounded-md"),loading:"lazy"}),c.jsxs("span",{className:"flex flex-col items-start gap-0.5",children:[c.jsxs("span",{className:"text-sm font-medium",children:[":",o.name,":"]}),c.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:o.value})]})]}):c.jsx("span",{className:ie(i,"leading-none"),title:o.value,children:o.value})}function Pz({id:e,label:n,description:a,value:o,onChange:l,readOnly:i}){const[d,m]=f.useState(!1),[h,p]=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(Z=!1)=>{C(!0),S("");try{const Q=await ke.getGuildResources(Z);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 A=f.useMemo(()=>Array.isArray(y==null?void 0:y.emojis)?y.emojis:[],[y]),R=f.useMemo(()=>{const Z=N.trim().toLowerCase();return Z?A.filter(Q=>Q.name.toLowerCase().includes(Z)):A},[A,N]),L=String(o??""),z=f5(L);function B(Z){l(Z),m(!1)}function U(Z){l(nu(Z.name,Z.id,Z.animated)),m(!1)}function q(){l("")}return c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:e,children:n}),a?c.jsx("p",{className:"text-xs text-muted-foreground",children:a}):null,c.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:[c.jsx("div",{className:"min-w-0 flex-1",children:c.jsx(zz,{value:o,guildEmojis:A,size:"lg"})}),c.jsxs("div",{className:"flex shrink-0 gap-2",children:[c.jsx(be,{type:"button",variant:"secondary",size:"sm",disabled:i,onClick:()=>m(!0),children:"Choose emoji"}),L?c.jsx(be,{type:"button",variant:"ghost",size:"sm",disabled:i,onClick:q,children:"Clear"}):null]})]}),c.jsx($w,{open:d,onOpenChange:m,children:c.jsxs(Zh,{className:"max-h-[min(90vh,720px)] max-w-lg gap-0 overflow-hidden p-0 sm:max-w-xl",children:[c.jsxs(Qh,{className:"space-y-1 border-b border-border px-5 py-4",children:[c.jsx(Jh,{children:"Choose emoji"}),c.jsxs(eg,{children:["Server emojis save as"," ",c.jsx("code",{className:"rounded bg-muted px-1 text-xs",children:"<:name:id>"}),". Standard emojis save as Unicode characters."]})]}),c.jsxs(Yj,{value:h,onValueChange:Z=>p(Z),className:"flex min-h-0 flex-1 flex-col",children:[c.jsxs(fg,{className:"mx-5 mt-3 grid h-9 w-auto grid-cols-2",children:[c.jsx(Ka,{value:"server",children:"Server"}),c.jsx(Ka,{value:"unicode",children:"All emojis"})]}),c.jsxs(Wp,{value:"server",className:"mt-0 flex-1 px-5 pb-4 pt-3",children:[c.jsxs("div",{className:"relative mb-3",children:[c.jsx(ye,{icon:_u,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(rt,{placeholder:"Search by name…",value:N,onChange:Z=>E(Z.target.value),className:"h-9 border-border bg-secondary/30 pl-9"})]}),y?c.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[y.guildName," · ",A.length," custom emoji",A.length===1?"":"s"]}):null,c.jsx(hi,{className:"h-[min(50vh,320px)] rounded-lg border border-border/50 bg-secondary/20",children:j?c.jsx("div",{className:"grid grid-cols-6 gap-2 p-3 sm:grid-cols-8",children:Array.from({length:24}).map((Z,Q)=>c.jsx(Fe,{className:"aspect-square rounded-lg"},Q))}):x?c.jsxs("div",{className:"space-y-3 p-4 text-center",children:[c.jsx("p",{className:"text-sm text-destructive",children:x}),c.jsx(be,{type:"button",variant:"outline",size:"sm",onClick:()=>void k(!0),children:"Retry"})]}):R.length===0?c.jsx("p",{className:"p-6 text-center text-sm text-muted-foreground",children:A.length===0?"No custom emojis in this server, or the bot needs the Guild Emojis intent (restart after update).":"No emojis match your search."}):c.jsx("div",{className:"grid grid-cols-6 gap-1.5 p-2 sm:grid-cols-8",children:R.map(Z=>{const Q=z.kind==="custom"&&z.id===Z.id;return c.jsx("button",{type:"button",title:`:${Z.name}:`,className:ie("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:()=>U(Z),children:c.jsx("img",{src:Z.url??m5(Z.id,Z.animated),alt:Z.name,className:"size-8 object-contain",loading:"lazy"})},Z.id)})})})]}),c.jsx(Wp,{value:"unicode",className:"mt-0 px-5 pb-4 pt-3",children:c.jsx(Oz,{onPick:B})})]})]})}),c.jsx(rt,{value:L,disabled:i,onChange:Z=>l(Z.target.value),placeholder:"Unicode or <:name:id>",className:"border-border bg-secondary/30 font-mono text-xs"})]})}const Ux="BOT_TOKEN",Bz="MODEL_API_KEY";function yg({field:e,value:n,onChange:a,readOnly:o}){const l=e.path.replace(/\./g,"-");if(e.type==="googleFont")return c.jsx(UD,{field:e,value:n,onChange:a,readOnly:o});if(e.type==="boolean")return c.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-lg border border-border bg-secondary/20 px-3 py-2.5",children:[c.jsxs("div",{children:[c.jsx(Ze,{htmlFor:l,className:"font-medium",children:e.label}),e.description?c.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null]}),c.jsx(Dn,{id:l,checked:!!n,disabled:o,onCheckedChange:a})]});if(e.type==="stringList")return c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{children:e.label}),e.description?c.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,c.jsx(BD,{value:Array.isArray(n)?n:[],onChange:a})]});if(e.type==="select"&&e.options)return c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:l,children:e.label}),c.jsxs(ud,{value:String(n??""),disabled:o,onValueChange:a,children:[c.jsx(gi,{id:l,className:"border-border bg-secondary/30",children:c.jsx(dd,{placeholder:"Select…"})}),c.jsx(vi,{children:e.options.map(d=>c.jsx(no,{value:d.value,children:d.label},d.value))})]})]});if(e.type==="color"){const d=lr(String(n??"#000000"));return c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:l,children:e.label}),e.description?c.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,c.jsxs("div",{className:"flex gap-2",children:[c.jsx(cg,{value:d,onChange:a}),c.jsx(rt,{id:l,value:d,disabled:o,onChange:m=>a(m.target.value),onBlur:m=>a(lr(m.target.value,d)),className:"border-border bg-secondary/30 font-mono uppercase",placeholder:"#000000",maxLength:7})]})]})}if(e.type==="emoji")return c.jsx(Pz,{id:l,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 c.jsx(HD,{id:l,label:e.label,description:e.description,kind:d,value:n,onChange:a,readOnly:o})}if(e.type==="secret"){const d=n===Ux||n===Bz||!n?"":"••••••••••••";return c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:l,children:e.label}),e.description?c.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,c.jsx(rt,{id:l,type:"password",value:d,disabled:o,placeholder:e.placeholder??"Unchanged if empty",onChange:m=>{const h=m.target.value;a(h||(e.placeholder??Ux))},className:"border-border bg-secondary/30"})]})}const i="border-border bg-secondary/30";return e.type==="textarea"?c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:l,children:e.label}),c.jsx(sd,{id:l,value:String(n??""),disabled:o,onChange:d=>a(d.target.value),className:`min-h-[88px] ${i}`})]}):c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:l,children:e.label}),e.description?c.jsx("p",{className:"text-xs text-muted-foreground",children:e.description}):null,c.jsx(rt,{id:l,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:i})]})}const We=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("rounded-xl border border-border bg-card text-card-foreground shadow-none",e),...n}));We.displayName="Card";const at=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("flex flex-col space-y-1.5 p-6",e),...n}));at.displayName="CardHeader";const ot=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("font-semibold leading-none tracking-tight",e),...n}));ot.displayName="CardTitle";const Nt=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("text-sm text-muted-foreground",e),...n}));Nt.displayName="CardDescription";const qe=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("p-6 pt-0",e),...n}));qe.displayName="CardContent";const p5=f.forwardRef(({className:e,...n},a)=>c.jsx("div",{ref:a,className:ie("flex items-center p-6 pt-0",e),...n}));p5.displayName="CardFooter";function Hx(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function $z(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 xg(e,n=""){const a=[];for(const[o,l]of Object.entries(e)){const i=n?`${n}.${o}`:o;if(Array.isArray(l)){if(l.length>0&&typeof l[0]=="object"&&l[0]!==null&&!Array.isArray(l[0]))continue;a.push({path:i,label:Hx(o),type:"stringList"});continue}if(l&&typeof l=="object"&&Object.keys(l).length>0){a.push(...xg(l,i));continue}a.push({path:i,label:Hx(o),type:$z(o,l)})}return a}function Iz(e){const n=xg(e);return n.length===0?[{title:"Configuration",fields:[]}]:[{title:"Settings",description:"Values from this addon’s config file.",fields:n}]}function ao(e,n){const a=n.split(".");let o=e;for(const l of a){if(o==null||typeof o!="object")return;o=o[l]}return o}function Xl(e,n,a){const o=n.split("."),l=structuredClone(e);let i=l;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 Hz=e=>{switch(e){case"success":return Fz;case"info":return Wz;case"warning":return Yz;case"error":return qz;default:return null}},Vz=Array(12).fill(0),Gz=({visible:e,className:n})=>ue.createElement("div",{className:["sonner-loading-wrapper",n].filter(Boolean).join(" "),"data-visible":e},ue.createElement("div",{className:"sonner-spinner"},Vz.map((a,o)=>ue.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${o}`})))),Fz=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"})),Yz=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"})),Wz=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"})),qz=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"})),Kz=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"})),Xz=()=>{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 Jp=1;class Zz{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,...l}=n,i=typeof(n==null?void 0:n.id)=="number"||((a=n.id)==null?void 0:a.length)>0?n.id:Jp++,d=this.toasts.find(h=>h.id===i),m=n.dismissible===void 0?!0:n.dismissible;return this.dismissedToasts.has(i)&&this.dismissedToasts.delete(i),d?this.toasts=this.toasts.map(h=>h.id===i?(this.publish({...h,...n,id:i,title:o}),{...h,...n,id:i,dismissible:m,title:o}):h):this.addToast({title:o,...l,dismissible:m,id:i}),i},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 l=Promise.resolve(n instanceof Function?n():n);let i=o!==void 0,d;const m=l.then(async p=>{if(d=["resolve",p],ue.isValidElement(p))i=!1,this.create({id:o,type:"default",message:p});else if(Jz(p)&&!p.ok){i=!1;const v=typeof a.error=="function"?await a.error(`HTTP error! status: ${p.status}`):a.error,x=typeof a.description=="function"?await a.description(`HTTP error! status: ${p.status}`):a.description,j=typeof v=="object"&&!ue.isValidElement(v)?v:{message:v};this.create({id:o,type:"error",description:x,...j})}else if(p instanceof Error){i=!1;const v=typeof a.error=="function"?await a.error(p):a.error,x=typeof a.description=="function"?await a.description(p):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){i=!1;const v=typeof a.success=="function"?await a.success(p):a.success,x=typeof a.description=="function"?await a.description(p):a.description,j=typeof v=="object"&&!ue.isValidElement(v)?v:{message:v};this.create({id:o,type:"success",description:x,...j})}}).catch(async p=>{if(d=["reject",p],a.error!==void 0){i=!1;const y=typeof a.error=="function"?await a.error(p):a.error,v=typeof a.description=="function"?await a.description(p):a.description,S=typeof y=="object"&&!ue.isValidElement(y)?y:{message:y};this.create({id:o,type:"error",description:v,...S})}}).finally(()=>{i&&(this.dismiss(o),o=void 0),a.finally==null||a.finally.call(a)}),h=()=>new Promise((p,y)=>m.then(()=>d[0]==="reject"?y(d[1]):p(d[1])).catch(y));return typeof o!="string"&&typeof o!="number"?{unwrap:h}:Object.assign(o,{unwrap:h})},this.custom=(n,a)=>{const o=(a==null?void 0:a.id)||Jp++;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 cn=new Zz,Qz=(e,n)=>{const a=(n==null?void 0:n.id)||Jp++;return cn.addToast({title:e,...n,id:a}),a},Jz=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",eP=Qz,tP=()=>cn.toasts,nP=()=>cn.getActiveToasts(),rs=Object.assign(eP,{success:cn.success,info:cn.info,warning:cn.warning,error:cn.error,custom:cn.custom,message:cn.message,promise:cn.promise,dismiss:cn.dismiss,loading:cn.loading},{getHistory:tP,getToasts:nP});Uz("[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 Wc(e){return e.label!==void 0}const rP=3,aP="24px",oP="16px",Vx=4e3,sP=356,lP=14,iP=45,cP=200;function ar(...e){return e.filter(Boolean).join(" ")}function uP(e){const[n,a]=e.split("-"),o=[];return n&&o.push(n),a&&o.push(a),o}const dP=e=>{var n,a,o,l,i,d,m,h,p;const{invert:y,toast:v,unstyled:x,interacting:S,setHeights:j,visibleToasts:C,heights:N,index:E,toasts:k,expanded:A,removeToast:R,defaultRichColors:L,closeButton:z,style:B,cancelButtonStyle:U,actionButtonStyle:q,className:Z="",descriptionClassName:Q="",duration:fe,position:de,gap:ce,expandByDefault:he,classNames:M,icons:K,closeButtonAriaLabel:re="Close toast"}=e,[oe,ee]=ue.useState(null),[_,O]=ue.useState(null),[H,I]=ue.useState(!1),[V,ne]=ue.useState(!1),[J,me]=ue.useState(!1),[pe,G]=ue.useState(!1),[se,ge]=ue.useState(!1),[je,Ae]=ue.useState(0),[Qe,ct]=ue.useState(0),Tt=ue.useRef(v.duration||fe||Vx),Ca=ue.useRef(null),Rt=ue.useRef(null),Os=E===0,Ds=E+1<=C,Yt=v.type,$r=v.dismissible!==!1,Wt=v.className||"",gd=v.descriptionClassName||"",ja=ue.useMemo(()=>N.findIndex(Te=>Te.toastId===v.id)||0,[N,v.id]),xi=ue.useMemo(()=>{var Te;return(Te=v.closeButton)!=null?Te:z},[v.closeButton,z]),Ea=ue.useMemo(()=>v.duration||fe||Vx,[v.duration,fe]),Ls=ue.useRef(0),dr=ue.useRef(0),Si=ue.useRef(0),Ir=ue.useRef(null),[Na,qt]=de.split("-"),$n=ue.useMemo(()=>N.reduce((Te,ut,At)=>At>=ja?Te:Te+ut.height,0),[N,ja]),Ht=Xz(),vd=v.invert||y,zs=Yt==="loading";dr.current=ue.useMemo(()=>ja*ce+$n,[ja,$n]),ue.useEffect(()=>{Tt.current=Ea},[Ea]),ue.useEffect(()=>{I(!0)},[]),ue.useEffect(()=>{const Te=Rt.current;if(Te){const ut=Te.getBoundingClientRect().height;return ct(ut),j(At=>[{toastId:v.id,height:ut,position:v.position},...At]),()=>j(At=>At.filter(Vt=>Vt.toastId!==v.id))}},[j,v.id]),ue.useLayoutEffect(()=>{if(!H)return;const Te=Rt.current,ut=Te.style.height;Te.style.height="auto";const At=Te.getBoundingClientRect().height;Te.style.height=ut,ct(At),j(Vt=>Vt.find(mt=>mt.toastId===v.id)?Vt.map(mt=>mt.toastId===v.id?{...mt,height:At}:mt):[{toastId:v.id,height:At,position:v.position},...Vt])},[H,v.title,v.description,j,v.id,v.jsx,v.action,v.cancel]);const Xn=ue.useCallback(()=>{ne(!0),Ae(dr.current),j(Te=>Te.filter(ut=>ut.toastId!==v.id)),setTimeout(()=>{R(v)},cP)},[v,R,j,dr]);ue.useEffect(()=>{if(v.promise&&Yt==="loading"||v.duration===1/0||v.type==="loading")return;let Te;return A||S||Ht?(()=>{if(Si.current{Tt.current!==1/0&&(Ls.current=new Date().getTime(),Te=setTimeout(()=>{v.onAutoClose==null||v.onAutoClose.call(v,v),Xn()},Tt.current))})(),()=>clearTimeout(Te)},[A,S,v,Yt,Ht,Xn]),ue.useEffect(()=>{v.delete&&(Xn(),v.onDismiss==null||v.onDismiss.call(v,v))},[Xn,v.delete]);function fo(){var Te;if(K!=null&&K.loading){var ut;return ue.createElement("div",{className:ar(M==null?void 0:M.loader,v==null||(ut=v.classNames)==null?void 0:ut.loader,"sonner-loader"),"data-visible":Yt==="loading"},K.loading)}return ue.createElement(Gz,{className:ar(M==null?void 0:M.loader,v==null||(Te=v.classNames)==null?void 0:Te.loader),visible:Yt==="loading"})}const mo=v.icon||(K==null?void 0:K[Yt])||Hz(Yt);var ka,Zn;return ue.createElement("li",{tabIndex:0,ref:Rt,className:ar(Z,Wt,M==null?void 0:M.toast,v==null||(n=v.classNames)==null?void 0:n.toast,M==null?void 0:M.default,M==null?void 0:M[Yt],v==null||(a=v.classNames)==null?void 0:a[Yt]),"data-sonner-toast":"","data-rich-colors":(ka=v.richColors)!=null?ka:L,"data-styled":!(v.jsx||v.unstyled||x),"data-mounted":H,"data-promise":!!v.promise,"data-swiped":se,"data-removed":V,"data-visible":Ds,"data-y-position":Na,"data-x-position":qt,"data-index":E,"data-front":Os,"data-swiping":J,"data-dismissible":$r,"data-type":Yt,"data-invert":vd,"data-swipe-out":pe,"data-swipe-direction":_,"data-expanded":!!(A||he&&H),"data-testid":v.testId,style:{"--index":E,"--toasts-before":E,"--z-index":k.length-E,"--offset":`${V?je:dr.current}px`,"--initial-height":he?"auto":`${Qe}px`,...B,...v.style},onDragEnd:()=>{me(!1),ee(null),Ir.current=null},onPointerDown:Te=>{Te.button!==2&&(zs||!$r||(Ca.current=new Date,Ae(dr.current),Te.target.setPointerCapture(Te.pointerId),Te.target.tagName!=="BUTTON"&&(me(!0),Ir.current={x:Te.clientX,y:Te.clientY})))},onPointerUp:()=>{var Te,ut,At;if(pe||!$r)return;Ir.current=null;const Vt=Number(((Te=Rt.current)==null?void 0:Te.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Ur=Number(((ut=Rt.current)==null?void 0:ut.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),mt=new Date().getTime()-((At=Ca.current)==null?void 0:At.getTime()),Zt=oe==="x"?Vt:Ur,Ta=Math.abs(Zt)/mt;if(Math.abs(Zt)>=iP||Ta>.11){Ae(dr.current),v.onDismiss==null||v.onDismiss.call(v,v),O(oe==="x"?Vt>0?"right":"left":Ur>0?"down":"up"),Xn(),G(!0);return}else{var Qt,Jt;(Qt=Rt.current)==null||Qt.style.setProperty("--swipe-amount-x","0px"),(Jt=Rt.current)==null||Jt.style.setProperty("--swipe-amount-y","0px")}ge(!1),me(!1),ee(null)},onPointerMove:Te=>{var ut,At,Vt;if(!Ir.current||!$r||((ut=window.getSelection())==null?void 0:ut.toString().length)>0)return;const mt=Te.clientY-Ir.current.y,Zt=Te.clientX-Ir.current.x;var Ta;const Qt=(Ta=e.swipeDirections)!=null?Ta:uP(de);!oe&&(Math.abs(Zt)>1||Math.abs(mt)>1)&&ee(Math.abs(Zt)>Math.abs(mt)?"x":"y");let Jt={x:0,y:0};const po=In=>1/(1.5+Math.abs(In)/20);if(oe==="y"){if(Qt.includes("top")||Qt.includes("bottom"))if(Qt.includes("top")&&mt<0||Qt.includes("bottom")&&mt>0)Jt.y=mt;else{const In=mt*po(mt);Jt.y=Math.abs(In)0)Jt.x=Zt;else{const In=Zt*po(Zt);Jt.x=Math.abs(In)0||Math.abs(Jt.y)>0)&&ge(!0),(At=Rt.current)==null||At.style.setProperty("--swipe-amount-x",`${Jt.x}px`),(Vt=Rt.current)==null||Vt.style.setProperty("--swipe-amount-y",`${Jt.y}px`)}},xi&&!v.jsx&&Yt!=="loading"?ue.createElement("button",{"aria-label":re,"data-disabled":zs,"data-close-button":!0,onClick:zs||!$r?()=>{}:()=>{Xn(),v.onDismiss==null||v.onDismiss.call(v,v)},className:ar(M==null?void 0:M.closeButton,v==null||(o=v.classNames)==null?void 0:o.closeButton)},(Zn=K==null?void 0:K.close)!=null?Zn:Kz):null,(Yt||v.icon||v.promise)&&v.icon!==null&&((K==null?void 0:K[Yt])!==null||v.icon)?ue.createElement("div",{"data-icon":"",className:ar(M==null?void 0:M.icon,v==null||(l=v.classNames)==null?void 0:l.icon)},v.promise||v.type==="loading"&&!v.icon?v.icon||fo():null,v.type!=="loading"?mo:null):null,ue.createElement("div",{"data-content":"",className:ar(M==null?void 0:M.content,v==null||(i=v.classNames)==null?void 0:i.content)},ue.createElement("div",{"data-title":"",className:ar(M==null?void 0:M.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:ar(Q,gd,M==null?void 0:M.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&&Wc(v.cancel)?ue.createElement("button",{"data-button":!0,"data-cancel":!0,style:v.cancelButtonStyle||U,onClick:Te=>{Wc(v.cancel)&&$r&&(v.cancel.onClick==null||v.cancel.onClick.call(v.cancel,Te),Xn())},className:ar(M==null?void 0:M.cancelButton,v==null||(h=v.classNames)==null?void 0:h.cancelButton)},v.cancel.label):null,ue.isValidElement(v.action)?v.action:v.action&&Wc(v.action)?ue.createElement("button",{"data-button":!0,"data-action":!0,style:v.actionButtonStyle||q,onClick:Te=>{Wc(v.action)&&(v.action.onClick==null||v.action.onClick.call(v.action,Te),!Te.defaultPrevented&&Xn())},className:ar(M==null?void 0:M.actionButton,v==null||(p=v.classNames)==null?void 0:p.actionButton)},v.action.label):null)};function Gx(){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 fP(e,n){const a={};return[e,n].forEach((o,l)=>{const i=l===1,d=i?"--mobile-offset":"--offset",m=i?oP:aP;function h(p){["top","right","bottom","left"].forEach(y=>{a[`${d}-${y}`]=typeof p=="number"?`${p}px`:p})}typeof o=="number"||typeof o=="string"?h(o):typeof o=="object"?["top","right","bottom","left"].forEach(p=>{o[p]===void 0?a[`${d}-${p}`]=m:a[`${d}-${p}`]=typeof o[p]=="number"?`${o[p]}px`:o[p]}):h(m)}),a}const mP=ue.forwardRef(function(n,a){const{id:o,invert:l,position:i="bottom-right",hotkey:d=["altKey","KeyT"],expand:m,closeButton:h,className:p,offset:y,mobileOffset:v,theme:x="light",richColors:S,duration:j,style:C,visibleToasts:N=rP,toastOptions:E,dir:k=Gx(),gap:A=lP,icons:R,containerAriaLabel:L="Notifications"}=n,[z,B]=ue.useState([]),U=ue.useMemo(()=>o?z.filter(H=>H.toasterId===o):z.filter(H=>!H.toasterId),[z,o]),q=ue.useMemo(()=>Array.from(new Set([i].concat(U.filter(H=>H.position).map(H=>H.position)))),[U,i]),[Z,Q]=ue.useState([]),[fe,de]=ue.useState(!1),[ce,he]=ue.useState(!1),[M,K]=ue.useState(x!=="system"?x:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),re=ue.useRef(null),oe=d.join("+").replace(/Key/g,"").replace(/Digit/g,""),ee=ue.useRef(null),_=ue.useRef(!1),O=ue.useCallback(H=>{B(I=>{var V;return(V=I.find(ne=>ne.id===H.id))!=null&&V.delete||cn.dismiss(H.id),I.filter(({id:ne})=>ne!==H.id)})},[]);return ue.useEffect(()=>cn.subscribe(H=>{if(H.dismiss){requestAnimationFrame(()=>{B(I=>I.map(V=>V.id===H.id?{...V,delete:!0}:V))});return}setTimeout(()=>{g0.flushSync(()=>{B(I=>{const V=I.findIndex(ne=>ne.id===H.id);return V!==-1?[...I.slice(0,V),{...I[V],...H},...I.slice(V+1)]:[H,...I]})})})}),[z]),ue.useEffect(()=>{if(x!=="system"){K(x);return}if(x==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?K("dark"):K("light")),typeof window>"u")return;const H=window.matchMedia("(prefers-color-scheme: dark)");try{H.addEventListener("change",({matches:I})=>{K(I?"dark":"light")})}catch{H.addListener(({matches:V})=>{try{K(V?"dark":"light")}catch(ne){console.error(ne)}})}},[x]),ue.useEffect(()=>{z.length<=1&&de(!1)},[z]),ue.useEffect(()=>{const H=I=>{var V;if(d.every(me=>I[me]||I.code===me)){var J;de(!0),(J=re.current)==null||J.focus()}I.code==="Escape"&&(document.activeElement===re.current||(V=re.current)!=null&&V.contains(document.activeElement))&&de(!1)};return document.addEventListener("keydown",H),()=>document.removeEventListener("keydown",H)},[d]),ue.useEffect(()=>{if(re.current)return()=>{ee.current&&(ee.current.focus({preventScroll:!0}),ee.current=null,_.current=!1)}},[re.current]),ue.createElement("section",{ref:a,"aria-label":`${L} ${oe}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},q.map((H,I)=>{var V;const[ne,J]=H.split("-");return U.length?ue.createElement("ol",{key:H,dir:k==="auto"?Gx():k,tabIndex:-1,ref:re,className:p,"data-sonner-toaster":!0,"data-sonner-theme":M,"data-y-position":ne,"data-x-position":J,style:{"--front-toast-height":`${((V=Z[0])==null?void 0:V.height)||0}px`,"--width":`${sP}px`,"--gap":`${A}px`,...C,...fP(y,v)},onBlur:me=>{_.current&&!me.currentTarget.contains(me.relatedTarget)&&(_.current=!1,ee.current&&(ee.current.focus({preventScroll:!0}),ee.current=null))},onFocus:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||_.current||(_.current=!0,ee.current=me.relatedTarget)},onMouseEnter:()=>de(!0),onMouseMove:()=>de(!0),onMouseLeave:()=>{ce||de(!1)},onDragEnd:()=>de(!1),onPointerDown:me=>{me.target instanceof HTMLElement&&me.target.dataset.dismissible==="false"||he(!0)},onPointerUp:()=>he(!1)},U.filter(me=>!me.position&&I===0||me.position===H).map((me,pe)=>{var G,se;return ue.createElement(dP,{key:me.id,icons:R,index:pe,toast:me,defaultRichColors:S,duration:(G=E==null?void 0:E.duration)!=null?G:j,className:E==null?void 0:E.className,descriptionClassName:E==null?void 0:E.descriptionClassName,invert:l,visibleToasts:N,closeButton:(se=E==null?void 0:E.closeButton)!=null?se:h,interacting:ce,position:H,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:O,toasts:U.filter(ge=>ge.position==me.position),heights:Z.filter(ge=>ge.position==me.position),setHeights:Q,expandByDefault:m,gap:A,expanded:fe,swipeDirections:n.swipeDirections})})):null}))});async function ru(e){const n=rs.loading("Saving changes…");try{const a=await e();if(rs.success("Changes saved",{id:n}),a.botRestart){const o=rs.loading("Restarting bot…");a.botRestart.success?rs.success("Bot started",{id:o}):rs.error(a.botRestart.error??"Could not start bot",{id:o})}return a}catch(a){throw rs.error(a instanceof Error?a.message:"Save failed",{id:n}),a}}function pP({filename:e}){const{canEditConfig:n}=Ft(),a=!n("supportbot"),[o,l]=f.useState(null),[i,d]=f.useState(null),[m,h]=f.useState(!0),[p,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),C=f.useCallback(async()=>{h(!0),x(""),j("");try{const L=(await ke.getAddonConfigJson(e)).data??{};l(L),d(structuredClone(L))}catch(R){x(R instanceof Error?R.message:"Failed to load config")}finally{h(!1)}},[e]);f.useEffect(()=>{C()},[C]);const N=o?Iz(o):null;function E(R,L){l(z=>z&&Xl(z,R,L))}async function k(){if(!(a||!o)){y(!0),x(""),j("");try{const R=await ru(()=>ke.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 c.jsxs("div",{className:"space-y-4",children:[c.jsx(Fe,{className:"h-24 w-full rounded-xl"}),c.jsx(Fe,{className:"h-48 w-full rounded-xl"})]});if(!o||!N)return c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v||"Failed to load"})});const A=i&&JSON.stringify(o)!==JSON.stringify(i);return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-2",children:[A?c.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,c.jsx(be,{variant:"outline",size:"sm",onClick:C,disabled:m||p,children:"Reload"}),a?c.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):c.jsxs(be,{size:"sm",onClick:k,disabled:p||!A,children:[c.jsx(ye,{icon:Au,size:16,className:"mr-1.5"}),p?"Saving…":"Save"]})]}),v?c.jsxs(Ue,{variant:"destructive",children:[c.jsx(ye,{icon:mh,size:18}),c.jsx(He,{children:v})]}):null,S?c.jsx(Ue,{className:"border-primary/30 bg-primary/10 text-primary",children:c.jsx(He,{children:S})}):null,N.map(R=>c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"pb-3",children:[c.jsx(ot,{className:"text-base",children:R.title}),R.description?c.jsx(Nt,{children:R.description}):null]}),c.jsx(qe,{className:"grid gap-4 sm:grid-cols-2",children:R.fields.map(L=>c.jsx("div",{className:L.type==="textarea"||L.type==="stringList"?"sm:col-span-2":"",children:c.jsx(yg,{field:L,value:ao(o,L.path),readOnly:a,onChange:z=>E(L.path,z)})},L.path))})]},R.title))]})}function hP(e){return e.replace(/_/g," ").replace(/([a-z])([A-Z])/g,"$1 $2").replace(/\b\w/g,n=>n.toUpperCase())}function gP(e,n){const a=new Set(e.flatMap(d=>d.fields.map(m=>m.path))),o=xg(n).filter(d=>!a.has(d.path));if(o.length===0)return e;const l=new Map;for(const d of o){const m=d.path.split(".")[0]??"Other",h=l.get(m)??[];h.push(d),l.set(m,h)}const i=[...l.entries()].sort(([d],[m])=>d.localeCompare(m)).map(([d,m])=>({title:hP(d),description:"These options exist in your config file but are not in the main editor sections.",fields:m.sort((h,p)=>h.path.localeCompare(p.path))}));return[...e,...i]}function vP(e){return e!==null&&typeof e=="object"&&"Command"in e}function bP(e){return Object.entries(e).filter(([,n])=>vP(n)).map(([n,a])=>({key:n,...a}))}function yP({data:e,onChange:n}){const a=bP(e);function o(l,i){const d=e[l];n({...e,[l]:{...d,...i}})}return a.length===0?c.jsx("p",{className:"text-sm text-muted-foreground",children:"No commands found in this config."}):c.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:a.map(l=>c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"flex flex-row items-center gap-2 space-y-0 pb-2",children:[c.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-primary/15 text-primary",children:c.jsx(ye,{icon:ms,size:18})}),c.jsx(ot,{className:"text-base",children:l.key})]}),c.jsxs(qe,{className:"space-y-3",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(Ze,{htmlFor:`${l.key}-enabled`,children:"Enabled"}),c.jsx(Dn,{id:`${l.key}-enabled`,checked:l.Enabled!==!1,onCheckedChange:i=>o(l.key,{Enabled:i})})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ze,{children:"Slash command"}),c.jsx(rt,{value:l.Command??"",onChange:i=>o(l.key,{Command:i.target.value}),className:"border-border bg-secondary/30 font-mono"})]}),c.jsxs("div",{className:"space-y-1.5",children:[c.jsx(Ze,{children:"Description"}),c.jsx(rt,{value:l.Description??"",onChange:i=>o(l.key,{Description:i.target.value}),className:"border-border bg-secondary/30"})]})]})]},l.key))})}function xP(e,n){let a=structuredClone(n);if(e==="supportbot"){const o=ao(a,"General.Token");o&&o!=="BOT_TOKEN"&&(a=Xl(a,"General.Token","BOT_TOKEN"))}if(e==="supportbot-ai"){const o=ao(a,"General.Model_API_Key");o&&o!=="MODEL_API_KEY"&&(a=Xl(a,"General.Model_API_Key","MODEL_API_KEY"))}return a}function SP(e,n,a,o){const l={};for(const i of n)for(const d of i.fields){const m=ao(a,d.path),h=ao(o,d.path);d.type==="secret"&&(m==="BOT_TOKEN"||m==="MODEL_API_KEY"||m===""||m===void 0)||JSON.stringify(m)!==JSON.stringify(h)&&(l[`${e}:${d.path}`]=m)}return l}function wP({configFile:e}){const{canEditConfig:n}=Ft(),a=!n(e),[o,l]=f.useState(null),[i,d]=f.useState(null),[m,h]=f.useState(!0),[p,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState("visual"),[E,k]=f.useState(""),[A,R]=f.useState(""),L=V7(e),z=f.useMemo(()=>!L||L==="commands"||!o?L:gP(L,o),[L,o]),B=f.useCallback(async()=>{h(!0),x(""),j("");try{const he=(await ke.getConfigJson(e)).data??{},M=xP(e,he);l(M),d(M);const re=(await ke.getConfigRaw(e)).data??"",oe=D4(re,e);k(oe),R(oe)}catch(ce){x(ce instanceof Error?ce.message:"Failed to load config")}finally{h(!1)}},[e]);f.useEffect(()=>{B()},[B]);function U(ce,he){l(M=>M&&Xl(M,ce,he))}async function q(){if(!(a||E===A)){y(!0),x(""),j("");try{const ce=await ru(()=>ke.saveConfigRaw(e,E));j(ce.message||"Config saved."),await B()}catch(ce){x(ce instanceof Error?ce.message:"Save failed")}finally{y(!1)}}}async function Z(){if(!(a||!o||!i)){if(C==="yaml"){await q();return}y(!0),x(""),j("");try{if(L==="commands"){const ce={};for(const M of Object.keys(o))JSON.stringify(o[M])!==JSON.stringify(i[M])&&(ce[`${e}:${M}`]=o[M]);if(Object.keys(ce).length===0){j("No changes to save.");return}const he=await ru(()=>ke.updateConfigFields(ce));j(he.message||"")}else if(z&&z!=="commands"){const ce=SP(e,z,o,i);if(Object.keys(ce).length===0){j("No changes to save.");return}const he=await ru(()=>ke.updateConfigFields(ce));j(he.message||"")}await B()}catch(ce){x(ce instanceof Error?ce.message:"Save failed")}finally{y(!1)}}}if(L===null)return c.jsx(Ue,{children:c.jsx(He,{children:"No visual editor available for this file."})});if(m)return c.jsxs("div",{className:"space-y-4",children:[c.jsx(Fe,{className:"h-24 w-full rounded-xl"}),c.jsx(Fe,{className:"h-48 w-full rounded-xl"})]});if(!o)return c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v||"Failed to load"})});const Q=i&&JSON.stringify(o)!==JSON.stringify(i),de=C==="yaml"?E!==A:Q;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[c.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[c.jsx(be,{type:"button",variant:C==="visual"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("visual"),children:"Visual"}),c.jsx(be,{type:"button",variant:C==="yaml"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>N("yaml"),children:"YAML"})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[de?c.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,c.jsx(be,{variant:"outline",size:"sm",onClick:B,disabled:m||p,children:"Reload"}),a?c.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):c.jsxs(be,{size:"sm",onClick:Z,disabled:p||!de,children:[c.jsx(ye,{icon:Au,size:16,className:"mr-1.5"}),p?"Saving…":"Save"]})]})]}),v?c.jsxs(Ue,{variant:"destructive",children:[c.jsx(ye,{icon:mh,size:18}),c.jsx(He,{children:v})]}):null,S?c.jsx(Ue,{className:"border-primary/30 bg-primary/10 text-primary",children:c.jsx(He,{children:S})}):null,C==="yaml"?c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"pb-3",children:[c.jsx(ot,{className:"text-base",children:"Raw YAML"}),c.jsx(Nt,{children:"Edit the full file. Use this for nested lists (e.g. welcome buttons) or any option not in Visual mode."})]}),c.jsx(qe,{children:c.jsx(sd,{value:E,disabled:a,onChange:ce=>k(ce.target.value),className:"min-h-[min(520px,60vh)] font-mono text-xs leading-relaxed",spellCheck:!1})})]}):L==="commands"?c.jsx(yP,{data:o,onChange:ce=>l(ce)}):z&&z!=="commands"?z.map(ce=>c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"pb-3",children:[c.jsx(ot,{className:"text-base",children:ce.title}),ce.description?c.jsx(Nt,{children:ce.description}):null]}),c.jsx(qe,{className:"grid gap-4 sm:grid-cols-2",children:ce.fields.map(he=>c.jsx("div",{className:he.type==="textarea"||he.type==="stringList"?"sm:col-span-2":"",children:c.jsx(yg,{field:he,value:ao(o,he.path),readOnly:a,onChange:M=>U(he.path,M)})},he.path))})]},ce.title)):null]})}const CP=ke.listConfigs(),jP={supportbot:"Bot config","ticket-panel":"Ticket system",commands:"Commands",messages:"Messages","supportbot-ai":"AI assistant"};function EP(){var R,L;const{permissions:e,canViewConfig:n}=Ft(),{files:a}=R0(),[o,l]=dh(),i=o.get("file"),d=n("supportbot"),m=f.useMemo(()=>CP.filter(z=>n(z)),[n]),h=f.useMemo(()=>d?a:[],[d,a]),p=f.useMemo(()=>[...m,...h.map(z=>is(z))],[m,h]),y=p[0]??"",[v,x]=f.useState(()=>i&&p.includes(i)?i:y);if(f.useEffect(()=>{i&&p.includes(i)?x(i):p.includes(v)||(x(y),y&&l({file:y}))},[i,p,v,y,l]),p.length===0)return c.jsx(Mr,{to:Sh(e),replace:!0});function S(z){x(z),l({file:z})}const j=V4(v),C=(j==null?void 0:j.type)==="addon",N=C?j.file:null,E=C?A0(N):jP[v]??"Configuration",k=C?!!((R=e==null?void 0:e.configs.supportbot)!=null&&R.edit):e?!!((L=e.configs[v])!=null&&L.edit):!1,A=C?N:`${v}.yml`;return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:E}),c.jsx("p",{className:"text-muted-foreground",children:k?`Edit ${A} — changes apply to the running bot without restarting the dashboard.`:`Viewing ${A} — you do not have permission to save changes.`})]}),c.jsxs("div",{className:"grid gap-4 lg:grid-cols-[220px_1fr]",children:[c.jsxs(We,{className:"h-fit border-border bg-card",children:[c.jsx(at,{className:"pb-2",children:c.jsx(ot,{className:"text-sm font-medium text-muted-foreground",children:"Configuration files"})}),c.jsx(qe,{className:"p-0",children:c.jsx(hi,{className:"h-[min(400px,50vh)]",children:c.jsxs("ul",{className:"space-y-3 p-2",children:[m.length>0?c.jsxs("li",{children:[c.jsx("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80",children:"Core"}),c.jsx("ul",{className:"space-y-0.5",children:m.map(z=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>S(z),className:ie("w-full rounded-lg px-3 py-2.5 text-left text-sm transition-colors",z===v?"bg-primary/15 font-medium text-primary":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:[z,".yml"]})},z))})]}):null,h.length>0?c.jsxs("li",{children:[c.jsx("p",{className:"px-3 pb-1 text-[10px] font-semibold uppercase tracking-widest text-muted-foreground/80",children:"Addons"}),c.jsx("ul",{className:"space-y-0.5",children:h.map(z=>{const B=is(z);return c.jsx("li",{children:c.jsx("button",{type:"button",onClick:()=>S(B),className:ie("w-full rounded-lg px-3 py-2.5 text-left text-sm transition-colors",B===v?"bg-primary/15 font-medium text-primary":"text-muted-foreground hover:bg-secondary hover:text-foreground"),children:z})},z)})})]}):null]})})})]}),c.jsx("div",{className:"min-w-0",children:C&&N?c.jsx(pP,{filename:N},N):c.jsx(wP,{configFile:v},v)})]})]})}const NP={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 kP(e){return e?NP[e]||"Sign-in failed. Please try again.":""}function TP(){const{branding:e}=Ou(),{isAuthenticated:n,loading:a,loginWithDiscord:o}=Ft(),[l]=dh(),i=f.useMemo(()=>kP(l.get("error")),[l]);return!a&&n?c.jsx(Mr,{to:"/",replace:!0}):c.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background p-4",children:c.jsxs(We,{className:"w-full max-w-md border-border bg-card",children:[c.jsx(at,{className:"space-y-4",children:c.jsxs("div",{className:"flex items-center gap-3",children:[e.hasFavicon&&e.faviconUrl?c.jsx("img",{src:`${e.faviconUrl}${e.updatedAt?`?v=${e.updatedAt}`:""}`,alt:"",className:"size-11 rounded-xl object-contain"}):c.jsx("div",{className:"flex size-11 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:c.jsx(ye,{icon:ku,size:22})}),c.jsxs("div",{children:[c.jsx(ot,{className:"text-xl",children:e.title}),c.jsx(Nt,{children:"Sign in to your dashboard"})]})]})}),c.jsxs(qe,{className:"space-y-4",children:[c.jsxs("p",{className:"text-sm text-muted-foreground",children:["Sign in with Discord. Your application credentials and allowed user IDs are configured in"," ",c.jsx("code",{className:"rounded-md bg-secondary px-1.5 py-0.5 text-xs text-foreground",children:"Configs/api.yml"}),"."]}),i?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:i})}):null,c.jsx(be,{type:"button",className:"w-full",disabled:a,onClick:o,children:a?"Checking session…":"Continue with Discord"})]})]})})}const fs=[{id:"botToken",title:"Bot token",subtitle:"Connect your Discord bot",icon:ku},{id:"secretKey",title:"Session secret",subtitle:"Secure dashboard logins",icon:M4},{id:"oauth",title:"Discord OAuth",subtitle:"Sign in with Discord",icon:N4},{id:"redirectUri",title:"Redirect URL",subtitle:"OAuth callback address",icon:gh},{id:"owners",title:"Dashboard owners",subtitle:"Who can access this panel",icon:yh}];function RP(e){return e==="oauth"?"oauth":e==="owners"?"owners":e}function AP({brandingTitle:e,faviconUrl:n,faviconVersion:a,hasFavicon:o,children:l}){return c.jsx("div",{className:"min-h-svh bg-background",children:c.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:[c.jsxs("header",{className:"mb-8 flex items-center gap-4",children:[o&&n?c.jsx("img",{src:`${n}${a?`?v=${a}`:""}`,alt:"",className:"size-12 rounded-2xl border border-border object-contain"}):c.jsx("div",{className:"flex size-12 items-center justify-center rounded-2xl border border-border bg-primary text-primary-foreground",children:c.jsx(ye,{icon:ku,size:24})}),c.jsxs("div",{children:[c.jsx("p",{className:"text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"First-time setup"}),c.jsx("h1",{className:"text-2xl font-semibold tracking-tight md:text-3xl",children:e})]})]}),l]})})}function _P({currentIndex:e,validation:n}){const a=(e+1)/fs.length*100;return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[c.jsxs("span",{children:["Step ",e+1," of ",fs.length]}),c.jsxs("span",{children:[Math.round(a),"%"]})]}),c.jsx("div",{className:"h-2 overflow-hidden rounded-full bg-secondary",children:c.jsx("div",{className:"h-full rounded-full bg-primary transition-all duration-300 ease-out",style:{width:`${a}%`}})})]}),c.jsx("nav",{className:"hidden space-y-1 md:block","aria-label":"Setup steps",children:fs.map((o,l)=>{var p;const i=RP(o.id),d=(p=n[i])==null?void 0:p.ok,m=l===e,h=lc.jsxs("li",{className:"flex items-center gap-2",children:[c.jsx(ye,{icon:Tu,size:14}),o.globalName||o.username,c.jsx("span",{className:"font-mono text-xs opacity-80",children:o.id})]},o.id))}):null,!e.bot&&!((a=e.users)!=null&&a.length)?c.jsx("p",{children:e.warning||"Verified successfully."}):null]})}):c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:e.error})}):null}function OP({values:e,setValues:n,validation:a,validating:o,onValidate:l}){return c.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[c.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Open the"," ",c.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 ",c.jsx("strong",{children:"Bot"}),", and reset or copy the token."]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"botToken",children:"Bot token"}),c.jsx(rt,{id:"botToken",type:"password",autoComplete:"off",value:e.botToken,onChange:i=>n({...e,botToken:i.target.value}),placeholder:"MTI…",className:"h-11 font-mono text-sm"})]}),c.jsx(yi,{result:a.botToken}),c.jsx("div",{className:"mt-auto",children:c.jsx(be,{type:"button",variant:"secondary",disabled:o||!e.botToken,onClick:l,children:o?"Checking with Discord…":"Verify bot token"})})]})}function DP({values:e,setValues:n,validation:a,validating:o,onValidate:l,onGenerate:i}){return c.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[c.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."}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"secretKey",children:"Session secret"}),c.jsx(rt,{id:"secretKey",type:"password",autoComplete:"off",value:e.secretKey,onChange:d=>n({...e,secretKey:d.target.value}),className:"h-11 font-mono text-sm"})]}),c.jsx(yi,{result:a.secretKey}),c.jsxs("div",{className:"mt-auto flex flex-wrap gap-2",children:[c.jsx(be,{type:"button",variant:"outline",onClick:i,children:"Generate secure secret"}),c.jsx(be,{type:"button",variant:"secondary",disabled:o||!e.secretKey,onClick:l,children:o?"Checking…":"Validate"})]})]})}function LP({values:e,setValues:n,validation:a,validating:o,onValidate:l}){return c.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[c.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Use the ",c.jsx("strong",{children:"same application"})," as your bot. Under OAuth2, copy the Client ID and Client Secret."]}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[c.jsx(Ze,{htmlFor:"clientId",children:"Client ID"}),c.jsx(rt,{id:"clientId",value:e.clientId,onChange:i=>n({...e,clientId:i.target.value}),className:"h-11 font-mono text-sm"})]}),c.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[c.jsx(Ze,{htmlFor:"clientSecret",children:"Client Secret"}),c.jsx(rt,{id:"clientSecret",type:"password",autoComplete:"off",value:e.clientSecret,onChange:i=>n({...e,clientSecret:i.target.value}),className:"h-11 font-mono text-sm"})]})]}),c.jsx(yi,{result:a.oauth}),c.jsx("div",{className:"mt-auto",children:c.jsx(be,{type:"button",variant:"secondary",disabled:o||!e.clientId||!e.clientSecret,onClick:l,children:o?"Checking with Discord…":"Verify OAuth credentials"})})]})}function zP({values:e,setValues:n,validation:a}){async function o(){if(e.redirectUri)try{await navigator.clipboard.writeText(e.redirectUri)}catch{}}return c.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[c.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Add this exact URL under ",c.jsx("strong",{children:"OAuth2 → Redirects"})," in the Developer Portal. It must match character-for-character."]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"redirectUri",children:"Redirect URI"}),c.jsxs("div",{className:"flex gap-2",children:[c.jsx(rt,{id:"redirectUri",value:e.redirectUri,onChange:l=>n({...e,redirectUri:l.target.value}),className:"h-11 flex-1 font-mono text-xs"}),c.jsx(be,{type:"button",variant:"outline",size:"icon",className:"size-11 shrink-0",onClick:()=>void o(),title:"Copy URL",children:c.jsx(ye,{icon:x0,size:18})})]})]}),a.redirectUri&&!a.redirectUri.ok?c.jsx(yi,{result:a.redirectUri}):c.jsx(Ue,{className:"border-border bg-secondary",children:c.jsx(He,{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 PP({values:e,setValues:n,validation:a,validating:o,onValidate:l}){return c.jsxs("div",{className:"flex flex-1 flex-col gap-5",children:[c.jsxs("p",{className:"text-sm leading-relaxed text-muted-foreground",children:["Enable ",c.jsx("strong",{children:"Developer Mode"})," in Discord (Settings → Advanced), then right-click your profile and ",c.jsx("strong",{children:"Copy User ID"}),". Add one ID per line."]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"owners",children:"Owner user IDs"}),c.jsx(sd,{id:"owners",value:e.ownerUserIds,onChange:i=>n({...e,ownerUserIds:i.target.value}),placeholder:`829112572816130058 987654321098765432`,className:"min-h-[120px] font-mono text-sm"})]}),c.jsx(yi,{result:a.owners}),c.jsx("div",{className:"mt-auto",children:c.jsx(be,{type:"button",variant:"secondary",disabled:o||!e.ownerUserIds.trim(),onClick:l,children:o?"Checking with Discord…":"Verify owner IDs"})})]})}function BP({onContinue:e}){return c.jsx("div",{className:"mx-auto flex w-full max-w-lg flex-1 flex-col justify-center py-8",children:c.jsxs("div",{className:"rounded-2xl border border-border bg-card px-6 py-10 text-center md:px-10",children:[c.jsx("div",{className:"mx-auto mb-6 flex size-16 items-center justify-center rounded-2xl bg-primary/10 text-primary",children:c.jsx(ye,{icon:Tu,size:40})}),c.jsx("h2",{className:"text-2xl font-semibold tracking-tight",children:"Setup complete"}),c.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"," ",c.jsx("code",{className:"rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs",children:"npm start"}),")."]}),c.jsx(Ue,{className:"mt-6 text-left",children:c.jsx(He,{children:"After restarting, sign in with Discord to open the dashboard."})}),c.jsx(be,{type:"button",size:"lg",className:"mt-8 min-w-[220px]",onClick:e,children:"Continue to sign in"})]})})}function $P({currentIndex:e,validating:n,saving:a,onBack:o,onNext:l,onFinish:i}){const d=e===fs.length-1;return c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[c.jsxs(be,{type:"button",variant:"ghost",disabled:e===0||a,onClick:o,children:[c.jsx(ye,{icon:b0,size:18,className:"mr-1"}),"Back"]}),c.jsx("div",{className:"flex flex-1 justify-end gap-2",children:d?c.jsx(be,{type:"button",size:"lg",disabled:a||n,onClick:i,className:"min-w-[200px]",children:a?"Saving…":"Finish setup"}):c.jsxs(be,{type:"button",size:"lg",disabled:n||a,onClick:l,children:["Continue",c.jsx(ye,{icon:ph,size:18,className:"ml-1"})]})})]})}function IP(){const e=crypto.randomUUID().replace(/-/g,""),n=crypto.randomUUID().replace(/-/g,"");return e+n}function UP(e){return e.split(/[\s,]+/).map(n=>n.trim()).filter(Boolean)}function Fx(e){return e==="oauth"?"oauth":e==="owners"?"owners":e}function HP(){const e=oo(),{branding:n}=Ou(),{loading:a,error:o,refresh:l,status:i}=yC(),[d,m]=f.useState(0),[h,p]=f.useState({botToken:"",secretKey:"",clientId:"",clientSecret:"",redirectUri:"",ownerUserIds:""}),[y,v]=f.useState({}),[x,S]=f.useState(!1),[j,C]=f.useState(!1),[N,E]=f.useState(""),[k,A]=f.useState(!1),R=fs[d];f.useEffect(()=>{i!=null&&i.suggestedRedirectUri&&!h.redirectUri&&p(Q=>({...Q,redirectUri:i.suggestedRedirectUri}))},[i==null?void 0:i.suggestedRedirectUri,h.redirectUri]);const L=f.useMemo(()=>({botToken:h.botToken,secretKey:h.secretKey,clientId:h.clientId,clientSecret:h.clientSecret,redirectUri:h.redirectUri,ownerUserIds:UP(h.ownerUserIds)}),[h]);async function z(){S(!0),E("");try{const Q=await ke.validateSetup(L);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 B(){var de,ce;const Q=Fx(R.id),fe=await z();return!!((ce=(de=fe==null?void 0:fe.results)==null?void 0:de[Q])!=null&&ce.ok)}async function U(){const Q=Fx(R.id),fe=y[Q];!(fe!=null&&fe.ok)&&!await B()||m(de=>Math.min(de+1,fs.length-1))}async function q(){C(!0),E("");try{const Q=await z();if(!(Q!=null&&Q.ok)){E("Fix the steps marked with errors before finishing.");return}await ke.completeSetup(L),A(!0)}catch(Q){E(Q instanceof Error?Q.message:"Could not save setup")}finally{C(!1)}}function Z(){const Q={values:h,setValues:p,validation:y,validating:x};switch(R.id){case"botToken":return c.jsx(OP,{...Q,onValidate:()=>void B()});case"secretKey":return c.jsx(DP,{...Q,onGenerate:()=>p(fe=>({...fe,secretKey:IP()})),onValidate:()=>void B()});case"oauth":return c.jsx(LP,{...Q,onValidate:()=>void B()});case"redirectUri":return c.jsx(zP,{values:h,setValues:p,validation:y});case"owners":return c.jsx(PP,{...Q,onValidate:()=>void B()})}}return a?c.jsx("div",{className:"min-h-svh bg-background px-4 py-10",children:c.jsxs("div",{className:"mx-auto max-w-6xl space-y-8",children:[c.jsx(Fe,{className:"h-14 w-64"}),c.jsxs("div",{className:"grid gap-8 lg:grid-cols-[280px_1fr]",children:[c.jsx(Fe,{className:"hidden h-80 lg:block"}),c.jsx(Fe,{className:"h-[520px] rounded-2xl"})]})]})}):c.jsxs(AP,{brandingTitle:n.title,faviconUrl:n.faviconUrl,faviconVersion:n.updatedAt,hasFavicon:n.hasFavicon,children:[o?c.jsx(Ue,{variant:"destructive",className:"mb-6",children:c.jsx(He,{children:o})}):null,N?c.jsx(Ue,{variant:"destructive",className:"mb-6",children:c.jsx(He,{children:N})}):null,k?c.jsx(BP,{onContinue:async()=>{await l(),e("/login",{replace:!0})}}):c.jsxs("div",{className:"grid flex-1 gap-8 lg:grid-cols-[minmax(0,280px)_1fr]",children:[c.jsx(_P,{currentIndex:d,validation:y}),c.jsx(MP,{step:R,footer:c.jsx($P,{currentIndex:d,validating:x,saving:j,onBack:()=>m(Q=>Math.max(0,Q-1)),onNext:()=>void U(),onFinish:()=>void q()}),children:Z()})]})]})}const VP={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 GP({title:e,icon:n,href:a,badge:o="Configured",status:l="done"}){return c.jsxs(kt,{to:a,className:ie("flex items-center gap-3 rounded-2xl border border-border bg-card p-4 transition-colors","hover:border-primary hover:bg-secondary"),children:[c.jsx("div",{className:"flex size-11 shrink-0 items-center justify-center rounded-full bg-secondary text-primary",children:c.jsx(ye,{icon:n,size:20})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate font-semibold",children:e}),c.jsx("span",{className:ie("mt-1 inline-flex rounded-md px-2 py-0.5 text-[10px] font-semibold",VP[l]),children:o})]})]})}function FP({percent:e,size:n=128,className:a,trackClassName:o="stroke-white/20",strokeClassName:l="stroke-white"}){const d=2*Math.PI*42,m=Math.min(100,Math.max(0,e)),h=d-m/100*d;return c.jsxs("div",{className:ie("relative inline-flex",a),children:[c.jsxs("svg",{width:n,height:n,viewBox:"0 0 100 100",className:"-rotate-90","aria-hidden":!0,children:[c.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",className:o}),c.jsx("circle",{cx:"50",cy:"50",r:42,fill:"none",strokeWidth:"9",strokeLinecap:"round",strokeDasharray:d,strokeDashoffset:h,className:l})]}),c.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center text-center",children:[c.jsxs("span",{className:"text-2xl font-bold tabular-nums leading-none",children:[Math.round(m),"%"]}),c.jsx("span",{className:"mt-0.5 text-[10px] font-medium uppercase tracking-wide opacity-80",children:"Complete"})]})]})}const YP={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 WP({title:e,subtitle:n,icon:a,href:o,status:l,meta:i="Open in dashboard"}){const d=YP[l];return c.jsxs(kt,{to:o,className:ie("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:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsx("span",{className:ie("mt-1.5 size-2 shrink-0 rounded-full",d.dot)}),c.jsx("span",{className:"text-xs text-muted-foreground",children:n})]}),c.jsxs("div",{children:[c.jsx("h3",{className:"font-semibold leading-snug tracking-tight",children:e}),c.jsx("span",{className:ie("mt-2 inline-flex rounded-md px-2 py-0.5 text-[11px] font-semibold",d.badge),children:d.label})]}),c.jsxs("div",{className:"mt-auto flex items-center justify-between border-t border-border pt-3",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"flex size-8 items-center justify-center rounded-lg bg-secondary text-primary",children:c.jsx(ye,{icon:a,size:16})}),c.jsx("span",{className:"text-xs text-muted-foreground",children:i})]}),c.jsxs("div",{className:"flex items-center gap-3 text-muted-foreground",children:[c.jsx(ye,{icon:gh,size:14,className:"opacity-60"}),c.jsx(ye,{icon:Xa,size:14,className:"opacity-60 group-hover:text-primary"}),c.jsx(ye,{icon:ph,size:14,className:"text-primary opacity-0 transition-opacity group-hover:opacity-100"})]})]})]})}function qP({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:j0(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 c.jsxs("aside",{className:"hidden w-[min(100%,320px)] shrink-0 space-y-4 xl:block",children:[c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"flex flex-row items-center justify-between space-y-0 pb-3",children:[c.jsxs(ot,{className:"text-sm font-semibold",children:["Connected servers (",e.servers,")"]}),c.jsx(be,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:c.jsx("span",{className:"text-lg leading-none",children:"+"})})]}),c.jsxs(qe,{className:"pt-0",children:[c.jsxs("div",{className:"flex -space-x-2",children:[Array.from({length:Math.min(6,e.servers)}).map((a,o)=>c.jsxs(gs,{className:"size-9 border-2 border-card ring-0",children:[c.jsx(vs,{src:e.bot.avatar,alt:""}),c.jsx(bs,{className:"bg-primary/25 text-[10px] text-primary",children:String(o+1)})]},o)),e.servers>6?c.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]}),c.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[e.users.toLocaleString()," members across your guilds"]})]})]}),c.jsx(We,{className:"overflow-hidden border-border bg-secondary",children:c.jsx(qe,{className:"p-5",children:c.jsxs("div",{className:"space-y-3",children:[c.jsx("div",{className:"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground",children:c.jsx(ye,{icon:_4,size:22})}),c.jsxs("div",{children:[c.jsx("p",{className:"font-semibold",children:"Keep SupportBot up to date"}),c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Check for releases and install updates from settings."})]}),c.jsx(be,{asChild:!0,size:"sm",className:"w-full",children:c.jsxs(kt,{to:"/settings",children:[c.jsx(ye,{icon:Ru,size:16,className:"mr-2"}),"Open settings"]})})]})})}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[c.jsx(ot,{className:"text-sm font-semibold",children:"System activity"}),c.jsx(be,{variant:"ghost",size:"icon",className:"size-7 text-muted-foreground",children:c.jsx("span",{className:"text-base leading-none",children:"⋯"})})]}),c.jsxs(qe,{className:"space-y-1 p-0 pb-2",children:[n.map(a=>c.jsxs("div",{className:"flex items-center gap-3 px-4 py-2.5 transition-colors hover:bg-secondary/40",children:[c.jsxs(gs,{className:"size-9",children:[c.jsx(vs,{src:e.bot.avatar,alt:e.bot.username}),c.jsx(bs,{className:"bg-secondary text-xs",children:"SB"})]}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate text-sm font-medium",children:a.label}),c.jsx("p",{className:"truncate text-xs text-muted-foreground",children:a.detail})]}),c.jsx("span",{className:`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold ${a.badgeClass}`,children:a.badge})]},a.id)),c.jsx(be,{asChild:!0,variant:"ghost",className:"mx-2 mt-1 w-[calc(100%-1rem)] justify-between text-xs text-muted-foreground",children:c.jsxs(kt,{to:"/system",children:["All system details",c.jsx(ye,{icon:ph,size:14})]})})]})]}),c.jsx(We,{className:"border-border bg-card",children:c.jsxs(qe,{className:"flex items-center gap-3 p-4",children:[c.jsx("div",{className:"flex size-9 items-center justify-center rounded-lg bg-secondary text-primary",children:c.jsx(ye,{icon:Xa,size:18})}),c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsxs("p",{className:"text-sm font-medium",children:["v",e.bot.version]}),c.jsxs("p",{className:"text-xs text-muted-foreground",children:["CPU ",e.hosting.cpu_load]})]})]})})]})}const h5={todo:"Needs setup",progress:"In progress",done:"Active"};function eh(e,n,a="Configure module"){const o=n==null?void 0:n[e];return o||{status:"todo",subtitle:a}}function KP(){return c.jsxs("div",{className:"flex gap-6",children:[c.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsx(Fe,{className:"h-44 rounded-2xl"}),c.jsx(Fe,{className:"h-44 rounded-2xl"})]}),c.jsx(Fe,{className:"h-8 w-48"}),c.jsx("div",{className:"flex gap-4 overflow-hidden",children:Array.from({length:3}).map((e,n)=>c.jsx(Fe,{className:"h-40 min-w-[280px] rounded-2xl"},n))}),c.jsx(Fe,{className:"h-8 w-56"}),c.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:Array.from({length:4}).map((e,n)=>c.jsx(Fe,{className:"h-20 rounded-2xl"},n))})]}),c.jsx(Fe,{className:"hidden h-[520px] w-80 shrink-0 rounded-2xl xl:block"})]})}function XP(){const{stats:e,loading:n,error:a}=Du(),[o,l]=f.useState("all"),i=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"?ls.filter(y=>y.category==="tickets"):o==="all"?ls:ls.filter(y=>y.category===o),[o]);if(n)return c.jsx(KP,{});if(a||!e)return c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:a||"No stats available"})});const m=e.tickets.open,h=e.tickets.closed,p=e.tickets.total;return c.jsxs("div",{className:"flex flex-col gap-6 xl:flex-row xl:items-start",children:[c.jsxs("div",{className:"min-w-0 flex-1 space-y-6",children:[c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsx(We,{className:"overflow-hidden border-border bg-card",children:c.jsxs(qe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsxs("p",{className:"text-lg font-semibold leading-snug",children:["You have"," ",c.jsx("span",{className:"text-primary",children:m})," open ticket",m===1?"":"s"]}),c.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."}),c.jsx(be,{asChild:!0,size:"sm",className:"rounded-lg px-5",children:c.jsx(kt,{to:"/transcripts",children:"Review"})})]}),c.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:[c.jsx("div",{className:"absolute inset-0 rounded-2xl bg-secondary"}),c.jsx("span",{className:"relative text-6xl",children:"🎫"})]})]})}),c.jsx(We,{className:"overflow-hidden border-border bg-primary text-primary-foreground",children:c.jsxs(qe,{className:"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",children:[c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm font-medium text-white/80",children:"Ticket summary"}),c.jsxs("ul",{className:"space-y-1.5 text-sm",children:[c.jsxs("li",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),c.jsxs("span",{className:"text-white/90",children:[p," total"]})]}),c.jsxs("li",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),c.jsxs("span",{className:"text-white/90",children:[h," closed"]})]}),c.jsxs("li",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"size-1.5 rounded-full bg-white/70"}),c.jsxs("span",{className:"text-white/90",children:[m," open"]})]})]})]}),c.jsx(FP,{percent:i,size:120})]})})]}),c.jsxs("section",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[c.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Module overview"}),c.jsx(Yj,{value:o,onValueChange:y=>l(y),children:c.jsxs(fg,{className:"h-auto flex-wrap rounded-xl bg-secondary/60 p-1",children:[c.jsx(Ka,{value:"all",className:"rounded-lg text-xs data-[state=active]:bg-background data-[state=active]:shadow-sm",children:"All"}),c.jsx(Ka,{value:"open",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Open"}),c.jsx(Ka,{value:"closed",className:"rounded-lg text-xs data-[state=active]:bg-background",children:"Closed"}),G7.filter(y=>y.id!=="all").map(y=>c.jsx(Ka,{value:y.id,className:"rounded-lg text-xs data-[state=active]:bg-background",children:y.label},y.id))]})})]}),c.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:Mu,href:"/transcripts",status:"todo",meta:"View transcripts"}]:o==="closed"?[{id:"closed-archive",title:"Closed tickets",subtitle:`${h} resolved`,icon:Tu,href:"/transcripts",status:"done",meta:"Browse archive"}]:d.map(y=>{const v=eh(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=>c.jsx(WP,{title:y.title,subtitle:y.subtitle,icon:y.icon,href:y.href,status:y.status,meta:y.meta},y.id))})]}),c.jsxs("section",{className:"space-y-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-xl font-bold tracking-tight",children:"Active modules"}),c.jsx(kt,{to:"/configs",className:"text-sm font-medium text-primary hover:underline",children:"See all"})]}),c.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ls.slice(0,4).map(y=>{const v=eh(y.id,e.modules);return c.jsx(GP,{title:y.title,icon:y.icon,href:y.href,badge:h5[v.status],status:v.status},y.id)})})]})]}),c.jsx(qP,{stats:e})]})}function ZP(){const{permissions:e}=Ft();return Ln(e,"overview")?c.jsx(XP,{}):c.jsx(Mr,{to:Sh(e),replace:!0})}function as({permission:e,children:n}){const{loading:a,isAuthenticated:o,permissions:l}=Ft();return a?c.jsx("div",{className:"flex flex-1 items-center justify-center py-16 text-sm text-muted-foreground",children:"Loading…"}):o?Ln(l,e)?c.jsx(c.Fragment,{children:n}):c.jsx(Mr,{to:Sh(l),replace:!0}):c.jsx(Mr,{to:"/login",replace:!0})}const Sg="supportbot-dashboard-accent",$l="#45b46c",QP=["--primary","--ring","--chart-1","--sidebar-primary","--sidebar-ring","--accent","--accent-foreground","--sidebar-accent","--sidebar-accent-foreground"];function JP(e){const n=lr(e,$l),a=parseInt(n.slice(1,3),16)/255,o=parseInt(n.slice(3,5),16)/255,l=parseInt(n.slice(5,7),16)/255,i=Math.max(a,o,l),d=Math.min(a,o,l),m=(i+d)/2;let h=0,p=0;if(i!==d){const y=i-d;switch(p=m>.5?y/(2-i-d):y/(i+d),i){case a:h=((o-l)/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 aB({canEdit:e}){const{branding:n,setBrandingLocal:a}=Ou(),o=f.useRef(null),[l,i]=f.useState(n.title),[d,m]=f.useState(n.pageTitle),[h,p]=f.useState(!1),[y,v]=f.useState(!1),[x,S]=f.useState("");f.useEffect(()=>{i(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){p(!0),S("");try{const R=await ke.updateBranding({title:l,pageTitle:d});R.data&&a(R.data),S(R.message||"Branding saved.")}catch(R){S(R instanceof Error?R.message:"Save failed")}finally{p(!1)}}}async function N(R){if(!(!e||!R)){v(!0),S("");try{const L=await rB(R),z=await ke.uploadBrandingFavicon(L);z.data&&a(z.data),S(z.message||"Favicon uploaded.")}catch(L){S(L instanceof Error?L.message:"Upload failed")}finally{v(!1),o.current&&(o.current.value="")}}}async function E(){if(e){v(!0),S("");try{const R=await ke.removeBrandingFavicon();R.data&&a(R.data),S(R.message||"Favicon removed.")}catch(R){S(R instanceof Error?R.message:"Remove failed")}finally{v(!1)}}}async function k(){if(e){p(!0),S("");try{const R=await ke.resetBranding();R.data&&a(R.data),S(R.message||"Reset to defaults.")}catch(R){S(R instanceof Error?R.message:"Reset failed")}finally{p(!1)}}}const A=l.trim()!==n.title||d.trim()!==n.pageTitle;return c.jsxs("div",{className:"space-y-4 border-t border-border pt-4",children:[c.jsxs("div",{children:[c.jsx("p",{className:"text-sm font-medium",children:"Branding"}),c.jsx("p",{className:"text-xs text-muted-foreground",children:"Sidebar title, browser tab title, and favicon — saved on the server for everyone using this dashboard."})]}),c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"brand-title",children:"Sidebar title"}),c.jsx(rt,{id:"brand-title",value:l,disabled:!e,maxLength:64,onChange:R=>i(R.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot"})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"brand-page-title",children:"Browser tab title"}),c.jsx(rt,{id:"brand-page-title",value:d,disabled:!e,maxLength:80,onChange:R=>m(R.target.value),className:"border-border bg-secondary/30",placeholder:"SupportBot Dashboard"})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{children:"Favicon"}),c.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."}),c.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[c.jsx("div",{className:"flex size-14 items-center justify-center overflow-hidden rounded-lg border border-border bg-secondary/30",children:j?c.jsx("img",{src:j,alt:"Favicon preview",className:"size-full object-contain p-1"}):c.jsx(ye,{icon:j4,size:22,className:"text-muted-foreground"})}),c.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:R=>{var L;return void N(((L=R.target.files)==null?void 0:L[0])??null)}}),e?c.jsxs(c.Fragment,{children:[c.jsx(be,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>{var R;return(R=o.current)==null?void 0:R.click()},children:y?"Uploading…":"Upload favicon"}),n.hasFavicon?c.jsx(be,{type:"button",variant:"outline",size:"sm",disabled:y,onClick:()=>void E(),children:"Remove"}):null]}):c.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"})]})]}),e?c.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.jsx(be,{type:"button",size:"sm",disabled:h||!A,onClick:()=>void C(),children:h?"Saving…":"Save titles"}),c.jsx(be,{type:"button",variant:"outline",size:"sm",disabled:h||y,onClick:()=>void k(),children:"Reset branding"})]}):null,x?c.jsx("p",{className:"text-xs text-muted-foreground",children:x}):null]})}function oB(){const{hasPermission:e}=Ft(),n=e("settings.update"),[a,o]=f.useState(null),[l,i]=f.useState(!0),[d,m]=f.useState(!1),[h,p]=f.useState(""),[y,v]=f.useState(""),[x,S]=f.useState(()=>v5()??$l),[j,C]=f.useState(""),N=f.useCallback(async()=>{i(!0),p("");try{const k=await ke.checkForUpdates();k.data&&o(k.data)}catch(k){p(k instanceof Error?k.message:"Could not check for updates")}finally{i(!1)}},[]);f.useEffect(()=>{N()},[N]);async function E(){if(a!=null&&a.updateAvailable){m(!0),p(""),v("");try{const k=await ke.runUpdate(a.latest);v(k.message||"Update installed. Restart your server (stop and run npm start again) to finish applying changes."),await N()}catch(k){p(k instanceof Error?k.message:"Update failed")}finally{m(!1)}}}return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Settings"}),c.jsx("p",{className:"text-muted-foreground",children:"Application updates and maintenance — config files are edited under each module in the sidebar."})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Dashboard appearance"}),c.jsx(Nt,{children:"Customise branding for all users, and pick an accent colour for this browser only."})]}),c.jsxs(qe,{className:"space-y-4",children:[c.jsx(aB,{canEdit:n}),c.jsxs("div",{className:"border-t border-border pt-4",children:[c.jsx("p",{className:"mb-3 text-sm font-medium",children:"Accent colour"}),c.jsx("p",{className:"mb-4 text-xs text-muted-foreground",children:"Buttons, links, and highlights — saved in this browser only."}),c.jsxs("div",{className:"flex flex-wrap items-end gap-4",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"accent-colour",children:"Accent colour"}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(cg,{value:x,onChange:k=>{S(k),Yx(k),C("Accent updated.")}}),c.jsx(rt,{id:"accent-colour",value:x,onChange:k=>S(k.target.value),onBlur:()=>{const k=lr(x,$l);S(k),Yx(k),C("Accent updated.")},className:"w-32 border-border bg-secondary/30 font-mono uppercase",maxLength:7})]})]}),c.jsx(be,{type:"button",variant:"outline",onClick:()=>{tB(),S($l),C("Reset to default purple.")},children:"Reset to default"})]}),c.jsxs("div",{className:"flex flex-wrap gap-2 text-sm",children:[c.jsx("span",{className:"rounded-md bg-primary px-3 py-1.5 font-medium text-primary-foreground",children:"Primary button"}),c.jsx("span",{className:"rounded-md bg-primary/15 px-3 py-1.5 text-primary",children:"Highlight"}),c.jsx("span",{className:"rounded-md bg-accent px-3 py-1.5 text-accent-foreground",children:"Accent surface"})]}),j?c.jsx("p",{className:"text-xs text-muted-foreground",children:j}):null]})]})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Software updates"}),c.jsxs(Nt,{children:["Checks"," ",c.jsx("a",{href:"https://github.com/C-h-a-r/SupportBot-Dashboard",target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"SupportBot-Dashboard"})," ","on the release branch."]})]}),c.jsxs(qe,{className:"space-y-4",children:[l?c.jsx(Fe,{className:"h-24 w-full"}):a?c.jsxs("div",{className:"space-y-3 rounded-lg border border-border bg-secondary/20 p-4",children:[c.jsxs("div",{className:"flex flex-wrap gap-x-6 gap-y-2 text-sm",children:[c.jsxs("p",{children:[c.jsx("span",{className:"text-muted-foreground",children:"Installed: "}),c.jsxs("span",{className:"font-mono font-medium",children:["v",a.current]})]}),c.jsxs("p",{children:[c.jsx("span",{className:"text-muted-foreground",children:"Latest: "}),c.jsxs("span",{className:"font-mono font-medium",children:["v",a.latest]})]})]}),a.updateAvailable?c.jsx("p",{className:"text-sm text-amber-500",children:"A newer version is available. Update downloads bot files while keeping your Configs and Data."}):c.jsx("p",{className:"text-sm text-emerald-500",children:"You are on the latest release."})]}):null,h?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:h})}):null,y?c.jsx(Ue,{children:c.jsx(He,{children:y})}):null,c.jsxs("div",{className:"flex flex-wrap gap-2",children:[c.jsxs(be,{type:"button",variant:"outline",onClick:N,disabled:l||d,children:[c.jsx(ye,{icon:Jl,size:16,className:"mr-2"}),"Check again"]}),a!=null&&a.updateAvailable&&n?c.jsxs(be,{type:"button",onClick:E,disabled:d,children:[d?c.jsx(ye,{icon:w0,size:16,className:"mr-2 animate-spin"}):c.jsx(ye,{icon:Ru,size:16,className:"mr-2"}),d?"Installing…":"Update now"]}):null,a!=null&&a.updateAvailable&&!n?c.jsx("p",{className:"text-xs text-muted-foreground",children:"You can check for updates but cannot install them with your role."}):null]})]})]})]})}function pt({label:e,value:n,mono:a=!1}){return c.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:[c.jsx("dt",{className:"text-sm text-muted-foreground",children:e}),c.jsx("dd",{className:`text-sm font-medium text-foreground ${a?"font-mono text-xs sm:text-sm":""}`,children:n})]})}const sB={ok:"Healthy",missing_config:"Guild ID not set",not_in_guild:"Not in configured server",extra_guilds:"Extra servers joined",offline:"Bot offline"};function lB(e){return e==="ok"?"text-emerald-500":e==="offline"?"text-destructive":"text-amber-500"}function iB(){var S;const{stats:e,loading:n,error:a,refresh:o}=Du(),[l,i]=f.useState(null),[d,m]=f.useState(null),[h,p]=f.useState(!1),y=f.useCallback(async()=>{const[j,C]=await Promise.all([ke.getGuildStatus().catch(()=>null),ke.health().catch(()=>null)]);j!=null&&j.data&&i(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(){p(!0);try{await Promise.all([o(),y()])}finally{p(!1)}}if(n&&!e)return c.jsxs("div",{className:"space-y-6",children:[c.jsx(Fe,{className:"h-10 w-64"}),c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsx(Fe,{className:"h-56 rounded-2xl"}),c.jsx(Fe,{className:"h-56 rounded-2xl"})]})]});if(a||!e)return c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:a||"Could not load system details."})});const x=e.bot.ping<200;return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(be,{asChild:!0,variant:"ghost",size:"sm",className:"-ml-2 h-8 px-2 text-muted-foreground",children:c.jsxs(kt,{to:"/",children:[c.jsx(ye,{icon:b0,size:16,className:"mr-1.5"}),"Back to dashboard"]})}),c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"System details"}),c.jsx("p",{className:"text-muted-foreground",children:"Live bot, host, and dashboard status — refreshed every 30 seconds."})]})]}),c.jsxs(be,{type:"button",variant:"outline",disabled:h,onClick:()=>void v(),children:[c.jsx(ye,{icon:Jl,size:16,className:"mr-2"}),h?"Refreshing…":"Refresh now"]})]}),c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Discord bot"}),c.jsx(Nt,{children:"Connection and identity"})]}),c.jsxs(qe,{children:[c.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[c.jsxs(gs,{className:"size-12",children:[c.jsx(vs,{src:e.bot.avatar,alt:e.bot.username}),c.jsx(bs,{children:"SB"})]}),c.jsxs("div",{children:[c.jsx("p",{className:"font-semibold",children:e.bot.username}),c.jsx("p",{className:"font-mono text-xs text-muted-foreground",children:e.bot.id})]})]}),c.jsxs("dl",{children:[c.jsx(pt,{label:"Version",value:`v${e.bot.version}`,mono:!0}),c.jsx(pt,{label:"Gateway latency",value:c.jsxs("span",{className:x?"text-emerald-500":"text-amber-500",children:[e.bot.ping," ms"]})}),c.jsx(pt,{label:"Process uptime",value:j0(e.bot.uptime)}),c.jsx(pt,{label:"Connected servers",value:e.servers.toLocaleString()}),c.jsx(pt,{label:"Members tracked",value:e.users.toLocaleString()}),e.bot.inviteUrl?c.jsx(pt,{label:"Invite link",value:c.jsx("a",{href:e.bot.inviteUrl,target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"Open in Discord"})}):null]})]})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Host machine"}),c.jsx(Nt,{children:"Server resources running this instance"})]}),c.jsx(qe,{children:c.jsxs("dl",{children:[c.jsx(pt,{label:"Memory used",value:`${e.hosting.ram_used} / ${e.hosting.ram_total}`}),c.jsx(pt,{label:"Memory usage",value:c.jsxs("span",{className:e.hosting.ram_percent>85?"text-amber-500":"text-foreground",children:[e.hosting.ram_percent,"%"]})}),c.jsx(pt,{label:"CPU load (1 min avg)",value:e.hosting.cpu_load,mono:!0}),c.jsx(pt,{label:"Host uptime",value:e.hosting.uptime})]})})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Tickets"}),c.jsx(Nt,{children:"Database snapshot"})]}),c.jsx(qe,{children:c.jsxs("dl",{children:[c.jsx(pt,{label:"Total tickets",value:e.tickets.total}),c.jsx(pt,{label:"Open",value:c.jsx("span",{className:"text-primary",children:e.tickets.open})}),c.jsx(pt,{label:"Closed",value:e.tickets.closed}),c.jsx(pt,{label:"Transcripts",value:c.jsx(kt,{to:"/transcripts",className:"text-primary underline-offset-4 hover:underline",children:"Browse archive"})})]})})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Guild health"}),c.jsx(Nt,{children:"Configured server and membership"})]}),c.jsx(qe,{children:l?c.jsxs("dl",{children:[c.jsx(pt,{label:"Status",value:c.jsx("span",{className:lB(l.status),children:sB[l.status]})}),c.jsx(pt,{label:"Configured guild ID",value:l.configuredGuildId||"Not set",mono:!0}),l.configuredGuild?c.jsx(pt,{label:"Configured server",value:`${l.configuredGuild.name} (${((S=l.configuredGuild.memberCount)==null?void 0:S.toLocaleString())??"?"} members)`}):null,l.message?c.jsx("div",{className:"mt-3 rounded-lg border border-border bg-secondary/30 px-3 py-2 text-sm text-muted-foreground",children:l.message}):null,l.extraGuilds.length>0?c.jsxs("div",{className:"mt-3 space-y-2",children:[c.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-muted-foreground",children:"Extra servers"}),c.jsx("ul",{className:"space-y-1 text-sm",children:l.extraGuilds.map(j=>c.jsxs("li",{className:"font-mono text-xs",children:[j.name," · ",j.id]},j.id))})]}):null]}):c.jsx(Fe,{className:"h-24 w-full"})})]})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Dashboard services"}),c.jsx(Nt,{children:"API and authentication"})]}),c.jsx(qe,{children:d?c.jsxs("dl",{className:"max-w-xl",children:[c.jsx(pt,{label:"Dashboard UI",value:d.dashboard?"Available":"Missing build"}),c.jsx(pt,{label:"Bot connection",value:d.botReady?"Online":"Starting or offline"}),c.jsx(pt,{label:"Discord OAuth",value:d.oauthEnabled?"Configured":"Not configured"}),c.jsx(pt,{label:"Initial setup",value:d.setupComplete?"Complete":"Incomplete"}),c.jsx(pt,{label:"Software updates",value:c.jsx(kt,{to:"/settings",className:"text-primary underline-offset-4 hover:underline",children:"Open settings"})}),c.jsx(pt,{label:"Logs",value:c.jsx(kt,{to:"/logs",className:"text-primary underline-offset-4 hover:underline",children:"View log files"})})]}):c.jsx(Fe,{className:"h-32 w-full max-w-xl"})})]}),e.modules?c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-lg",children:"Module setup status"}),c.jsx(Nt,{children:"Which features are configured and active"})]}),c.jsx(qe,{children:c.jsx("div",{className:"grid gap-3 sm:grid-cols-2",children:ls.map(j=>{const C=eh(j.id,e.modules);return c.jsxs(kt,{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:[c.jsxs("div",{className:"min-w-0",children:[c.jsx("p",{className:"text-sm font-medium",children:j.title}),c.jsx("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:C.subtitle})]}),c.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:h5[C.status]})]},j.id)})})})]}):null]})}function cB(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 uB=[{id:"all",label:"All"},{id:"Output",label:"Output"},{id:"Warn",label:"Warn"},{id:"Error",label:"Error"}],dB=["Output","Warn","Error"],fB={Output:"text-foreground/90",Warn:"text-amber-400",Error:"text-rose-400"},mB={Output:"bg-muted text-muted-foreground",Warn:"bg-amber-500/15 text-amber-400",Error:"bg-rose-500/15 text-rose-400"},Wx=2e3,pB=2e3;function th(e,n){return`${e.type}-${e.timestamp??"na"}-${n}-${e.message.slice(0,32)}`}function hB(e,n,a){const o=a?[]:e,l=new Set(o.map((m,h)=>th(m,h))),i=[];for(let m=0;mWx?d.slice(d.length-Wx):d}function gB(){const[e,n]=f.useState([]),[a,o]=f.useState(!0),[l,i]=f.useState(""),[d,m]=f.useState(!1),[h,p]=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),A=f.useRef(null),R=f.useRef(d);R.current=d;const L=f.useMemo(()=>y==="all"?dB:[y],[y]),z=f.useCallback(async q=>{var fe,de;const Z=await ke.getLogs({types:L,cursor:q?void 0:k.current??void 0,tail:q?500:0}),Q=((fe=Z.data)==null?void 0:fe.entries)??[];return k.current=((de=Z.data)==null?void 0:de.cursor)??{},n(ce=>hB(ce,Q,q)),Q.length},[L]),B=f.useCallback(async()=>{var q;o(!0),i(""),k.current=null;try{const fe=(((q=(await ke.getLogsMeta()).data)==null?void 0:q.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 z(!0),C(!0)}catch(Z){i(Z instanceof Error?Z.message:"Failed to load logs"),C(!1)}finally{o(!1)}},[z]);f.useEffect(()=>{B()},[B]),f.useEffect(()=>{if(d||a)return;const q=window.setInterval(async()=>{if(!R.current)try{await z(!1),C(!0),i("")}catch(Z){C(!1),i(Z instanceof Error?Z.message:"Live update failed")}},pB);return()=>window.clearInterval(q)},[d,a,z]),f.useEffect(()=>{if(!h||d)return;const q=A.current;q&&(q.scrollTop=q.scrollHeight)},[e,h,d]);const U=f.useMemo(()=>e.filter(q=>{var Q;if(y!=="all"&&q.type!==y)return!1;if(!x.trim())return!0;const Z=x.toLowerCase();return q.message.toLowerCase().includes(Z)||(((Q=q.timestamp)==null?void 0:Q.toLowerCase().includes(Z))??!1)}),[e,y,x]);return c.jsxs("div",{className:"flex h-[calc(100svh-8rem)] min-h-[480px] flex-col gap-4",children:[c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Logs"}),c.jsx("p",{className:"text-muted-foreground",children:"Live bot output — updates every 2 seconds"}),N?c.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:N}):null]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:ie("size-2 rounded-full",j&&!d?"animate-pulse bg-emerald-500":"bg-muted-foreground")}),c.jsx("span",{className:"text-xs text-muted-foreground",children:d?"Paused":j?"Live":"Disconnected"})]})]}),l?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:l})}):null,c.jsxs(We,{className:"flex min-h-0 flex-1 flex-col border-border bg-card",children:[c.jsxs(at,{className:"shrink-0 space-y-4 border-b border-border pb-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[c.jsxs(ot,{className:"text-base font-medium",children:["Console",a?null:c.jsxs("span",{className:"ml-2 text-xs font-normal text-muted-foreground",children:[U.length," line",U.length===1?"":"s"]})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-border px-2 py-1",children:[c.jsx(Dn,{id:"auto-scroll",checked:h,onCheckedChange:p}),c.jsx(Ze,{htmlFor:"auto-scroll",className:"text-xs font-normal",children:"Auto-scroll"})]}),c.jsxs(be,{type:"button",variant:"outline",size:"sm",onClick:()=>m(q=>!q),children:[c.jsx(ye,{icon:d?A4:R4,size:16,className:"mr-1.5"}),d?"Resume":"Pause"]}),c.jsxs(be,{type:"button",variant:"outline",size:"sm",onClick:()=>{n([]),B()},disabled:a,children:[c.jsx(ye,{icon:Jl,size:16,className:"mr-1.5"}),"Refresh"]})]})]}),c.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center",children:[c.jsx("div",{className:"flex flex-wrap gap-1 rounded-xl bg-secondary/50 p-1",children:uB.map(q=>c.jsx(be,{type:"button",variant:y===q.id?"secondary":"ghost",size:"sm",className:"h-8 rounded-lg text-xs",onClick:()=>v(q.id),children:q.label},q.id))}),c.jsxs("div",{className:"relative flex-1 sm:max-w-xs",children:[c.jsx(ye,{icon:_u,size:16,className:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(rt,{placeholder:"Filter lines…",value:x,onChange:q=>S(q.target.value),className:"h-9 pl-9"})]})]})]}),c.jsx(qe,{className:"min-h-0 flex-1 p-0",children:a?c.jsx("div",{className:"space-y-2 p-4",children:Array.from({length:8}).map((q,Z)=>c.jsx(Fe,{className:"h-4 w-full"},Z))}):c.jsx("div",{ref:A,className:"h-full max-h-[calc(100svh-18rem)] overflow-y-auto bg-[#0d0d12] p-4 font-mono text-[13px] leading-relaxed",children:U.length===0?c.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)."}):c.jsx("ul",{className:"space-y-1",children:U.map((q,Z)=>c.jsxs("li",{className:"flex gap-2 rounded px-1 py-0.5 hover:bg-white/[0.03]",children:[c.jsx("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:cB(q.timestamp)}),c.jsx("span",{className:ie("shrink-0 rounded px-1.5 py-0 text-[10px] font-semibold uppercase",mB[q.type]),children:q.type}),c.jsx("span",{className:ie("min-w-0 flex-1 whitespace-pre-wrap break-words",fB[q.type]),children:q.message||" "})]},th(q,Z)))})})})]})]})}const vB=[{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; }"}]}],bB=450;function yB(e,n){return n&&e!=="viewer"}function xB(){const{user:e,hasPermission:n}=Ft(),a=!yB(e==null?void 0:e.role,n("transcripts")),[o,l]=f.useState(null),[i,d]=f.useState(null),[m,h]=f.useState(!0),[p,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState(""),[E,k]=f.useState(!1),A=f.useRef(null),R=f.useCallback(async()=>{var q;h(!0),x(""),j("");try{const Q=(await ke.getTranscriptTemplate()).data??null;if(Q){const fe={...Q,Typography:{...Q.Typography,FontFamily:Mj((q=Q.Typography)==null?void 0:q.FontFamily)}};l(fe),d(structuredClone(fe))}}catch(Z){x(Z instanceof Error?Z.message:"Failed to load template")}finally{h(!1)}},[]);f.useEffect(()=>{R()},[R]);const L=f.useCallback(async q=>{k(!0);try{const Z=await ke.previewTranscriptTemplate(q);N(Z)}catch{N("

Preview failed to load.

")}finally{k(!1)}},[]);f.useEffect(()=>{if(o)return A.current&&clearTimeout(A.current),A.current=setTimeout(()=>{L(o)},bB),()=>{A.current&&clearTimeout(A.current)}},[o,L]);function z(q,Z){l(Q=>Q&&Xl(Q,q,Z))}async function B(){if(!(a||!o)){y(!0),x(""),j("");try{const q=await ke.saveTranscriptTemplate(o);j(q.message||"Saved."),d(structuredClone(o))}catch(q){x(q instanceof Error?q.message:"Save failed")}finally{y(!1)}}}const U=o&&i&&JSON.stringify(o)!==JSON.stringify(i);return m?c.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[c.jsx(Fe,{className:"h-96 rounded-xl"}),c.jsx(Fe,{className:"h-96 rounded-xl"})]}):o?c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[c.jsx("p",{className:"text-sm text-muted-foreground",children:"Customize how new ticket transcripts look. Existing saved transcripts are not changed."}),c.jsxs("div",{className:"flex items-center gap-2",children:[U?c.jsx("span",{className:"text-xs text-amber-500",children:"Unsaved changes"}):null,a?c.jsx("span",{className:"text-xs text-muted-foreground",children:"View only"}):c.jsxs(be,{size:"sm",onClick:B,disabled:p||!U,children:[c.jsx(ye,{icon:Au,size:16,className:"mr-1.5"}),p?"Saving…":"Save appearance"]})]})]}),v?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v})}):null,S?c.jsx(Ue,{className:"border-primary/30 bg-primary/10 text-primary",children:c.jsx(He,{children:S})}):null,c.jsxs("div",{className:"grid min-h-0 gap-4 xl:grid-cols-[minmax(320px,420px)_1fr]",children:[c.jsx(SB,{data:o,readOnly:a,onPatch:z}),c.jsxs(We,{className:"flex min-h-[520px] flex-col overflow-hidden border-border bg-card",children:[c.jsxs(at,{className:"pb-2",children:[c.jsx(ot,{className:"text-base",children:"Live preview"}),c.jsxs(Nt,{children:["Sample ticket with your current settings",E?" · updating…":""]})]}),c.jsx(qe,{className:"min-h-0 flex-1 p-4 pt-0",children:c.jsx("iframe",{title:"Transcript template preview",srcDoc:C,className:ie("h-[min(640px,calc(100svh-14rem))] w-full rounded-lg border border-border bg-background",E&&"opacity-60"),sandbox:"allow-same-origin"})})]})]})]}):c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v||"Failed to load template"})})}function SB({data:e,readOnly:n,onPatch:a}){return c.jsx("div",{className:"max-h-[min(720px,calc(100svh-12rem))] space-y-4 overflow-y-auto pr-1",children:vB.map(o=>c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"pb-3",children:[c.jsx(ot,{className:"text-base",children:o.title}),o.description?c.jsx(Nt,{children:o.description}):null]}),c.jsx(qe,{className:"grid gap-4 sm:grid-cols-2",children:o.fields.map(l=>c.jsx("div",{className:l.type==="textarea"?"sm:col-span-2":"",children:c.jsx(yg,{field:l,value:ao(e,l.path),readOnly:n,onChange:i=>a(l.path,i)})},l.path))})]},o.title))})}function wB(e,n){return n&&e!=="viewer"}function CB(){const{user:e,hasPermission:n}=Ft(),a=!wB(e==null?void 0:e.role,n("transcripts")),[o,l]=f.useState(null),[i,d]=f.useState(!0),[m,h]=f.useState(!1),[p,y]=f.useState(!1),[v,x]=f.useState(""),[S,j]=f.useState(""),C=f.useCallback(async()=>{var k,A,R;d(!0),x(""),j("");try{const z=(await ke.getTranscriptSettings()).data;z&&l({autoDelete:{enabled:!!((k=z.autoDelete)!=null&&k.enabled),afterDays:((A=z.autoDelete)==null?void 0:A.afterDays)??30},publicAccess:{enabled:!!((R=z.publicAccess)!=null&&R.enabled)}})}catch(L){x(L instanceof Error?L.message:"Failed to load settings")}finally{d(!1)}},[]);f.useEffect(()=>{C()},[C]);async function N(){if(!(!o||a)){h(!0),x(""),j("");try{const k=await ke.updateTranscriptSettings(o);k.data&&l({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{h(!1)}}}async function E(){var k,A;if(!a){y(!0),x(""),j("");try{const R=await ke.purgeTranscripts();j(R.message??((k=R.data)!=null&&k.skipped?"Auto-delete is disabled.":`Removed ${((A=R.data)==null?void 0:A.deleted)??0} transcript(s).`))}catch(R){x(R instanceof Error?R.message:"Purge failed")}finally{y(!1)}}}return i?c.jsxs("div",{className:"space-y-4",children:[c.jsx(Fe,{className:"h-40 w-full rounded-xl"}),c.jsx(Fe,{className:"h-40 w-full rounded-xl"})]}):o?c.jsxs("div",{className:"mx-auto max-w-2xl space-y-4",children:[a?c.jsx(Ue,{children:c.jsx(He,{children:"You have view-only access. An admin or editor can change these settings."})}):null,v?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v})}):null,S?c.jsx(Ue,{children:c.jsx(He,{children:S})}):null,c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-base",children:"Auto-delete"}),c.jsx(Nt,{children:"Remove transcript files automatically after they reach a certain age. The server checks hourly and whenever you open the library."})]}),c.jsxs(qe,{className:"space-y-4",children:[c.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[c.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.autoDelete.enabled,disabled:a,onChange:k=>l(A=>A&&{...A,autoDelete:{...A.autoDelete,enabled:k.target.checked}})}),c.jsxs("span",{className:"text-sm",children:[c.jsx("span",{className:"font-medium",children:"Enable auto-delete"}),c.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Deletes HTML files in Data/Transcripts based on last modified time."})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("label",{className:"text-sm font-medium",htmlFor:"transcript-after-days",children:"Delete after (days)"}),c.jsx(rt,{id:"transcript-after-days",type:"number",min:1,max:3650,disabled:a||!o.autoDelete.enabled,value:o.autoDelete.afterDays,onChange:k=>l(A=>A&&{...A,autoDelete:{...A.autoDelete,afterDays:Math.min(3650,Math.max(1,parseInt(k.target.value,10)||1))}}),className:"max-w-[8rem]"})]}),c.jsxs(be,{type:"button",variant:"outline",size:"sm",disabled:a||p,onClick:()=>void E(),children:[c.jsx(ye,{icon:Jl,size:16,className:ie(p&&"animate-spin")}),"Run cleanup now"]})]})]}),c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-base",children:"Public transcripts"}),c.jsxs(Nt,{children:["When enabled, anyone with the link can view a transcript at"," ",c.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."]})]}),c.jsx(qe,{children:c.jsxs("label",{className:"flex cursor-pointer items-start gap-3",children:[c.jsx("input",{type:"checkbox",className:"mt-1 size-4 rounded border-border accent-primary",checked:o.publicAccess.enabled,disabled:a,onChange:k=>l(A=>A&&{...A,publicAccess:{enabled:k.target.checked}})}),c.jsxs("span",{className:"text-sm",children:[c.jsx("span",{className:"font-medium",children:"Allow public transcript URLs"}),c.jsx("span",{className:"mt-0.5 block text-muted-foreground",children:"Dashboard preview and download still require login."})]})]})})]}),a?null:c.jsxs(be,{type:"button",disabled:m,onClick:()=>void N(),children:[c.jsx(ye,{icon:Au,size:16}),m?"Saving…":"Save settings"]})]}):c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:"Could not load transcript settings."})})}function jB(e,n){return n&&e!=="viewer"}function qx(e){return e==null?"":e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Kx(e){const n=new Date(e);return Number.isNaN(n.getTime())?e:n.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}function EB(){var H;const{user:e,hasPermission:n}=Ft(),a=jB(e==null?void 0:e.role,n("transcripts")),[o,l]=f.useState("browse"),[i,d]=f.useState([]),[m,h]=f.useState(null),[p,y]=f.useState(!0),[v,x]=f.useState(""),[S,j]=f.useState(""),[C,N]=f.useState(""),[E,k]=f.useState(0),[A,R]=f.useState(!1),[L,z]=f.useState(!1),[B,U]=f.useState(!1),[q,Z]=f.useState(!1),Q=f.useCallback(async()=>{y(!0),j("");try{const V=(await ke.listTranscripts()).data??[];d(V),h(ne=>{var J;return ne&&V.some(me=>me.id===ne)?ne:((J=V[0])==null?void 0:J.id)??null})}catch(I){j(I instanceof Error?I.message:"Failed to load transcripts")}finally{y(!1)}},[]);f.useEffect(()=>{Q()},[Q]),f.useEffect(()=>{o==="browse"&&ke.getTranscriptSettings().then(I=>{var V,ne;U(!!((ne=(V=I.data)==null?void 0:V.publicAccess)!=null&&ne.enabled))}).catch(()=>U(!1))},[o]);const fe=f.useMemo(()=>{if(!C.trim())return i;const I=C.toLowerCase();return i.filter(V=>V.id.includes(I)||V.filename.toLowerCase().includes(I)||V.ticketName&&V.ticketName.toLowerCase().includes(I))},[i,C]),de=f.useMemo(()=>i.find(I=>I.id===m)??null,[i,m]),ce=m?`/api/system/transcripts/${encodeURIComponent(m)}/view`:null,he=m?`/api/system/transcripts/${encodeURIComponent(m)}/download`:null,M=m&&B?`${window.location.origin}/transcripts/${encodeURIComponent(m)}`:null;function K(I){x(""),h(I),k(V=>V+1)}function re(){ce&&window.open(ce,"_blank","noopener,noreferrer")}function oe(){M&&window.open(M,"_blank","noopener,noreferrer")}async function ee(){if(M)try{await navigator.clipboard.writeText(M),Z(!0),window.setTimeout(()=>Z(!1),2e3)}catch{x("Could not copy link to clipboard.")}}async function _(){var V;if(!m||!a)return;const I=((V=de==null?void 0:de.ticketName)==null?void 0:V.trim())||`channel ${m}`;if(window.confirm(`Delete the transcript for ${I}? This cannot be undone.`)){z(!0),x("");try{await ke.deleteTranscript(m),await Q()}catch(ne){x(ne instanceof Error?ne.message:"Failed to delete transcript")}finally{z(!1)}}}async function O(){if(!(!he||!de)){R(!0),x("");try{const I=await fetch(he,{credentials:"include"});if(!I.ok){const me=await I.json().catch(()=>({}));throw new Error(me.error||`Download failed (${I.status})`)}const V=await I.blob(),ne=URL.createObjectURL(V),J=document.createElement("a");J.href=ne,J.download=de.filename,J.click(),URL.revokeObjectURL(ne)}catch(I){x(I instanceof Error?I.message:"Failed to download transcript")}finally{R(!1)}}}return c.jsxs("div",{className:"flex min-h-0 flex-1 flex-col gap-4",children:[c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-semibold tracking-tight",children:"Transcripts"}),c.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Browse saved transcripts or customize how new ones look when tickets close."})]}),c.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[c.jsxs("div",{className:"flex rounded-lg border border-border p-0.5",children:[c.jsx(be,{type:"button",variant:o==="browse"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>l("browse"),children:"Library"}),c.jsx(be,{type:"button",variant:o==="appearance"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>l("appearance"),children:"Appearance"}),c.jsx(be,{type:"button",variant:o==="settings"?"secondary":"ghost",size:"sm",className:"h-8",onClick:()=>l("settings"),children:"Settings"})]}),o==="browse"?c.jsxs(be,{variant:"outline",size:"sm",onClick:()=>Q(),disabled:p,children:[c.jsx(ye,{icon:Jl,size:16,className:ie(p&&"animate-spin")}),"Refresh"]}):null]})]}),o==="appearance"?c.jsx(xB,{}):o==="settings"?c.jsx(CB,{}):c.jsxs(c.Fragment,{children:[S?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:S})}):null,c.jsxs("div",{className:"grid min-h-0 flex-1 gap-4 lg:grid-cols-[minmax(240px,320px)_1fr]",children:[c.jsxs(We,{className:"flex min-h-[420px] flex-col border-border bg-card",children:[c.jsxs(at,{className:"space-y-3 pb-3",children:[c.jsxs(ot,{className:"text-base font-medium",children:["Saved transcripts",!p&&i.length>0?c.jsxs("span",{className:"ml-2 font-normal text-muted-foreground",children:["(",i.length,")"]}):null]}),c.jsxs("div",{className:"relative",children:[c.jsx(ye,{icon:_u,size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),c.jsx(rt,{placeholder:"Search by ticket name or channel ID…",value:C,onChange:I=>N(I.target.value),className:"pl-9"})]})]}),c.jsx(qe,{className:"min-h-0 flex-1 p-0 pb-4",children:c.jsx(hi,{className:"h-[min(520px,calc(100svh-16rem))] px-4",children:p?c.jsx("div",{className:"space-y-2",children:Array.from({length:6}).map((I,V)=>c.jsx(Fe,{className:"h-16 w-full rounded-lg"},V))}):fe.length===0?c.jsxs("div",{className:"flex flex-col items-center justify-center gap-2 py-12 text-center text-sm text-muted-foreground",children:[c.jsx(ye,{icon:Ul,size:32,className:"opacity-40"}),c.jsx("p",{children:i.length===0?"No transcripts yet. They appear when tickets are closed.":"No transcripts match your search."})]}):c.jsx("ul",{className:"space-y-1.5",children:fe.map(I=>{var J;const V=I.id===m,ne=((J=I.ticketName)==null?void 0:J.trim())||`Channel ${I.id}`;return c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>K(I.id),className:ie("w-full rounded-lg border px-3 py-2.5 text-left transition-colors",V?"border-primary/50 bg-primary/10":"border-transparent bg-secondary/30 hover:bg-secondary/50"),children:[c.jsx("p",{className:"truncate text-sm font-medium",children:ne}),c.jsxs("p",{className:"mt-0.5 text-xs text-muted-foreground",children:[Kx(I.createdAt),I.size!=null?` · ${qx(I.size)}`:""]})]})},I.id)})})})})]}),c.jsxs(We,{className:"flex min-h-[420px] flex-col overflow-hidden border-border bg-card",children:[c.jsxs(at,{className:"flex flex-row flex-wrap items-center justify-between gap-2 space-y-0 pb-3",children:[c.jsxs("div",{className:"min-w-0",children:[c.jsx(ot,{className:"truncate text-base font-medium",children:de?((H=de.ticketName)==null?void 0:H.trim())||`Channel ${de.id}`:"Preview"}),de?c.jsxs("p",{className:"mt-0.5 truncate text-xs text-muted-foreground",children:[Kx(de.createdAt),de.size!=null?` · ${qx(de.size)}`:""]}):null]}),c.jsxs("div",{className:"flex shrink-0 flex-wrap gap-2",children:[M?c.jsxs(c.Fragment,{children:[c.jsxs(be,{variant:"outline",size:"sm",onClick:()=>void ee(),children:[c.jsx(ye,{icon:x0,size:16}),q?"Copied":"Copy link"]}),c.jsxs(be,{variant:"outline",size:"sm",onClick:oe,children:[c.jsx(ye,{icon:gh,size:16}),"Public page"]})]}):null,c.jsxs(be,{variant:"outline",size:"sm",disabled:!ce,onClick:re,children:[c.jsx(ye,{icon:S4,size:16}),"Open tab"]}),c.jsxs(be,{variant:"outline",size:"sm",disabled:!he||A,onClick:()=>void O(),children:[c.jsx(ye,{icon:Ru,size:16}),A?"Saving…":"Download"]}),a?c.jsxs(be,{variant:"outline",size:"sm",disabled:!m||L,className:"text-destructive hover:text-destructive",onClick:()=>void _(),children:[c.jsx(ye,{icon:hh,size:16}),L?"Deleting…":"Delete"]}):null]})]}),c.jsxs(qe,{className:"flex min-h-0 flex-1 flex-col gap-2 p-4 pt-0",children:[v?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:v})}):null,de&&ce?c.jsx("iframe",{title:`Transcript ${de.id}`,src:ce,className:"min-h-[min(560px,calc(100svh-18rem))] w-full flex-1 rounded-lg border border-border bg-background",sandbox:"allow-same-origin"},E):c.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:[c.jsx(ye,{icon:Ul,size:40,className:"opacity-30"}),c.jsx("p",{children:"Select a transcript from the list to preview it here."})]})]})]})]})]})]})}const NB=["admin","moderator","editor","viewer","custom"];function kB(){return{mode:"add",id:"",username:"",globalName:"",role:"viewer",enabled:!0,permissions:Hl("viewer"),yamlOwner:!1}}function TB({permissions:e,onChange:n,disabled:a}){const o=l=>n({...e,...l});return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[[["Dashboard overview","overview"],["Logs","logs"],["Transcripts","transcripts"]].map(([l,i])=>c.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:l}),c.jsx(Dn,{checked:e[i],disabled:a,onCheckedChange:d=>o({[i]:d})})]},i)),c.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:"Settings — view"}),c.jsx(Dn,{checked:e.settings.view,disabled:a,onCheckedChange:l=>o({settings:{...e.settings,view:l}})})]}),c.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:"Settings — install updates"}),c.jsx(Dn,{checked:e.settings.update,disabled:a,onCheckedChange:l=>o({settings:{...e.settings,update:l}})})]}),c.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:"Users — view"}),c.jsx(Dn,{checked:e.users.view,disabled:a,onCheckedChange:l=>o({users:{...e.users,view:l}})})]}),c.jsxs("label",{className:"flex items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:"Users — manage"}),c.jsx(Dn,{checked:e.users.manage,disabled:a,onCheckedChange:l=>o({users:{...e.users,manage:l}})})]})]}),c.jsxs("div",{className:"space-y-3",children:[c.jsx("p",{className:"text-sm font-medium",children:"Configuration files"}),c.jsx("div",{className:"space-y-2",children:xh.map(l=>c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:z4[l]}),c.jsxs("div",{className:"flex items-center gap-4",children:[c.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:["View",c.jsx(Dn,{checked:e.configs[l].view,disabled:a,onCheckedChange:i=>n({...e,configs:{...e.configs,[l]:{...e.configs[l],view:i}}})})]}),c.jsxs("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:["Edit",c.jsx(Dn,{checked:e.configs[l].edit,disabled:a,onCheckedChange:i=>n({...e,configs:{...e.configs,[l]:{...e.configs[l],edit:i,view:i?!0:e.configs[l].view}}})})]})]})]},l))})]})]})}function RB(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 AB(){const{user:e,hasPermission:n}=Ft(),a=n("users.manage"),[o,l]=f.useState([]),[i,d]=f.useState(!0),[m,h]=f.useState(""),[p,y]=f.useState(null),[v,x]=f.useState(!1),S=f.useCallback(async()=>{d(!0),h("");try{const R=await ke.listDashboardUsers();R.data&&l(R.data.users)}catch(R){h(R instanceof Error?R.message:"Failed to load users")}finally{d(!1)}},[]);f.useEffect(()=>{S()},[S]);const j=f.useMemo(()=>[...o].sort((R,L)=>R.yamlOwner!==L.yamlOwner?R.yamlOwner?-1:1:(R.username||R.id).localeCompare(L.username||L.id)),[o]);function C(){y(kB())}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:Hl(R.role),yamlOwner:R.yamlOwner})}function E(R){p&&y({...p,role:R,permissions:Hl(R,p.permissions)})}async function k(){if(!(!p||!a)){x(!0),h("");try{p.mode==="add"?await ke.addDashboardUser({id:p.id.trim(),role:p.role,username:p.username||void 0,globalName:p.globalName||void 0,enabled:p.enabled,permissions:p.role==="custom"?p.permissions:void 0}):await ke.updateDashboardUser(p.id,{role:p.yamlOwner?void 0:p.role,enabled:p.enabled,username:p.username||void 0,globalName:p.globalName||void 0,permissions:p.role==="custom"?p.permissions:void 0}),y(null),await S()}catch(R){h(R instanceof Error?R.message:"Could not save user")}finally{x(!1)}}}async function A(R){if(a&&window.confirm("Remove this user from the dashboard?")){h("");try{await ke.removeDashboardUser(R),await S()}catch(L){h(L instanceof Error?L.message:"Could not remove user")}}}return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Users"}),c.jsxs("p",{className:"text-muted-foreground",children:["Control who can sign in and what they can view or edit. Owners in"," ",c.jsx("code",{className:"rounded bg-primary/10 px-1 text-xs text-primary",children:"api.yml"})," ","always have full access."]})]}),a?c.jsxs(be,{onClick:C,children:[c.jsx(ye,{icon:x4,size:16,className:"mr-2"}),"Add user"]}):null]}),m?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:m})}):null,c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{children:[c.jsx(ot,{className:"text-base",children:"Dashboard access"}),c.jsxs(Nt,{children:[j.length," user",j.length===1?"":"s",a?" — use edit to change permissions":""]})]}),c.jsx(qe,{children:i?c.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading users…"}):c.jsx("div",{className:"divide-y divide-border/60",children:j.map(R=>c.jsxs("div",{className:"flex flex-wrap items-center gap-4 py-4 first:pt-0 last:pb-0",children:[c.jsxs("div",{className:"flex min-w-[200px] flex-1 items-center gap-3",children:[c.jsxs(gs,{className:"size-9",children:[c.jsx(vs,{src:R.avatar,alt:R.username}),c.jsx(bs,{children:(R.username||R.id).slice(0,2).toUpperCase()})]}),c.jsxs("div",{className:"min-w-0",children:[c.jsxs("p",{className:"truncate font-medium",children:[E0(R),R.id===(e==null?void 0:e.id)?" (you)":""]}),c.jsx("p",{className:"truncate text-xs text-muted-foreground",children:R.id})]})]}),c.jsx(Ll,{variant:"secondary",children:M1[R.yamlOwner?"owner":R.role]}),c.jsx("p",{className:"max-w-[200px] text-xs text-muted-foreground",children:RB(R)}),R.enabled?c.jsx(Ll,{className:"bg-emerald-500/15 text-emerald-400 hover:bg-emerald-500/15",children:"Active"}):c.jsx(Ll,{variant:"outline",children:"Disabled"}),a?c.jsxs("div",{className:"ml-auto flex gap-1",children:[c.jsx(be,{variant:"ghost",size:"icon",onClick:()=>N(R),"aria-label":"Edit user",children:c.jsx(ye,{icon:C4,size:16})}),R.yamlOwner?null:c.jsx(be,{variant:"ghost",size:"icon",className:"text-destructive",onClick:()=>A(R.id),"aria-label":"Remove user",children:c.jsx(ye,{icon:hh,size:16})})]}):null]},R.id))})})]}),c.jsx($w,{open:!!p,onOpenChange:R=>!R&&y(null),children:c.jsxs(Zh,{className:"max-h-[90vh] max-w-lg overflow-y-auto",children:[c.jsxs(Qh,{children:[c.jsx(Jh,{children:(p==null?void 0:p.mode)==="add"?"Add dashboard user":"Edit user"}),c.jsx(eg,{children:p!=null&&p.yamlOwner?"This user is an owner in api.yml. Role and removal are managed in the config file.":L4[(p==null?void 0:p.role)??"viewer"]})]}),p?c.jsxs("div",{className:"space-y-4",children:[p.mode==="add"?c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{htmlFor:"discord-id",children:"Discord user ID"}),c.jsx(rt,{id:"discord-id",value:p.id,onChange:R=>y({...p,id:R.target.value}),placeholder:"829112572816130058"})]}):null,c.jsxs("div",{className:"grid gap-3 sm:grid-cols-2",children:[c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{children:"Display name (optional)"}),c.jsx(rt,{value:p.globalName,onChange:R=>y({...p,globalName:R.target.value})})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{children:"Username (optional)"}),c.jsx(rt,{value:p.username,onChange:R=>y({...p,username:R.target.value})})]})]}),c.jsxs("div",{className:"space-y-2",children:[c.jsx(Ze,{children:"Role"}),c.jsxs(ud,{value:p.role,disabled:p.yamlOwner,onValueChange:R=>E(R),children:[c.jsx(gi,{children:c.jsx(dd,{})}),c.jsx(vi,{children:p.yamlOwner?c.jsx(no,{value:"owner",children:"Owner"}):NB.map(R=>c.jsx(no,{value:R,children:M1[R]},R))})]})]}),c.jsxs("label",{className:"flex items-center justify-between rounded-lg border border-border px-3 py-2",children:[c.jsx("span",{className:"text-sm",children:"Account enabled"}),c.jsx(Dn,{checked:p.enabled,disabled:p.yamlOwner,onCheckedChange:R=>y({...p,enabled:R})})]}),p.role==="custom"&&!p.yamlOwner?c.jsx(TB,{permissions:p.permissions,onChange:R=>y({...p,permissions:R})}):null]}):null,c.jsxs(Uw,{children:[c.jsx(be,{variant:"outline",onClick:()=>y(null),children:"Cancel"}),c.jsx(be,{disabled:v||!a||(p==null?void 0:p.mode)==="add"&&!/^\d{17,20}$/.test(p.id.trim()),onClick:()=>void k(),children:v?"Saving…":"Save"})]})]})})]})}function _B(){const{hasPermission:e}=Ft(),n=e("settings.update"),a=oo(),[o,l]=f.useState([]),[i,d]=f.useState(""),[m,h]=f.useState(!0),[p,y]=f.useState(""),[v,x]=f.useState(""),[S,j]=f.useState(null),C=f.useCallback(async()=>{h(!0),y("");try{const E=await ke.getAddonsCatalog();E.data&&(l(E.data.addons),d(E.data.repository))}catch(E){y(E instanceof Error?E.message:"Failed to load addons")}finally{h(!1)}},[]);f.useEffect(()=>{C()},[C]);async function N(E){if(n){j(E.id),x(""),y("");try{const k=await ke.installAddon(E.id);x(k.message||`${E.name} installed.`),await C();const A=E.configFiles[0];A&&a(`/configs?file=${is(A)}`)}catch(k){y(k instanceof Error?k.message:"Install failed")}finally{j(null)}}}return c.jsxs("div",{className:"space-y-6",children:[c.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[c.jsxs("div",{children:[c.jsx("h1",{className:"text-2xl font-bold tracking-tight",children:"Addons"}),c.jsxs("p",{className:"text-muted-foreground",children:["Install community addons from"," ",c.jsx("a",{href:i||"https://github.com/Emerald-Services/Addons",target:"_blank",rel:"noreferrer",className:"text-primary underline-offset-4 hover:underline",children:"Emerald-Services/Addons"}),". Enable addons under"," ",c.jsx(kt,{to:"/configs?file=supportbot",className:"text-primary underline-offset-4 hover:underline",children:"Bot config → General → Addons"}),". Installed addon configs appear in the left sidebar under"," ",c.jsx("strong",{className:"font-medium text-foreground",children:"Addons"}),"."]})]}),c.jsxs(be,{variant:"outline",size:"sm",onClick:C,disabled:m,children:[c.jsx(ye,{icon:w0,size:16,className:ie("mr-1.5",m&&"animate-spin")}),"Refresh"]})]}),p?c.jsx(Ue,{variant:"destructive",children:c.jsx(He,{children:p})}):null,v?c.jsx(Ue,{className:"border-primary/30 bg-primary/10 text-primary",children:c.jsx(He,{children:v})}):null,c.jsxs("section",{className:"space-y-4",children:[c.jsx("h2",{className:"text-sm font-semibold uppercase tracking-widest text-muted-foreground",children:"Marketplace"}),m?c.jsxs("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:[c.jsx(Fe,{className:"h-40 rounded-xl"}),c.jsx(Fe,{className:"h-40 rounded-xl"}),c.jsx(Fe,{className:"h-40 rounded-xl"})]}):c.jsx("div",{className:"grid gap-4 sm:grid-cols-2 lg:grid-cols-3",children:o.map(E=>c.jsxs(We,{className:"border-border bg-card",children:[c.jsxs(at,{className:"pb-2",children:[c.jsxs("div",{className:"flex items-start justify-between gap-2",children:[c.jsxs(ot,{className:"flex items-center gap-2 text-lg",children:[c.jsx(ye,{icon:bh,size:20,className:"text-primary"}),E.name]}),E.installed?c.jsxs(Ll,{variant:"secondary",className:"shrink-0 gap-1",children:[c.jsx(ye,{icon:O4,size:14}),"Installed"]}):null]}),c.jsx(Nt,{children:E.description})]}),c.jsxs(qe,{className:"space-y-2 text-xs text-muted-foreground",children:[c.jsxs("p",{children:[E.jsFiles.length," command file",E.jsFiles.length===1?"":"s",":"," ",c.jsx("span",{className:"font-mono",children:E.jsFiles.join(", ")})]}),E.configFiles.length>0?c.jsxs("p",{children:["Config:"," ",E.configFiles.map((k,A)=>c.jsxs("span",{children:[A>0?", ":null,c.jsx(kt,{to:`/configs?file=${is(k)}`,className:"font-mono text-primary hover:underline",children:k})]},k))]}):null]}),c.jsxs(p5,{className:"flex flex-wrap gap-2",children:[c.jsx(be,{variant:"outline",size:"sm",asChild:!0,children:c.jsx("a",{href:E.repositoryUrl,target:"_blank",rel:"noreferrer",children:"View on GitHub"})}),E.installed&&E.configFiles[0]?c.jsx(be,{size:"sm",variant:"secondary",asChild:!0,children:c.jsx(kt,{to:`/configs?file=${is(E.configFiles[0])}`,children:"Edit config"})}):null,E.installed?c.jsx(be,{size:"sm",disabled:!0,variant:"secondary",children:"Installed"}):c.jsxs(be,{size:"sm",disabled:!n||S===E.id,onClick:()=>N(E),children:[c.jsx(ye,{icon:Ru,size:14,className:"mr-1"}),S===E.id?"Installing…":"Install"]})]})]},E.id))})]})]})}function MB({children:e}){const{isAuthenticated:n,loading:a}=Ft();return a?c.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):n?c.jsx(c.Fragment,{children:e}):c.jsx(Mr,{to:"/login",replace:!0})}function OB(){const{complete:e,loading:n}=yC(),a=Sn();return n?c.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background text-sm text-muted-foreground",children:"Loading…"}):e?a.pathname==="/setup"?c.jsx(Mr,{to:"/login",replace:!0}):c.jsxs(A1,{children:[c.jsx(ln,{path:"/login",element:c.jsx(TP,{})}),c.jsxs(ln,{element:c.jsx(MB,{children:c.jsx(XM,{})}),children:[c.jsx(ln,{index:!0,element:c.jsx(ZP,{})}),c.jsx(ln,{path:"system",element:c.jsx(as,{permission:"overview",children:c.jsx(iB,{})})}),c.jsx(ln,{path:"settings",element:c.jsx(as,{permission:"settings.view",children:c.jsx(oB,{})})}),c.jsx(ln,{path:"configs",element:c.jsx(EP,{})}),c.jsx(ln,{path:"logs",element:c.jsx(as,{permission:"logs",children:c.jsx(gB,{})})}),c.jsx(ln,{path:"transcripts",element:c.jsx(as,{permission:"transcripts",children:c.jsx(EB,{})})}),c.jsx(ln,{path:"users",element:c.jsx(as,{permission:"users.view",children:c.jsx(AB,{})})}),c.jsx(ln,{path:"addons",element:c.jsx(as,{permission:"settings.view",children:c.jsx(_B,{})})})]}),c.jsx(ln,{path:"*",element:c.jsx(Mr,{to:"/",replace:!0})})]}):c.jsxs(A1,{children:[c.jsx(ln,{path:"/setup",element:c.jsx(HP,{})}),c.jsx(ln,{path:"*",element:c.jsx(Mr,{to:"/setup",replace:!0})})]})}function DB({...e}){return c.jsx(mP,{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})}nB();IN.createRoot(document.getElementById("root")).render(c.jsx(f.StrictMode,{children:c.jsx(d4,{children:c.jsx(xw,{children:c.jsx(U4,{children:c.jsx(ZM,{children:c.jsxs(I4,{children:[c.jsx(OB,{}),c.jsx(DB,{})]})})})})})}));